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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 21 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 9 additions & 1 deletion
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

Lines changed: 10 additions & 1 deletion
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 21 additions & 1 deletion
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

Lines changed: 6 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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+
}

0 commit comments

Comments
 (0)