[Piglit] [PATCH] arb_tessellation_shader: Fix large-uniforms test
Chris Forbes
chrisf at ijw.co.nz
Tue Aug 26 02:08:05 PDT 2014
If this test worked before, it was by accident.
- Declare blocks as layout(std140) for portability.
- Use vec4[] rather than float[]; According to std140 rules, the array
stride of float[] is actually sizeof(vec4), not sizeof(float), so
we were asking for a considerably larger UBO than intended.
- Don't insist on an error when exceeding GL_MAX_UNIFORM_BLOCK_SIZE. The
spec doesn't require it to be emitted.
- Fetch max uniform block size before using it.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
Various fixes for the `large-uniforms` test sent out a few days ago. Will squash it
in when these land.
.../spec/arb_tessellation_shader/large-uniforms.c | 46 ++++++++++++++--------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/tests/spec/arb_tessellation_shader/large-uniforms.c b/tests/spec/arb_tessellation_shader/large-uniforms.c
index 118f12e..7502d2e 100644
--- a/tests/spec/arb_tessellation_shader/large-uniforms.c
+++ b/tests/spec/arb_tessellation_shader/large-uniforms.c
@@ -73,8 +73,8 @@ static const char *const tcs_source_uniform_block_template =
"#version 150\n"
"#extension GL_ARB_tessellation_shader: require\n"
"layout(vertices = 3) out;\n"
-"uniform block {\n"
-" float large_array[%d];\n"
+"layout(std140) uniform block {\n"
+" vec4 large_array[%d];\n"
"} large_block[%d];\n"
"void main() {\n"
" gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);\n"
@@ -104,8 +104,8 @@ static const char *const tes_source_uniform_block_template =
"#version 150\n"
"#extension GL_ARB_tessellation_shader: require\n"
"layout(triangles) in;\n"
-"uniform block {\n"
-" float large_array[%d];\n"
+"layout(std140) uniform block {\n"
+" vec4 large_array[%d];\n"
"} large_block[%d];\n"
"void main() {\n"
" gl_Position = vec4(0.0);\n"
@@ -170,7 +170,7 @@ test_uniform_block(const GLenum shader, const int num_blocks, const int size,
const char *source_template = shader == GL_TESS_CONTROL_SHADER ?
tcs_source_uniform_block_template :
tes_source_uniform_block_template;
- const char *summand_template = " + large_block[%d].large_array[i]";
+ const char *summand_template = " + large_block[%d].large_array[i].w";
char *sum;
int i;
@@ -204,13 +204,13 @@ test_uniform_block(const GLenum shader, const int num_blocks, const int size,
link_status = piglit_link_check_status_quiet(prog);
if (link_status && expect_fail) {
- fprintf(stderr, "Program with %d uniform blocks of size %d "
- "in %s linked succesfully\n", num_blocks, size,
+ fprintf(stderr, "Program with %d uniform blocks of size %d (vec4s)"
+ "in %s linked successfully\n", num_blocks, size,
piglit_get_gl_enum_name(shader));
return false;
}
if (!link_status && !expect_fail) {
- fprintf(stderr, "Program with %d uniform blocks of size %d "
+ fprintf(stderr, "Program with %d uniform blocks of size %d (vec4s)"
"in %s failed to link\n", num_blocks, size,
piglit_get_gl_enum_name(shader));
return false;
@@ -224,6 +224,17 @@ test_uniform_block(const GLenum shader, const int num_blocks, const int size,
static bool
+report(bool result, GLenum shader, char const *name)
+{
+ piglit_report_subtest_result(result ? PIGLIT_PASS : PIGLIT_FAIL,
+ "%s-%s",
+ piglit_get_gl_enum_name(shader),
+ name);
+ return result;
+}
+
+
+static bool
test_shader(const GLenum shader, const int max_uniform_components,
const int max_combined_uniform_components,
const int max_uniform_blocks)
@@ -239,19 +250,22 @@ test_shader(const GLenum shader, const int max_uniform_components,
* (MAX_UNIFORM_BLOCK_SIZE/4)
* using the minimum values of the corresponding terms.
*/
- pass = max_combined_uniform_components >=
+ glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &max_uniform_block_size);
+
+ pass = report(max_combined_uniform_components >=
max_uniform_components +
max_uniform_blocks *
- (max_uniform_block_size/4) && pass;
+ (max_uniform_block_size/4), shader, "combined-limit-large-enough") && pass;
- pass = test_uniform_array(shader, max_uniform_components, false) && pass;
- pass = test_uniform_array(shader, max_uniform_components + 1, true) && pass;
+ pass = report(test_uniform_array(shader, max_uniform_components, false), shader, "array-at-limit") && pass;
+ pass = report(test_uniform_array(shader, max_uniform_components + 1, true), shader, "array-too-large") && pass;
- glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &max_uniform_block_size);
- pass = test_uniform_block(shader, max_uniform_blocks, max_uniform_block_size/4, false) && pass;
- pass = test_uniform_block(shader, max_uniform_blocks + 1, max_uniform_block_size/4, true) && pass;
- pass = test_uniform_block(shader, max_uniform_blocks, max_uniform_block_size/4 + 1, true) && pass;
+ pass = report(test_uniform_block(shader, max_uniform_blocks, max_uniform_block_size/16, false), shader, "blocks-at-limits") && pass;
+ pass = report(test_uniform_block(shader, max_uniform_blocks + 1, max_uniform_block_size/16, true), shader, "blocks-too-many-blocks") && pass;
+ /* For uniform blocks too large, the spec says a linker error *may* be
+ * emitted; it is not required. so don't test that.
+ */
return pass;
}
--
2.0.4
More information about the Piglit
mailing list