3 ms·
As far as I understand it WebGPU is just a thin translation layer to binary SPIR-V with fake Rust syntax. Is it really faster than GLSL? The lack of important
by sprash 3y ago
As far as I understand it WebGPU is just a thin translation layer to binary SPIR-V with fake Rust syntax. Is it really faster than GLSL?
The lack of important language features like function overloading or clear client side code separation via preprocessors is annoying. Also misleading notations like mat4x4<f32> instead of mat4 that imply that you could put any type between "<>" and expect it to be hardware accelerated which is not the case. Finally, the lack of assignment and ternary operators and forced bracing will make your code look really ugly.
I don't like it. It would have been better if they simply extended GLSL to cover the full SPIR-V capabilities.
- ChadNauseam 3y agoWGSL is the shading language, which is technically not the same thing as WebGPU. WebGPU is the graphics API, which uses WGSL as its shading language. You can feel free to preprocess the files any way you like, it's just not something the browser does for you (imo the correct decision). WebGPU implementations like wgpu-rs let you use any shading language that compiles to SPIR-V. My feeling is that bespoke shading languages like WGSL and GLSL are on their way out, anyway. Things like rust-gpu that allow you to write your shader code in the same language as your application code are just so much more ergonomic.
- LoganDark 3y ago> WebGPU implementations like wgpu-rs wgpu isn't exactly an implementation of WebGPU, it's just based on WebGPU (heavily inspired).
- dlivingston 3y agoI was surprised to read your comment, despite ostensibly being familiar with wgpu. But sure enough (from the homepage): > wgpu is a safe and portable graphics library for Rust based on the WebGPU API. It is suitable for general purpose graphics and compute on the GPU. > Applications using wgpu run natively on Vulkan, Metal, DirectX 11/12, and OpenGL ES; and browsers via WebAssembly on WebGPU and WebGL2.
- LoganDark 3y agoTo be fair, > Applications using wgpu run natively on Vulkan, Metal, DirectX 11/12, and OpenGL ES; and browsers via WebAssembly on WebGPU and WebGL2. is not an argument against being WebGPU, as GPU drivers don't talk WebGPU directly (for now?), and WebGPU implementations are free to use whatever backend they please, as long as they provide the right API. However, wgpu is still only based on the WebGPU API, which makes the topic of backends irrelevant anyway~