framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / arb_texture_buffer_object / fetch-outside-bounds.c
blobc0e3976e62416f9f2b996bf8443d75d29069f390
1 /* Copyright © 2012 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 fetch-outside-bounds.c
25 * Tests that we can sample from outside of a texture buffer object
26 * without crashing.
28 * From the GL_ARB_texture_buffer_object spec:
30 * "When a buffer texture is accessed in a shader, the results of
31 * a texel fetch are undefined if the specified texel number is
32 * greater than or equal to the clamped number of texels in the
33 * texel array."
35 * we interpret this as allowing any result to come back, but not
36 * terminate the program. To test that, we glReadPixels the result
37 * but don't test the values returned.
40 #include "piglit-util-gl.h"
42 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config.supports_gl_compat_version = 10;
44 config.supports_gl_core_version = 31;
45 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
46 config.khr_no_error_support = PIGLIT_NO_ERRORS;
47 PIGLIT_GL_TEST_CONFIG_END
49 enum piglit_result
50 piglit_display(void)
52 static const char *vs_source =
53 "#version 140\n"
54 "in vec4 vertex;\n"
55 "void main()\n"
56 "{\n"
57 " gl_Position = vertex;\n"
58 "}\n";
60 static const char *fs_source =
61 "#version 140\n"
62 "uniform samplerBuffer s;\n"
63 "void main()\n"
64 "{\n"
65 " gl_FragColor = texelFetch(s, 4096);\n"
66 "}\n";
68 GLuint tex, tbo, vbo;
69 /* data stored in our TBO, not actually read by the shader. */
70 static const uint8_t data[4] = {0x0, 0xff, 0x0, 0x0};
71 uint8_t junk[4];
72 static const GLfloat verts[8] = {
73 -1, -1,
74 1, -1,
75 1, 1,
76 -1, 1
78 int vertex_location;
79 GLuint prog;
81 prog = piglit_build_simple_program(vs_source, fs_source);
82 glUseProgram(prog);
84 vertex_location = glGetAttribLocation(prog, "vertex");
86 glGenBuffers(1, &tbo);
87 glBindBuffer(GL_TEXTURE_BUFFER, tbo);
89 glGenTextures(1, &tex);
90 glBindTexture(GL_TEXTURE_BUFFER, tex);
92 glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, tbo);
93 glBufferData(GL_TEXTURE_BUFFER, sizeof(data), data, GL_STATIC_READ);
95 if (piglit_get_gl_version() >= 31) {
96 GLuint vao;
97 glGenVertexArrays(1, &vao);
98 glBindVertexArray(vao);
100 glGenBuffers(1, &vbo);
101 glBindBuffer(GL_ARRAY_BUFFER, vbo);
102 glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_READ);
103 glVertexAttribPointer(vertex_location, 2, GL_FLOAT,
104 GL_FALSE, 0, NULL);
105 glEnableVertexAttribArray(vertex_location);
106 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
108 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &junk);
109 /* We don't verify the junk read, since it's undefined. */
111 piglit_present_results();
113 return PIGLIT_PASS;
116 void
117 piglit_init(int argc, char **argv)
119 piglit_require_GLSL_version(140);
120 if (piglit_get_gl_version() < 31)
121 piglit_require_extension("GL_ARB_texture_buffer_object");