framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / arb_gpu_shader_fp64 / vs-non-uniform-control-flow-ubo.c
blob6db743df2e50ffe2224b7b56bd58c02d11845972
1 /*
2 * Copyright © 2016 Intel Corporation
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
21 * DEALINGS IN THE SOFTWARE.
24 /** @file vs-non-uniform-control-flow-ubo.c
26 * This test checks that uniform block reads works correctly when they are
27 * under non-uniform control flow.
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config.window_width = 62;
34 config.window_height = 62;
35 config.supports_gl_compat_version = 32;
36 config.supports_gl_core_version = 32;
37 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
38 config.khr_no_error_support = PIGLIT_NO_ERRORS;
39 PIGLIT_GL_TEST_CONFIG_END
41 #define UBO_SIZE 12
43 static const char vs_source[] =
44 "#version 330\n"
45 "#extension GL_ARB_gpu_shader_fp64 : require\n"
46 "#extension GL_ARB_shading_language_420pack : require\n"
47 "\n"
48 "out vec4 color;\n"
49 "\n"
50 "layout(binding=2) uniform ubo {\n"
51 " dvec2 color2[];\n"
52 "};\n"
53 "\n"
54 "layout(location = 0) in vec3 inVertexPosition;\n"
55 "\n"
56 "void main() {\n"
57 " gl_Position = vec4(inVertexPosition, 1);\n"
58 " dvec2 rg;\n"
59 " if (inVertexPosition.x < 0 && inVertexPosition.y < 0)\n"
60 " rg = color2[0];\n"
61 " else\n"
62 " rg = color2[1];\n"
63 " color = vec4(rg, 0, 1);\n"
64 "}\n";
66 static const char fs_source[] =
67 "#version 130\n"
68 "\n"
69 "in vec4 color;\n"
70 "out vec4 frag_color;\n"
71 "\n"
72 "void main() {\n"
73 " frag_color = color;\n"
74 "}\n";
76 static GLuint prog, vertexArrayID;
77 static GLuint fb, rb;
79 void
80 piglit_init(int argc, char **argv)
82 GLuint vertexBuffer, buffer;
83 // Vertex data
84 static const GLfloat vertexData[4 * 3] = {
85 -1.0f, -1.0f, -1.0f,
86 1.0f, -1.0f, -1.0f,
87 -1.0f, 1.0f, -1.0f,
88 1.0f, 1.0f, -1.0f,
90 static double ubo_values[UBO_SIZE] = {0, 1, 1, 0,
91 0, 0, 0, 0,
92 0, 0, 0, 0};
94 piglit_require_extension("GL_ARB_gpu_shader_fp64");
96 piglit_require_GLSL_version(330);
98 prog = piglit_build_simple_program(vs_source, fs_source);
99 glUseProgram(prog);
101 glClearColor(0, 0, 0, 1);
102 glPointSize(10.0);
104 glGenRenderbuffers(1, &rb);
105 glBindRenderbuffer(GL_RENDERBUFFER, rb);
106 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA,
107 piglit_width, piglit_height);
109 glGenFramebuffers(1, &fb);
110 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb);
111 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
112 GL_RENDERBUFFER, rb);
114 // Record vertex data and attributes in a VAO
115 glGenVertexArrays(1, &vertexArrayID);
116 glBindVertexArray(vertexArrayID);
117 // Upload vertex position data to a VBO
118 glGenBuffers(1, &vertexBuffer);
119 glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
120 glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData),
121 vertexData, GL_STATIC_DRAW);
123 // Bind vertex position VBO to vertex shader attribute index 0
124 glEnableVertexAttribArray(0);
125 glVertexAttribPointer(
126 0, // attribute index
127 3, // size
128 GL_FLOAT, // type
129 GL_FALSE, // normalized?
130 0, // stride
131 (void*)0 // buffer offset
134 glBindBuffer(GL_ARRAY_BUFFER, 0);
135 // Unbind VAO
136 glBindVertexArray(0);
137 // Disable attribute arrays
138 glDisableVertexAttribArray(0);
140 glGenBuffers(1, &buffer);
141 glBindBufferBase(GL_UNIFORM_BUFFER, 2, buffer);
142 glBufferData(GL_UNIFORM_BUFFER, UBO_SIZE*sizeof(GLdouble),
143 &ubo_values[0], GL_DYNAMIC_DRAW);
145 if (!piglit_check_gl_error(GL_NO_ERROR))
146 piglit_report_result(PIGLIT_FAIL);
149 enum piglit_result piglit_display(void)
151 bool pass = true;
152 float red[4] = {1.0, 0.0, 0.0, 1.0};
153 float green[4] = {0.0, 1.0, 0.0, 1.0};
155 glUseProgram(prog);
156 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb);
157 glViewport(0, 0, piglit_width, piglit_height);
159 glClear(GL_COLOR_BUFFER_BIT);
160 glBindVertexArray(vertexArrayID);
161 glDrawArrays(GL_POINTS, 0, 4);
162 glBindVertexArray(0);
164 glBindFramebuffer(GL_READ_FRAMEBUFFER, fb);
166 /* Verify */
167 pass = piglit_probe_pixel_rgba(0, 0, green) && pass;
168 pass = piglit_probe_pixel_rgba(0, piglit_height - 1, red) && pass;
169 pass = piglit_probe_pixel_rgba(piglit_width - 1,
170 piglit_height - 1, red) && pass;
171 pass = piglit_probe_pixel_rgba(piglit_width - 1, 0, red) && pass;
173 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
174 piglit_present_results();
176 return pass ? PIGLIT_PASS : PIGLIT_FAIL;