From 9619e6a6ab523961fb5635ba9bc32d4a647f3074 Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Wed, 11 Sep 2024 21:42:14 +0800 Subject: [PATCH] Add shader validation tests about `clip_distances` and the extension (#3946) This patch adds shader validation tests to verify that using `clip_distances` the extension `clip_distances` must be enabled in the shader. --- .../extension/clip_distances.spec.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/webgpu/shader/validation/extension/clip_distances.spec.ts diff --git a/src/webgpu/shader/validation/extension/clip_distances.spec.ts b/src/webgpu/shader/validation/extension/clip_distances.spec.ts new file mode 100644 index 000000000000..88957d8e8e62 --- /dev/null +++ b/src/webgpu/shader/validation/extension/clip_distances.spec.ts @@ -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, + @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; + } + ` + ); + });