[Mesa-dev] [PATCH] mesa: bump MAX_VARYING to 32

Kenneth Graunke kenneth at whitecape.org
Fri Oct 26 10:32:26 PDT 2012


On 10/26/2012 09:58 AM, Marek Olšák wrote:
> We're starting to get apps utilizing more than 16 varyings and
> most current hardware supports 32 anyway.
>
> Tested with r600g.
> swrast, softpipe and llvmpipe still advertise 16 varyings.
>
> This fixes a WebGL crash after launching this demo:
> https://developer.mozilla.org/en-US/demos/detail/falling-cubes
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54402
>
> NOTE: This is a candidate for the stable branches.
> ---
>   src/gallium/auxiliary/tgsi/tgsi_ureg.c |    2 +-
>   src/gallium/include/pipe/p_state.h     |    4 ++--
>   src/mesa/main/config.h                 |    2 +-
>   src/mesa/main/context.c                |    2 +-
>   src/mesa/program/prog_print.c          |   36 ++++++++++++++++++++++++++++++--
>   5 files changed, 39 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> index 3fe78e0..3c2a923 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> @@ -73,7 +73,7 @@ struct ureg_tokens {
>
>   #define UREG_MAX_INPUT PIPE_MAX_ATTRIBS
>   #define UREG_MAX_SYSTEM_VALUE PIPE_MAX_ATTRIBS
> -#define UREG_MAX_OUTPUT PIPE_MAX_ATTRIBS
> +#define UREG_MAX_OUTPUT PIPE_MAX_SHADER_OUTPUTS
>   #define UREG_MAX_CONSTANT_RANGE 32
>   #define UREG_MAX_IMMEDIATE 256
>   #define UREG_MAX_ADDR 2
> diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
> index 6d0db0f..f84bfd7 100644
> --- a/src/gallium/include/pipe/p_state.h
> +++ b/src/gallium/include/pipe/p_state.h
> @@ -59,7 +59,7 @@ extern "C" {
>   #define PIPE_MAX_CONSTANT_BUFFERS 32
>   #define PIPE_MAX_SAMPLERS         16
>   #define PIPE_MAX_SHADER_INPUTS    32
> -#define PIPE_MAX_SHADER_OUTPUTS   32
> +#define PIPE_MAX_SHADER_OUTPUTS   48 /* 32 GENERICs + POS, PSIZE, FOG, etc. */
>   #define PIPE_MAX_SHADER_SAMPLER_VIEWS 32
>   #define PIPE_MAX_SHADER_RESOURCES 32
>   #define PIPE_MAX_TEXTURE_LEVELS   16
> @@ -145,7 +145,7 @@ struct pipe_rasterizer_state
>      unsigned line_stipple_factor:8;  /**< [1..256] actually */
>      unsigned line_stipple_pattern:16;
>
> -   unsigned sprite_coord_enable:PIPE_MAX_SHADER_OUTPUTS;
> +   unsigned sprite_coord_enable; /* bitfield referring to 32 GENERIC inputs */
>
>      float line_width;
>      float point_size;           /**< used when no per-vertex size */
> diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
> index 1b72b54..99910d7 100644
> --- a/src/mesa/main/config.h
> +++ b/src/mesa/main/config.h
> @@ -187,7 +187,7 @@
>   #define MAX_PROGRAM_CALL_DEPTH         8
>   #define MAX_PROGRAM_TEMPS              256
>   #define MAX_PROGRAM_ADDRESS_REGS       2
> -#define MAX_VARYING                    16    /**< number of float[4] vectors */
> +#define MAX_VARYING                    32    /**< number of float[4] vectors */
>   #define MAX_SAMPLERS                   MAX_TEXTURE_IMAGE_UNITS
>   #define MAX_PROGRAM_INPUTS             32
>   #define MAX_PROGRAM_OUTPUTS            64
> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
> index b00c642..a510738 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -614,7 +614,7 @@ _mesa_init_constants(struct gl_context *ctx)
>
>      ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
>      ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
> -   ctx->Const.MaxVarying = MAX_VARYING;
> +   ctx->Const.MaxVarying = 16; /* old limit not to break tnl and swrast */
>      ctx->Const.MaxGeometryTextureImageUnits = MAX_GEOMETRY_TEXTURE_IMAGE_UNITS;
>      ctx->Const.MaxVertexVaryingComponents = MAX_VERTEX_VARYING_COMPONENTS;
>      ctx->Const.MaxGeometryVaryingComponents = MAX_GEOMETRY_VARYING_COMPONENTS;

I think there are some crazy restrictions on using more than 16 on our 
hardware...you can apply certain transformations to either the first 16, 
or the second 16.

But it looks like this hunk should cause i965 to continue advertizing 
16, so I think this should be fine.

Acked-by: Kenneth Graunke <kenneth at whitecape.org>



More information about the mesa-dev mailing list