ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ati_fragment_shader / error10-dotx.c
blobc112e7eeb342ff73af5dc712c099560d8250d4ac
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 10 of the Errors section:
26 * The error INVALID_OPERATION is generated by AlphaFragmentOp[2..3]ATI
27 * if <op> is DOT3_ATI, DOT4_ATI, or DOT2_ADD_ATI and there was no
28 * matching ColorFragmentOp[2..3]ATI immediately preceding, or if <op>
29 * is not DOT4_ATI and the immediately preceding ColorFragmentOp2ATI
30 * specifies an <op> of DOT4_ATI.
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config.supports_gl_compat_version = 10;
38 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
40 PIGLIT_GL_TEST_CONFIG_END
42 enum piglit_result
43 piglit_display(void)
45 /* UNREACHED */
46 return PIGLIT_FAIL;
49 void
50 piglit_init(int argc, char **argv)
52 bool pass = true;
54 piglit_require_extension("GL_ATI_fragment_shader");
56 /* nothing before it */
58 /* In these shaders all instructions are invalid, so the shader should
59 * be empty, which is invalid
61 glBeginFragmentShaderATI();
62 pass &= piglit_check_gl_error(GL_NO_ERROR);
63 glAlphaFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_ATI, GL_NONE,
64 GL_CON_2_ATI, GL_NONE, GL_NONE,
65 GL_REG_1_ATI, GL_NONE, GL_NONE);
66 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
67 glEndFragmentShaderATI();
68 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
70 glBeginFragmentShaderATI();
71 pass &= piglit_check_gl_error(GL_NO_ERROR);
72 glAlphaFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE,
73 GL_CON_2_ATI, GL_NONE, GL_NONE,
74 GL_REG_1_ATI, GL_NONE, GL_NONE);
75 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
76 glEndFragmentShaderATI();
77 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
79 glBeginFragmentShaderATI();
80 pass &= piglit_check_gl_error(GL_NO_ERROR);
81 glAlphaFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI, GL_NONE,
82 GL_CON_2_ATI, GL_NONE, GL_NONE,
83 GL_REG_2_ATI, GL_NONE, GL_NONE,
84 GL_REG_1_ATI, GL_NONE, GL_NONE);
85 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
86 glEndFragmentShaderATI();
87 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
89 /* mismatching color op before it */
91 glBeginFragmentShaderATI();
92 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
93 GL_CON_3_ATI, GL_NONE, GL_NONE);
94 pass &= piglit_check_gl_error(GL_NO_ERROR);
95 glAlphaFragmentOp2ATI(GL_DOT3_ATI, GL_REG_0_ATI, GL_NONE,
96 GL_CON_2_ATI, GL_NONE, GL_NONE,
97 GL_REG_1_ATI, GL_NONE, GL_NONE);
98 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
99 glEndFragmentShaderATI();
101 glBeginFragmentShaderATI();
102 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
103 GL_CON_3_ATI, GL_NONE, GL_NONE);
104 pass &= piglit_check_gl_error(GL_NO_ERROR);
105 glAlphaFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE,
106 GL_CON_2_ATI, GL_NONE, GL_NONE,
107 GL_REG_1_ATI, GL_NONE, GL_NONE);
108 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
109 glEndFragmentShaderATI();
111 glBeginFragmentShaderATI();
112 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
113 GL_CON_3_ATI, GL_NONE, GL_NONE);
114 pass &= piglit_check_gl_error(GL_NO_ERROR);
115 glAlphaFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI, GL_NONE,
116 GL_CON_2_ATI, GL_NONE, GL_NONE,
117 GL_REG_2_ATI, GL_NONE, GL_NONE,
118 GL_REG_1_ATI, GL_NONE, GL_NONE);
119 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
120 glEndFragmentShaderATI();
122 /* after color DOT4 the alpha is not DOT4 */
124 glBeginFragmentShaderATI();
125 glColorFragmentOp2ATI(GL_DOT4_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
126 GL_REG_2_ATI, GL_NONE, GL_NONE,
127 GL_CON_3_ATI, GL_NONE, GL_NONE);
128 pass &= piglit_check_gl_error(GL_NO_ERROR);
129 glAlphaFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE,
130 GL_CON_2_ATI, GL_NONE, GL_NONE,
131 GL_REG_1_ATI, GL_NONE, GL_NONE);
132 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
133 glEndFragmentShaderATI();
135 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);