ARB_ubo/referenced-by-shader: pass if shader compiler moves UBOs between shaders
[piglit.git] / tests / spec / ati_fragment_shader / error05-passes.c
blob35ef65be427c40c0d4f3dd82ea14cb26bc588598
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 5 of the Errors section:
26 * The error INVALID_OPERATION is generated by PassTexCoordATI or
27 * SampleMapATI if two shader passes have already been specified, or if
28 * the same <dst> register is specified twice in the same pass.
31 #include "piglit-util-gl.h"
33 static struct piglit_gl_test_config *piglit_config;
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 piglit_config = &config;
38 config.supports_gl_compat_version = 10;
39 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
41 PIGLIT_GL_TEST_CONFIG_END
43 enum piglit_result
44 piglit_display(void)
46 /* UNREACHED */
47 return PIGLIT_FAIL;
50 static enum piglit_result
51 too_many_passes(void *data)
53 bool pass = true;
55 glBeginFragmentShaderATI();
56 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
57 GL_REG_1_ATI, GL_NONE, GL_NONE);
58 glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
59 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
60 GL_REG_1_ATI, GL_NONE, GL_NONE);
61 pass &= piglit_check_gl_error(GL_NO_ERROR);
62 glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
63 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
64 glEndFragmentShaderATI();
66 glBeginFragmentShaderATI();
67 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
68 GL_REG_1_ATI, GL_NONE, GL_NONE);
69 glPassTexCoordATI(GL_REG_0_ATI, GL_REG_0_ATI, GL_SWIZZLE_STR_ATI);
70 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
71 GL_REG_1_ATI, GL_NONE, GL_NONE);
72 pass &= piglit_check_gl_error(GL_NO_ERROR);
73 glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
74 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
75 glEndFragmentShaderATI();
77 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
80 static enum piglit_result
81 same_reg_written_twice(void *data)
83 bool pass = true;
85 glBeginFragmentShaderATI();
86 glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
87 pass &= piglit_check_gl_error(GL_NO_ERROR);
88 glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);
89 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
90 /* note: Mesa requires at least 1 arith instruction,
91 * but this is not in the spec */
92 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
93 GL_REG_1_ATI, GL_NONE, GL_NONE);
94 glEndFragmentShaderATI();
96 glBeginFragmentShaderATI();
97 glPassTexCoordATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
98 pass &= piglit_check_gl_error(GL_NO_ERROR);
99 glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);
100 pass &= piglit_check_gl_error(GL_INVALID_OPERATION);
101 /* note: Mesa requires at least 1 arith instruction,
102 * but this is not in the spec */
103 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
104 GL_REG_1_ATI, GL_NONE, GL_NONE);
105 glEndFragmentShaderATI();
107 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
110 static const struct piglit_subtest subtests[] = {
112 "Too many passes",
113 "too-many-passes",
114 too_many_passes,
115 NULL
118 "Same reg written twice",
119 "same-reg-written-twice",
120 same_reg_written_twice,
121 NULL
124 NULL,
125 NULL,
126 NULL,
127 NULL
131 void
132 piglit_init(int argc, char **argv)
134 piglit_require_extension("GL_ATI_fragment_shader");
136 piglit_report_result(piglit_run_selected_subtests(subtests,
137 piglit_config->selected_subtests,
138 piglit_config->num_selected_subtests,
139 PIGLIT_SKIP));