[Piglit] [PATCH] GL_ARB_ubo/getintegeri_v: Fix assumptions about offset alignment

Fredrik Höglund fredrik at kde.org
Mon Jan 14 08:26:33 PST 2013


Don't assume that GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT is 1.

This makes the test pass with gallium drivers.
---
 tests/spec/arb_uniform_buffer_object/getintegeri_v.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tests/spec/arb_uniform_buffer_object/getintegeri_v.c b/tests/spec/arb_uniform_buffer_object/getintegeri_v.c
index e35e653..e537e6b 100644
--- a/tests/spec/arb_uniform_buffer_object/getintegeri_v.c
+++ b/tests/spec/arb_uniform_buffer_object/getintegeri_v.c
@@ -71,6 +71,12 @@ test_range(int line, int index, int bo, int offset, int size)
 	test_index(line, GL_UNIFORM_BUFFER_SIZE, index, size);
 }
 
+static GLint
+align(int offset, int alignment)
+{
+	return offset + (alignment - (offset % alignment)) % alignment;
+}
+
 void
 piglit_init(int argc, char **argv)
 {
@@ -78,6 +84,7 @@ piglit_init(int argc, char **argv)
 	int size = 1024;
 	GLint max_bindings;
 	GLint junk;
+	GLint alignment;
 
 	piglit_require_extension("GL_ARB_uniform_buffer_object");
 
@@ -89,10 +96,12 @@ piglit_init(int argc, char **argv)
 	glBindBuffer(GL_UNIFORM_BUFFER, bo[1]);
 	glBufferData(GL_UNIFORM_BUFFER, size, NULL, GL_STATIC_READ);
 
-	glBindBufferRange(GL_UNIFORM_BUFFER, 0, bo[0], 0, 1);
-	glBindBufferRange(GL_UNIFORM_BUFFER, 1, bo[1], 2, 3);
-	test_range(__LINE__, 0, bo[0], 0, 1);
-	test_range(__LINE__, 1, bo[1], 2, 3);
+	glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment);
+
+	glBindBufferRange(GL_UNIFORM_BUFFER, 0, bo[0], align(0, alignment), 1);
+	glBindBufferRange(GL_UNIFORM_BUFFER, 1, bo[1], align(2, alignment), 3);
+	test_range(__LINE__, 0, bo[0], align(0, alignment), 1);
+	test_range(__LINE__, 1, bo[1], align(2, alignment), 3);
 
 	/* There's a bit of a contradiction in the spec.  On the one
 	 * hand, "BindBufferBase is equivalent to calling
-- 
1.7.10.4



More information about the Piglit mailing list