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 11 of the Errors section:
26 * The error INVALID_ENUM is generated if <dst> passed to
27 * PassTexCoordATI, SampleMapATI, ColorFragmentOp[1..3]ATI, or
28 * AlphaFragmentOp[1..3]ATI is not a valid register or is greater than
29 * the number of texture units available on the implementation.
32 #include "piglit-util-gl.h"
34 PIGLIT_GL_TEST_CONFIG_BEGIN
36 config
.supports_gl_compat_version
= 10;
37 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
39 PIGLIT_GL_TEST_CONFIG_END
48 #define check_enum_error(en) if (!piglit_check_gl_error(GL_INVALID_ENUM)) \
49 { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); pass = false; }
56 printf(" trying %s 0x%x\n", piglit_get_gl_enum_name(e
), e
);
58 glBeginFragmentShaderATI();
59 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
60 glPassTexCoordATI(e
, GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_ATI
);
63 glSampleMapATI(e
, GL_TEXTURE0_ARB
, GL_SWIZZLE_STR_ATI
);
66 glColorFragmentOp1ATI(GL_MOV_ATI
, e
, GL_NONE
, GL_NONE
,
67 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
70 glAlphaFragmentOp1ATI(GL_MOV_ATI
, e
, GL_NONE
,
71 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
73 glEndFragmentShaderATI();
74 /* All instructions were invalid, so the shader should be empty,
77 pass
&= piglit_check_gl_error(GL_INVALID_OPERATION
);
79 /* TODO check fragment ops with more arguments? */
84 /* Trying all possible enum values is overkill, only try ones that are
85 * used in fragment shaders, thus being common user errors.
86 * Note that some of them have the same numeric value.
88 static const unsigned enums
[] = {
108 GL_SECONDARY_INTERPOLATOR_ATI
,
111 GL_SWIZZLE_STR_DR_ATI
,
112 GL_SWIZZLE_STQ_DQ_ATI
,
114 GL_SWIZZLE_STRQ_DQ_ATI
,
136 GL_PRIMARY_COLOR_ARB
,
145 piglit_init(int argc
, char **argv
)
151 piglit_require_extension("GL_ATI_fragment_shader");
153 /* The spec defines the number of registers to be fixed at 6, even
154 * though the enum values are defined up to 31 in glext.h. According
155 * to the paragraph above, when an implementation has less than 6
156 * texture units, glSampleMapATI(GL_REG_5_ATI, ...) is invalid.
158 * However, Doom3 uses 6 textures and 6 texcoords, so an implementation
159 * that supports less than 6 textures is not able to run it. Let's fail
160 * if it's less than 6.
162 glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS
, &num_tex_units
);
163 if (num_tex_units
< 6) {
164 printf("Max texture units %d < 6 is not enough for ATI_fragment_shader\n", num_tex_units
);
165 piglit_report_result(PIGLIT_FAIL
);
168 /* Try some invalid enums */
170 for (i
=0; i
<ARRAY_SIZE(enums
); i
++)
171 if (!try_enum(enums
[i
]))
174 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);