On Sun, May 27, 2012 at 10:37 PM, Jordan Justen <[email protected]> wrote: > 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 <[email protected]> > --- > tests/all.tests | 1 + > tests/spec/arb_instanced_arrays/instanced_arrays.c | 47 > +++++++++++++++++--- > 2 files changed, 41 insertions(+), 7 deletions(-) > > diff --git a/tests/all.tests b/tests/all.tests > index 374f8cf..892ee39 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 ce8318f..d6c14bc 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,8 +167,6 @@ test_instancing(GLuint divisor) > glDisableVertexAttribArray(PosAttrib); > glDisableVertexAttribArray(ColorAttrib); > > - glutSwapBuffers(); > -
Why are you removing the SwapBuffers? It's nice to be able to see the results on-screen when debugging. Replacing glutSwapBuffers() with piglit_present_results() would be good, btw. -Brian _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
