[Mesa-dev] [PATCH 2/2] mesa: add hard limits for the number of varyings and uniforms for the linker

Marek Olšák maraeo at gmail.com
Tue Nov 22 07:54:04 PST 2011

On Tue, Nov 22, 2011 at 4:05 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
> Marek,
> I think we should take one of two approaches here:
> - aim for a short-term workaround, without gallium interface changes:
>  - e.g., provide to GLSL compiler infinite/huge limits, while advertising to the app the pipe driver ones
>  - or detect the wine process and advertise bigger limits in the r300 driver
> - aim for accurately describing the pipe driver compiling abilities
>  - e.g., allow the state tracker to create shaders that exceed abilities, and force a trial generation and compilation of the TGSI shaders when the GLSL shader is first linked
> But the hard limit caps interface change you propose below doesn't quite align to neither approach: it is an interface change which doesn't truly help describing the pipe driver compiler abilities any better (the actual maximum constants/inputs depends on the shader and is not a global constant), so it merely provides a short term relief.

I would gladly commit this patch:

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 3527088..4e1e648 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1813,6 +1813,9 @@ assign_varying_locations(struct gl_context *ctx,

+   /* Enable this once the GLSL compiler can properly count in just
+    * active array elements, not whole arrays. */
+#if 0
    if (ctx->API == API_OPENGLES2 || prog->Version == 100) {
       if (varying_vectors > ctx->Const.MaxVarying) {
         linker_error(prog, "shader uses too many varying vectors "
@@ -1829,6 +1832,7 @@ assign_varying_locations(struct gl_context *ctx,
         return false;

    return true;
@@ -1959,10 +1963,16 @@ check_resources(struct gl_context *ctx, struct
gl_shader_program *prog)

+      /* Enable this once the GLSL compiler can properly count in just
+       * active array elements, not whole arrays. */
+#if 0
       if (sh->num_uniform_components > max_uniform_components[i]) {
          linker_error(prog, "Too many %s shader uniform components",
+      (void) max_uniform_components;

    return prog->LinkStatus;

BUT I had a very informative discussion with one Intel developer last
night and he said we can't change the linker because he's on the ARB.

Now seriously. I do really care about users. And I'd like to release a
product which works best for them. Some people obviously don't want me
to release such a product.


More information about the mesa-dev mailing list