Skip to content

Commit 8bf2231

Browse files
committed
Add vec function var uniformity cases
Add cases to the uniformity tests for vector function variables, including cases to test the uniformity rules for swizzle assignment as specified in: gpuweb/gpuweb#5268 All tests pass in Tint following this fix: https://dawn-review.googlesource.com/c/dawn/+/304176
1 parent ded8b77 commit 8bf2231

1 file changed

Lines changed: 132 additions & 1 deletion

File tree

src/webgpu/shader/validation/uniformity/uniformity.spec.ts

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { makeTestGroup } from '../../../../common/framework/test_group.js';
44
import { keysOf } from '../../../../common/util/data_tables.js';
55
import { unreachable } from '../../../../common/util/util.js';
66
import { ShaderValidationTest } from '../shader_validation_test.js';
7+
import { WGSLLanguageFeature } from '../../../capability_info.js';
78

89
import { Snippet, LoopCase, compileShouldSucceed } from './snippet.js';
910

@@ -1333,7 +1334,16 @@ function expectedUniformity(uniform: string, init: string): boolean {
13331334
return false;
13341335
}
13351336

1336-
const kFuncVarCases = {
1337+
interface FuncVarCase {
1338+
typename: string;
1339+
typedecl: string;
1340+
assignment: string;
1341+
cond: string;
1342+
uniform: string;
1343+
requires?: WGSLLanguageFeature;
1344+
}
1345+
1346+
const kFuncVarCases: Record<string, FuncVarCase> = {
13371347
no_assign: {
13381348
typename: `u32`,
13391349
typedecl: ``,
@@ -2146,6 +2156,124 @@ const kFuncVarCases = {
21462156
cond: `x.x > 0`,
21472157
uniform: `never`,
21482158
},
2159+
full_assignment_vec_uniform: {
2160+
typename: `vec3u`,
2161+
typedecl: ``,
2162+
assignment: `x = uniform_value[0];`,
2163+
cond: `x.x > 0`,
2164+
uniform: `always`,
2165+
},
2166+
full_assignment_vec_nonuniform: {
2167+
typename: `vec3u`,
2168+
typedecl: ``,
2169+
assignment: `x = nonuniform_value[0];`,
2170+
cond: `x.x > 0`,
2171+
uniform: `never`,
2172+
},
2173+
partial_assignment_vec_uniform: {
2174+
typename: `vec3u`,
2175+
typedecl: ``,
2176+
assignment: `x.x = uniform_value[0].x;`,
2177+
cond: `x.x > 0`,
2178+
uniform: `init`,
2179+
},
2180+
partial_assignment_vec_nonuniform: {
2181+
typename: `vec3u`,
2182+
typedecl: ``,
2183+
assignment: `x.x = nonuniform_value[0].x;`,
2184+
cond: `x.x > 0`,
2185+
uniform: `never`,
2186+
},
2187+
partial_assignment_vec_all_components_uniform: {
2188+
typename: `vec3u`,
2189+
typedecl: ``,
2190+
assignment: `x.x = uniform_value[0].x;
2191+
x.y = uniform_value[0].y;
2192+
x.z = uniform_value[0].z;`,
2193+
cond: `x.x > 0`,
2194+
uniform: `init`,
2195+
},
2196+
partial_assignment_vec_all_components_nonuniform: {
2197+
typename: `vec3u`,
2198+
typedecl: ``,
2199+
assignment: `x.x = nonuniform_value[0].x;
2200+
x.y = uniform_value[0].y;
2201+
x.z = uniform_value[0].z;`,
2202+
cond: `x.x > 0`,
2203+
uniform: `never`,
2204+
},
2205+
full_swizzle_assignment_uniform: {
2206+
requires: 'swizzle_assignment',
2207+
typename: `vec3u`,
2208+
typedecl: ``,
2209+
assignment: `x.xyz = uniform_value[0].xyz;`,
2210+
cond: `x.x > 0`,
2211+
uniform: `always`,
2212+
},
2213+
full_swizzle_assignment_nonuniform: {
2214+
typename: `vec3u`,
2215+
typedecl: ``,
2216+
assignment: `x.xyz = nonuniform_value[0].xyz;`,
2217+
cond: `x.x > 0`,
2218+
uniform: `never`,
2219+
requires: 'swizzle_assignment',
2220+
},
2221+
full_swizzle_assignment_permutation_uniform: {
2222+
requires: 'swizzle_assignment',
2223+
typename: `vec3u`,
2224+
typedecl: ``,
2225+
assignment: `x.zyx = uniform_value[0].xyz;`,
2226+
cond: `x.x > 0`,
2227+
uniform: `always`,
2228+
},
2229+
full_swizzle_assignment_permutation_nonuniform: {
2230+
requires: 'swizzle_assignment',
2231+
typename: `vec3u`,
2232+
typedecl: ``,
2233+
assignment: `x.zyx = nonuniform_value[0].xyz;`,
2234+
cond: `x.x > 0`,
2235+
uniform: `never`,
2236+
},
2237+
partial_swizzle_assignment_uniform: {
2238+
requires: 'swizzle_assignment',
2239+
typename: `vec3u`,
2240+
typedecl: ``,
2241+
assignment: `x.xy = uniform_value[0].xy;`,
2242+
cond: `x.x > 0`,
2243+
uniform: `init`,
2244+
},
2245+
partial_swizzle_assignment_nonuniform: {
2246+
requires: 'swizzle_assignment',
2247+
typename: `vec3u`,
2248+
typedecl: ``,
2249+
assignment: `x.xy = nonuniform_value[0].xy;`,
2250+
cond: `x.x > 0`,
2251+
uniform: `never`,
2252+
},
2253+
chained_full_swizzle_assignment_uniform: {
2254+
requires: 'swizzle_assignment',
2255+
typename: `vec3u`,
2256+
typedecl: ``,
2257+
assignment: `x.xyz.zyx = uniform_value[0].xyz;`,
2258+
cond: `x.x > 0`,
2259+
uniform: `always`,
2260+
},
2261+
chained_partial_swizzle_assignment_uniform: {
2262+
requires: 'swizzle_assignment',
2263+
typename: `vec3u`,
2264+
typedecl: ``,
2265+
assignment: `x.xyz.xy = uniform_value[0].xy;`,
2266+
cond: `x.x > 0`,
2267+
uniform: `init`,
2268+
},
2269+
chained_full_swizzle_assignment_nonuniform: {
2270+
requires: 'swizzle_assignment',
2271+
typename: `vec3u`,
2272+
typedecl: ``,
2273+
assignment: `x.xyz.zyx = nonuniform_value[0].xyz;`,
2274+
cond: `x.x > 0`,
2275+
uniform: `never`,
2276+
},
21492277
};
21502278

21512279
const kVarInit = {
@@ -2159,6 +2287,9 @@ g.test('function_variables')
21592287
.params(u => u.combine('case', keysOf(kFuncVarCases)).combine('init', keysOf(kVarInit)))
21602288
.fn(t => {
21612289
const func_case = kFuncVarCases[t.params.case];
2290+
if (func_case.requires) {
2291+
t.skipIfLanguageFeatureNotSupported(func_case.requires);
2292+
}
21622293
const code = `
21632294
${func_case.typedecl}
21642295

0 commit comments

Comments
 (0)