Closed Bug 2023425 Opened 2 months ago Closed 1 month ago

WebGPU: GPURenderPassEncoder.setVertexBuffer(.., null) does not work

Categories

(Core :: Graphics: WebGPU, defect, P2)

Firefox 150
defect

Tracking

()

RESOLVED FIXED
Tracking Status
firefox150 --- affected

People

(Reporter: jujjyl, Unassigned)

References

(Blocks 1 open bug)

Details

STR:

<!DOCTYPE html><html><body><canvas id="canvas"></canvas><script type="module">
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const colorFormat = navigator.gpu.getPreferredCanvasFormat();
const vb = device.createBuffer({ size: 256, usage: GPUBufferUsage.VERTEX });
const shader = device.createShaderModule({ code: `
  @vertex fn vs(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4f {
    var pos = array<vec2f,3>(vec2f(0,1), vec2f(-1,-1), vec2f(1,-1));
    return vec4f(pos[vi], 0, 1);
  }
  @fragment fn fs() -> @location(0) vec4f { return vec4f(1,0,0,1); }
`});

const pipeline = device.createRenderPipeline({
  layout: 'auto',
  vertex: { module: shader, entryPoint: 'vs' },
  fragment: { module: shader, entryPoint: 'fs', targets: [{ format: colorFormat }] },
});

const ctx = document.getElementById('canvas').getContext('webgpu');
ctx.configure({ device, format: colorFormat });
const enc = device.createCommandEncoder();
const pass = enc.beginRenderPass({
  colorAttachments: [{
    view: ctx.getCurrentTexture().createView(),
    loadOp: 'clear',
    clearValue: [0, 0, 0, 0],
    storeOp: 'store',
  }],
});
pass.setPipeline(pipeline);
pass.setVertexBuffer(0, vb);
pass.setVertexBuffer(0, null);  // null = unbind ***
pass.draw(3);
pass.end();
device.queue.submit([enc.finish()]);
</script></body></html>

passes in Chrome. Gives

Uncaught TypeError: GPURenderPassEncoder.setVertexBuffer: Argument 2 is not an object.

in Firefox from the starred line.

Seems like the second argument is not marked optional, as it apparently needs to be.

Severity: -- → S2
Priority: -- → P2

(In reply to Brad Werth [:bradwerth] from comment #1)

Seems like the second argument is not marked optional, as it apparently needs to be.

Hmm, that's not quite right. The argument is required, but can be null. Not sure to how express that in webidl. Perhaps GPUBuffer? buffer.

Depends on: 2031993
Duplicate of this bug: 1954476
Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.