Re: [Mesa-dev] [PATCH] mesa: add const flags to skip MaxVarying and MaxUniform linker checks (v2)

2011-12-12 Thread Kenneth Graunke
On 12/11/2011 11:07 PM, Marek Olšák wrote:
> This is only temporary until a better solution is available.
> 
> v2: print warnings and add gallium CAPs

Thanks, Marek---this looks good to me.

Reviewed-by: Kenneth Graunke 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: add const flags to skip MaxVarying and MaxUniform linker checks (v2)

2011-12-12 Thread Ian Romanick

On 12/11/2011 11:07 PM, Marek Olšák wrote:

This is only temporary until a better solution is available.

v2: print warnings and add gallium CAPs


Reviewed-by: Ian Romanick 


---
  src/gallium/drivers/r300/r300_screen.c |2 +
  src/gallium/include/pipe/p_defines.h   |4 ++-
  src/glsl/linker.cpp|   43 ---
  src/mesa/main/mtypes.h |9 ++
  src/mesa/state_tracker/st_extensions.c |6 
  5 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_screen.c 
b/src/gallium/drivers/r300/r300_screen.c
index e734ff2..0bae065 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -100,6 +100,8 @@ static int r300_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
  case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
  case PIPE_CAP_CONDITIONAL_RENDER:
  case PIPE_CAP_TEXTURE_BARRIER:
+case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS:
+case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
  return 1;

  /* r300 cannot do swizzling of compressed textures. Supported 
otherwise. */
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index f00077c..30f1d7f 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -465,7 +465,9 @@ enum pipe_cap {
 PIPE_CAP_MIN_TEXEL_OFFSET = 50,
 PIPE_CAP_MAX_TEXEL_OFFSET = 51,
 PIPE_CAP_CONDITIONAL_RENDER = 52,
-   PIPE_CAP_TEXTURE_BARRIER = 53
+   PIPE_CAP_TEXTURE_BARRIER = 53,
+   PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS = 54, /* temporary */
+   PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS = 55 /* temporary */
  };

  /**
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 3527088..b8a7126 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1815,18 +1815,34 @@ assign_varying_locations(struct gl_context *ctx,

 if (ctx->API == API_OPENGLES2 || prog->Version == 100) {
if (varying_vectors>  ctx->Const.MaxVarying) {
-linker_error(prog, "shader uses too many varying vectors "
- "(%u>  %u)\n",
- varying_vectors, ctx->Const.MaxVarying);
-return false;
+ if (ctx->Const.GLSLSkipStrictMaxVaryingLimitCheck) {
+linker_warning(prog, "shader uses too many varying vectors "
+   "(%u>  %u), but the driver will try to optimize "
+   "them out; this is non-portable out-of-spec "
+   "behavior\n",
+   varying_vectors, ctx->Const.MaxVarying);
+ } else {
+linker_error(prog, "shader uses too many varying vectors "
+ "(%u>  %u)\n",
+ varying_vectors, ctx->Const.MaxVarying);
+return false;
+ }
}
 } else {
const unsigned float_components = varying_vectors * 4;
if (float_components>  ctx->Const.MaxVarying * 4) {
-linker_error(prog, "shader uses too many varying components "
- "(%u>  %u)\n",
- float_components, ctx->Const.MaxVarying * 4);
-return false;
+ if (ctx->Const.GLSLSkipStrictMaxVaryingLimitCheck) {
+linker_warning(prog, "shader uses too many varying components "
+   "(%u>  %u), but the driver will try to optimize "
+   "them out; this is non-portable out-of-spec "
+   "behavior\n",
+   float_components, ctx->Const.MaxVarying * 4);
+ } else {
+linker_error(prog, "shader uses too many varying components "
+ "(%u>  %u)\n",
+ float_components, ctx->Const.MaxVarying * 4);
+return false;
+ }
}
 }

@@ -1960,8 +1976,15 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
}

if (sh->num_uniform_components>  max_uniform_components[i]) {
- linker_error(prog, "Too many %s shader uniform components",
- shader_names[i]);
+ if (ctx->Const.GLSLSkipStrictMaxUniformLimitCheck) {
+linker_warning(prog, "Too many %s shader uniform components, "
+   "but the driver will try to optimize them out; "
+   "this is non-portable out-of-spec behavior\n",
+   shader_names[i]);
+ } else {
+linker_error(prog, "Too many %s shader uniform components",
+ shader_names[i]);
+ }
}
 }

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index fc494f7..2073c8f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2829,6 +2829,15 @@ struct gl_constants
  * Texture borders are deprecated in GL 3.0.
  **/
 GLboolean StripText