[Mesa-dev] [PATCH] glsl: extend GLSLSkipStrictMaxUniformLimitCheck to uniform block size

Marcin Ĺšlusarz marcin.slusarz at gmail.com
Sat Apr 11 09:48:15 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 | 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