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
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
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
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
46 char const *vs_source
=
48 "uniform samplerBuffer s;\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"
56 char const *fs_source
=
59 "out vec4 frag_color;\n"
61 " frag_color = color;\n"
95 int chunk_size
= 24 * sizeof(float);
99 piglit_display(void) {
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
++) {
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]),
128 piglit_height
/2, c
) && pass
;
131 piglit_present_results();
133 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
137 piglit_init(int argc
, char **argv
) {
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
);
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
);
161 glGenTextures(1, &tex
);
162 glBindTexture(GL_TEXTURE_BUFFER
, tex
);