ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_texture_buffer_object / subdata-sync.c
blob636d8fcdde15b9a66a0a30db6c80e589fe212eb2
1 /*
2 * Copyright © 2013 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 DEALINGS
21 * IN THE SOFTWARE.
24 /** @file subdata-sync.c
26 * Tests that glBufferSubData() synchronizes correctly with TBO rendering.
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
32 config.supports_gl_compat_version = 10;
33 config.supports_gl_core_version = 31;
35 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
36 config.khr_no_error_support = PIGLIT_NO_ERRORS;
37 PIGLIT_GL_TEST_CONFIG_END
39 enum piglit_result
40 piglit_display(void)
42 static const char *vs_source =
43 "#version 140\n"
44 "in vec4 piglit_vertex;\n"
45 "void main()\n"
46 "{\n"
47 " gl_Position = piglit_vertex;\n"
48 "}\n";
50 static const char *fs_source =
51 "#version 140\n"
52 "uniform samplerBuffer s;\n"
53 "void main()\n"
54 "{\n"
55 " gl_FragColor = texelFetch(s, 0);\n"
56 "}\n";
58 bool pass = true;
59 GLuint tex, bo;
60 GLuint prog;
61 float green[] = {0, 1, 0, 0};
62 float blue[] = {0, 0, 1, 0};
63 uint8_t g_rgba8[] = {0x00, 0xff, 0x00, 0x00};
64 uint8_t b_rgba8[] = {0x00, 0x00, 0xff, 0x00};
66 prog = piglit_build_simple_program(vs_source, fs_source);
67 glUseProgram(prog);
69 glGenBuffers(1, &bo);
70 glBindBuffer(GL_TEXTURE_BUFFER, bo);
71 /* Make the buffer bigger than the data to trigger the driver
72 * code path we want.
74 glBufferData(GL_TEXTURE_BUFFER, 4096, NULL, GL_STREAM_DRAW);
75 glBufferSubData(GL_TEXTURE_BUFFER, 0, sizeof(g_rgba8), g_rgba8);
77 glGenTextures(1, &tex);
78 glBindTexture(GL_TEXTURE_BUFFER, tex);
79 glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, bo);
81 piglit_draw_rect(-1, -1, 1, 2);
82 glBufferSubData(GL_TEXTURE_BUFFER, 0, sizeof(b_rgba8), b_rgba8);
83 piglit_draw_rect(0, -1, 1, 2);
85 pass = pass && piglit_probe_rect_rgba(0, 0,
86 piglit_width / 2, piglit_height,
87 green);
88 pass = pass && piglit_probe_rect_rgba(piglit_width / 2, 0,
89 piglit_width / 2, piglit_height,
90 blue);
92 piglit_present_results();
94 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
97 void
98 piglit_init(int argc, char **argv)
100 piglit_require_GLSL_version(140);
101 if (piglit_get_gl_version() < 31)
102 piglit_require_extension("GL_ARB_texture_buffer_object");