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 4 of the Errors section:
26 * The error INVALID_OPERATION is generated by EndFragmentShaderATI if
27 * <argN> passed to ColorFragmentOp[1..3]ATI or
28 * AlphaFragmentOp[1..3]ATI is PRIMARY_COLOR_ARB or
29 * SECONDARY_INTERPOLATOR_ATI on the first pass of a two-pass shader,
30 * or if the shader cannot be compiled due to some other
31 * implementation-dependent limitation. EndFragmentShaderATI will
32 * still have a side-effect if this error is encountered: the
33 * Begin/EndFragmentShaderATI pair will be closed, and the current
34 * shader will be undefined.
37 #include "piglit-util-gl.h"
39 PIGLIT_GL_TEST_CONFIG_BEGIN
41 config
.supports_gl_compat_version
= 10;
42 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
44 PIGLIT_GL_TEST_CONFIG_END
54 piglit_init(int argc
, char **argv
)
58 piglit_require_extension("GL_ATI_fragment_shader");
60 /* use GL_PRIMARY_COLOR_ARB in the first pass */
61 glBeginFragmentShaderATI();
62 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
63 GL_PRIMARY_COLOR_ARB
, GL_NONE
, GL_NONE
);
64 glPassTexCoordATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
);
65 /* note: Mesa requires at least 1 arith instruction per pass,
66 * but this is not in the spec */
67 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
68 GL_REG_0_ATI
, GL_NONE
, GL_NONE
);
69 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
70 glEndFragmentShaderATI();
71 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
73 /* see if EndFragmentShaderATI really ended the shader */
74 glEndFragmentShaderATI();
75 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
77 /* use GL_SECONDARY_INTERPOLATOR_ATI in the first pass */
78 glBeginFragmentShaderATI();
79 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
80 GL_SECONDARY_INTERPOLATOR_ATI
, GL_NONE
, GL_NONE
);
81 glPassTexCoordATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
);
82 /* note: Mesa requires at least 1 arith instruction per pass,
83 * but this is not in the spec */
84 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
85 GL_REG_0_ATI
, GL_NONE
, GL_NONE
);
86 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
87 glEndFragmentShaderATI();
88 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
90 /* see if EndFragmentShaderATI really ended the shader */
91 glEndFragmentShaderATI();
92 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
94 /* use them in a single-pass shader */
95 glBeginFragmentShaderATI();
96 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
97 GL_PRIMARY_COLOR_ARB
, GL_NONE
, GL_NONE
);
98 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
99 GL_SECONDARY_INTERPOLATOR_ATI
, GL_NONE
, GL_NONE
);
100 glEndFragmentShaderATI();
101 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
103 /* use them in the second pass */
104 glBeginFragmentShaderATI();
105 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
106 GL_REG_0_ATI
, GL_NONE
, GL_NONE
);
107 glPassTexCoordATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
);
108 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
109 GL_PRIMARY_COLOR_ARB
, GL_NONE
, GL_NONE
);
110 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
111 GL_SECONDARY_INTERPOLATOR_ATI
, GL_NONE
, GL_NONE
);
112 glEndFragmentShaderATI();
113 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
115 /* use color in first pass, but the instruction is not added because
116 * the other argument is invalid, so EndFragmentShader should not
117 * complain about color in first pass */
118 glBeginFragmentShaderATI();
119 glColorFragmentOp2ATI(GL_ADD_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
120 GL_PRIMARY_COLOR_ARB
, GL_NONE
, GL_NONE
,
121 GL_TEXTURE0_ARB
, GL_NONE
, GL_NONE
);
122 pass
&= piglit_check_gl_error(GL_INVALID_ENUM
);
123 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
124 GL_REG_0_ATI
, GL_NONE
, GL_NONE
);
125 glPassTexCoordATI(GL_REG_0_ATI
, GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
);
126 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
127 GL_REG_0_ATI
, GL_NONE
, GL_NONE
);
128 glEndFragmentShaderATI();
129 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
131 /* use color, then start a second pass, but the PassTexCoord is
132 * invalid, so it should register as a valid single pass shader */
133 glBeginFragmentShaderATI();
134 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
135 GL_PRIMARY_COLOR_ARB
, GL_NONE
, GL_NONE
);
136 glPassTexCoordATI(GL_TEXTURE0_ARB
, GL_REG_0_ATI
, GL_SWIZZLE_STR_ATI
);
137 pass
&= piglit_check_gl_error(GL_INVALID_ENUM
);
138 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
139 GL_REG_0_ATI
, GL_NONE
, GL_NONE
);
140 glEndFragmentShaderATI();
141 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
143 /* TODO what implementation-dependent limitation to check here? */
145 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);