Skip to content

WebGPU spec validation not met with beginRenderPass #24813

Closed
@matthew-wong1

Description

Hi! I've been using the most recent commit of Deno compiled from source (1faac2d) and I think there might be an issue with some of the validation for beginRenderPass. But I'm not sure if it might be an upstream wgpu issue.

Based on the most recent spec (https://www.w3.org/TR/webgpu/#abstract-opdef-gpurenderpassdescriptor-valid-usage), if this.occlusionQuerySet is not null, it must be 'valid to use'. This mean that object.[[[device]] must equal targetObject.[[[device]]] (https://www.w3.org/TR/webgpu/#abstract-opdef-valid-to-use-with).

I expected the following program to emit an error because the querySet that is used belongs to a different device:

async function main() {
    const adapter = await navigator.gpu.requestAdapter();
    const device = await adapter.requestDevice();
    const encoder = device.createCommandEncoder();
    const texture = device.createTexture({
        dimension: "2d",
        sampleCount: 1,
        format: "bgra8unorm",
        label: "GPUTexture2",
        size: {
            width: 30,
            height: 30,
            depthOrArrayLayers: 2
        },
        mipLevelCount: 1,
        usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC,
        viewFormats: ["bgra8unorm-srgb"]
    });
    const textureView = texture.createView({
        aspect: "all",
        dimension: "2d-array",
        arrayLayerCount: 1,
        baseArrayLayer: 0,
        mipLevelCount: 1,
        baseMipLevel: 0,
        format: "bgra8unorm",
        label: "GPUTextureView2"
    });

    const adapter2 = await navigator.gpu.requestAdapter();
    const device2 = await adapter2.requestDevice()
    const querySetFromDevice2 = device2.createQuerySet({
        count: 1162,
        label: "GPUQuerySet0",
        type: "occlusion"
    })

    const renderPassEncoder = encoder.beginRenderPass({
        colorAttachments: [{
            clearValue: {
                r: 0,
                g: 0,
                b: 0,
                a: 0
            },
            loadOp: "load",
            storeOp: "discard",
            view: textureView
        }],
        label: "GPURenderPassEncoder0",
        maxDrawCount: 439496549,
        occlusionQuerySet: querySetFromDevice2 // Should throw an error 
    });



}
main().catch(console.error);

This type of error is caught when textureView is from a different device instance, but not for occlusionQuerySet.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlyupstreamChanges in upstream are required to solve these issueswebrelated to Web APIswebgpuWebGPU API

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions