diff options
author | Brian Paul <brianp@vmware.com> | 2014-10-20 12:47:43 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2014-10-24 08:34:39 -0600 |
commit | 69fa359114e5c650d47cc39f8224e323f1b7a6f3 (patch) | |
tree | 57b62b023dd1945a2ce9b84a81b7c15efbfe2698 | |
parent | 28505ec885274a0451f8ca831e12f5839ce79305 (diff) |
arb_uniform_buffer_object: add 'offset' option to the rendering test
If argc[1]=="offset" use glBindBufferRange with a non-zero offset.
The offset is simply the value of GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT.
It seems no other UBO test actually exercises this.
-rw-r--r-- | tests/all.py | 1 | ||||
-rw-r--r-- | tests/spec/arb_uniform_buffer_object/rendering.c | 32 |
2 files changed, 27 insertions, 6 deletions
diff --git a/tests/all.py b/tests/all.py index 8f75796aa..ea83695ba 100644 --- a/tests/all.py +++ b/tests/all.py @@ -3281,6 +3281,7 @@ arb_uniform_buffer_object['negative-getactiveuniformblockiv'] = PiglitGLTest('ar arb_uniform_buffer_object['negative-getactiveuniformsiv'] = PiglitGLTest('arb_uniform_buffer_object-negative-getactiveuniformsiv', run_concurrent=True) arb_uniform_buffer_object['referenced-by-shader'] = PiglitGLTest('arb_uniform_buffer_object-referenced-by-shader', run_concurrent=True) arb_uniform_buffer_object['rendering'] = PiglitGLTest('arb_uniform_buffer_object-rendering', run_concurrent=True) +arb_uniform_buffer_object['rendering-offset'] = PiglitGLTest('arb_uniform_buffer_object-rendering offset', run_concurrent=True) arb_uniform_buffer_object['row-major'] = PiglitGLTest('arb_uniform_buffer_object-row-major', run_concurrent=True) arb_uniform_buffer_object['uniformblockbinding'] = PiglitGLTest('arb_uniform_buffer_object-uniformblockbinding', run_concurrent=True) diff --git a/tests/spec/arb_uniform_buffer_object/rendering.c b/tests/spec/arb_uniform_buffer_object/rendering.c index 0f3b40832..8179b6ece 100644 --- a/tests/spec/arb_uniform_buffer_object/rendering.c +++ b/tests/spec/arb_uniform_buffer_object/rendering.c @@ -92,6 +92,8 @@ static const float rotation[NUM_SQUARES] = { static GLuint prog; static GLuint buffers[NUM_UBOS]; +static GLint alignment; +static bool test_buffer_offset = false; static void @@ -105,6 +107,17 @@ setup_ubos(void) static GLubyte zeros[1000] = {0}; int i; + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment); + printf("GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = %d\n", alignment); + + if (test_buffer_offset) { + printf("Testing buffer offset %d\n", alignment); + } + else { + /* we use alignment as the offset */ + alignment = 0; + } + glGenBuffers(NUM_UBOS, buffers); for (i = 0; i < NUM_UBOS; i++) { @@ -127,10 +140,13 @@ setup_ubos(void) * really shouldn't matter. */ glBindBuffer(GL_UNIFORM_BUFFER, buffers[i]); - glBufferData(GL_UNIFORM_BUFFER, size, zeros, GL_DYNAMIC_DRAW); + glBufferData(GL_UNIFORM_BUFFER, size + alignment, + zeros, GL_DYNAMIC_DRAW); /* Attach UBO */ - glBindBufferBase(GL_UNIFORM_BUFFER, i, buffers[i]); + glBindBufferRange(GL_UNIFORM_BUFFER, i, buffers[i], + alignment, /* offset */ + size); glUniformBlockBinding(prog, index, i); if (!piglit_check_gl_error(GL_NO_ERROR)) @@ -144,6 +160,10 @@ piglit_init(int argc, char **argv) { piglit_require_extension("GL_ARB_uniform_buffer_object"); + if (argc > 1 && strcmp(argv[1], "offset") == 0) { + test_buffer_offset = true; + } + prog = piglit_build_simple_program(vert_shader_text, frag_shader_text); assert(prog); glUseProgram(prog); @@ -184,15 +204,15 @@ piglit_display(void) glClear(GL_COLOR_BUFFER_BIT); for (i = 0; i < NUM_SQUARES; i++) { - /* Load UBO data */ + /* Load UBO data, at offset=alignment */ glBindBuffer(GL_UNIFORM_BUFFER, buffers[0]); - glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(pos_size[0]), + glBufferSubData(GL_UNIFORM_BUFFER, alignment, sizeof(pos_size[0]), pos_size[i]); glBindBuffer(GL_UNIFORM_BUFFER, buffers[1]); - glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(color[0]), + glBufferSubData(GL_UNIFORM_BUFFER, alignment, sizeof(color[0]), color[i]); glBindBuffer(GL_UNIFORM_BUFFER, buffers[2]); - glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(rotation[0]), + glBufferSubData(GL_UNIFORM_BUFFER, alignment, sizeof(rotation[0]), &rotation[i]); if (!piglit_check_gl_error(GL_NO_ERROR)) |