Skip to content

Commit

Permalink
Add storage texture loads to uniformity tests (#3327)
Browse files Browse the repository at this point in the history
Loads from a read-write storage texture are considered non-uniform,
whereas loads from a read-only storage texture are uniform.
  • Loading branch information
jrprice authored Jan 25, 2024
1 parent 8109bfd commit 482b442
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/webgpu/shader/validation/uniformity/uniformity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const kConditions = [
{ cond: 'nonuniform_and2', expectation: false },
{ cond: 'uniform_func_var', expectation: true },
{ cond: 'nonuniform_func_var', expectation: false },
{ cond: 'storage_texture_ro', expectation: true },
{ cond: 'storage_texture_rw', expectation: false },
];

function generateCondition(condition: string): string {
Expand Down Expand Up @@ -99,6 +101,12 @@ function generateCondition(condition: string): string {
case 'nonuniform_func_var': {
return `n_f == 0`;
}
case 'storage_texture_ro': {
return `textureLoad(ro_storage_texture, vec2()).x == 0`;
}
case 'storage_texture_rw': {
return `textureLoad(rw_storage_texture, vec2()).x == 0`;
}
default: {
unreachable(`Unhandled condition`);
}
Expand Down Expand Up @@ -189,7 +197,7 @@ g.test('basics')
.beginSubcases()
)
.fn(t => {
if (t.params.op === 'textureBarrier') {
if (t.params.op === 'textureBarrier' || t.params.cond.startsWith('storage_texture')) {
t.skipIfLanguageFeatureNotSupported('readonly_and_readwrite_storage_textures');
}

Expand All @@ -203,6 +211,9 @@ g.test('basics')
@group(1) @binding(1) var<storage, read_write> rw_buffer : array<f32, 4>;
@group(1) @binding(2) var<uniform> uniform_buffer : vec4<f32>;
@group(2) @binding(0) var ro_storage_texture : texture_storage_2d<rgba8unorm, read>;
@group(2) @binding(1) var rw_storage_texture : texture_storage_2d<rgba8unorm, read_write>;
var<private> priv_var : array<f32, 4> = array(0,0,0,0);
const c = false;
Expand Down

0 comments on commit 482b442

Please sign in to comment.