[Piglit] [PATCH 1/2 v2] arb_uniform_buffer_object: Reference all UBO members from the shader

Ian Romanick idr at freedesktop.org
Mon Jan 28 12:31:57 PST 2013


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

OpenGL ES 3.0 (and presumably other versions of OpenGL) requires that
UBO members that are not accessed by the shader not be marked as
active.  Previously these tests assumed that all members would be active
regardless of use.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59957
---
 tests/spec/arb_uniform_buffer_object/dlist.c           |  2 +-
 .../getactiveuniformsiv-uniform-array-stride.c         |  2 +-
 .../getactiveuniformsiv-uniform-matrix-stride.c        |  2 +-
 .../getactiveuniformsiv-uniform-type.c                 | 13 +++++++++++--
 .../layout-std140-base-size-and-alignment.c            | 13 +++++++++++--
 tests/spec/arb_uniform_buffer_object/layout-std140.c   |  2 +-
 tests/spec/arb_uniform_buffer_object/row-major.c       | 18 ++++++++++++++++++
 7 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/tests/spec/arb_uniform_buffer_object/dlist.c b/tests/spec/arb_uniform_buffer_object/dlist.c
index 1d101a9..4fe28f8 100644
--- a/tests/spec/arb_uniform_buffer_object/dlist.c
+++ b/tests/spec/arb_uniform_buffer_object/dlist.c
@@ -69,7 +69,7 @@ const char *source =
 	"uniform A { float a; };\n"
 	"uniform B { float b; };\n"
 	"void main() {\n"
-	"	gl_FragColor = vec4(a);\n"
+	"	gl_FragColor = vec4(a + b);\n"
 	"}\n";
 
 enum piglit_result
diff --git a/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-array-stride.c b/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-array-stride.c
index 0d51f3f..8668aef 100644
--- a/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-array-stride.c
+++ b/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-array-stride.c
@@ -53,7 +53,7 @@ static const char fs_source[] =
 	"\n"
 	"void main()\n"
 	"{\n"
-	"	gl_FragColor = a + e + f[0];\n"
+	"	gl_FragColor = a + b[0] + vec4(c[0]) + d[0][0] + e + f[0];\n"
 	"}\n";
 
 void
diff --git a/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-matrix-stride.c b/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-matrix-stride.c
index 6e6269a..0aacf62 100644
--- a/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-matrix-stride.c
+++ b/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-matrix-stride.c
@@ -58,7 +58,7 @@ static const char fs_source[] =
 	"\n"
 	"void main()\n"
 	"{\n"
-	"	gl_FragColor = v4 + default_v4 + default_m4[0];\n"
+	"	gl_FragColor = v4 + default_v4 + default_m4[0] + m4[0] + vec4(m3[0], 0.) + vec4(m2[0], 0., 0.) + m4a[0][0];\n"
 	"}\n";
 
 void
diff --git a/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c b/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c
index c97d914..95849ba 100644
--- a/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c
+++ b/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c
@@ -54,15 +54,24 @@ test_format(const struct uniform_type *type)
 		"};\n"
 		"\n"
 		"void main() {\n"
-		"	gl_FragColor = vec4(align_test);\n"
+		"	gl_FragColor = vec4(align_test + float(%s));\n"
 		"}\n";
 	char *fs_source;
 	GLuint fs, prog;
 	const char *uniform_name = "u";
 	GLuint uniform_index;
 	GLint uniform_type;
+	const char *deref;
 
-	asprintf(&fs_source, fs_template, type->type);
+	if (type->size == 4) {
+		deref = "u";
+	} else if (type->size <= 16) {
+		deref = "u.x";
+	} else {
+		deref = "u[0].x";
+	}
+
+	asprintf(&fs_source, fs_template, type->type, deref);
 	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
 	prog = piglit_link_simple_program(0, fs);
 	if (!fs || !prog) {
diff --git a/tests/spec/arb_uniform_buffer_object/layout-std140-base-size-and-alignment.c b/tests/spec/arb_uniform_buffer_object/layout-std140-base-size-and-alignment.c
index 8976435..3450f8d 100644
--- a/tests/spec/arb_uniform_buffer_object/layout-std140-base-size-and-alignment.c
+++ b/tests/spec/arb_uniform_buffer_object/layout-std140-base-size-and-alignment.c
@@ -62,7 +62,7 @@ test_format(const struct uniform_type *type, bool row_major)
 		"};\n"
 		"\n"
 		"void main() {\n"
-		"	gl_FragColor = vec4(pad);\n"
+		"	gl_FragColor = vec4(pad + %s + size_test);\n"
 		"}\n";
 	char *fs_source;
 	GLuint fs, prog;
@@ -72,15 +72,24 @@ test_format(const struct uniform_type *type, bool row_major)
 	int offset, size, expected_offset;
 	const struct uniform_type *transposed_type;
 	bool pass;
+	const char *deref;
 
 	if (row_major)
 		transposed_type = get_transposed_type(type);
 	else
 		transposed_type = type;
 
+	if (type->size == 4)
+		deref = "u";
+	else if (type->size <= 16)
+		deref = "u.x";
+	else
+		deref = "u[0].x";
+
 	asprintf(&fs_source, fs_template,
 		 row_major ? "layout(row_major) " : "",
-		 type->type);
+		 type->type,
+		 deref);
 	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
 	prog = piglit_link_simple_program(0, fs);
 	if (!fs || !prog) {
diff --git a/tests/spec/arb_uniform_buffer_object/layout-std140.c b/tests/spec/arb_uniform_buffer_object/layout-std140.c
index 0f85f3b..d7d6654 100644
--- a/tests/spec/arb_uniform_buffer_object/layout-std140.c
+++ b/tests/spec/arb_uniform_buffer_object/layout-std140.c
@@ -97,7 +97,7 @@ static const char frag_shader_text[] =
 	"\n"
 	"void main()\n"
 	"{\n"
-	"	gl_FragColor = vec4(a);\n"
+	"	gl_FragColor = vec4(a + b.x + c.x + float(f.d) + g + h[0] + i[0].x + o[1].k.x);\n"
 	"}\n";
 
 static void
diff --git a/tests/spec/arb_uniform_buffer_object/row-major.c b/tests/spec/arb_uniform_buffer_object/row-major.c
index 55752c5..7e3425a 100644
--- a/tests/spec/arb_uniform_buffer_object/row-major.c
+++ b/tests/spec/arb_uniform_buffer_object/row-major.c
@@ -122,6 +122,24 @@ static const char *source =
 	"	gl_FragColor = (\n"
 	"		non_ubo_mat[0] + \n"
 	"		non_mat + \n"
+	"		a_cm1[0] + \n"
+	"		a_cm2[0] + \n"
+	"		a_cm3[0] + \n"
+	"		b_cm1[0] + \n"
+	"		b_rm1[0] + \n"
+	"		b_rm2[0] + \n"
+	"		c_cm1[0] + \n"
+	"		c_cm2[0] + \n"
+	"		c_rm1[0] + \n"
+	"		d_cm1[0] + \n"
+	"		d_cm2[0] + \n"
+	"		d_rm1[0] + \n"
+	"		e_cm1[0] + \n"
+	"		e_rm1[0] + \n"
+	"		e_rm2[0] + \n"
+	"		f_cm1[0] + \n"
+	"		f_rm1[0] + \n"
+	"		f_rm2[0] + \n"
 	"		a_non_matrix + \n"
 	"		b_non_matrix + \n"
 	"		c_non_matrix + \n"
-- 
1.7.11.7



More information about the Piglit mailing list