[Piglit] [PATCH V2] arb_separate_shader_objects: test mixed explicit and non-explicit locations

Timothy Arceri t_arceri at yahoo.com.au
Mon Nov 23 14:15:24 PST 2015


This tests a bug in Mesa where explicit locations are not taken into
account when assigning varying locations which results in two
inputs/outputs being given the same location.

Test results:
Nvidia GeForce 840M - NVIDIA 352.41: pass
i965 - Mesa 11.1-dev: pass

V2: use pick_a_glsl_version() helper

Cc: Gregory Hainaut <gregory.hainaut at gmail.com>
---
 tests/all.py                                       |   2 +
 .../arb_separate_shader_objects/CMakeLists.gl.txt  |   1 +
 .../mixed_explicit_and_non_explicit_locations.c    | 152 +++++++++++++++++++++
 3 files changed, 155 insertions(+)
 create mode 100644 tests/spec/arb_separate_shader_objects/mixed_explicit_and_non_explicit_locations.c

diff --git a/tests/all.py b/tests/all.py
index e80f3af..3adc503 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2160,6 +2160,8 @@ with profile.group_manager(
       'Rendezvous by name')
     g(['arb_separate_shader_object-rendezvous_by_name_interpolation'],
       'Rendezvous by name with multiple interpolation qualifier')
+    g(['arb_separate_shader_object-mixed_explicit_and_non_explicit_locations', '-fbo'],
+      'Mixed explicit and non-explicit locations', run_concurrent=False)
     g(['arb_separate_shader_object-rendezvous_by_location', '-fbo'],
       'Rendezvous by location', run_concurrent=False)
     g(['arb_separate_shader_object-rendezvous_by_location-5-stages'],
diff --git a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
index 1dc5f14..db5f7c8 100644
--- a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
+++ b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ piglit_add_executable (arb_separate_shader_object-ActiveShaderProgram-invalid-pr
 piglit_add_executable (arb_separate_shader_object-compat-builtins compat-builtins.c)
 piglit_add_executable (arb_separate_shader_object-GetProgramPipelineiv GetProgramPipelineiv.c)
 piglit_add_executable (arb_separate_shader_object-IsProgramPipeline IsProgramPipeline.c)
+piglit_add_executable (arb_separate_shader_object-mixed_explicit_and_non_explicit_locations mixed_explicit_and_non_explicit_locations.c sso-common.c)
 piglit_add_executable (arb_separate_shader_object-ProgramUniform-coverage ProgramUniform-coverage.c)
 piglit_add_executable (arb_separate_shader_object-rendezvous_by_location rendezvous_by_location.c sso-common.c)
 piglit_add_executable (arb_separate_shader_object-rendezvous_by_location-3-stages rendezvous_by_location-3-stages.c)
diff --git a/tests/spec/arb_separate_shader_objects/mixed_explicit_and_non_explicit_locations.c b/tests/spec/arb_separate_shader_objects/mixed_explicit_and_non_explicit_locations.c
new file mode 100644
index 0000000..b91687e
--- /dev/null
+++ b/tests/spec/arb_separate_shader_objects/mixed_explicit_and_non_explicit_locations.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * This tests a bug in Mesa where explicit locations are not taken into
+ * account when assigning varying locations which results in two
+ * inputs/outputs being given the same location.
+ */
+#include "piglit-util-gl.h"
+#include "sso-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static GLuint pipeline;
+
+static const char *vs_code_template =
+	"#version %d\n"
+	"#extension GL_ARB_separate_shader_objects: require\n"
+	"#extension GL_ARB_explicit_attrib_location: require\n"
+	"\n"
+	"layout(location = 0) in vec4 piglit_vertex;\n"
+	"\n"
+	"layout(location = 0) out vec3 a;\n"
+        "out vec3 d;\n"
+        "out vec3 e;\n"
+	"layout(location = 1) out vec3 b;\n"
+        "out vec3 f;\n"
+	"layout(location = 2) out vec3 c;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"    gl_Position = piglit_vertex;\n"
+	"    a = vec3(0.25, 0, 0);\n"
+	"    b = vec3(0, 0.25, 0);\n"
+	"    c = vec3(0, 0, 0.25);\n"
+	"    d = vec3(0.5, 0, 0);\n"
+	"    e = vec3(0, 0.5, 0);\n"
+	"    f = vec3(0, 0, 0.5);\n"
+	"}\n"
+	;
+
+static const char *fs_code_template =
+	"#version %d\n"
+	"#extension GL_ARB_separate_shader_objects: require\n"
+	"#extension GL_ARB_explicit_attrib_location: enable\n"
+	"\n"
+	"#if __VERSION__ >= 130\n"
+	"layout(location = 0) out vec4 out_color;\n"
+	"#else\n"
+	"#define out_color gl_FragColor\n"
+	"#endif\n"
+	"\n"
+	"layout(location = 0) in vec3 a; /* should get vec3(0.25, 0, 0) */\n"
+        "in vec3 d;                      /* should get vec3(0.5, 0, 0)  */\n"
+        "in vec3 e;                      /* should get vec3(0, 0.5, 0)  */\n"
+	"layout(location = 1) in vec3 b; /* should get vec3(0, 0.25, 0) */\n"
+        "in vec3 f;                      /* should get vec3(0, 0, 0.5)  */\n"
+	"layout(location = 2) in vec3 c; /* should get vec3(0, 0, 0.25) */\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"    out_color = vec4(a.x + d.x, b.y + e.y, c.z + f.z, 1);\n"
+	"}\n"
+	;
+
+enum piglit_result
+piglit_display(void)
+{
+	static const float expected[] = {
+		0.75f, 0.75f, 0.75f, 1.0f
+	};
+	bool pass;
+
+	glClearColor(0.1f, 0.1f, 0.1f, 0.1f);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glBindProgramPipeline(pipeline);
+	piglit_draw_rect(-1, -1, 2, 2);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      expected);
+
+	piglit_present_results();
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	unsigned glsl_version;
+	GLuint vs_prog;
+	GLuint fs_prog;
+	bool es;
+	int glsl_major;
+	int glsl_minor;
+	char *source;
+
+	piglit_require_vertex_shader();
+	piglit_require_fragment_shader();
+	piglit_require_extension("GL_ARB_separate_shader_objects");
+	piglit_require_extension("GL_ARB_explicit_attrib_location");
+
+	glsl_version = pick_a_glsl_version();
+
+	asprintf(&source, vs_code_template, glsl_version);
+	vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1,
+					 (const GLchar *const *) &source);
+	piglit_link_check_status(vs_prog);
+	free(source);
+
+	asprintf(&source, fs_code_template, glsl_version);
+	fs_prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
+				        (const GLchar *const *) &source);
+	piglit_link_check_status(fs_prog);
+	free(source);
+
+	glGenProgramPipelines(1, &pipeline);
+	glUseProgramStages(pipeline,
+			   GL_VERTEX_SHADER_BIT,
+			   vs_prog);
+	glUseProgramStages(pipeline,
+			   GL_FRAGMENT_SHADER_BIT,
+			   fs_prog);
+	piglit_program_pipeline_check_status(pipeline);
+
+	if (!piglit_check_gl_error(0))
+		piglit_report_result(PIGLIT_FAIL);
+}
-- 
2.4.3



More information about the Piglit mailing list