framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / arb_texture_buffer_range / ranges-2.c
blob54bcdb8ad546ea21ca1e4433a77b0cee658d9e8c
1 /* Copyright © 2014 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
23 /** @file ranges-2.c
25 * Test that *just* changing the bound range of a TexBO (without changing
26 * anything else) works. This is to demonstrate a bug in Mesa's dirty state
27 * flagging.
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config.supports_gl_core_version = 31;
36 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
37 config.khr_no_error_support = PIGLIT_NO_ERRORS;
39 PIGLIT_GL_TEST_CONFIG_END
41 GLuint prog;
42 GLuint vao;
43 GLuint tbo;
44 GLuint tex;
46 char const *vs_source =
47 "#version 140\n"
48 "uniform samplerBuffer s;\n"
49 "out vec4 color;\n"
50 "void main() {\n"
51 " vec4 x = texelFetch(s, gl_VertexID);\n"
52 " gl_Position = vec4(x.xy, 0, 1);\n"
53 " color = vec4(x.zw, 0, 1);\n"
54 "}\n";
56 char const *fs_source =
57 "#version 140\n"
58 "in vec4 color;\n"
59 "out vec4 frag_color;\n"
60 "void main() {\n"
61 " frag_color = color;\n"
62 "}\n";
64 float data[] = {
65 -1, -1, 0, 1,
66 0, -1, 0, 1,
67 0, 0, 0, 1,
68 -1, -1, 0, 1,
69 0, 0, 0, 1,
70 -1, 0, 0, 1,
72 -1, 0, 0, 0.5,
73 0, 0, 0, 0.5,
74 0, 1, 0, 0.5,
75 -1, 0, 0, 0.5,
76 0, 1, 0, 0.5,
77 -1, 1, 0, 0.5,
79 0, 0, 1, 0,
80 1, 0, 1, 0,
81 1, 1, 1, 0,
82 0, 0, 1, 0,
83 1, 1, 1, 0,
84 0, 1, 1, 0,
86 0, -1, 0.5, 0,
87 1, -1, 0.5, 0,
88 1, 0, 0.5, 0,
89 0, -1, 0.5, 0,
90 1, 0, 0.5, 0,
91 0, 0, 0.5, 0,
94 int aligned_size = 0;
95 int chunk_size = 24 * sizeof(float);
96 int num_chunks = 4;
98 enum piglit_result
99 piglit_display(void) {
100 int i;
101 bool pass = true;
103 glClearColor(0.2, 0.2, 0.2, 0.2);
104 glClear(GL_COLOR_BUFFER_BIT);
106 /* verify unaligned offsets produce an error */
107 glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, tbo, aligned_size - 1, 1);
108 pass &= glGetError() == GL_INVALID_VALUE;
110 for (i = 0; i < num_chunks; i++) {
111 glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F,
112 tbo, i * aligned_size, chunk_size);
113 glDrawArrays(GL_TRIANGLES, 0, 6);
116 for (i = 0; i < num_chunks; i++) {
117 float c[4] = {
118 data[i * 24 + 2],
119 data[i * 24 + 3],
124 pass &= piglit_probe_rect_rgba(
125 piglit_width * 0.5 * (1 + data[i * 24 + 0]),
126 piglit_height * 0.5 * (1 + data[i * 24 + 1]),
127 piglit_width/2,
128 piglit_height/2, c) && pass;
131 piglit_present_results();
133 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
136 void
137 piglit_init(int argc, char **argv) {
138 GLint align, i;
139 uint8_t *chunk;
141 piglit_require_extension("GL_ARB_texture_buffer_range");
143 glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, &align);
144 aligned_size = ALIGN(chunk_size, align);
146 prog = piglit_build_simple_program(vs_source, fs_source);
147 glUseProgram(prog);
149 glGenVertexArrays(1, &vao);
150 glBindVertexArray(vao);
152 glGenBuffers(1, &tbo);
153 glBindBuffer(GL_ARRAY_BUFFER, tbo);
154 glBufferData(GL_ARRAY_BUFFER, aligned_size * num_chunks, NULL, GL_STATIC_DRAW);
156 for (i = 0, chunk = (uint8_t *)data; i < num_chunks; i++) {
157 glBufferSubData(GL_ARRAY_BUFFER, aligned_size * i, chunk_size, chunk);
158 chunk += chunk_size;
161 glGenTextures(1, &tex);
162 glBindTexture(GL_TEXTURE_BUFFER, tex);