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
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
26 * Tests that glBufferData() synchronizes correctly with TBO rendering.
28 * Caught a bug in the i965 driver after a core Mesa refactor.
31 #include "piglit-util-gl.h"
33 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config
.supports_gl_compat_version
= 10;
35 config
.supports_gl_core_version
= 31;
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
44 static const char *vs_source
=
46 "in vec4 piglit_vertex;\n"
49 " gl_Position = piglit_vertex;\n"
52 static const char *fs_source
=
54 "uniform samplerBuffer s;\n"
57 " gl_FragColor = texelFetch(s, 0);\n"
63 float green
[] = {0, 1, 0, 0};
64 float blue
[] = {0, 0, 1, 0};
65 uint8_t g_rgba8
[] = {0x00, 0xff, 0x00, 0x00};
66 uint8_t b_rgba8
[] = {0x00, 0x00, 0xff, 0x00};
68 prog
= piglit_build_simple_program(vs_source
, fs_source
);
72 glBindBuffer(GL_TEXTURE_BUFFER
, bo
);
73 glBufferData(GL_TEXTURE_BUFFER
, sizeof(g_rgba8
), g_rgba8
,
76 glGenTextures(1, &tex
);
77 glBindTexture(GL_TEXTURE_BUFFER
, tex
);
78 glTexBuffer(GL_TEXTURE_BUFFER
, GL_RGBA8
, bo
);
80 piglit_draw_rect(-1, -1, 1, 2);
81 glBufferData(GL_TEXTURE_BUFFER
, 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
,
88 pass
= pass
&& piglit_probe_rect_rgba(piglit_width
/ 2, 0,
89 piglit_width
/ 2, piglit_height
,
92 piglit_present_results();
94 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
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");