[Mesa-dev] [PATCH] glsl: validate uniform blocks don't exceed MAX_UNIFORM_BLOCK_SIZE
Marcin Ĺšlusarz
marcin.slusarz at gmail.com
Sat Apr 4 06:16:03 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."
Fixes these piglit tests:
spec at arb_uniform_buffer_object@maxuniformblocksize at fsexceed
spec at arb_uniform_buffer_object@maxuniformblocksize at vsexceed
on nouveau/gk107.
---
src/glsl/linker.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 85830e6..3f7bfbe 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1626,6 +1626,14 @@ link_intrastage_shaders(void *mem_ctx,
if (!prog->LinkStatus)
return NULL;
+ for (unsigned i = 0; i < num_uniform_blocks; ++i) {
+ if (uniform_blocks[i].UniformBufferSize > ctx->Const.MaxUniformBlockSize) {
+ linker_error(prog,
+ "shader uses uniform block whose size exceeds MAX_UNIFORM_BLOCK_SIZE\n");
+ return NULL;
+ }
+ }
+
/* Check that there is only a single definition of each function signature
* across all shaders.
*/
--
2.1.0
More information about the mesa-dev
mailing list