ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ati_fragment_shader / render-textargets.c
blobc3dfe5f5148b094b53d7c1ed39fc5cc76cfe2308
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 /**
25 * Tests rendering with GL_ATI_fragment_shader: using different
26 * texture targets with the same shader.
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config.supports_gl_compat_version = 10;
34 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
36 PIGLIT_GL_TEST_CONFIG_END
38 static const float color1[] = {0.2, 0.3, 0.8};
39 static const float color2[] = {0.9, 0.8, 0.3};
40 static const float texcoord[] = {0.2, 0.7, 0.4};
42 static GLuint tex2D;
43 static GLuint texCUBE;
45 enum piglit_result
46 piglit_display(void)
48 bool pass = true;
50 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
52 glClearColor(1.0, 0.0, 0.0, 1.0);
53 glClear(GL_COLOR_BUFFER_BIT);
55 glTexCoord3fv(texcoord);
57 glEnable(GL_FRAGMENT_SHADER_ATI);
58 glEnable(GL_TEXTURE_2D);
59 glBindTexture(GL_TEXTURE_2D, tex2D);
60 piglit_draw_rect(0, 0, piglit_width / 2, piglit_height);
61 glDisable(GL_TEXTURE_2D);
62 glEnable(GL_TEXTURE_CUBE_MAP);
63 glBindTexture(GL_TEXTURE_CUBE_MAP, texCUBE);
64 piglit_draw_rect(piglit_width / 2, 0, piglit_width / 2, piglit_height);
65 glDisable(GL_TEXTURE_CUBE_MAP);
66 glDisable(GL_FRAGMENT_SHADER_ATI);
68 pass = pass && piglit_probe_rect_rgb(0, 0,
69 piglit_width / 2,
70 piglit_height, color1);
71 pass = pass && piglit_probe_rect_rgb(piglit_width / 2, 0,
72 piglit_width / 2,
73 piglit_height, color2);
75 piglit_present_results();
77 pass &= piglit_check_gl_error(GL_NO_ERROR);
79 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
82 void
83 piglit_init(int argc, char **argv)
85 piglit_require_extension("GL_ATI_fragment_shader");
87 glBeginFragmentShaderATI();
88 glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
89 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
90 GL_REG_0_ATI, GL_NONE, GL_NONE);
91 glEndFragmentShaderATI();
93 glGenTextures(1, &tex2D);
94 glBindTexture(GL_TEXTURE_2D, tex2D);
95 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_FLOAT,
96 (void*)color1);
97 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
98 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
99 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
100 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
102 glGenTextures(1, &texCUBE);
103 glBindTexture(GL_TEXTURE_CUBE_MAP, texCUBE);
104 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, 1, 1, 0,
105 GL_RGB, GL_FLOAT, (void*)color2);
106 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, 1, 1, 0,
107 GL_RGB, GL_FLOAT, (void*)color2);
108 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, 1, 1, 0,
109 GL_RGB, GL_FLOAT, (void*)color2);
110 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, 1, 1, 0,
111 GL_RGB, GL_FLOAT, (void*)color2);
112 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, 1, 1, 0,
113 GL_RGB, GL_FLOAT, (void*)color2);
114 glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, 1, 1, 0,
115 GL_RGB, GL_FLOAT, (void*)color2);
116 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
117 glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
119 if (!piglit_check_gl_error(GL_NO_ERROR))
120 piglit_report_result(PIGLIT_FAIL);