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 12 of the Errors section:
26 * The error INVALID_ENUM is generated if <coord> passed to
27 * PassTexCoordATI or <interp> passed to SampleMapATI is not a valid
28 * register or texture unit, or the register or texture unit is greater
29 * than 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(GL_REG_0_ATI
, e
, GL_SWIZZLE_STR_ATI
);
63 glSampleMapATI(GL_REG_0_ATI
, e
, GL_SWIZZLE_STR_ATI
);
66 /* note: Mesa requires at least 1 arith instruction per pass,
67 * but this is not in the spec */
68 glColorFragmentOp1ATI(GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
69 GL_REG_1_ATI
, GL_NONE
, GL_NONE
);
70 glEndFragmentShaderATI();
72 pass
&= piglit_check_gl_error(GL_NO_ERROR
);
77 /* Trying all possible enum values is overkill, only try ones that are
78 * used in fragment shaders, thus being common user errors.
79 * Note that some of them have the same numeric value.
81 static const unsigned enums
[] = {
101 GL_SECONDARY_INTERPOLATOR_ATI
,
104 GL_SWIZZLE_STR_DR_ATI
,
105 GL_SWIZZLE_STQ_DQ_ATI
,
107 GL_SWIZZLE_STRQ_DQ_ATI
,
121 GL_PRIMARY_COLOR_ARB
,
130 piglit_init(int argc
, char **argv
)
136 piglit_require_extension("GL_ATI_fragment_shader");
138 /* The spec lists texture coordinates up to GL_TEXTURE7_ARB.
139 * According to the above paragraph, when an implementation supports
140 * less than 8 texture coordinates
141 * glSampleMapATI(GL_REG_x_ATI, GL_TEXTURE7_ARB, ...) is invalid.
143 * Doom3 uses 6 textures and 6 texcoords, so an implementation
144 * that supports less than 6 texcoords is not able to run it. Let's
145 * fail if it's less than 6, and do some checks if it's less than 8.
147 glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB
, &num_tex_coords
);
148 if (num_tex_coords
< 6) {
149 printf("Max texture coordinate interpolators %d < 6 is not enough for ATI_fragment_shader\n", num_tex_coords
);
150 piglit_report_result(PIGLIT_FAIL
);
151 } else if (num_tex_coords
< 8) {
152 if (!try_enum(GL_TEXTURE7_ARB
))
156 /* Try some invalid enums */
158 for (i
=0; i
<ARRAY_SIZE(enums
); i
++)
159 if (!try_enum(enums
[i
]))
162 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);