Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/webgpu/capability_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ export const kKnownWGSLLanguageFeatures = [
'linear_indexing',
'texture_formats_tier1',
'immediate_address_space',
'fragment_depth',
] as const;

export type WGSLLanguageFeature = (typeof kKnownWGSLLanguageFeatures)[number];
1 change: 0 additions & 1 deletion src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,6 @@
"webgpu:shader,validation,shader_io,builtins:duplicates:*": { "subcaseMS": 1.913 },
"webgpu:shader,validation,shader_io,builtins:missing_vertex_position:*": { "subcaseMS": 0.975 },
"webgpu:shader,validation,shader_io,builtins:nesting:*": { "subcaseMS": 2.700 },
"webgpu:shader,validation,shader_io,builtins:parse:*": { "subcaseMS": 10.114 },
"webgpu:shader,validation,shader_io,builtins:placement:*": { "subcaseMS": 10.371 },
"webgpu:shader,validation,shader_io,builtins:reuse_builtin_name:*": { "subcaseMS": 1.202 },
"webgpu:shader,validation,shader_io,builtins:stage_inout:*": { "subcaseMS": 1.231 },
Expand Down
67 changes: 62 additions & 5 deletions src/webgpu/shader/validation/shader_io/builtins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
t.expectCompileResult(true, code);
});

const kTests = {
const kBuiltinTests = {
pos: {
src: `@builtin(position)`,
pass: true,
Expand Down Expand Up @@ -496,17 +496,17 @@
},
};

g.test('parse')
g.test('parse_builtin')
.desc(`Test that @builtin is parsed correctly.`)
.params(u => u.combine('builtin', keysOf(kTests)))
.params(u => u.combine('builtin', keysOf(kBuiltinTests)))
.fn(t => {
const src = kTests[t.params.builtin].src;
const src = kBuiltinTests[t.params.builtin].src;
const code = `
@vertex
fn main() -> ${src} vec4<f32> {
return vec4<f32>(.4, .2, .3, .1);
}`;
t.expectCompileResult(kTests[t.params.builtin].pass, code);
t.expectCompileResult(kBuiltinTests[t.params.builtin].pass, code);
});

g.test('placement')
Expand Down Expand Up @@ -577,3 +577,60 @@

t.expectCompileResult(scope === undefined || t.params.attribute[scope], code);
});

const kFragDepthTests = {
unset: {
src: `@builtin(frag_depth)`,
pass: true,
requires_feature: false,
},
less: {
src: `@builtin(frag_depth, less)`,
pass: true,
requires_feature: true,
},
greater: {
src: `@builtin(frag_depth, greater)`,
pass: true,
requires_feature: true,
},
trailing_comma: {
src: `@builtin(frag_depth, less,)`,
pass: true,
requires_feature: true,
},
missing_enum: {
src: `@builtin(frag_depth,)`,
pass: true,
requires_feature: false,
},
invalid_enum: {
src: `@builtin(frag_depth, any)`,
pass: false,
requires_feature: false,
},
missing_comma: {
src: `@builtin(frag_depth greater)`,
pass: false,
requires_feature: false,
},
};

g.test('parse_frag_depth')
.desc(`Test that @builtin is parsed correctly.`)
.params(u => u.combine('builtin', keysOf(kFragDepthTests)))
.fn(t => {
let data = kFragDepthTests[t.params.builtin];

Check failure on line 623 in src/webgpu/shader/validation/shader_io/builtins.spec.ts

View workflow job for this annotation

GitHub Actions / build

'data' is never reassigned. Use 'const' instead

if (data.requires_feature) {
t.skipIfLanguageFeatureNotSupported('fragment_depth');
}

const code = `
@fragment
fn main() -> ${data.src} f32 {
return .5;
}`;
t.expectCompileResult(data.pass, code);
});

Check failure on line 636 in src/webgpu/shader/validation/shader_io/builtins.spec.ts

View workflow job for this annotation

GitHub Actions / build

Delete `⏎`
Loading