Mesa (master): ir_to_mesa: do not check the number of uniforms against hw limits

Marek Olšák mareko at kemper.freedesktop.org
Mon Mar 14 02:25:31 UTC 2011


Module: Mesa
Branch: master
Commit: 0f84ddad29284b407c6bbef0b731201056d40324
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f84ddad29284b407c6bbef0b731201056d40324

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sun Mar 13 03:12:11 2011 +0100

ir_to_mesa: do not check the number of uniforms against hw limits

The r300 compiler can eliminate unused uniforms and remap uniform locations
if their number surpasses hardware limits, so the limit is actually
NumParameters + NumUnusedParameters. This is important for some apps
under Wine to run.

Wine sometimes declares a uniform array of 256 vec4's and some Wine-specific
constants on top of that, so in total there is more uniforms than r300 can
handle. This was the main motivation for implementing the elimination
of unused constants.

We should allow drivers to implement fail & recovery paths where it makes
sense, so giving up too early especially when comes to uniforms is not
so good idea, though I agree there should be some hard limit for all drivers.

This patch fixes:
- glsl-fs-uniform-array-5
- glsl-vs-large-uniform-array
on drivers which can eliminate unused uniforms.

---

 src/mesa/program/ir_to_mesa.cpp |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index eff0d37..9578f42 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2453,8 +2453,7 @@ check_resources(const struct gl_context *ctx,
           ctx->Const.MaxVertexTextureImageUnits) {
          fail_link(shader_program, "Too many vertex shader texture samplers");
       }
-      if (prog->Parameters->NumParameters >
-          ctx->Const.VertexProgram.MaxUniformComponents / 4) {
+      if (prog->Parameters->NumParameters > MAX_UNIFORMS) {
          fail_link(shader_program, "Too many vertex shader constants");
       }
       break;
@@ -2464,7 +2463,7 @@ check_resources(const struct gl_context *ctx,
          fail_link(shader_program, "Too many geometry shader texture samplers");
       }
       if (prog->Parameters->NumParameters >
-          ctx->Const.GeometryProgram.MaxUniformComponents / 4) {
+          MAX_GEOMETRY_UNIFORM_COMPONENTS / 4) {
          fail_link(shader_program, "Too many geometry shader constants");
       }
       break;
@@ -2473,8 +2472,7 @@ check_resources(const struct gl_context *ctx,
           ctx->Const.MaxTextureImageUnits) {
          fail_link(shader_program, "Too many fragment shader texture samplers");
       }
-      if (prog->Parameters->NumParameters >
-          ctx->Const.FragmentProgram.MaxUniformComponents / 4) {
+      if (prog->Parameters->NumParameters > MAX_UNIFORMS) {
          fail_link(shader_program, "Too many fragment shader constants");
       }
       break;




More information about the mesa-commit mailing list