fbo-mrt-alphatest: Actually require MRTs to be available.
[piglit.git] / tests / spec / arb_direct_state_access / texture-buffer.c
blob39cafc8080271385669bf13f9ed292b5bb13ad9a
1 /*
2 * Copyright © 2013, 2014 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 texture-buffer.c
26 * Tests that glBufferData() synchronizes correctly with TBO rendering.
28 * Caught a bug in the i965 driver after a core Mesa refactor.
30 * Adapted to test glTextureBuffer by Laura Ekstrand (December 2014).
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
36 config.supports_gl_core_version = 31;
38 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE |
39 PIGLIT_GL_VISUAL_RGBA;
40 config.khr_no_error_support = PIGLIT_NO_ERRORS;
41 PIGLIT_GL_TEST_CONFIG_END
43 static const char vs_source[] =
44 "#version 140\n"
45 "in vec4 piglit_vertex;\n"
46 "void main()\n"
47 "{\n"
48 " gl_Position = piglit_vertex;\n"
49 "}\n"
52 static const char fs_source[] =
53 "#version 140\n"
54 "uniform samplerBuffer s;\n"
55 "void main()\n"
56 "{\n"
57 " gl_FragColor = texelFetch(s, 0);\n"
58 "}\n"
61 static GLuint prog;
62 static GLuint tex;
63 static GLuint bo;
65 enum piglit_result
66 piglit_display(void)
69 bool pass = true;
70 static const float green[] = {0, 1, 0, 0};
71 static const float blue[] = {0, 0, 1, 0};
72 static const uint8_t g_rgba8[] = {0x00, 0xff, 0x00, 0x00};
73 static const uint8_t b_rgba8[] = {0x00, 0x00, 0xff, 0x00};
75 glBufferData(GL_TEXTURE_BUFFER, sizeof(g_rgba8), g_rgba8,
76 GL_STREAM_DRAW);
77 piglit_draw_rect(-1, -1, 1, 2);
78 glBufferData(GL_TEXTURE_BUFFER, sizeof(b_rgba8), b_rgba8,
79 GL_STREAM_DRAW);
80 piglit_draw_rect(0, -1, 1, 2);
82 pass = piglit_probe_rect_rgba(0, 0,
83 piglit_width / 2, piglit_height,
84 green)
85 && pass;
86 pass = piglit_probe_rect_rgba(piglit_width / 2, 0,
87 piglit_width / 2, piglit_height,
88 blue)
89 && pass;
91 piglit_present_results();
93 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
96 void
97 piglit_init(int argc, char **argv)
99 piglit_require_extension("GL_ARB_direct_state_access");
101 prog = piglit_build_simple_program(vs_source, fs_source);
102 glUseProgram(prog);
104 glGenBuffers(1, &bo);
105 glBindBuffer(GL_TEXTURE_BUFFER, bo);
107 glCreateTextures(GL_TEXTURE_BUFFER, 1, &tex);
108 glTextureBuffer(tex, GL_RGBA8, bo);
109 glBindTextureUnit(0, tex);