rustwebglrust-wasmwebgpuwgpu-rs

Compute Shaders in Google chrome and Apple M1


I have a working physics simulator written in wgpu/rust that works when I am running from the command line. However, when I try to run on the chrome v114 (supported according to what I saw online), I get the following error saying the max number of compute workgroups is zero. I printed out my adapter features and i get the following: Limits { . . . max_compute_workgroup_storage_size: 0, max_compute_invocations_per_workgroup: 0, max_compute_workgroup_size_x: 0, max_compute_workgroup_size_y: 0, max_compute_workgroup_size_z: 0, max_compute_workgroups_per_dimension: 0, max_push_constant_size: 256 }

Also, the console dumps the following when the error is thrown: Version: WebGL 2.0 (OpenGL ES 3.0 Chromium)

Am I setting up my adapter wrong? Or does wgpu not support compute shaders in the browser yet? Any advice is welcome. Thanks everyone.

Edit: Just in case this cracks the code, these are my device capabilities whenever I run natively.


...
max_compute_workgroup_storage_size: 16384, 
max_compute_invocations_per_workgroup: 256, max_compute_workgroup_size_x: 256, max_compute_workgroup_size_y: 256, max_compute_workgroup_size_z: 64, max_compute_workgroups_per_dimension: 65535, max_push_constant_size: 0 }```

Solution

  • wgpu in Wasm currently supports either WebGL 2 or WebGPU, but not both in one build.

    Since you are seeing WebGL 2 reported, you have features = ["webgl"] activated in your wgpu dependency specification; you must remove it to enable WebGPU support instead.

    This will not do any harm to compatibility since your application requires compute shaders, which are not part of WebGL 2.