denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.95k stars 5.23k forks source link

`GPURenderBundleEncoder.setIndexBuffer` `size` parameter defaults to `0` #24288

Open 0f-0b opened 2 months ago

0f-0b commented 2 months ago
const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
  throw "no adapter";
}
const device = await adapter.requestDevice();
const buffer = device.createBuffer({ size: 2, usage: GPUBufferUsage.INDEX });
const encoder = device.createRenderBundleEncoder({ colorFormats: [] });
encoder.setIndexBuffer(buffer, "uint16");
$ deno run --unstable-webgpu a.ts
error: Uncaught (in promise) TypeError: size must be larger than 0
encoder.setIndexBuffer(buffer, "uint16");
        ^
    at GPURenderBundleEncoder.setIndexBuffer (ext:deno_webgpu/01_webgpu.js:4943:5)
    at …/a.ts:8:9
$ deno --version
deno 1.44.4+6ab1433 (canary, aarch64-apple-darwin)
v8 12.6.228.9
typescript 5.4.5
Hajime-san commented 3 weeks ago

I found some diff between deno's implementation and current spec around this issue.

GPURenderCommandsMixin

GPURenderCommandsMixin defines rendering commands common to GPURenderPassEncoder and GPURenderBundleEncoder.

GPURenderCommandsMixin assumes the presence of GPUObjectBase, GPUCommandsMixin, and GPUBindingCommandsMixin members on the same object. It must only be included by interfaces which also include those mixins.

GPUDebugCommandsMixin

GPUDebugCommandsMixin is also common to GPURenderPassEncoder and GPUComputePassEncoder

GPUBindingCommandsMixin

The setBindGroup() method has two overloads, and the bindGroup argument to be nullable.

upstream wgpu