vulkan/shader_draw_parameters: Add a test for gl_BaseVertex

Submitted by Neil Roberts on Nov. 8, 2018, 12:29 p.m.

Details

Message ID 20181108122931.14888-1-nroberts@igalia.com
State New
Headers show
Series "vulkan/shader_draw_parameters: Add a test for gl_BaseVertex" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Neil Roberts Nov. 8, 2018, 12:29 p.m.
gl_BaseVertex has slightly different semantics under Vulkan and GL so
this is worth testing.
---
 .../base-vertex.vk_shader_test                | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 tests/vulkan/shader_draw_parameters/base-vertex.vk_shader_test

Patch hide | download patch | download mbox

diff --git a/tests/vulkan/shader_draw_parameters/base-vertex.vk_shader_test b/tests/vulkan/shader_draw_parameters/base-vertex.vk_shader_test
new file mode 100644
index 000000000..c4c8c3e32
--- /dev/null
+++ b/tests/vulkan/shader_draw_parameters/base-vertex.vk_shader_test
@@ -0,0 +1,66 @@ 
+# Tests that gl_BaseVertex is firstVertex for non-indexed calls or
+# vertexOffset for indexed ones.
+
+[require]
+framebuffer R32G32B32A32_SFLOAT
+VK_KHR_shader_draw_parameters
+
+[vertex shader]
+#version 450
+#extension GL_ARB_shader_draw_parameters: require
+
+layout(location = 0) in vec4 piglit_vertex;
+layout(location = 0) out vec4 color;
+
+layout(std140, push_constant) uniform block {
+        uint expected_base_vertex;
+};
+
+void
+main()
+{
+        if (gl_BaseVertexARB == expected_base_vertex)
+	        color = vec4(0.0, 1.0, 0.0, 1.0);
+        else
+	        color = vec4(1.0, gl_BaseVertexARB / 255.0, 0.0, 1.0);
+
+        gl_Position = piglit_vertex;
+}
+
+[fragment shader]
+#version 450
+
+layout(location = 0) in vec4 color_in;
+layout(location = 0) out vec4 color_out;
+
+void
+main()
+{
+        color_out = color_in;
+}
+
+[indices]
+0 1 2 3
+
+[vertex data]
+0/R32G32_SFLOAT
+-1 -1
+-1 -1
+-1 -1
+-1 -1
+-1 -1
+1  -1
+-1 1
+1  1
+
+[test]
+clear color 0.8 0.0 0.0 0.0
+clear
+
+uniform uint 0 4
+
+draw arrays GL_TRIANGLE_STRIP 4 4
+probe all rgba 0.0 1.0 0.0 1.0
+
+draw arrays indexed GL_TRIANGLE_STRIP 4 4
+probe all rgba 0.0 1.0 0.0 1.0