3 ms·
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 G
by ww520 6y ago
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?
- skohan 6y agoGLSL 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.
- ww520 6y agoYes. 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?
- skohan 6y agoI 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.
- ww520 6y agoThanks for the detail explanation. Good to know different platforms have different approach to it.
- BadInformatics 6y agoThe 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.
- ww520 6y agoGot it. Thanks for the clarification.