[Mesa-dev] [PATCH v2] glsl: extend GLSLSkipStrictMaxUniformLimitCheck to uniform block size
Marcin Ĺšlusarz
marcin.slusarz at gmail.com
Mon Apr 13 15:48:00 PDT 2015
ARB_uniform_buffer_object spec says:
"The total amount of buffer object storage available for any given uniform
block is subject to an implementation-dependent limit; the maximum amount
of available space, in basic machine units, can be queried by calling
GetIntegerv with the constant MAX_UNIFORM_BLOCK_SIZE. If the amount
of storage required for a uniform block exceeds this limit, a program may
fail to link."
Currently spec at arb_uniform_buffer_object@maxuniformblocksize@*exceed tests
fail on nouveau because shader can't calculate expected values. With this
patch linking fails (GLSLSkipStrictMaxUniformLimitCheck is false on nouveau),
allowing tests to pass.
v2: tweak commit message
---
src/glsl/linker.cpp | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 85830e6..88a4548 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2308,6 +2308,25 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
_mesa_shader_stage_to_string(i));
}
}
+
+ for (unsigned j = 0; j < sh->NumUniformBlocks; ++j) {
+ if (sh->UniformBlocks[j].UniformBufferSize >
+ ctx->Const.MaxUniformBlockSize) {
+ if (ctx->Const.GLSLSkipStrictMaxUniformLimitCheck) {
+ linker_warning(prog,
+ "%s shader uses uniform block whose size exceeds "
+ "MAX_UNIFORM_BLOCK_SIZE, but the driver will try "
+ "to optimize them out; this is non-portable "
+ "out-of-spec behaviour\n",
+ _mesa_shader_stage_to_string(i));
+ } else {
+ linker_error(prog,
+ "%s shader uses uniform block whose size exceeds "
+ "MAX_UNIFORM_BLOCK_SIZE\n",
+ _mesa_shader_stage_to_string(i));
+ }
+ }
+ }
}
unsigned blocks[MESA_SHADER_STAGES] = {0};
--
2.1.0
More information about the mesa-dev
mailing list