ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ati_fragment_shader / render-notexture.c
blob86a5a04c21b2cbd33f0e723e34018b93baf1de96
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: when no texture is bound
26 * - glPassTexCoordATI() should work as normal
27 * - glSampleMapATI() should return all zeros
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config.supports_gl_compat_version = 10;
35 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
37 PIGLIT_GL_TEST_CONFIG_END
39 static const float color1[] = {0.2, 0.3, 0.8};
40 static const float texcoord[] = {0.2, 0.7, 0.4};
41 static const float black[] = {0.0, 0.0, 0.0};
43 enum {
44 SHADER_TEXCOORD = 1,
45 SHADER_TEX,
48 enum piglit_result
49 piglit_display(void)
51 bool pass = true;
52 GLuint tex;
54 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
56 glClearColor(1.0, 0.0, 0.0, 1.0);
57 glClear(GL_COLOR_BUFFER_BIT);
59 glTexCoord3fv(texcoord);
61 glEnable(GL_FRAGMENT_SHADER_ATI);
62 glBindFragmentShaderATI(SHADER_TEXCOORD);
63 piglit_draw_rect(0, 0, piglit_width / 4, piglit_height);
64 glBindFragmentShaderATI(SHADER_TEX);
65 piglit_draw_rect(piglit_width / 4, 0, piglit_width / 4, piglit_height);
66 glGenTextures(1, &tex);
67 glBindTexture(GL_TEXTURE_2D, tex);
68 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_FLOAT,
69 (void*)color1);
70 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
72 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
73 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
74 piglit_draw_rect(2 * piglit_width / 4, 0,
75 piglit_width / 4, piglit_height);
76 glEnable(GL_TEXTURE_2D);
77 piglit_draw_rect(3 * piglit_width / 4, 0,
78 piglit_width / 4, piglit_height);
79 glDisable(GL_TEXTURE_2D);
80 glDeleteTextures(1, &tex);
81 glDisable(GL_FRAGMENT_SHADER_ATI);
83 pass = pass && piglit_probe_rect_rgb(0, 0, piglit_width / 4,
84 piglit_height, texcoord);
85 pass = pass && piglit_probe_rect_rgb(piglit_width / 4, 0,
86 piglit_width / 4,
87 piglit_height, black);
88 pass = pass && piglit_probe_rect_rgb(2 * piglit_width / 4, 0,
89 piglit_width / 4,
90 piglit_height, black);
91 pass = pass && piglit_probe_rect_rgb(3 * piglit_width / 4, 0,
92 piglit_width / 4,
93 piglit_height, color1);
95 piglit_present_results();
97 pass &= piglit_check_gl_error(GL_NO_ERROR);
99 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
102 void
103 piglit_init(int argc, char **argv)
105 piglit_require_extension("GL_ATI_fragment_shader");
107 glBindFragmentShaderATI(SHADER_TEXCOORD);
108 glBeginFragmentShaderATI();
109 glPassTexCoordATI(GL_REG_1_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
110 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
111 GL_REG_1_ATI, GL_NONE, GL_NONE);
112 glEndFragmentShaderATI();
114 glBindFragmentShaderATI(SHADER_TEX);
115 glBeginFragmentShaderATI();
116 glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);
117 glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
118 GL_REG_0_ATI, GL_NONE, GL_NONE);
119 glEndFragmentShaderATI();
121 if (!piglit_check_gl_error(GL_NO_ERROR))
122 piglit_report_result(PIGLIT_FAIL);