[Piglit] [PATCH 2/2] Add a test for ARB_transform_feedback_instanced
Marek Olšák
maraeo at gmail.com
Thu Jul 5 03:40:36 PDT 2012
---
tests/all.tests | 4 +++
tests/spec/arb_transform_feedback2/draw-auto.c | 40 +++++++++++++++++++++---
2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/tests/all.tests b/tests/all.tests
index 22cb896..547c2af 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1778,6 +1778,10 @@ arb_transform_feedback2 = Group()
spec['ARB_transform_feedback2'] = arb_transform_feedback2
arb_transform_feedback2['draw-auto'] = PlainExecTest(['arb_transform_feedback2-draw-auto', '-auto'])
+arb_transform_feedback_instanced = Group()
+spec['ARB_transform_feedback_instanced'] = arb_transform_feedback_instanced
+arb_transform_feedback_instanced['draw-auto instanced'] = PlainExecTest(['arb_transform_feedback2-draw-auto', '-auto', 'instanced'])
+
arb_transform_feedback3 = Group()
spec['ARB_transform_feedback3'] = arb_transform_feedback3
diff --git a/tests/spec/arb_transform_feedback2/draw-auto.c b/tests/spec/arb_transform_feedback2/draw-auto.c
index 06f55ca..e7fe8bb 100644
--- a/tests/spec/arb_transform_feedback2/draw-auto.c
+++ b/tests/spec/arb_transform_feedback2/draw-auto.c
@@ -31,7 +31,7 @@
PIGLIT_GL_TEST_MAIN(
64 /*window_width*/,
- 64 /*window_height*/,
+ 128 /*window_height*/,
GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA)
static const char *vstext = {
@@ -42,21 +42,32 @@ static const char *vstext = {
};
static const char *vstext_notransform = {
"void main() {"
- " gl_Position = gl_Vertex + vec4(0.0, 0.625, 0.0, 0.0);"
+ " gl_Position = gl_Vertex + vec4(0.0, 0.32, 0.0, 0.0);"
+ " gl_FrontColor = gl_Color;"
+ "}"
+};
+static const char *vstext_notransform_instanced = {
+ "#extension GL_ARB_draw_instanced : enable\n"
+ "void main() {"
+ " gl_Position = gl_Vertex + vec4(0.0, 0.32 * float(gl_InstanceID+1), 0.0, 0.0);"
" gl_FrontColor = gl_Color;"
"}"
};
static const char *varyings[] = {"gl_FrontColor", "gl_Position"};
GLuint buf;
-GLuint prog, prog_notransform;
+GLuint prog, prog_notransform, prog_notransform_instanced;
GLuint tfb;
+GLboolean instanced;
void piglit_init(int argc, char **argv)
{
GLuint vs;
GLint maxcomps;
+ if (argc == 2 && strcmp(argv[1], "instanced") == 0)
+ instanced = GL_TRUE;
+
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
/* Check the driver. */
@@ -67,6 +78,8 @@ void piglit_init(int argc, char **argv)
piglit_require_GLSL();
piglit_require_extension("GL_EXT_transform_feedback");
piglit_require_extension("GL_ARB_transform_feedback2");
+ if (instanced)
+ piglit_require_extension("GL_ARB_transform_feedback_instanced");
glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT, &maxcomps);
if (maxcomps < 8) {
@@ -88,6 +101,10 @@ void piglit_init(int argc, char **argv)
vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext_notransform);
prog_notransform = piglit_link_simple_program(vs, 0);
+ if (instanced) {
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext_notransform_instanced);
+ prog_notransform_instanced = piglit_link_simple_program(vs, 0);
+ }
/* Set up transform feedback. */
glGenBuffers(1, &buf);
@@ -149,12 +166,16 @@ enum piglit_result piglit_display(void)
assert(glGetError() == 0);
- piglit_UseProgram(prog_notransform);
+ piglit_UseProgram(instanced ? prog_notransform_instanced : prog_notransform);
glBindBuffer(GL_ARRAY_BUFFER, buf);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_FLOAT, sizeof(float)*8, NULL);
glVertexPointer(4, GL_FLOAT, sizeof(float)*8, (void*)(intptr_t)(4*sizeof(float)));
- glDrawTransformFeedback(GL_TRIANGLES, tfb);
+ if (instanced) {
+ glDrawTransformFeedbackInstanced(GL_TRIANGLES, tfb, 4);
+ } else {
+ glDrawTransformFeedback(GL_TRIANGLES, tfb);
+ }
glDisableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -168,6 +189,15 @@ enum piglit_result piglit_display(void)
pass = piglit_probe_pixel_rgb(35, 35, clearcolor) && pass;
pass = piglit_probe_pixel_rgb(55, 35, blue) && pass;
+ if (instanced) {
+ unsigned i;
+ for (i = 1; i < 4; i++) {
+ pass = piglit_probe_pixel_rgb(15, 35 + 20*i, red) && pass;
+ pass = piglit_probe_pixel_rgb(35, 35 + 20*i, clearcolor) && pass;
+ pass = piglit_probe_pixel_rgb(55, 35 + 20*i, blue) && pass;
+ }
+ }
+
glutSwapBuffers();
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
--
1.7.9.5
More information about the Piglit
mailing list