WebGPU error incorrectly thrown when buffer used in setVertexBuffer call is destroyed
Categories
(Core :: Graphics: WebGPU, defect)
Tracking
()
People
(Reporter: 17wongmk1, Unassigned)
References
(Blocks 1 open bug)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Steps to reproduce:
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0
Hi! I think I've found an issue with the WebGPU implementation in Firefox. I'm able to reproduce this in the latest Nightly (build ID 20241007093651).
I'm able to consistently reproduce this by running the following WebGPU program included below. For me, I visited a locally hosted webpage (hosted using $ npx http-server -p 8080) with the following WebGPU program included in the script tag of a basic HTML file.
async function main() {
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const commandEncoder = device.createCommandEncoder();
const buffer = device.createBuffer({
mappedAtCreation: false,
size: 32,
usage:
GPUBufferUsage.STORAGE |
GPUBufferUsage.COPY_SRC |
GPUBufferUsage.QUERY_RESOLVE |
GPUBufferUsage.INDEX |
GPUBufferUsage.VERTEX,
});
const texture = device.createTexture({
dimension: "2d",
format: "rgba8unorm-srgb",
size: {
width: 500,
height: 500,
depthOrArrayLayers: 10,
},
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
});
const textureView = texture.createView({
aspect: "all",
dimension: "2d",
arrayLayerCount: 1,
baseArrayLayer: 0,
mipLevelCount: 1,
baseMipLevel: 0,
format: "rgba8unorm-srgb",
});
const rPassEncoder = commandEncoder.beginRenderPass({
colorAttachments: [
{
clearValue: {
r: 0.0,
g: 0.0,
b: 0.0,
a: 0.0,
},
loadOp: "clear",
storeOp: "store",
view: textureView,
},
],
maxDrawCount: 120,
});
rPassEncoder.setVertexBuffer(0, buffer);
buffer.destroy();
rPassEncoder.end();
}
main();
I've also included the basic html file I used if it might be helpful:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WebGPU</title>
</head>
<body>
<p>Basic WebGPU</p>
<canvas width="512" height="512"></canvas>
</body>
</html>
Actual results:
The following uncaught WebGPU error message is shown in the console: "In a set_vertex_buffer command, caused by: Buffer with '' label has been destroyed"
Expected results:
I expected no error message to be thrown. I tested the same WebGPU program using Google's Dawn on Chrome Canary Version 131.0.6763.0 (Official Build) canary (arm64) and no error was thrown. I also looked through the W3 WebGPU specification (7 October 2024 ver) and didn't seem to find anything indicating that destroying a vertexBuffer after it has been used in a setVertexBuffer call would be invalid when the render pass is ended.
Updated•1 year ago
|
Updated•1 year ago
|
Comment 2•8 months ago
|
||
Marking as a duplicate of bug 1848857. In the strictest sense it is not a duplicate, since that bug (and wgpu#7391) are talking about raising errors on finish, while in this case and other cases of destroyed buffers, the error is not supposed to be raised until the command buffer is submitted. But the destroyed buffer case is also going to be addressed by the work I am doing on error reporting.
Description
•