2 * Copyright © 2017 Miklós Máté
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 /** Paragraph 6 of the Errors section:
26 * The error INVALID_OPERATION is generated by PassTexCoordATI or
27 * SampleMapATI if <coord> passed to PassTexCoordATI or <interp> passed
28 * to SampleMapATI is a register in the first pass, or a register with
29 * SWIZZLE_STQ_ATI or SWIZZLE_STQ_DQ_ATI <swizzle> in the second pass,
30 * or if different <swizzle> parameters are specified for the same
31 * <coord> or <interp> in the same pass.
34 /* Note that the spec is sloppy at the last part. Only STR and STQ are
35 * incompatible, but e.g. STR and STR_DR are not. This only applies to
36 * texture sources, but not to registers. And instead of "same pass" it
37 * should read "same shader".
38 * See r200_fragshader.c:333
41 #include "piglit-util-gl.h"
43 static struct piglit_gl_test_config
*piglit_config
;
45 PIGLIT_GL_TEST_CONFIG_BEGIN
47 piglit_config
= &config
;
48 config
.supports_gl_compat_version
= 10;
49 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
51 PIGLIT_GL_TEST_CONFIG_END
60 static enum piglit_result
61 reg_src_in_first_pass(void *data
)
65 glBeginFragmentShaderATI();
66 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
67 glPassTexCoordATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
);
68 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
69 /* note: Mesa requires at least 1 arith instruction per pass,
70 * but this is not in the spec */
71 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
72 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
73 glEndFragmentShaderATI();
75 glBeginFragmentShaderATI();
76 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
77 glSampleMapATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
);
78 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
79 /* note: Mesa requires at least 1 arith instruction per pass,
80 * but this is not in the spec */
81 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
82 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
83 glEndFragmentShaderATI();
84 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
86 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
89 static enum piglit_result
90 stq_swizzle_on_reg(void *data
)
94 glBeginFragmentShaderATI();
95 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
96 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
97 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
98 glPassTexCoordATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STQ_ATI
);
99 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
100 /* note: Mesa requires at least 1 arith instruction per pass,
101 * but this is not in the spec */
102 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
103 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
104 glEndFragmentShaderATI();
106 glBeginFragmentShaderATI();
107 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
108 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
109 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
110 glPassTexCoordATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STQ_DQ_ATI
);
111 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
112 /* note: Mesa requires at least 1 arith instruction per pass,
113 * but this is not in the spec */
114 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
115 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
116 glEndFragmentShaderATI();
118 glBeginFragmentShaderATI();
119 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
120 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
121 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
122 glSampleMapATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STQ_ATI
);
123 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
124 /* note: Mesa requires at least 1 arith instruction per pass,
125 * but this is not in the spec */
126 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
127 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
128 glEndFragmentShaderATI();
130 glBeginFragmentShaderATI();
131 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
132 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
133 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
134 glSampleMapATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STQ_DQ_ATI
);
135 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
136 /* note: Mesa requires at least 1 arith instruction per pass,
137 * but this is not in the spec */
138 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
139 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
140 glEndFragmentShaderATI();
141 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
143 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
147 check_swizzle_passtexcoord(unsigned src
, unsigned swizzle1
, unsigned swizzle2
, unsigned error
)
151 glBeginFragmentShaderATI();
152 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
153 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
154 glPassTexCoordATI(GL_REG_0_ATI
, src
, swizzle1
);
155 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
156 glPassTexCoordATI(GL_REG_1_ATI
, src
, swizzle2
);
157 pass
&= piglit_check_gl_error(error
);
158 /* note: Mesa requires at least 1 arith instruction per pass,
159 * but this is not in the spec */
160 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
161 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
162 glEndFragmentShaderATI();
163 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
168 static enum piglit_result
169 different_swizzle_on_same_tex_passtexcoord(void *data
)
173 pass
&= check_swizzle_passtexcoord(GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STQ_ATI
, GL_INVALID_OPERATION
);
174 pass
&= check_swizzle_passtexcoord(GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STR_DR_ATI
, GL_NO_ERROR
);
175 pass
&= check_swizzle_passtexcoord(GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STQ_DQ_ATI
, GL_INVALID_OPERATION
);
176 pass
&= check_swizzle_passtexcoord(GL_TEXTURE0_ARB
, GL_SWIZZLE_STQ_ATI
, GL_SWIZZLE_STR_DR_ATI
, GL_INVALID_OPERATION
);
177 pass
&= check_swizzle_passtexcoord(GL_TEXTURE0_ARB
, GL_SWIZZLE_STQ_ATI
, GL_SWIZZLE_STQ_DQ_ATI
, GL_NO_ERROR
);
178 pass
&= check_swizzle_passtexcoord(GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_DR_ATI
, GL_SWIZZLE_STQ_DQ_ATI
, GL_INVALID_OPERATION
);
180 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
184 check_swizzle_samplemap(unsigned src
, unsigned swizzle1
, unsigned swizzle2
, unsigned error
)
188 glBeginFragmentShaderATI();
189 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
190 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
191 glPassTexCoordATI(GL_REG_0_ATI
, src
, swizzle1
);
192 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
193 glSampleMapATI(GL_REG_1_ATI
, src
, swizzle2
);
194 pass
&= piglit_check_gl_error(error
);
195 /* note: Mesa requires at least 1 arith instruction per pass,
196 * but this is not in the spec */
197 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
198 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
199 glEndFragmentShaderATI();
200 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
205 static enum piglit_result
206 different_swizzle_on_same_tex_samplemap(void *data
)
210 pass
&= check_swizzle_samplemap(GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STQ_ATI
, GL_INVALID_OPERATION
);
211 pass
&= check_swizzle_samplemap(GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STR_DR_ATI
, GL_NO_ERROR
);
212 pass
&= check_swizzle_samplemap(GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STQ_DQ_ATI
, GL_INVALID_OPERATION
);
213 pass
&= check_swizzle_samplemap(GL_TEXTURE0_ARB
, GL_SWIZZLE_STQ_ATI
, GL_SWIZZLE_STR_DR_ATI
, GL_INVALID_OPERATION
);
214 pass
&= check_swizzle_samplemap(GL_TEXTURE0_ARB
, GL_SWIZZLE_STQ_ATI
, GL_SWIZZLE_STQ_DQ_ATI
, GL_NO_ERROR
);
215 pass
&= check_swizzle_samplemap(GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_DR_ATI
, GL_SWIZZLE_STQ_DQ_ATI
, GL_INVALID_OPERATION
);
217 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
220 static enum piglit_result
221 different_swizzle_on_same_reg(void *data
)
225 pass
&= check_swizzle_passtexcoord(GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STR_DR_ATI
, GL_NO_ERROR
);
226 pass
&= check_swizzle_samplemap(GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STR_DR_ATI
, GL_NO_ERROR
);
228 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
231 static bool check_swizzle_2pass(bool samplemap
, unsigned swizzle1
, unsigned swizzle2
, unsigned error
)
235 glBeginFragmentShaderATI();
237 glSampleMapATI(GL_REG_0_ATI
, GL_TEXTURE0_ARB
, swizzle1
);
239 glPassTexCoordATI(GL_REG_0_ATI
, GL_TEXTURE0_ARB
, swizzle1
);
240 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
241 GL_REG_0_ATI
, GL_NONE
, GL_NONE
);
242 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
244 glSampleMapATI(GL_REG_0_ATI
, GL_TEXTURE0_ARB
, swizzle2
);
246 glPassTexCoordATI(GL_REG_0_ATI
, GL_TEXTURE0_ARB
, swizzle2
);
247 pass
&= piglit_check_gl_error(error
);
248 /* note: Mesa requires at least 1 arith instruction per pass,
249 * but this is not in the spec */
250 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
251 GL_REG_0_ATI
, GL_NONE
, GL_NONE
);
252 glEndFragmentShaderATI();
257 static enum piglit_result
258 different_swizzle_in_different_pass(void *data
)
262 pass
&= check_swizzle_2pass(false, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STQ_ATI
, GL_INVALID_OPERATION
);
263 pass
&= check_swizzle_2pass(true, GL_SWIZZLE_STR_ATI
, GL_SWIZZLE_STQ_ATI
, GL_INVALID_OPERATION
);
265 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
268 static const struct piglit_subtest subtests
[] = {
270 "REG source in first pass",
271 "reg-src-in-first-pass",
272 reg_src_in_first_pass
,
276 "STQ swizzle on REG",
277 "stq-swizzle-on-reg",
282 "Different swizzle on the same TEX in PassTexCoord",
283 "different_swizzle_on_same_tex_passtexcoord",
284 different_swizzle_on_same_tex_passtexcoord
,
288 "Different swizzle on the same TEX in SampleMap",
289 "different_swizzle_on_same_tex_samplemap",
290 different_swizzle_on_same_tex_samplemap
,
294 "Different swizzle on the same REG",
295 "different_swizzle_on_same_reg",
296 different_swizzle_on_same_reg
,
300 "Different swizzle in different pass",
301 "different_swizzle_in_different_pass",
302 different_swizzle_in_different_pass
,
314 piglit_init(int argc
, char **argv
)
316 piglit_require_extension("GL_ATI_fragment_shader");
318 piglit_report_result(piglit_run_selected_subtests(subtests
,
319 piglit_config
->selected_subtests
,
320 piglit_config
->num_selected_subtests
,