summaryrefslogtreecommitdiff
path: root/tests/shaders/glsl-fs-integer-multiplication.shader_test
blob: 5b1936da6257ede07520fde5f0bf5821c594065b (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
# Test integer multiplication where 2x2 subspans of fragments do not
# necessarily write the same color and some fragments may be disabled.
#
# In a 250x250 window, the test draws 36 250x7 rectangles. A height of 7 is
# chosen to generate 2x2 subspans with some fragments disabled.
#
# Each of these rectangles is shaded with an identical 25-step gradient,
# producing 25 columns that can be checked with "probe rect rgba".
#
# This C program generates the "probe rect rgba" tests, modulo minor manual
# changes at the right and left boundaries of the image.
#
#
# #include <math.h>
# #include <stdio.h>
#
# int main() {
#     float coord = 0.5;
#
#     for (int i = 1; i < 250; i += 10, coord += 1.0f) {
#         int int_coord = coord * 10;
#         float f = (float)int_coord / 10.0;
#
#         printf("probe rect rgba (%3d, %d, %d, %d) (%.2f, %.2f, %.2f, %.2f)\n",
#                i, 0, 10, 250,
#                ceilf(f) / 25.0f, ceilf(f) / 25.0f, 0.0, 1.0);
#     }
#
#     return 0;
# }
#
# This test is designed to detect bugs in i965's integer multiplication. In
# SIMD16 mode on Gen7+ only 8 values can be multiplied at once, so the first
# 8 fragments must be handled separately from the second 8 fragments. If
# channel enables are not correct, small amounts of noise will appear in this
# test.
#
# Borrows heavily from glsl-fs-ceil.shader_test.

[require]
GLSL >= 1.10

[vertex shader]
void main()
{
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

[fragment shader]
uniform int i;

void main()
{
    int coord = int(gl_FragCoord.x) * i;
    float f = float(coord) / 100.0;

    /* Divide by 25.0 to bring it into the [0, 1] range. */
    gl_FragColor = vec4(ceil(f) / 25.0, ceil(f) / 25.0, 0.0, 1.0);
}

[test]
ortho

uniform int i 10

# Draw horizontal rectangles
draw rect 0   0 250 7
draw rect 0   7 250 7
draw rect 0  14 250 7
draw rect 0  21 250 7
draw rect 0  28 250 7
draw rect 0  35 250 7
draw rect 0  42 250 7
draw rect 0  49 250 7
draw rect 0  56 250 7
draw rect 0  63 250 7
draw rect 0  70 250 7
draw rect 0  77 250 7
draw rect 0  84 250 7
draw rect 0  91 250 7
draw rect 0  98 250 7
draw rect 0 105 250 7
draw rect 0 112 250 7
draw rect 0 119 250 7
draw rect 0 126 250 7
draw rect 0 133 250 7
draw rect 0 140 250 7
draw rect 0 147 250 7
draw rect 0 154 250 7
draw rect 0 161 250 7
draw rect 0 168 250 7
draw rect 0 175 250 7
draw rect 0 182 250 7
draw rect 0 189 250 7
draw rect 0 196 250 7
draw rect 0 203 250 7
draw rect 0 210 250 7
draw rect 0 217 250 7
draw rect 0 224 250 7
draw rect 0 231 250 7
draw rect 0 238 250 7
draw rect 0 245 250 7

# Probe vertical rectangles
probe rect rgba (  0, 0,  1, 250) (0.00, 0.00, 0.0, 1.0)
probe rect rgba (  1, 0, 10, 250) (0.04, 0.04, 0.0, 1.0)
probe rect rgba ( 11, 0, 10, 250) (0.08, 0.08, 0.0, 1.0)
probe rect rgba ( 21, 0, 10, 250) (0.12, 0.12, 0.0, 1.0)
probe rect rgba ( 31, 0, 10, 250) (0.16, 0.16, 0.0, 1.0)
probe rect rgba ( 41, 0, 10, 250) (0.20, 0.20, 0.0, 1.0)
probe rect rgba ( 51, 0, 10, 250) (0.24, 0.24, 0.0, 1.0)
probe rect rgba ( 61, 0, 10, 250) (0.28, 0.28, 0.0, 1.0)
probe rect rgba ( 71, 0, 10, 250) (0.32, 0.32, 0.0, 1.0)
probe rect rgba ( 81, 0, 10, 250) (0.36, 0.36, 0.0, 1.0)
probe rect rgba ( 91, 0, 10, 250) (0.40, 0.40, 0.0, 1.0)
probe rect rgba (101, 0, 10, 250) (0.44, 0.44, 0.0, 1.0)
probe rect rgba (111, 0, 10, 250) (0.48, 0.48, 0.0, 1.0)
probe rect rgba (121, 0, 10, 250) (0.52, 0.52, 0.0, 1.0)
probe rect rgba (131, 0, 10, 250) (0.56, 0.56, 0.0, 1.0)
probe rect rgba (141, 0, 10, 250) (0.60, 0.60, 0.0, 1.0)
probe rect rgba (151, 0, 10, 250) (0.64, 0.64, 0.0, 1.0)
probe rect rgba (161, 0, 10, 250) (0.68, 0.68, 0.0, 1.0)
probe rect rgba (171, 0, 10, 250) (0.72, 0.72, 0.0, 1.0)
probe rect rgba (181, 0, 10, 250) (0.76, 0.76, 0.0, 1.0)
probe rect rgba (191, 0, 10, 250) (0.80, 0.80, 0.0, 1.0)
probe rect rgba (201, 0, 10, 250) (0.84, 0.84, 0.0, 1.0)
probe rect rgba (211, 0, 10, 250) (0.88, 0.88, 0.0, 1.0)
probe rect rgba (221, 0, 10, 250) (0.92, 0.92, 0.0, 1.0)
probe rect rgba (231, 0, 10, 250) (0.96, 0.96, 0.0, 1.0)
probe rect rgba (241, 0,  9, 250) (1.00, 1.00, 0.0, 1.0)