summaryrefslogtreecommitdiff
path: root/tests/spec/arb_gpu_shader5/execution/sampler_array_indexing/vs-nonuniform-control-flow.shader_test
blob: 07710dbba7ac01343bdcde55f0a1ccb4d82d85e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# The spec requires sampler array indexing expressions to be
# dynamically uniform, as defined in section 3.8.3 of the GLSL 4.50
# specification:
#
# "A fragment-shader expression is dynamically uniform if all
#  fragments evaluating it get the same resulting value. [...] This
#  is similarly defined for other shader stages, based on the
#  per-instance data they process."
#
# This however doesn't have any implications on the control flow that
# leads to the evaluation of that expression being uniform, so it's
# easy to get wrong.  This test verifies that dynamically uniform
# sampler indexing expressions are evaluated correctly in the vertex
# shader under non-uniform control flow.
#
[require]
GLSL >= 1.50
GL_ARB_gpu_shader5

[vertex shader]
#version 150
#extension GL_ARB_gpu_shader5: require

uniform sampler2D s[4];

uniform uint n;

in vec4 vertex;
out vec4 color;

void main()
{
        vec4 v = vec4(0);

        if (int(round(10 * vertex.x)) % 2 != int(round(10 * vertex.y)) % 3) {
                for (uint i = 0; i < 4; ++i)
                       v[i] = texture(s[(n + i) % 4u], vec2(0.5, 0.5)).x;
        }

        gl_Position = vec4(-1 + 1.0 / 250.0 + vertex.x * 2,
                           -1 + 1.0 / 250.0 + vertex.y * 2,
                           0, 1);
        color = v;
}

[fragment shader]
#version 150

in vec4 color;
out vec4 out_color;

void main()
{
        out_color = color;
}

[vertex data]
vertex/float/3
0.0 0.0 0.0
0.0 0.1 0.0
0.0 0.2 0.0
0.0 0.3 0.0
0.0 0.4 0.0
0.0 0.5 0.0
0.1 0.0 0.0
0.1 0.1 0.0
0.1 0.2 0.0
0.1 0.3 0.0
0.1 0.4 0.0
0.1 0.5 0.0
0.2 0.0 0.0
0.2 0.1 0.0
0.2 0.2 0.0
0.2 0.3 0.0
0.2 0.4 0.0
0.2 0.5 0.0
0.3 0.0 0.0
0.3 0.1 0.0
0.3 0.2 0.0
0.3 0.3 0.0
0.3 0.4 0.0
0.3 0.5 0.0
0.4 0.0 0.0
0.4 0.1 0.0
0.4 0.2 0.0
0.4 0.3 0.0
0.4 0.4 0.0
0.4 0.5 0.0
0.5 0.0 0.0
0.5 0.1 0.0
0.5 0.2 0.0
0.5 0.3 0.0
0.5 0.4 0.0
0.5 0.5 0.0
0.6 0.0 0.0
0.6 0.1 0.0
0.6 0.2 0.0
0.6 0.3 0.0
0.6 0.4 0.0
0.6 0.5 0.0
0.7 0.0 0.0
0.7 0.1 0.0
0.7 0.2 0.0
0.7 0.3 0.0
0.7 0.4 0.0
0.7 0.5 0.0

[test]
clear color 0.2 0.2 0.2 0.2
clear

uniform int s[0] 0
uniform int s[1] 1
uniform int s[2] 2
uniform int s[3] 3

texture checkerboard 0 0 (32, 32) (0.2, 0.0, 0.0, 0.0) (0.2, 0.0, 0.0, 0.0)
texparameter 2D min nearest
texparameter 2D mag nearest

texture checkerboard 1 0 (32, 32) (0.4, 0.0, 0.0, 0.0) (0.4, 0.0, 0.0, 0.0)
texparameter 2D min nearest
texparameter 2D mag nearest

texture checkerboard 2 0 (32, 32) (0.6, 0.0, 0.0, 0.0) (0.6, 0.0, 0.0, 0.0)
texparameter 2D min nearest
texparameter 2D mag nearest

texture checkerboard 3 0 (32, 32) (0.8, 0.0, 0.0, 0.0) (0.8, 0.0, 0.0, 0.0)
texparameter 2D min nearest
texparameter 2D mag nearest

uniform uint n 1
draw arrays GL_POINTS 0 48

# This is likely to give the expected result for some vertices even if
# the implementation doesn't take this possibility into account.
# Probe a bunch of pixels for good measure.
#
relative probe rgba (0.1, 0.0) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.3, 0.0) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.5, 0.0) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.7, 0.0) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.0, 0.1) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.2, 0.1) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.4, 0.1) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.6, 0.1) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.0, 0.2) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.1, 0.2) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.2, 0.2) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.3, 0.2) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.4, 0.2) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.5, 0.2) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.6, 0.2) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.7, 0.2) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.1, 0.3) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.3, 0.3) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.5, 0.3) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.7, 0.3) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.0, 0.4) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.2, 0.4) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.4, 0.4) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.6, 0.4) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.0, 0.5) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.1, 0.5) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.2, 0.5) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.3, 0.5) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.4, 0.5) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.5, 0.5) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.6, 0.5) (0.4, 0.6, 0.8, 0.2)
relative probe rgba (0.7, 0.5) (0.4, 0.6, 0.8, 0.2)