Hacker News new | past | comments | ask | show | jobs | submit login

What's the difference between WGSL and GLSL? Is WGSL a native language understood by the GPU? Or is it a purely Web-level construct and needs translation to GLSL before piped to the GPU?



GLSL is not a native language understood by the GPU. GLSL is a high level language which has to be compiled to machine instructions for the GPU, just like HLSL and WGSL.


Yes. The GPU only runs machine code. That makes sense.

GLSL is compiled by the OpenGL driver. The question becomes is WGSL sitting on top of OpenGL driver and thus requires the OpenGL drivers to support it or with a transpiling to GLSL, or does it has its own WebGPU driver that can compile the WGSL and interface with the GPU directly?


I would imagine the details are platform specific. I doubt that anyone is using OpenGL, as WebGPU is intended to bring the benefits of the Vulkan/Metal/DX12 generation of graphics APIs to the web.

On platforms supporting Vulkan, WebGPU implementations are probably compiling WGSL to SPIRV before handing it to the driver, and a DX12 implementation would probably compile it to DXIL. I'm not aware of any intermediate representation on Apple platforms, so it's probably transpiled to MSL there.


Thanks for the detail explanation. Good to know different platforms have different approach to it.


The latter. WGSL (purposefully) lacks many of the high-level niceties of GLSL or HLSL in order to be a good compile target as well. IIRC it has a 1-1 mapping to SPIR-V constructs, so you can see how one might build higher-level languages/DSLs/compilers on top of it.


Got it. Thanks for the clarification.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: