arb_uniform_buffer_object-rendering: add option to test buffer range size

Submitted by Brian Paul on Oct. 6, 2015, 2:25 p.m.

Details

Message ID 1444141549-30537-1-git-send-email-brianp@vmware.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Brian Paul Oct. 6, 2015, 2:25 p.m.
If the "size" argument is used we create a UBO and bind a range of
with two extra bytes.  This exercises a path in the Mesa VMware driver.
---
 tests/all.py                                     |  2 ++
 tests/spec/arb_uniform_buffer_object/rendering.c | 28 +++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/all.py b/tests/all.py
index f3a4b8a..3b88fa3 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3513,6 +3513,8 @@  with profile.group_manager(
       'referenced-by-shader')
     g(['arb_uniform_buffer_object-rendering'], 'rendering')
     g(['arb_uniform_buffer_object-rendering', 'offset'], 'rendering-offset')
+    g(['arb_uniform_buffer_object-rendering', 'size'], 'rendering-size')
+    g(['arb_uniform_buffer_object-rendering', 'size', 'offset'], 'rendering-size-offset')
     g(['arb_uniform_buffer_object-row-major'], 'row-major')
     g(['arb_uniform_buffer_object-uniformblockbinding'], 'uniformblockbinding')
 
diff --git a/tests/spec/arb_uniform_buffer_object/rendering.c b/tests/spec/arb_uniform_buffer_object/rendering.c
index 20c86b2..8725bf6 100644
--- a/tests/spec/arb_uniform_buffer_object/rendering.c
+++ b/tests/spec/arb_uniform_buffer_object/rendering.c
@@ -95,6 +95,7 @@  static GLuint prog;
 static GLuint buffers[NUM_UBOS];
 static GLint alignment;
 static bool test_buffer_offset = false;
+static bool test_buffer_size = false;
 
 
 static void
@@ -106,6 +107,7 @@  setup_ubos(void)
 		"ub_rot"
 	};
 	static GLubyte zeros[1000] = {0};
+	int extra_size;
 	int i;
 
 	glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment);
@@ -119,6 +121,15 @@  setup_ubos(void)
 		alignment = 0;
 	}
 
+	if (test_buffer_size) {
+		extra_size = 2;  /* two extra bytes */
+		printf("Testing buffer size + %d extra bytes\n", extra_size);
+	}
+	else {
+		/* use normal size */
+		extra_size = 0;
+	}
+
 	glGenBuffers(NUM_UBOS, buffers);
 
 	for (i = 0; i < NUM_UBOS; i++) {
@@ -132,7 +143,7 @@  setup_ubos(void)
 					  GL_UNIFORM_BLOCK_DATA_SIZE, &size);
 
 		printf("UBO %s: index = %d, size = %d\n",
-		       names[i], index, size);
+		       names[i], index, size + extra_size);
 
 		/* Allocate UBO */
 		/* XXX for some reason, this test doesn't work at all with
@@ -141,13 +152,13 @@  setup_ubos(void)
 		 * really shouldn't matter.
 		 */
 		glBindBuffer(GL_UNIFORM_BUFFER, buffers[i]);
-		glBufferData(GL_UNIFORM_BUFFER, size + alignment,
+		glBufferData(GL_UNIFORM_BUFFER, size + extra_size + alignment,
                              zeros, GL_DYNAMIC_DRAW);
 
 		/* Attach UBO */
 		glBindBufferRange(GL_UNIFORM_BUFFER, i, buffers[i],
 				  alignment,  /* offset */
-				  size);
+				  size + extra_size);
 		glUniformBlockBinding(prog, index, i);
 
 		if (!piglit_check_gl_error(GL_NO_ERROR))
@@ -159,10 +170,17 @@  setup_ubos(void)
 void
 piglit_init(int argc, char **argv)
 {
+	int i;
+
 	piglit_require_extension("GL_ARB_uniform_buffer_object");
 
-	if (argc > 1 && strcmp(argv[1], "offset") == 0) {
-		test_buffer_offset = true;
+	for (i = 1; i < argc; i++) {
+		if (strcmp(argv[i], "offset") == 0) {
+			test_buffer_offset = true;
+		}
+		else if (strcmp(argv[i], "size") == 0) {
+			test_buffer_size = true;
+		}
 	}
 
 	prog = piglit_build_simple_program(vert_shader_text, frag_shader_text);