[Piglit] [PATCH] Add test for SSO geometry shader inputs

Pavol Klačanský pavol at klacansky.com
Sun Dec 14 00:55:10 PST 2014


---
 tests/all.py                                       |   1 +
 .../arb_separate_shader_objects/CMakeLists.gl.txt  |   1 +
 .../geometry_shader_in.c                           | 152 +++++++++++++++++++++
 3 files changed, 154 insertions(+)
 create mode 100644 tests/spec/arb_separate_shader_objects/geometry_shader_in.c

diff --git a/tests/all.py b/tests/all.py
index ea652f4..0535653 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1983,6 +1983,7 @@ arb_separate_shader_objects['ValidateProgramPipeline'] = PiglitGLTest('arb_separ
 arb_separate_shader_objects['400 combinations by location'] = PiglitGLTest('arb_separate_shader_object-400-combinations -fbo --by-location')
 arb_separate_shader_objects['400 combinations by name'] = PiglitGLTest('arb_separate_shader_object-400-combinations -fbo')
 arb_separate_shader_objects['active sampler conflict'] = PiglitGLTest('arb_separate_shader_object-active-sampler-conflict', run_concurrent=True)
+arb_separate_shader_objects['geometry-shader-in'] = PiglitGLTest('arb_separate_shader_object-geometry-shader-in')
 
 # Group ARB_sampler_objects
 arb_sampler_objects = {}
diff --git a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
index 2705ac7..2c1f30d 100644
--- a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
+++ b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
@@ -18,3 +18,4 @@ piglit_add_executable (arb_separate_shader_object-ProgramUniform-coverage Progra
 piglit_add_executable (arb_separate_shader_object-rendezvous_by_location rendezvous_by_location.c)
 piglit_add_executable (arb_separate_shader_object-UseProgramStages-non-separable UseProgramStages-non-separable.c)
 piglit_add_executable (arb_separate_shader_object-ValidateProgramPipeline ValidateProgramPipeline.c)
+piglit_add_executable (arb_separate_shader_object-geometry-shader-in geometry_shader_in.c)
diff --git a/tests/spec/arb_separate_shader_objects/geometry_shader_in.c b/tests/spec/arb_separate_shader_objects/geometry_shader_in.c
new file mode 100644
index 0000000..52c8b99
--- /dev/null
+++ b/tests/spec/arb_separate_shader_objects/geometry_shader_in.c
@@ -0,0 +1,152 @@
+/* Pavol Klacansky <pavol at klacansky.com>
+
+   The read in geometry shader of passed variable must be read correctly.
+
+   https://bugs.freedesktop.org/show_bug.cgi?id=82585
+*/
+
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+    config.supports_gl_core_version = 33;
+    config.window_visual = PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static const char vs_src[] =
+    "#version 330"
+
+    "layout(location = 0) in vec4 position;"
+
+    "out gl_PerVertex"
+    "{"
+    "    vec4 gl_Position;"
+    "};"
+
+    "out vec4 v_colour;"
+
+    "void main(void)"
+    "{"
+    "    v_colour = vec4(1.0);"
+    "    gl_Position = position;"
+    "};";
+
+
+static const char gs_src[] =
+    "#version 330"
+
+    "layout(triangles) in;"
+    "layout(triangle_strip, max_vertices = 3) out;"
+
+    "in gl_PerVertex"
+    "{"
+    "    vec4 gl_Position;"
+    "} gl_in[];"
+
+    "in vec4 v_colour[];"
+
+    "out gl_PerVertex"
+    "{"
+    "    vec4 gl_Position;"
+    "};"
+
+    "out vec4 g_colour;"
+
+    "void main(void)"
+    "{"
+    "    for (int i = 0; i < gl_in.length(); ++i) {"
+    "        gl_Position = gl_in[i].gl_Position;"
+    "        g_colour = v_colour[i];"
+    "        EmitVertex();"
+    "    }"
+    "EndPrimitive();"
+    "}";
+
+
+static const char fs_src[] =
+    "#version 330"
+
+    "out vec4 colour;"
+
+    "in vec4 g_colour;"
+
+    "void main(void)"
+    "{"
+    "    colour = g_colour;"
+    "}";
+
+
+static const GLfloat vertices[] = {
+    -1.0f, -1.0f,  0.0f,  1.0f,
+     1.0f, -1.0f,  0.0f,  1.0f,
+     1.0f,  1.0f,  0.0f,  1.0f,
+    -1.0f,  1.0f,  0.0f,  1.0f,
+};
+
+
+
+
+
+void piglit_init(int argc, char *argv[])
+{
+    piglit_require_gl_version(33);
+    piglit_require_extension("GL_ARB_separate_shader_objects");
+    piglit_require_extension("GL_ARB_buffer_storage");
+}
+
+
+enum piglit_result piglit_display(void)
+{
+    const GLuint vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1,
+                                                  (const char **)&vs_src);
+    const GLuint gs_prog = glCreateShaderProgramv(GL_GEOMETRY_SHADER, 1,
+                                                  (const char **)&gs_src);
+    const GLuint fs_prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
+                                                  (const char **)&fs_src);
+
+
+    GLuint pipeline;
+    glGenProgramPipelines(1, &pipeline);
+    glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, vs_prog);
+    glUseProgramStages(pipeline, GL_GEOMETRY_SHADER_BIT, gs_prog);
+    glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, fs_prog);
+
+    GLuint vbo;
+    glGenBuffers(1, &vbo);
+    glBindBuffer(GL_ARRAY_BUFFER, vbo);
+    glBufferStorage(GL_ARRAY_BUFFER, sizeof(vertices), vertices, 0);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+    GLuint vao;
+    glGenVertexArrays(1, &vao);
+    glBindVertexArray(vao);
+    glBindBuffer(GL_ARRAY_BUFFER, vbo);
+    glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4*sizeof(GLfloat), 0);
+    glEnableVertexAttribArray(0);
+    glBindVertexArray(0);
+
+    glClear(GL_COLOR_BUFFER_BIT);
+    glBindProgramPipeline(pipeline);
+    glBindVertexArray(vao);
+    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+    glBindVertexArray(0);
+    glBindProgramPipeline(0);
+
+    glDeleteVertexArrays(1, &vao);
+    glDeleteBuffers(1, &vbo);
+    glDeleteProgramPipelines(1, &pipeline);
+    glDeleteProgram(vs_prog);
+    glDeleteProgram(gs_prog);
+    glDeleteProgram(fs_prog);
+
+    // colour should be white
+    const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+    const int pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+                                            white);
+
+    piglit_present_results();
+    piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
2.1.3



More information about the Piglit mailing list