[Piglit] [PATCH 4/4] ARB_draw_instanced: Add trivial instanced drawing tests

Ian Romanick idr at freedesktop.org
Fri Apr 8 19:49:32 PDT 2011


From: Ian Romanick <ian.d.romanick at intel.com>

---
 tests/all.tests                                    |    4 ++
 .../execution/draw-non-instanced.shader_test       |   41 +++++++++++++++++++
 .../instance-array-dereference.shader_test         |   42 ++++++++++++++++++++
 3 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/arb_draw_instanced/execution/draw-non-instanced.shader_test
 create mode 100644 tests/spec/arb_draw_instanced/execution/instance-array-dereference.shader_test

diff --git a/tests/all.tests b/tests/all.tests
index 75e01ff..d1b4647 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -692,6 +692,10 @@ import_glsl_parser_tests(arb_draw_instanced,
 			 os.path.dirname(__file__) + '/spec/arb_draw_instanced',
 			 [''])
 
+add_shader_test_dir(arb_draw_instanced,
+                    os.path.dirname(__file__) + '/spec/arb_draw_instanced/execution',
+                    recursive=True)
+
 
 # Group ARB_shader_texture_lod
 arb_shader_texture_lod = Group()
diff --git a/tests/spec/arb_draw_instanced/execution/draw-non-instanced.shader_test b/tests/spec/arb_draw_instanced/execution/draw-non-instanced.shader_test
new file mode 100644
index 0000000..6cf2403
--- /dev/null
+++ b/tests/spec/arb_draw_instanced/execution/draw-non-instanced.shader_test
@@ -0,0 +1,41 @@
+[require]
+
+[vertex shader]
+/* Verify that InstanceID is zero when drawing primitives using a
+ * non-instanced drawing function.
+ */
+//#version 110
+#extension GL_ARB_draw_instanced: require
+
+varying vec4 color;
+
+void main()
+{
+  color = vec4(float(gl_InstanceID),
+	       1.0 - float(gl_InstanceID),
+	       0.0,
+	       1.0);
+  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+}
+
+[fragment shader]
+varying vec4 color;
+
+void main()
+{
+  gl_FragColor = color;
+}
+
+[test]
+ortho
+clear color 0.5 0.5 0.5 0.5
+clear
+
+draw rect 10 10 10 10
+probe rgb 15 15 0 1 0
+
+draw rect 30 10 10 10
+probe rgb 35 15 0 1 0
+
+draw rect 50 10 10 10
+probe rgb 55 15 0 1 0
diff --git a/tests/spec/arb_draw_instanced/execution/instance-array-dereference.shader_test b/tests/spec/arb_draw_instanced/execution/instance-array-dereference.shader_test
new file mode 100644
index 0000000..e009320
--- /dev/null
+++ b/tests/spec/arb_draw_instanced/execution/instance-array-dereference.shader_test
@@ -0,0 +1,42 @@
+[require]
+GL_ARB_draw_instanced
+
+[vertex shader]
+/* Verify that InstanceID is zero when drawing primitives using a
+ * non-instanced drawing function.
+ */
+#extension GL_ARB_draw_instanced: require
+
+uniform vec4 instance_colors[] = vec4[](vec4(0.0, 1.0, 0.0, 1.0),
+					vec4(0.0, 0.5, 0.5, 1.0),
+					vec4(0.0, 0.0, 1.0, 1.0));
+
+varying vec4 color;
+
+void main()
+{
+  color = instance_colors[gl_InstanceIDARB];
+
+  vec4 v = gl_Vertex;
+  v.x += 20.0 * float(gl_InstanceIDARB);
+
+  gl_Position = gl_ModelViewProjectionMatrix * v;
+}
+
+[fragment shader]
+varying vec4 color;
+
+void main()
+{
+  gl_FragColor = color;
+}
+
+[test]
+ortho
+clear color 0.5 0.5 0.5 0.5
+clear
+
+draw instanced rect 3 10 10 10 10
+probe rgb 15 15 0.0 1.0 0.0
+probe rgb 35 15 0.0 0.5 0.5
+probe rgb 55 15 0.0 0.0 1.0
-- 
1.7.4



More information about the Piglit mailing list