ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ati_fragment_shader / error14-invalidmod.c
blob6b0899905be88604063b95be4dfd7ec6df341107
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 14 of the Errors section:
26 * The error INVALID_ENUM is generated if <dstMod> passed to
27 * ColorFragmentOp[1..3]ATI or AlphaFragmentOp[1..3]ATI contains
28 * multiple mutually exclusive modifier bits, not counting
29 * SATURATE_BIT_ATI.
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; }
50 #define check_enum_good(en) if (!piglit_check_gl_error(GL_NO_ERROR)) \
51 { printf("Enum %s 0x%x rejected\n", piglit_get_gl_enum_name(en), en); pass = false; }
53 bool
54 try_enum(unsigned e)
56 bool pass = true;
58 glBeginFragmentShaderATI();
59 pass &= piglit_check_gl_error(GL_NO_ERROR);
60 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, e,
61 GL_REG_0_ATI, GL_NONE, GL_NONE);
62 check_enum_error(e);
64 glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, e,
65 GL_REG_0_ATI, GL_NONE, GL_NONE);
66 check_enum_error(e);
67 glEndFragmentShaderATI();
68 /* All instructions were invalid, so the shader should be empty,
69 * which is invalid
71 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
73 /* TODO check fragment ops with more arguments? */
75 return pass;
78 static const unsigned enums[] = {
79 GL_2X_BIT_ATI | GL_4X_BIT_ATI,
80 GL_2X_BIT_ATI | GL_8X_BIT_ATI,
81 GL_2X_BIT_ATI | GL_HALF_BIT_ATI,
82 GL_2X_BIT_ATI | GL_QUARTER_BIT_ATI,
83 GL_2X_BIT_ATI | GL_EIGHTH_BIT_ATI,
84 GL_4X_BIT_ATI | GL_8X_BIT_ATI,
85 GL_4X_BIT_ATI | GL_HALF_BIT_ATI,
86 GL_4X_BIT_ATI | GL_QUARTER_BIT_ATI,
87 GL_4X_BIT_ATI | GL_EIGHTH_BIT_ATI,
88 GL_8X_BIT_ATI | GL_HALF_BIT_ATI,
89 GL_8X_BIT_ATI | GL_QUARTER_BIT_ATI,
90 GL_8X_BIT_ATI | GL_EIGHTH_BIT_ATI,
91 GL_HALF_BIT_ATI | GL_QUARTER_BIT_ATI,
92 GL_HALF_BIT_ATI | GL_EIGHTH_BIT_ATI,
93 GL_QUARTER_BIT_ATI | GL_EIGHTH_BIT_ATI,
96 bool try_compatible_enum(unsigned e)
98 bool pass = true;
100 glBeginFragmentShaderATI();
101 pass &= piglit_check_gl_error(GL_NO_ERROR);
102 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, e,
103 GL_REG_0_ATI, GL_NONE, GL_NONE);
104 check_enum_good(e);
106 glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, e,
107 GL_REG_0_ATI, GL_NONE, GL_NONE);
108 check_enum_good(e);
109 glEndFragmentShaderATI();
110 pass &= piglit_check_gl_error(GL_NO_ERROR);
112 /* TODO check fragment ops with more arguments? */
114 return pass;
117 static const unsigned good_enums[] = {
118 GL_2X_BIT_ATI | GL_SATURATE_BIT_ATI,
119 GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI,
120 GL_8X_BIT_ATI | GL_SATURATE_BIT_ATI,
121 GL_HALF_BIT_ATI | GL_SATURATE_BIT_ATI,
122 GL_QUARTER_BIT_ATI | GL_SATURATE_BIT_ATI,
123 GL_EIGHTH_BIT_ATI | GL_SATURATE_BIT_ATI,
126 void
127 piglit_init(int argc, char **argv)
129 unsigned i;
130 bool pass = true;
132 piglit_require_extension("GL_ATI_fragment_shader");
134 for (i=0; i<ARRAY_SIZE(enums); i++) {
135 if (!try_enum(enums[i]))
136 pass = false;
137 if (!try_enum(enums[i] | GL_SATURATE_BIT_ATI))
138 pass = false;
141 /* test that all the mods are compatible with SATURATE */
142 for (i=0; i<ARRAY_SIZE(good_enums); i++)
143 if (!try_compatible_enum(good_enums[i]))
144 pass = false;
146 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);