[Piglit] [PATCH] arb_program_interface_query: test stage ref for buffer blocks

Timothy Arceri timothy.arceri at collabora.com
Tue Apr 5 01:43:26 UTC 2016


This tests that we get the correct stage reference information when
a shader has both a shader storage and uniform block.

This exposes a bug in Mesa where we were expecting the index to be
an index of a combined SSBO and UBO resources list. When they should
instead each have their own resource list and indices.

Cc: Kenneth Graunke <kenneth at whitecape.org>
---
 tests/spec/arb_program_interface_query/common.h    | 25 ++++++++
 .../getprogramresourceiv.c                         | 68 +++++++++++++++++++++-
 2 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/tests/spec/arb_program_interface_query/common.h b/tests/spec/arb_program_interface_query/common.h
index d46ff26..371b033 100755
--- a/tests/spec/arb_program_interface_query/common.h
+++ b/tests/spec/arb_program_interface_query/common.h
@@ -117,6 +117,31 @@ static const char fs_std[] =
 		"             faub[1].fs_array[3] * faub[3].fs_array[3];\n"
 	"}";
 
+static const char vs_buff_blks[] =
+	"#version 150\n"
+	"#extension GL_ARB_shader_storage_buffer_object : require\n"
+	"buffer vs_buffer_block { vec4 vs_buf_var; };"
+	"uniform vs_uni_block {\n"
+	"	vec4 vs_test;\n"
+	"};\n"
+	"void main() {\n"
+	"	gl_Position = vs_buf_var + vs_test;\n"
+	"}";
+
+static const char fs_buff_blks[] =
+	"#version 150\n"
+	"#extension GL_ARB_shader_storage_buffer_object : require\n"
+	"uniform fs_uni_block {"
+	"	vec4 fs_color;\n"
+	"	float fs_array[4];\n"
+	"};\n"
+	"buffer fs_buffer_block { vec4 fs_buf_var; };\n"
+	"out vec4 fs_output0;\n"
+	"void main() {\n"
+	"	fs_output0 = fs_buf_var + fs_color +\n"
+	"	vec4(fs_array[0], fs_array[1], fs_array[2], fs_array[3]);\n"
+	"}";
+
 static const char vs_stor[] =
 	"#version 150\n"
 	"#extension GL_ARB_shader_storage_buffer_object : require\n"
diff --git a/tests/spec/arb_program_interface_query/getprogramresourceiv.c b/tests/spec/arb_program_interface_query/getprogramresourceiv.c
index 28cfc27..42a425c 100755
--- a/tests/spec/arb_program_interface_query/getprogramresourceiv.c
+++ b/tests/spec/arb_program_interface_query/getprogramresourceiv.c
@@ -283,6 +283,7 @@ PIGLIT_GL_TEST_CONFIG_END
 
 GLuint prog_std = -1; /* (vs,gs,fs)_std */
 GLuint prog_stor = -1; /* (vs,gs,fs)_stor */
+GLuint prog_buff_blks = -1; /* (vs,fs)_buff_blks */
 GLuint prog_sub = -1; /* (vs,gs,fs)_sub */
 GLuint prog_sub_tess = -1; /* tcs_sub */
 GLuint prog_cs = -1; /* cs_sub */
@@ -303,8 +304,11 @@ struct subtest_t {
 	} props[25];
 };
 
+const char *vs_std_vs_uniform_blk[] = {"vs_test", NULL };
 const char *fs_std_fs_uniform_blk[] = {"fs_color", "fs_array[0]", NULL };
+const char *vs_stor_vs_buf_blk[] = {"vs_buf_var", NULL };
 const char *fs_stor_gs_buf_blk[] = {"gs_buf_var", NULL };
+const char *fs_stor_fs_buf_blk[] = {"fs_buf_var", NULL };
 const char *vs_sub_uniforms[] = {"vss", "vss2", NULL };
 const char *tess_sub_uniforms[] = {"tcss", NULL };
 const char *cs_sub_uniforms[] = {"css", NULL };
@@ -506,6 +510,62 @@ static const struct subtest_t subtests[] = {
 	{ GL_REFERENCED_BY_COMPUTE_SHADER, 1, { 0 } },
 	{ 0, 0, { 0 } }}
  },
+ { &prog_buff_blks, GL_UNIFORM_BLOCK, "vs_uni_block", vs_std_vs_uniform_blk, {
+	{ GL_NAME_LENGTH, 1, { 13 } },
+	{ GL_BUFFER_BINDING, 1, { 0 } },
+	{ GL_BUFFER_DATA_SIZE, 1, { 16 } }, /* only checks for GL errors */
+	{ GL_NUM_ACTIVE_VARIABLES, 1, { 1 } },
+	{ GL_ACTIVE_VARIABLES, 1, { 0 } },
+	{ GL_REFERENCED_BY_VERTEX_SHADER, 1, { 1 } },
+	{ GL_REFERENCED_BY_TESS_CONTROL_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_TESS_EVALUATION_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_GEOMETRY_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_FRAGMENT_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_COMPUTE_SHADER, 1, { 0 } },
+	{ 0, 0, { 0 } }}
+ },
+ { &prog_buff_blks, GL_UNIFORM_BLOCK, "fs_uni_block", fs_std_fs_uniform_blk, {
+	{ GL_NAME_LENGTH, 1, { 13 } },
+	{ GL_BUFFER_BINDING, 1, { 0 } },
+	{ GL_BUFFER_DATA_SIZE, 1, { 32 } }, /* only checks for GL errors */
+	{ GL_NUM_ACTIVE_VARIABLES, 1, { 2 } },
+	{ GL_ACTIVE_VARIABLES, 2, { 0, 0 } },
+	{ GL_REFERENCED_BY_VERTEX_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_TESS_CONTROL_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_TESS_EVALUATION_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_GEOMETRY_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_FRAGMENT_SHADER, 1, { 1 } },
+	{ GL_REFERENCED_BY_COMPUTE_SHADER, 1, { 0 } },
+	{ 0, 0, { 0 } }}
+ },
+ { &prog_buff_blks, GL_SHADER_STORAGE_BLOCK, "vs_buffer_block", vs_stor_vs_buf_blk, {
+	{ GL_NAME_LENGTH, 1, { 16 } },
+	{ GL_BUFFER_BINDING, 1, { 0 } },
+	{ GL_BUFFER_DATA_SIZE, 1, { 16 } }, /* only checks for GL errors */
+	{ GL_NUM_ACTIVE_VARIABLES, 1, { 1 } },
+	{ GL_ACTIVE_VARIABLES, 1, { 1 } },
+	{ GL_REFERENCED_BY_VERTEX_SHADER, 1, { 1 } },
+	{ GL_REFERENCED_BY_TESS_CONTROL_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_TESS_EVALUATION_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_GEOMETRY_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_FRAGMENT_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_COMPUTE_SHADER, 1, { 0 } },
+	{ 0, 0, { 0 } }}
+ },
+ { &prog_buff_blks, GL_SHADER_STORAGE_BLOCK, "fs_buffer_block", fs_stor_fs_buf_blk, {
+	{ GL_NAME_LENGTH, 1, { 16 } },
+	{ GL_BUFFER_BINDING, 1, { 0 } },
+	{ GL_BUFFER_DATA_SIZE, 1, { 16 } }, /* only checks for GL errors */
+	{ GL_NUM_ACTIVE_VARIABLES, 1, { 1 } },
+	{ GL_ACTIVE_VARIABLES, 1, { 1 } },
+	{ GL_REFERENCED_BY_VERTEX_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_TESS_CONTROL_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_TESS_EVALUATION_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_GEOMETRY_SHADER, 1, { 0 } },
+	{ GL_REFERENCED_BY_FRAGMENT_SHADER, 1, { 1 } },
+	{ GL_REFERENCED_BY_COMPUTE_SHADER, 1, { 0 } },
+	{ 0, 0, { 0 } }}
+ },
  { &prog_std, GL_TRANSFORM_FEEDBACK_VARYING, "gs_output0", NULL, {
 	{ GL_NAME_LENGTH, 1, { 11 } },
 	{ GL_ARRAY_SIZE, 1, { 1 } },
@@ -860,7 +920,7 @@ check_extensions(GLuint prog, GLenum programInterface)
 	/* First check the availability of the extensions */
 	if ((programInterface == GL_BUFFER_VARIABLE ||
 	    programInterface == GL_SHADER_STORAGE_BLOCK ||
-	    prog == prog_stor) &&
+	    prog == prog_stor || prog == prog_buff_blks) &&
 	    !piglit_is_extension_supported("GL_ARB_shader_storage_buffer_object")) {
 		return false;
 	}
@@ -982,6 +1042,11 @@ piglit_init(int argc, char **argv)
 						GL_GEOMETRY_SHADER, gs_stor,
 						GL_FRAGMENT_SHADER, fs_stor,
 						0);
+
+		prog_buff_blks = piglit_build_simple_program_multiple_shaders(
+						GL_VERTEX_SHADER, vs_buff_blks,
+						GL_FRAGMENT_SHADER, fs_buff_blks,
+						0);
 	}
 
 	if (piglit_is_extension_supported("GL_ARB_explicit_attrib_location") &&
@@ -1137,6 +1202,7 @@ piglit_display(void)
 	glDeleteProgramSafe(prog_sub_tess);
 	glDeleteProgramSafe(prog_sub);
 	glDeleteProgramSafe(prog_stor);
+	glDeleteProgramSafe(prog_buff_blks);
 	glDeleteProgramSafe(prog_std);
 
 	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
-- 
2.5.5



More information about the Piglit mailing list