Skip to content

Commit 2a924a3

Browse files
[naga] Ensure test functions in glsl snapshots are reachable from the entry point (#7672)
1 parent 2694b32 commit 2a924a3

20 files changed

+173
-11
lines changed

naga/tests/in/glsl/931-constant-emitting.frag

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ float function() {
99
return 0.0;
1010
}
1111

12-
void main() {}
12+
void main() {
13+
function();
14+
}

naga/tests/in/glsl/constant-array-size.frag

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ vec4 function() {
1313
return sum;
1414
}
1515

16-
void main() {}
16+
void main() {
17+
function();
18+
}

naga/tests/in/glsl/expressions.frag

+21
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,27 @@ void testSwizzleWrites(vec3 a) {
159159

160160
out vec4 o_color;
161161
void main() {
162+
testBinOpVecFloat(vec4(0), 1.0);
163+
testBinOpFloatVec(vec4(0), 1.0);
164+
testBinOpIVecInt(ivec4(0), 1);
165+
testBinOpIntIVec(1, ivec4(0));
166+
testBinOpUVecUint(uvec4(0), 1);
167+
testBinOpUintUVec(1, uvec4(0));
168+
testBinOpMatMat(mat3(0), mat3(1));
169+
testBinOpMatFloat(1, mat3(1));
170+
testUnaryOpMat(mat3(1));
171+
testStructConstructor();
172+
testNonScalarToScalarConstructor();
173+
testArrayConstructor();
174+
testFreestandingConstructor();
175+
testNonImplicitCastVectorCast();
162176
privatePointer(global);
177+
ternary(false);
178+
testMatrixMultiplication(mat4x3(0), mat4x4(1));
179+
testLength();
180+
testConstantLength(float[4](0.0, 1.0, 2.0, 3.0));
181+
indexConstantNonConstantIndex(1);
182+
testSwizzleWrites(vec3(0));
183+
163184
o_color.rgba = vec4(1.0);
164185
}

naga/tests/in/glsl/fma.frag

+12
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,17 @@ void Fma(inout Mat4x3 d, Mat4x3 m, float s) { d.mx += m.mx * s; d.my += m.my * s
55

66
out vec4 o_color;
77
void main() {
8+
Mat4x3 m1 = {
9+
vec4(0),
10+
vec4(1),
11+
vec4(2),
12+
};
13+
Mat4x3 m2 = {
14+
vec4(0),
15+
vec4(1),
16+
vec4(2),
17+
};
18+
19+
Fma(m1, m2, 2.0);
820
o_color.rgba = vec4(1.0);
921
}

naga/tests/in/glsl/functions_call.frag

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ void swizzleImplicitCastCaller(vec3 a) {
1818
swizzleImplicitCastCallee(a.xz);
1919
}
2020

21-
void main() {}
21+
void main() {
22+
swizzleCaller(vec3(0));
23+
uint a;
24+
outImplicitCastCallee(a);
25+
outImplicitCastCaller(1.0);
26+
uvec2 b;
27+
swizzleImplicitCastCallee(b);
28+
swizzleImplicitCastCaller(vec3(0));
29+
}

naga/tests/in/glsl/images.frag

+10-1
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,13 @@ void testImgWriteReadOnly(in ivec2 coord) {
7070
vec2 size = imageSize(imgWriteReadOnly);
7171
}
7272

73-
void main() {}
73+
void main() {
74+
testImg1D(1);
75+
testImg1DArray(ivec2(0));
76+
testImg2D(ivec2(0));
77+
testImg2DArray(ivec3(0));
78+
testImg3D(ivec3(0));
79+
testImgReadOnly(ivec2(0));
80+
testImgWriteOnly(ivec2(0));
81+
testImgWriteReadOnly(ivec2(0));
82+
}

naga/tests/in/glsl/sampler-functions.frag

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#version 440
22
precision mediump float;
33

4+
layout(set = 1, binding = 0) uniform texture2D tex2D;
5+
layout(set = 1, binding = 1) uniform samplerShadow sampShadow;
6+
47
float CalcShadowPCF1(texture2D T_P_t_TextureDepth, samplerShadow S_P_t_TextureDepth, in vec3 t_ProjCoord) {
58
float t_Res = 0.0f;
69
t_Res += texture(sampler2DShadow(T_P_t_TextureDepth, S_P_t_TextureDepth), t_ProjCoord.xyz) * (1.0 / 5.0);
@@ -13,4 +16,6 @@ float CalcShadowPCF(texture2D T_P_t_TextureDepth, samplerShadow S_P_t_TextureDep
1316
}
1417

1518
void main() {
19+
CalcShadowPCF1(tex2D, sampShadow, vec3(0));
20+
CalcShadowPCF(tex2D, sampShadow, vec3(0), 1.0);
1621
}

naga/tests/in/glsl/samplers.frag

+21-1
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,24 @@ void testTex2DMSArray(in vec3 coord) {
296296
c = texelFetch(sampler2DMSArray(tex2DMSArray, samp), ivec3(coord), 3);
297297
}
298298

299-
void main() {}
299+
void main() {
300+
testTex1D(1.0);
301+
#if HAS_1D_DEPTH_TEXTURES
302+
testTex1DShadow(2.0);
303+
#endif
304+
testTex1DArray(vec2(3.0));
305+
#if HAS_1D_DEPTH_TEXTURES
306+
testTex1DArrayShadow(vec2(4.0));
307+
#endif
308+
testTex2D(vec2(1.0));
309+
testTex2DShadow(vec2(1.0));
310+
testTex2DArray(vec3(1.0));
311+
testTex2DArrayShadow(vec3(1.0));
312+
testTexCube(vec3(1.0));
313+
testTexCubeShadow(vec3(1.0));
314+
testTexCubeArray(vec4(1.0));
315+
testTexCubeArrayShadow(vec4(1.0));
316+
testTex3D(vec3(1.0));
317+
testTex2DMS(vec2(1.0));
318+
testTex2DMSArray(vec3(1.0));
319+
}

naga/tests/in/glsl/statements.frag

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ void switchNoLastBreak(int a) {
3333
return;
3434
}
3535

36-
void main() {}
36+
void main() {
37+
switchEmpty(1);
38+
switchNoDefault(2);
39+
switchCaseImplConv(3);
40+
switchNoLastBreak(4);
41+
}

naga/tests/in/glsl/vector-functions.frag

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ void btest(bvec4 a, bvec4 b) {
4444
bvec4 g = not(a);
4545
}
4646

47-
void main() {}
47+
void main() {
48+
ftest(vec4(0), vec4(0));
49+
dtest(dvec4(0), dvec4(0));
50+
itest(ivec4(0), ivec4(0));
51+
utest(uvec4(0), uvec4(0));
52+
btest(bvec4(false), bvec4(false));
53+
}

naga/tests/out/wgsl/glsl-931-constant-emitting.frag.wgsl

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ fn function() -> f32 {
55
}
66

77
fn main_1() {
8+
let _e0 = function();
89
return;
910
}
1011

naga/tests/out/wgsl/glsl-constant-array-size.frag.wgsl

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fn function() -> vec4<f32> {
3232
}
3333

3434
fn main_1() {
35+
let _e0 = function();
3536
return;
3637
}
3738

naga/tests/out/wgsl/glsl-expressions.frag.wgsl

+24-4
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,31 @@ fn testSwizzleWrites(a_27: vec3<f32>) {
427427
fn main_1() {
428428
var local_6: f32;
429429

430-
let _e2 = global;
431-
local_6 = _e2;
430+
testBinOpVecFloat(vec4(0f), 1f);
431+
testBinOpFloatVec(vec4(0f), 1f);
432+
testBinOpIVecInt(vec4(0i), 1i);
433+
testBinOpIntIVec(1i, vec4(0i));
434+
testBinOpUVecUint(vec4(0u), 1u);
435+
testBinOpUintUVec(1u, vec4(0u));
436+
testBinOpMatMat(mat3x3<f32>(vec3<f32>(0f, 0f, 0f), vec3<f32>(0f, 0f, 0f), vec3<f32>(0f, 0f, 0f)), mat3x3<f32>(vec3<f32>(1f, 0f, 0f), vec3<f32>(0f, 1f, 0f), vec3<f32>(0f, 0f, 1f)));
437+
testBinOpMatFloat(1f, mat3x3<f32>(vec3<f32>(1f, 0f, 0f), vec3<f32>(0f, 1f, 0f), vec3<f32>(0f, 0f, 1f)));
438+
testUnaryOpMat(mat3x3<f32>(vec3<f32>(1f, 0f, 0f), vec3<f32>(0f, 1f, 0f), vec3<f32>(0f, 0f, 1f)));
439+
testStructConstructor();
440+
testNonScalarToScalarConstructor();
441+
testArrayConstructor();
442+
testFreestandingConstructor();
443+
testNonImplicitCastVectorCast();
444+
let _e45 = global;
445+
local_6 = _e45;
432446
privatePointer((&local_6));
433-
let _e4 = local_6;
434-
global = _e4;
447+
let _e47 = local_6;
448+
global = _e47;
449+
ternary(false);
450+
testMatrixMultiplication(mat4x3<f32>(vec3<f32>(0f, 0f, 0f), vec3<f32>(0f, 0f, 0f), vec3<f32>(0f, 0f, 0f), vec3<f32>(0f, 0f, 0f)), mat4x4<f32>(vec4<f32>(1f, 0f, 0f, 0f), vec4<f32>(0f, 1f, 0f, 0f), vec4<f32>(0f, 0f, 1f, 0f), vec4<f32>(0f, 0f, 0f, 1f)));
451+
testLength();
452+
testConstantLength(array<f32, 4>(0f, 1f, 2f, 3f));
453+
indexConstantNonConstantIndex(1i);
454+
testSwizzleWrites(vec3(0f));
435455
o_color.x = 1f;
436456
o_color.y = 1f;
437457
o_color.z = 1f;

naga/tests/out/wgsl/glsl-fma.frag.wgsl

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ fn Fma(d: ptr<function, Mat4x3_>, m: Mat4x3_, s: f32) {
3232
}
3333

3434
fn main_1() {
35+
var m1_: Mat4x3_ = Mat4x3_(vec4(0f), vec4(1f), vec4(2f));
36+
var m2_: Mat4x3_ = Mat4x3_(vec4(0f), vec4(1f), vec4(2f));
37+
38+
let _e17 = m2_;
39+
Fma((&m1_), _e17, 2f);
3540
o_color.x = 1f;
3641
o_color.y = 1f;
3742
o_color.z = 1f;

naga/tests/out/wgsl/glsl-functions_call.frag.wgsl

+8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ fn swizzleImplicitCastCaller(a_7: vec3<f32>) {
5050
}
5151

5252
fn main_1() {
53+
var a_9: u32;
54+
var b: vec2<u32>;
55+
56+
swizzleCaller(vec3(0f));
57+
outImplicitCastCallee((&a_9));
58+
outImplicitCastCaller(1f);
59+
swizzleImplicitCastCallee((&b));
60+
swizzleImplicitCastCaller(vec3(0f));
5361
return;
5462
}
5563

naga/tests/out/wgsl/glsl-images.frag.wgsl

+8
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ fn testImgWriteReadOnly(coord_14: vec2<i32>) {
134134
}
135135

136136
fn main_1() {
137+
testImg1D(1i);
138+
testImg1DArray(vec2(0i));
139+
testImg2D(vec2(0i));
140+
testImg2DArray(vec3(0i));
141+
testImg3D(vec3(0i));
142+
testImgReadOnly(vec2(0i));
143+
testImgWriteOnly(vec2(0i));
144+
testImgWriteReadOnly(vec2(0i));
137145
return;
138146
}
139147

naga/tests/out/wgsl/glsl-sampler-functions.frag.wgsl

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
@group(1) @binding(0)
2+
var tex2D: texture_depth_2d;
3+
@group(1) @binding(1)
4+
var sampShadow: sampler_comparison;
5+
16
fn CalcShadowPCF1_(T_P_t_TextureDepth: texture_depth_2d, S_P_t_TextureDepth: sampler_comparison, t_ProjCoord: vec3<f32>) -> f32 {
27
var t_ProjCoord_1: vec3<f32>;
38
var t_Res: f32 = 0f;
@@ -27,6 +32,8 @@ fn CalcShadowPCF(T_P_t_TextureDepth_1: texture_depth_2d, S_P_t_TextureDepth_1: s
2732
}
2833

2934
fn main_1() {
35+
let _e4 = CalcShadowPCF1_(tex2D, sampShadow, vec3(0f));
36+
let _e8 = CalcShadowPCF(tex2D, sampShadow, vec3(0f), 1f);
3037
return;
3138
}
3239

naga/tests/out/wgsl/glsl-samplers.frag.wgsl

+13
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,19 @@ fn testTex2DMSArray(coord_24: vec3<f32>) {
628628
}
629629

630630
fn main_1() {
631+
testTex1D(1f);
632+
testTex1DArray(vec2(3f));
633+
testTex2D(vec2(1f));
634+
testTex2DShadow(vec2(1f));
635+
testTex2DArray(vec3(1f));
636+
testTex2DArrayShadow(vec3(1f));
637+
testTexCube(vec3(1f));
638+
testTexCubeShadow(vec3(1f));
639+
testTexCubeArray(vec4(1f));
640+
testTexCubeArrayShadow(vec4(1f));
641+
testTex3D(vec3(1f));
642+
testTex2DMS(vec2(1f));
643+
testTex2DMSArray(vec3(1f));
631644
return;
632645
}
633646

naga/tests/out/wgsl/glsl-statements.frag.wgsl

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ fn switchNoLastBreak(a_6: i32) {
5454
}
5555

5656
fn main_1() {
57+
switchEmpty(1i);
58+
switchNoDefault(2i);
59+
switchCaseImplConv(3u);
60+
switchNoLastBreak(4i);
5761
return;
5862
}
5963

naga/tests/out/wgsl/glsl-vector-functions.frag.wgsl

+5
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ fn btest(a_8: vec4<bool>, b_8: vec4<bool>) {
157157
}
158158

159159
fn main_1() {
160+
ftest(vec4(0f), vec4(0f));
161+
dtest(vec4(0.0lf), vec4(0.0lf));
162+
itest(vec4(0i), vec4(0i));
163+
utest(vec4(0u), vec4(0u));
164+
btest(vec4(false), vec4(false));
160165
return;
161166
}
162167

0 commit comments

Comments
 (0)