[Piglit] [PATCH 2/2] arb_separate_shader_objects: Verify results of program pipeline validation when a conflicting sampler configuration is used.

Ian Romanick idr at freedesktop.org
Fri Mar 14 17:25:55 PDT 2014


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

Section 2.11.11 (Shader Execution), subheading "Validation," of the
OpenGL 4.1 spec says:

    "[INVALID_OPERATION] is generated by any command that transfers
    vertices to the GL if:

        ...

        - Any two active samplers in the current program object are of
          different types, but refer to the same texture image unit."

This test verifies this behavior several ways.  First, an invalid
configuration is constructed.  When the pipeline is in the invalid
configuration, glValidateProgramPipeline is used to determine the
status.

The pipeline is then transitioned to a valid configuration, and
glValidateProgramPipeline is called again.

The pipeline is then transitioned back to the invalid configuration.
Without calling glValidateProgramPipeline, glDrawArrays is called.  This
should generate the aforementioned error.  While still in the invalid
state glValidateProgramPipeline is called a third time.

Finally, the pipeline is transitioned back to the valid configuration.
Without calling glValidateProgramPipeline, glDrawArrays is called.  This
should not generate any error.

All of the state flip-flopping is done in an attempt to catch
implementations that latch state in glValidateProgramPipeline and do not
re-validate in glDrawArrays.

NOTE: The work-in-progress GL_ARB_separate_shader_objects implementation
for Mesa currently fails this test because glValidateProgramPipeline
always succeeds, and it does not generate GL_INVALID_OPERATION the first
time glDrawArrays is called.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Eric Anholt <eric at anholt.net>
---
 tests/all.py                                       |   1 +
 .../arb_separate_shader_objects/CMakeLists.gl.txt  |   1 +
 .../active-sampler-conflict.c                      | 208 +++++++++++++++++++++
 3 files changed, 210 insertions(+)
 create mode 100644 tests/spec/arb_separate_shader_objects/active-sampler-conflict.c

diff --git a/tests/all.py b/tests/all.py
index e0a6c91..d395b7c 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1783,6 +1783,7 @@ arb_separate_shader_objects['Rendezvous by location'] = plain_test('arb_separate
 arb_separate_shader_objects['ValidateProgramPipeline'] = concurrent_test('arb_separate_shader_object-ValidateProgramPipeline')
 arb_separate_shader_objects['400 combinations by location'] = plain_test('arb_separate_shader_object-400-combinations -fbo --by-location')
 arb_separate_shader_objects['400 combinations by name'] = plain_test('arb_separate_shader_object-400-combinations -fbo')
+arb_separate_shader_objects['active sampler conflict'] = concurrent_test('arb_separate_shader_object-active-sampler-conflict')
 
 # Group ARB_sampler_objects
 arb_sampler_objects = Group()
diff --git a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
index 397ff9a..b8ac47d 100644
--- a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
+++ b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
@@ -10,6 +10,7 @@ link_libraries (
 )
 
 piglit_add_executable (arb_separate_shader_object-400-combinations 400-combinations.c)
+piglit_add_executable (arb_separate_shader_object-active-sampler-conflict active-sampler-conflict.c)
 piglit_add_executable (arb_separate_shader_object-ActiveShaderProgram-invalid-program ActiveShaderProgram-invalid-program.c)
 piglit_add_executable (arb_separate_shader_object-GetProgramPipelineiv GetProgramPipelineiv.c)
 piglit_add_executable (arb_separate_shader_object-IsProgramPipeline IsProgramPipeline.c)
diff --git a/tests/spec/arb_separate_shader_objects/active-sampler-conflict.c b/tests/spec/arb_separate_shader_objects/active-sampler-conflict.c
new file mode 100644
index 0000000..8cfb74b
--- /dev/null
+++ b/tests/spec/arb_separate_shader_objects/active-sampler-conflict.c
@@ -0,0 +1,208 @@
+/*
+ * Copyright © 2014 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.
+ */
+
+/**
+ * \file active-sampler-conflict.c
+ * Verify results of program pipeline validation when a conflicting sampler
+ * configuration is used.
+ *
+ * Section 2.11.11 (Shader Execution), subheading "Validation," of the OpenGL
+ * 4.1 spec says:
+ *
+ *     "[INVALID_OPERATION] is generated by any command that transfers
+ *     vertices to the GL if:
+ *
+ *         ...
+ *
+ *         - Any two active samplers in the current program object are of
+ *           different types, but refer to the same texture image unit."
+ *
+ * This test verifies this behavior several ways.  First, an invalid
+ * configuration is constructed.  When the pipeline is in the invalid
+ * configuration, glValidateProgramPipeline is used to determine the status.
+ *
+ * The pipeline is then transitioned to a valid configuration, and
+ * glValidateProgramPipeline is called again.
+ *
+ * The pipeline is then transitioned back to the invalid configuration.
+ * Without calling glValidateProgramPipeline, glDrawArrays is called.  This
+ * should generate the aforementioned error.  While still in the invalid state
+ * glValidateProgramPipeline is called a third time.
+ *
+ * Finally, the pipeline is transitioned back to the valid configuration.
+ * Without calling glValidateProgramPipeline, glDrawArrays is called.  This
+ * should not generate any error.
+ *
+ * All of the state flip-flopping is done in an attempt to catch
+ * implementations that latch state in glValidateProgramPipeline and do not
+ * re-validate in glDrawArrays.
+ */
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 30;
+	config.supports_gl_core_version = 31;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *fs_code =
+	"#version 130\n"
+	"#extension GL_ARB_separate_shader_objects: require\n"
+	"\n"
+	"out vec4 out_color;\n"
+	"\n"
+	"uniform sampler2D s2;\n"
+	"uniform sampler3D s3;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"    out_color = texture(s2, vec2(0)) + texture(s3, vec3(0));\n"
+	"}\n"
+	;
+
+static const float vert[2] = {
+	0.0, 0.0
+};
+
+void piglit_init(int argc, char **argv)
+{
+	GLuint prog;
+	GLint s2_loc;
+	GLint s3_loc;
+	GLuint pipe;
+	GLuint vao;
+	GLuint bo;
+	bool pass = true;
+
+	piglit_require_extension("GL_ARB_separate_shader_objects");
+
+	prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
+					 (const GLchar *const *) &fs_code);
+	piglit_link_check_status(prog);
+
+	s2_loc = glGetUniformLocation(prog, "s2");
+	if (s2_loc == -1) {
+		fprintf(stderr, "Failed to get uniform location for s2.\n");
+		pass = false;
+	}
+
+	s3_loc = glGetUniformLocation(prog, "s3");
+	if (s3_loc == -1) {
+		fprintf(stderr, "Failed to get uniform location for s3.\n");
+		pass = false;
+	}
+
+	glGenProgramPipelines(1, &pipe);
+	glUseProgramStages(pipe,
+			   GL_FRAGMENT_SHADER_BIT,
+			   prog);
+	glActiveShaderProgram(pipe, prog);
+	glBindProgramPipeline(pipe);
+
+	glGenVertexArrays(1, &vao);
+	glBindVertexArray(vao);
+
+	/* Configure a vertex array object and buffer object that will
+	 * be used for drawing later.
+	 */
+	glGenBuffers(1, &bo);
+	glBindBuffer(GL_ARRAY_BUFFER, bo);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(vert), vert, GL_STATIC_DRAW);
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	/* First, try an invalid configuration.
+	 */
+	glUniform1i(s2_loc, 1);
+	glUniform1i(s3_loc, 1);
+	if (piglit_program_pipeline_check_status_quiet(pipe)) {
+		fprintf(stderr,
+			"Pipeline was validated with conflicting "
+			"sampler configuration.\n");
+		pass = false;
+	}
+
+	/* Now try a valid configuration.
+	 */
+	glUniform1i(s2_loc, 1);
+	glUniform1i(s3_loc, 2);
+	if (!piglit_program_pipeline_check_status_quiet(pipe)) {
+		fprintf(stderr,
+			"Pipeline was not validated with non-conflicting "
+			"sampler configuration.\n");
+		pass = false;
+	}
+
+	/* Switch back to the invalid configuration.  Without first calling
+	 * glValidateProgramPipeline, try to draw something.  Verify that
+	 * GL_INVALID_OPERATION is generated.
+	 */
+	glUniform1i(s2_loc, 1);
+	glUniform1i(s3_loc, 1);
+
+	glDrawArrays(GL_POINTS, 0, 1);
+	
+	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
+
+	/* Re-validate the program.
+	 */
+	if (piglit_program_pipeline_check_status_quiet(pipe)) {
+		fprintf(stderr,
+			"Pipeline was validated with conflicting "
+			"sampler configuration (second attempt).\n");
+		pass = false;
+	}
+
+	/* Switch back to the valid configuration.  Without first calling
+	 * glValidateProgramPipeline, try to draw something.  Verify that
+	 * no error is generated.
+	 */
+	glUniform1i(s2_loc, 1);
+	glUniform1i(s3_loc, 2);
+
+	glDrawArrays(GL_POINTS, 0, 1);
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	/* Clean up.
+	 */
+	glBindProgramPipeline(0);
+	glDeleteProgram(prog);
+	glDeleteProgramPipelines(1, &pipe);
+	
+	glBindBuffer(GL_ARRAY_BUFFER, 0);
+	glBindVertexArray(0);
+
+	glDeleteBuffers(1, &bo);
+	glDeleteVertexArrays(1, &vao);
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	/* Not reached */
+	return PIGLIT_FAIL;
+}
-- 
1.8.1.4



More information about the Piglit mailing list