Closed Bug 1723700 Opened 3 years ago Closed 3 years ago

WebGPU Shader Language doesn't work in Firefox Nightly

Categories

(Core :: Graphics: WebGPU, defect)

Firefox 92
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: leonz5288, Unassigned)

References

Details

Attachments

(1 file)

4.71 KB, application/x-javascript
Details
Attached file matrixMulExample.js

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0

Steps to reproduce:

I am working with webGPU on Firefox Nightly and the WGSL code I passed in does not pass the wgpu_core check while the code works perfectly fine in Chrome Canary.
To reproduce, just run the javascript file I provided.

Actual results:

When initiating shader module, I put in WGSL code

const shaderModule = device.createShaderModule({
    code: `
      [[block]] struct Matrix {
        size : vec2<f32>;
        numbers : array<f32>;
      };
      
      [[group(0), binding(0)]] var<storage, read> firstMatrix : Matrix;
      [[group(0), binding(1)]] var<storage, read> secondMatrix : Matrix;
      [[group(0), binding(2)]] var<storage, write> resultMatrix : Matrix;
      
      [[stage(compute), workgroup_size(8, 8)]]
      fn main([[builtin(global_invocation_id)]] global_id : vec3<u32>) {
        // Guard against out-of-bounds work group sizes.
        if (global_id.x >= u32(firstMatrix.size.x) || global_id.y >= u32(secondMatrix.size.y)) {
          return;
        }
        
        resultMatrix.size = vec2<f32>(firstMatrix.size.x, secondMatrix.size.y);
        
        let resultCell : vec2<u32> = vec2<u32>(global_id.x, global_id.y);
        var result : f32 = 0.0;
        for (var i : u32 = 0u; i < u32(firstMatrix.size.y); i = i + 1u) {
          let a : u32 = i + resultCell.x * u32(firstMatrix.size.y);
          let b : u32 = resultCell.y + i * u32(secondMatrix.size.y);
          result = result + firstMatrix.numbers[a] * secondMatrix.numbers[b];
        }
        
        let index : u32 = resultCell.y + resultCell.x * u32(secondMatrix.size.y);
        resultMatrix.numbers[index] = result;
      }
    `
  });

The browser then gives me error:
ERROR wgpu_core::device Failed to parse WGSL code for None: expected paren, found ','

Expected results:

The code gets parsed and run normally.

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: WebGPU' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Graphics: WebGPU
Product: Firefox → Core

WGSL is not stable yet, language is being changed, and WebGPU implementations catch up at different rates.
So this isn't a bug, strictly speaking - there is no promise that a WIP API will work exactly the same way in Firefox and Chrome.
Let's see if https://phabricator.services.mozilla.com/D120764 helps here, it's currently blocked on bug 1722702.

Severity: -- → S4
Depends on: 1722702

We can ran most of the https://austineng.github.io/webgpu-samples/, which are WGSL based, so this issue can be closed.
I've also ran your shader through https://github.com/gfx-rs/naga, which we use for parsing, and it accepts it happily.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Depends on: 1622846
No longer depends on: 1722702
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: