Skip to content

Commit

Permalink
Add shader validation tests about clip_distances and the extension (#…
Browse files Browse the repository at this point in the history
…3946)

This patch adds shader validation tests to verify that using
`clip_distances` the extension `clip_distances` must be enabled in the
shader.
  • Loading branch information
Jiawei-Shao authored Sep 11, 2024
1 parent e42b1f6 commit 9619e6a
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/webgpu/shader/validation/extension/clip_distances.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export const description = `
Validation tests for the clip_distances extension
`;

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { ShaderValidationTest } from '../shader_validation_test.js';

export const g = makeTestGroup(ShaderValidationTest);

g.test('use_clip_distances_requires_extension_enabled')
.desc(
`Checks that the clip_distances built-in variable is only allowed with the WGSL extension
clip_distances enabled in shader and the WebGPU extension clip-distances supported on the
device.`
)
.params(u =>
u.combine('requireExtension', [true, false]).combine('enableExtension', [true, false])
)
.beforeAllSubcases(t => {
if (t.params.requireExtension) {
t.selectDeviceOrSkipTestCase({ requiredFeatures: ['clip-distances'] });
}
})
.fn(t => {
const { requireExtension, enableExtension } = t.params;

t.expectCompileResult(
requireExtension && enableExtension,
`
${enableExtension ? 'enable clip_distances;' : ''}
struct VertexOut {
@builtin(clip_distances) my_clip_distances : array<f32, 1>,
@builtin(position) my_position : vec4f,
}
@vertex fn main() -> VertexOut {
var output : VertexOut;
output.my_clip_distances[0] = 1.0;
output.my_position = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
}
`
);
});

0 comments on commit 9619e6a

Please sign in to comment.