summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2012-05-25 15:09:49 -0700
committerJordan Justen <jordan.l.justen@intel.com>2012-05-29 10:49:23 -0700
commit8e299b4acafde4c7c6b3addc6b4a1fe7b25edc2b (patch)
tree02e033dddc2893f006a1a11e19a7e1bde66c7bb4
parent833f913582e363a415bf9984c96ab5f7b866f81e (diff)
arb_instanced_arrays: test instanced_arrays with VBOs
The new test named instanced_arrays-vbo which adds a vbo parameter when running the instanced_arrays test. This will cause the test to run while using VBOs. Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--tests/all.tests1
-rw-r--r--tests/spec/arb_instanced_arrays/instanced_arrays.c47
2 files changed, 42 insertions, 6 deletions
diff --git a/tests/all.tests b/tests/all.tests
index 374f8cf8..892ee39c 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1682,6 +1682,7 @@ add_plain_test(ati_envmap_bumpmap, 'ati_envmap_bumpmap-bump')
arb_instanced_arrays = Group()
spec['ARB_instanced_arrays'] = arb_instanced_arrays
add_plain_test(arb_instanced_arrays, 'instanced_arrays')
+add_single_param_test_set(arb_instanced_arrays, 'instanced_arrays', 'vbo')
arb_map_buffer_range = Group()
spec['ARB_map_buffer_range'] = arb_map_buffer_range
diff --git a/tests/spec/arb_instanced_arrays/instanced_arrays.c b/tests/spec/arb_instanced_arrays/instanced_arrays.c
index ce8318f0..1cfd2e33 100644
--- a/tests/spec/arb_instanced_arrays/instanced_arrays.c
+++ b/tests/spec/arb_instanced_arrays/instanced_arrays.c
@@ -61,6 +61,8 @@ static const char *FragShaderText =
static GLuint VertShader, FragShader, Program;
+static GLboolean use_vbo = GL_FALSE;
+
static const GLfloat Positions[PRIMS][2] = {
{ -6, 6 },
{ -4, 4 },
@@ -90,14 +92,39 @@ test_instancing(GLuint divisor)
static const GLfloat verts[4][2] = {
{-1, -1}, {1, -1}, {1, 1}, {-1, 1}
};
-
- glVertexPointer(2, GL_FLOAT, 0, verts);
- glEnableClientState(GL_VERTEX_ARRAY);
+ GLuint vbo;
+ uintptr_t offset = 0;
+
+ if (use_vbo) {
+ glGenBuffers(1, &vbo);
+ glBindBuffer(GL_ARRAY_BUFFER, vbo);
+ glBufferData(GL_ARRAY_BUFFER,
+ sizeof(verts) + sizeof(Positions) + sizeof(Colors),
+ NULL,
+ GL_STATIC_DRAW);
+ glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(verts), verts);
+ glVertexPointer(2, GL_FLOAT, 0, (void*) offset);
+ offset += sizeof(verts);
+
+ glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(Positions), Positions);
+ glVertexAttribPointer(PosAttrib, 2, GL_FLOAT, GL_FALSE, 0, (void*) offset);
+ offset += sizeof(Positions);
+
+ glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(Colors), Colors);
+ glVertexAttribPointer(ColorAttrib, 4, GL_FLOAT, GL_FALSE, 0, (void*) offset);
+ offset += sizeof(Colors);
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ } else {
+ glVertexPointer(2, GL_FLOAT, 0, verts);
+ glVertexAttribPointer(PosAttrib, 2, GL_FLOAT, GL_FALSE, 0, Positions);
+ glVertexAttribPointer(ColorAttrib, 4, GL_FLOAT, GL_FALSE, 0, Colors);
+ }
- glVertexAttribPointer(PosAttrib, 2, GL_FLOAT, GL_FALSE, 0, Positions);
- glVertexAttribPointer(ColorAttrib, 4, GL_FLOAT, GL_FALSE, 0, Colors);
+ glEnableClientState(GL_VERTEX_ARRAY);
glEnableVertexAttribArray(PosAttrib);
glEnableVertexAttribArray(ColorAttrib);
+
glVertexAttribDivisorARB(PosAttrib, 1);
/* advance color once every 'n' instances */
glVertexAttribDivisorARB(ColorAttrib, divisor);
@@ -110,6 +137,10 @@ test_instancing(GLuint divisor)
glUseProgram(0);
+ if (use_vbo) {
+ glDeleteBuffers(1, &vbo);
+ }
+
{
GLint i;
GLint pos[4];
@@ -136,7 +167,7 @@ test_instancing(GLuint divisor)
glDisableVertexAttribArray(PosAttrib);
glDisableVertexAttribArray(ColorAttrib);
- glutSwapBuffers();
+ piglit_present_results();
return GL_TRUE;
}
@@ -183,4 +214,8 @@ piglit_init(int argc, char **argv)
glLoadIdentity();
glTranslatef(0, 0, -11.0);
glScalef(0.5, 0.5, 1.0);
+
+ if ((argc >= 2) && (strcmp(argv[1], "vbo") == 0)) {
+ use_vbo = GL_TRUE;
+ }
}