-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
e42b1f6
commit 9619e6a
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/webgpu/shader/validation/extension/clip_distances.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
` | ||
); | ||
}); |