Skip to content

Commit 25636e2

Browse files
andyleisersonjimblandy
authored andcommitted
[naga] Ensure globals in wgsl snapshot tests are reachable from an entry point
Convert tabs to spaces in access.wgsl
1 parent fd6f16f commit 25636e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3567
-2870
lines changed

naga/tests/in/wgsl/abstract-types-var.wgsl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,76 @@ var<private> iavipai = array(vec3(1));
8080
var<private> iavfpai = array(vec3(1));
8181
var<private> iavfpaf = array(vec3(1.0));
8282

83+
fn globals() {
84+
_ = xvipaiai;
85+
_ = xvupaiai;
86+
_ = xvfpaiai;
87+
_ = xvfpafaf;
88+
_ = xvfpaiaf;
89+
90+
_ = xvupuai;
91+
_ = xvupaiu;
92+
93+
_ = xvuuai;
94+
_ = xvuaiu;
95+
96+
_ = xvip____;
97+
_ = xvup____;
98+
_ = xvfp____;
99+
_ = xmfp____;
100+
101+
_ = xmfpaiaiaiai;
102+
_ = xmfpafaiaiai;
103+
_ = xmfpaiafaiai;
104+
_ = xmfpaiaiafai;
105+
_ = xmfpaiaiaiaf;
106+
107+
_ = xvispai;
108+
_ = xvfspaf;
109+
_ = xvis_ai;
110+
_ = xvus_ai;
111+
_ = xvfs_ai;
112+
_ = xvfs_af;
113+
114+
_ = xafafaf;
115+
_ = xafaiai;
116+
117+
_ = xaipaiai;
118+
_ = xaupaiai;
119+
_ = xafpaiaf;
120+
_ = xafpafai;
121+
_ = xafpafaf;
122+
123+
_ = xavipai;
124+
_ = xavfpai;
125+
_ = xavfpaf;
126+
127+
// Construction with splats
128+
_ = xvisai;
129+
_ = xvusai;
130+
_ = xvfsai;
131+
_ = xvfsaf;
132+
133+
_ = ivispai;
134+
_ = ivfspaf;
135+
_ = ivis_ai;
136+
_ = ivus_ai;
137+
_ = ivfs_ai;
138+
_ = ivfs_af;
139+
140+
_ = iafafaf;
141+
_ = iafaiai;
142+
143+
_ = iaipaiai;
144+
_ = iafpafaf;
145+
_ = iafpaiaf;
146+
_ = iafpafai;
147+
148+
_ = iavipai;
149+
_ = iavfpai;
150+
_ = iavfpaf;
151+
}
152+
83153
fn all_constant_arguments() {
84154
var xvipaiai: vec2<i32> = vec2(42, 43);
85155
var xvupaiai: vec2<u32> = vec2(44, 45);
@@ -278,6 +348,7 @@ fn mixed_constant_and_runtime_arguments() {
278348

279349
@compute @workgroup_size(1)
280350
fn main() {
351+
globals();
281352
all_constant_arguments();
282353
mixed_constant_and_runtime_arguments();
283354
}

naga/tests/in/wgsl/access.wgsl

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ struct GlobalConst {
66
c: i32,
77
}
88
// tests msl padding insertion for global constants
9-
var<private> global_const: GlobalConst = GlobalConst(0u, vec3<u32>(0u, 0u, 0u), 0);
9+
var<private> msl_padding_global_const: GlobalConst = GlobalConst(0u, vec3<u32>(0u, 0u, 0u), 0);
1010

1111
struct AlignedWrapper {
12-
@align(8) value: i32
12+
@align(8) value: i32
1313
}
1414

1515
struct Bar {
16-
_matrix: mat4x3<f32>,
17-
matrix_array: array<mat2x2<f32>, 2>,
18-
atom: atomic<i32>,
19-
atom_arr: array<atomic<i32>, 10>,
20-
arr: array<vec2<u32>, 2>,
21-
data: array<AlignedWrapper>,
16+
_matrix: mat4x3<f32>,
17+
matrix_array: array<mat2x2<f32>, 2>,
18+
atom: atomic<i32>,
19+
atom_arr: array<atomic<i32>, 10>,
20+
arr: array<vec2<u32>, 2>,
21+
data: array<AlignedWrapper>,
2222
}
2323

2424
@group(0) @binding(0)
2525
var<storage,read_write> bar: Bar;
2626

2727
struct Baz {
28-
m: mat3x2<f32>,
28+
m: mat3x2<f32>,
2929
}
3030

3131
@group(0) @binding(1)
@@ -35,11 +35,11 @@ var<uniform> baz: Baz;
3535
var<storage,read_write> qux: vec2<i32>;
3636

3737
fn test_matrix_within_struct_accesses() {
38-
var idx = 1;
38+
var idx = 1;
3939

4040
idx--;
4141

42-
// loads
42+
// loads
4343
let l0 = baz.m;
4444
let l1 = baz.m[0];
4545
let l2 = baz.m[idx];
@@ -52,7 +52,7 @@ fn test_matrix_within_struct_accesses() {
5252

5353
idx++;
5454

55-
// stores
55+
// stores
5656
t.m = mat3x2<f32>(vec2<f32>(6.0), vec2<f32>(5.0), vec2<f32>(4.0));
5757
t.m[0] = vec2<f32>(9.0);
5858
t.m[idx] = vec2<f32>(90.0);
@@ -63,18 +63,18 @@ fn test_matrix_within_struct_accesses() {
6363
}
6464

6565
struct MatCx2InArray {
66-
am: array<mat4x2<f32>, 2>,
66+
am: array<mat4x2<f32>, 2>,
6767
}
6868

6969
@group(0) @binding(3)
7070
var<uniform> nested_mat_cx2: MatCx2InArray;
7171

7272
fn test_matrix_within_array_within_struct_accesses() {
73-
var idx = 1;
73+
var idx = 1;
7474

7575
idx--;
7676

77-
// loads
77+
// loads
7878
let l0 = nested_mat_cx2.am;
7979
let l1 = nested_mat_cx2.am[0];
8080
let l2 = nested_mat_cx2.am[0][0];
@@ -88,7 +88,7 @@ fn test_matrix_within_array_within_struct_accesses() {
8888

8989
idx++;
9090

91-
// stores
91+
// stores
9292
t.am = array<mat4x2<f32>, 2>();
9393
t.am[0] = mat4x2<f32>(vec2<f32>(8.0), vec2<f32>(7.0), vec2<f32>(6.0), vec2<f32>(5.0));
9494
t.am[0][0] = vec2<f32>(9.0);
@@ -114,41 +114,42 @@ fn foo_vert(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4<f32> {
114114
let baz: f32 = foo;
115115
foo = 1.0;
116116

117-
test_matrix_within_struct_accesses();
118-
test_matrix_within_array_within_struct_accesses();
117+
_ = msl_padding_global_const;
118+
test_matrix_within_struct_accesses();
119+
test_matrix_within_array_within_struct_accesses();
119120

120121
// test storage loads
121-
let _matrix = bar._matrix;
122-
let arr = bar.arr;
123-
let index = 3u;
124-
let b = bar._matrix[index].x;
125-
let a = bar.data[arrayLength(&bar.data) - 2u].value;
126-
let c = qux;
122+
let _matrix = bar._matrix;
123+
let arr = bar.arr;
124+
let index = 3u;
125+
let b = bar._matrix[index].x;
126+
let a = bar.data[arrayLength(&bar.data) - 2u].value;
127+
let c = qux;
127128

128-
// test pointer types
129-
let data_pointer: ptr<storage, i32, read_write> = &bar.data[0].value;
130-
let foo_value = read_from_private(&foo);
129+
// test pointer types
130+
let data_pointer: ptr<storage, i32, read_write> = &bar.data[0].value;
131+
let foo_value = read_from_private(&foo);
131132

132-
// test array indexing
133-
var c2 = array<i32, 5>(a, i32(b), 3, 4, 5);
134-
c2[vi + 1u] = 42;
135-
let value = c2[vi];
133+
// test array indexing
134+
var c2 = array<i32, 5>(a, i32(b), 3, 4, 5);
135+
c2[vi + 1u] = 42;
136+
let value = c2[vi];
136137

137-
test_arr_as_arg(array<array<f32, 10>, 5>());
138+
test_arr_as_arg(array<array<f32, 10>, 5>());
138139

139-
return vec4<f32>(_matrix * vec4<f32>(vec4<i32>(value)), 2.0);
140+
return vec4<f32>(_matrix * vec4<f32>(vec4<i32>(value)), 2.0);
140141
}
141142

142143
@fragment
143144
fn foo_frag() -> @location(0) vec4<f32> {
144-
// test storage stores
145-
bar._matrix[1].z = 1.0;
146-
bar._matrix = mat4x3<f32>(vec3<f32>(0.0), vec3<f32>(1.0), vec3<f32>(2.0), vec3<f32>(3.0));
147-
bar.arr = array<vec2<u32>, 2>(vec2<u32>(0u), vec2<u32>(1u));
148-
bar.data[1].value = 1;
149-
qux = vec2<i32>();
145+
// test storage stores
146+
bar._matrix[1].z = 1.0;
147+
bar._matrix = mat4x3<f32>(vec3<f32>(0.0), vec3<f32>(1.0), vec3<f32>(2.0), vec3<f32>(3.0));
148+
bar.arr = array<vec2<u32>, 2>(vec2<u32>(0u), vec2<u32>(1u));
149+
bar.data[1].value = 1;
150+
qux = vec2<i32>();
150151

151-
return vec4<f32>(0.0);
152+
return vec4<f32>(0.0);
152153
}
153154

154155
fn assign_through_ptr_fn(p: ptr<function, u32>) {
@@ -163,7 +164,7 @@ fn assign_through_ptr() {
163164
var val = 33u;
164165
assign_through_ptr_fn(&val);
165166

166-
var arr = array<vec4<f32>, 2>(vec4(6.0), vec4(7.0));
167+
var arr = array<vec4<f32>, 2>(vec4(6.0), vec4(7.0));
167168
assign_array_through_ptr_fn(&arr);
168169
}
169170

naga/tests/in/wgsl/debug-symbol-large-source.wgsl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7418,6 +7418,11 @@ fn color23(p: vec2<f32>) -> vec3<f32> {
74187418

74197419
@fragment
74207420
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
7421+
_ = t_diffuse;
7422+
_ = s_diffuse;
7423+
_ = t_normal;
7424+
_ = s_normal;
7425+
74217426
color23(vec2(1, 2));
74227427

74237428
var color = smoothstep(vec3<f32>(0.0), vec3<f32>(0.1), fract(in.world_pos));

naga/tests/in/wgsl/debug-symbol-terrain.wgsl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn gen_terrain_fragment(in: GenVertexOutput) -> GenFragmentOutput {
186186
let v = terrain_vertex(p, gen_data.min_max_height);
187187

188188
var vert_component: f32 = 0.;
189-
189+
190190
switch comp_index {
191191
case 0u: { vert_component = v.position.x; }
192192
case 1u: { vert_component = v.position.y; }
@@ -275,6 +275,11 @@ fn color23(p: vec2<f32>) -> vec3<f32> {
275275

276276
@fragment
277277
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
278+
_ = t_diffuse;
279+
_ = s_diffuse;
280+
_ = t_normal;
281+
_ = s_normal;
282+
278283
color23(vec2(1, 2));
279284

280285
var color = smoothstep(vec3<f32>(0.0), vec3<f32>(0.1), fract(in.world_pos));

naga/tests/in/wgsl/f16.wgsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ var<storage, read_write> output: UniformCompatible;
5151
var<storage, read_write> output_arrays: StorageCompatible;
5252

5353
fn f16_function(x: f16) -> f16 {
54+
_ = private_variable;
55+
var l: LayoutTest;
56+
5457
var val: f16 = f16(constant_variable);
5558
// A number too big for f16
5659
val += 1h - 33333h;

naga/tests/in/wgsl/f64.wgsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var<private> v: f64 = 1lf;
22
const k: f64 = 2.0lf;
33

44
fn f(x: f64) -> f64 {
5+
_ = v;
56
let y: f64 = 3e1lf + 4.0e2lf;
67
var z = y + f64(5);
78
var w = -1.0lf;

naga/tests/in/wgsl/image.wgsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ fn main(@builtin(local_invocation_id) local_id: vec3<u32>) {
2929
let value5 = textureLoad(image_array_src, itc, local_id.z, i32(local_id.z) + 1);
3030
let value6 = textureLoad(image_array_src, itc, i32(local_id.z), i32(local_id.z) + 1);
3131
let value7 = textureLoad(image_1d_src, i32(local_id.x), i32(local_id.z));
32+
let value8 = textureLoad(image_dup_src, i32(local_id.x));
3233
// loads with uvec2 coords.
3334
let value1u = textureLoad(image_mipmapped_src, vec2<u32>(itc), i32(local_id.z));
3435
let value2u = textureLoad(image_multisampled_src, vec2<u32>(itc), i32(local_id.z));

naga/tests/in/wgsl/int64.wgsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var<storage, read_write> output: UniformCompatible;
3939
var<storage, read_write> output_arrays: StorageCompatible;
4040

4141
fn int64_function(x: i64) -> i64 {
42+
_ = private_variable;
4243
var val: i64 = i64(constant_variable);
4344
// A number too big for i32
4445
val += 31li - 1002003004005006li + -0x7fffffffffffffffli;

naga/tests/in/wgsl/overrides.wgsl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ fn main() {
2727
var gain_x_100 = gain_x_10 * 10.;
2828

2929
store_override = gain;
30+
31+
_ = specular_param;
32+
_ = width;
33+
_ = inferred_f32;
34+
_ = auto_conversion;
3035
}

0 commit comments

Comments
 (0)