ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ati_fragment_shader / error12-invalidsrc.c
blob5e2a641192c3800bd46130547e514bddd07f70ee
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 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
41 enum piglit_result
42 piglit_display(void)
44 /* UNREACHED */
45 return PIGLIT_FAIL;
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; }
51 bool
52 try_enum(unsigned e)
54 bool pass = true;
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);
61 check_enum_error(e);
63 glSampleMapATI(GL_REG_0_ATI, e, GL_SWIZZLE_STR_ATI);
64 check_enum_error(e);
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);
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_CON_0_ATI,
83 GL_CON_1_ATI,
84 GL_CON_2_ATI,
85 GL_CON_3_ATI,
86 GL_CON_4_ATI,
87 GL_CON_5_ATI,
88 GL_CON_6_ATI,
89 GL_CON_7_ATI,
90 GL_MOV_ATI,
91 GL_ADD_ATI,
92 GL_MUL_ATI,
93 GL_SUB_ATI,
94 GL_DOT3_ATI,
95 GL_DOT4_ATI,
96 GL_MAD_ATI,
97 GL_LERP_ATI,
98 GL_CND_ATI,
99 GL_CND0_ATI,
100 GL_DOT2_ADD_ATI,
101 GL_SECONDARY_INTERPOLATOR_ATI,
102 GL_SWIZZLE_STR_ATI,
103 GL_SWIZZLE_STQ_ATI,
104 GL_SWIZZLE_STR_DR_ATI,
105 GL_SWIZZLE_STQ_DQ_ATI,
106 GL_SWIZZLE_STRQ_ATI,
107 GL_SWIZZLE_STRQ_DQ_ATI,
108 GL_RED_BIT_ATI,
109 GL_GREEN_BIT_ATI,
110 GL_BLUE_BIT_ATI,
111 GL_2X_BIT_ATI,
112 GL_4X_BIT_ATI,
113 GL_8X_BIT_ATI,
114 GL_HALF_BIT_ATI,
115 GL_QUARTER_BIT_ATI,
116 GL_EIGHTH_BIT_ATI,
117 GL_SATURATE_BIT_ATI,
118 GL_COMP_BIT_ATI,
119 GL_NEGATE_BIT_ATI,
120 GL_BIAS_BIT_ATI,
121 GL_PRIMARY_COLOR_ARB,
122 GL_NONE,
123 GL_RED,
124 GL_GREEN,
125 GL_BLUE,
126 GL_ALPHA,
129 void
130 piglit_init(int argc, char **argv)
132 int num_tex_coords;
133 unsigned i;
134 bool pass = true;
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))
153 pass = false;
156 /* Try some invalid enums */
158 for (i=0; i<ARRAY_SIZE(enums); i++)
159 if (!try_enum(enums[i]))
160 pass = false;
162 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);