glsl: test loop unroll with uint overflow
[piglit.git] / tests / spec / ati_fragment_shader / error13-invalidarg.c
blobc787971d614e4dcc29eb21bb8296b0307ef7d33c
1 /*
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
13 * Software.
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
21 * IN THE SOFTWARE.
24 /** Paragraph 13 of the Errors section:
26 * The error INVALID_ENUM is generated if <argN> passed to
27 * ColorFragmentOp[1..3]ATI or AlphaFragmentOp[1..3]ATI is not a valid
28 * constant, interpolator, or register.
31 #include "piglit-util-gl.h"
33 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config.supports_gl_compat_version = 10;
36 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
38 PIGLIT_GL_TEST_CONFIG_END
40 enum piglit_result
41 piglit_display(void)
43 /* UNREACHED */
44 return PIGLIT_FAIL;
47 #define check_enum_error(en) if (!piglit_check_gl_error(GL_INVALID_ENUM)) \
48 { printf("Enum %s 0x%x not rejected\n", piglit_get_gl_enum_name(en), en); pass = false; }
50 bool
51 try_enum(unsigned e)
53 bool pass = true;
55 printf(" trying %s 0x%x\n", piglit_get_gl_enum_name(e), e);
57 glBeginFragmentShaderATI();
58 pass &= piglit_check_gl_error(GL_NO_ERROR);
59 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
60 e, GL_NONE, GL_NONE);
61 check_enum_error(e);
63 glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
64 e, GL_NONE, GL_NONE);
65 check_enum_error(e);
66 glEndFragmentShaderATI();
67 /* All instructions were invalid, so the shader should be empty,
68 * which is invalid
70 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
72 /* TODO check fragment ops with more arguments? */
74 return pass;
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[] = {
82 GL_MOV_ATI,
83 GL_ADD_ATI,
84 GL_MUL_ATI,
85 GL_SUB_ATI,
86 GL_DOT3_ATI,
87 GL_DOT4_ATI,
88 GL_MAD_ATI,
89 GL_LERP_ATI,
90 GL_CND_ATI,
91 GL_CND0_ATI,
92 GL_DOT2_ADD_ATI,
93 GL_SWIZZLE_STR_ATI,
94 GL_SWIZZLE_STQ_ATI,
95 GL_SWIZZLE_STR_DR_ATI,
96 GL_SWIZZLE_STQ_DQ_ATI,
97 GL_SWIZZLE_STRQ_ATI,
98 GL_SWIZZLE_STRQ_DQ_ATI,
99 /*GL_RED_BIT_ATI,*/
100 GL_GREEN_BIT_ATI,
101 GL_BLUE_BIT_ATI,
102 /*GL_2X_BIT_ATI,*/
103 GL_4X_BIT_ATI,
104 GL_8X_BIT_ATI,
105 GL_HALF_BIT_ATI,
106 GL_QUARTER_BIT_ATI,
107 GL_EIGHTH_BIT_ATI,
108 GL_SATURATE_BIT_ATI,
109 GL_COMP_BIT_ATI,
110 GL_NEGATE_BIT_ATI,
111 GL_BIAS_BIT_ATI,
112 GL_TEXTURE0_ARB,
113 GL_TEXTURE1_ARB,
114 GL_TEXTURE2_ARB,
115 GL_TEXTURE3_ARB,
116 GL_TEXTURE4_ARB,
117 GL_TEXTURE5_ARB,
118 GL_TEXTURE6_ARB,
119 GL_TEXTURE7_ARB,
120 /*GL_NONE,*/
121 GL_RED,
122 GL_GREEN,
123 GL_BLUE,
124 GL_ALPHA,
127 void
128 piglit_init(int argc, char **argv)
130 unsigned i = 0;
131 bool pass = true;
133 piglit_require_extension("GL_ATI_fragment_shader");
135 for (i=0; i<ARRAY_SIZE(enums); i++)
136 if (!try_enum(enums[i]))
137 pass = false;
139 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);