这是indexloc提供的服务,不要输入任何密码
Skip to content

Change layout: 'auto' algorithm so it doesn't generate invalid bindGroupLayouts #4952

@greggman

Description

@greggman

IIUC, given this shader

@group(0) @binding(0) var tex: texture_depth_2d;
@group(0) @binding(1) var smp: sampler;

@compute @workgroup_size(1) fn cs() {
  _ = textureSample(tex, smp, vec2f(0));
}

The layout: 'auto' algorithm will make a bind group layout with tex set to sampleType: 'depth' and smp set to type: 'filtering'

This layout is invalid as depth textures are unfiltered-float and require a sampler that is non-filtering.

Similarly

@group(0) @binding(0) var tex: texture_2d<u32>;
@group(0) @binding(1) var smp: sampler;

@compute @workgroup_size(1) fn cs() {
  _ = textureGather(0, tex, smp, vec2f(0));
}

will make a bind group layout with tex set to sampleType: 'uint' and smp set to type: 'filtering' which is also invalid.

I'm wondering if it would be good to change the layout: 'auto' algorithm so that a sampler starts as 'filtering' but if it's used with a texture_depth_xxx or texture_??<i32> or texture_??<u32> then it's set to non-filtering. That would make the layout valid.

Note: dawn was not correctly validating that sampleType: 'depth'/'sint'/'uint' texture binding can not be used with a type: 'filtering' sampler. With that validation added this issue surfaced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiWebGPU API

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions