[Mesa-dev] [PATCH] gallium: rename shader cap MAX_CONSTS to MAX_CONST_BUFFER_SIZE

Brian Paul brianp at vmware.com
Mon Jul 28 10:06:54 PDT 2014


On 07/24/2014 12:35 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> This new name isn't so confusing.
>
> I also changed the gallivm limit, because it looked wrong.
> ---
>   src/gallium/auxiliary/gallivm/lp_bld_limits.h     | 4 ++--
>   src/gallium/auxiliary/tgsi/tgsi_exec.h            | 8 ++++----
>   src/gallium/auxiliary/util/u_caps.c               | 4 ++--
>   src/gallium/docs/source/screen.rst                | 2 +-
>   src/gallium/drivers/freedreno/freedreno_screen.c  | 4 ++--
>   src/gallium/drivers/i915/i915_screen.c            | 4 ++--
>   src/gallium/drivers/ilo/ilo_screen.c              | 4 ++--
>   src/gallium/drivers/nouveau/nv30/nv30_screen.c    | 8 ++++----
>   src/gallium/drivers/nouveau/nv50/nv50_screen.c    | 4 ++--
>   src/gallium/drivers/nouveau/nvc0/nvc0_screen.c    | 4 ++--
>   src/gallium/drivers/r300/r300_screen.c            | 8 ++++----
>   src/gallium/drivers/r600/r600_pipe.c              | 2 +-
>   src/gallium/drivers/r600/r600_pipe.h              | 2 +-
>   src/gallium/drivers/radeonsi/si_pipe.c            | 4 ++--
>   src/gallium/drivers/svga/svga_screen.c            | 8 ++++----
>   src/gallium/include/pipe/p_defines.h              | 2 +-
>   src/gallium/state_trackers/clover/core/device.cpp | 2 +-
>   src/mesa/state_tracker/st_extensions.c            | 5 +++--
>   18 files changed, 40 insertions(+), 39 deletions(-)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
> index 9ccaf46..0b72dd0 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
> @@ -97,8 +97,8 @@ gallivm_get_shader_param(enum pipe_shader_cap param)
>         return LP_MAX_TGSI_NESTING;
>      case PIPE_SHADER_CAP_MAX_INPUTS:
>         return PIPE_MAX_SHADER_INPUTS;
> -   case PIPE_SHADER_CAP_MAX_CONSTS:
> -      return 16 * 2024;
> +   case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +      return 16 * 4096;
>      case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>         return PIPE_MAX_CONSTANT_BUFFERS;
>      case PIPE_SHADER_CAP_MAX_TEMPS:
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> index 56a7034..07c96b2 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> @@ -215,9 +215,9 @@ struct tgsi_sampler
>    */
>   #define TGSI_EXEC_MAX_INPUT_ATTRIBS PIPE_MAX_SHADER_INPUTS
>
> -/* The maximum number of constant vectors per constant buffer.
> +/* The maximum number of bytes per constant buffer.
>    */
> -#define TGSI_EXEC_MAX_CONST_BUFFER  4096
> +#define TGSI_EXEC_MAX_CONST_BUFFER_SIZE  (4096 * 16)
>
>   /* The maximum number of vertices per primitive */
>   #define TGSI_MAX_PRIM_VERTICES 6
> @@ -427,8 +427,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
>         return TGSI_EXEC_MAX_NESTING;
>      case PIPE_SHADER_CAP_MAX_INPUTS:
>         return TGSI_EXEC_MAX_INPUT_ATTRIBS;
> -   case PIPE_SHADER_CAP_MAX_CONSTS:
> -      return TGSI_EXEC_MAX_CONST_BUFFER;
> +   case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +      return TGSI_EXEC_MAX_CONST_BUFFER_SIZE;
>      case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>         return PIPE_MAX_CONSTANT_BUFFERS;
>      case PIPE_SHADER_CAP_MAX_TEMPS:
> diff --git a/src/gallium/auxiliary/util/u_caps.c b/src/gallium/auxiliary/util/u_caps.c
> index 6230707..ec8938b 100644
> --- a/src/gallium/auxiliary/util/u_caps.c
> +++ b/src/gallium/auxiliary/util/u_caps.c
> @@ -198,13 +198,13 @@ static unsigned caps_sm3[] = {
>       UTIL_CHECK_SHADER(FRAGMENT, MAX_INPUTS, 10),
>       UTIL_CHECK_SHADER(FRAGMENT, MAX_TEMPS, 32),
>       UTIL_CHECK_SHADER(FRAGMENT, MAX_ADDRS, 1),
> -    UTIL_CHECK_SHADER(FRAGMENT, MAX_CONSTS, 224),
> +    UTIL_CHECK_SHADER(FRAGMENT, MAX_CONST_BUFFER_SIZE, 224 * 16),
>
>       UTIL_CHECK_SHADER(VERTEX, MAX_INSTRUCTIONS, 512),
>       UTIL_CHECK_SHADER(VERTEX, MAX_INPUTS, 16),
>       UTIL_CHECK_SHADER(VERTEX, MAX_TEMPS, 32),
>       UTIL_CHECK_SHADER(VERTEX, MAX_ADDRS, 2),
> -    UTIL_CHECK_SHADER(VERTEX, MAX_CONSTS, 256),
> +    UTIL_CHECK_SHADER(VERTEX, MAX_CONST_BUFFER_SIZE, 256 * 16),
>
>       UTIL_CHECK_TERMINATE
>   };
> diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
> index ba583fe..bdc23f7 100644
> --- a/src/gallium/docs/source/screen.rst
> +++ b/src/gallium/docs/source/screen.rst
> @@ -250,7 +250,7 @@ support different features.
>   * ``PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS``: The maximum number of texture indirections.
>   * ``PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH``: The maximum nested control flow depth.
>   * ``PIPE_SHADER_CAP_MAX_INPUTS``: The maximum number of input registers.
> -* ``PIPE_SHADER_CAP_MAX_CONSTS``: The maximum number of constants.
> +* ``PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE``: The maximum size per constant buffer in bytes.
>   * ``PIPE_SHADER_CAP_MAX_CONST_BUFFERS``: Maximum number of constant buffers that can be bound
>     to any shader stage using ``set_constant_buffer``. If 0 or 1, the pipe will
>     only permit binding one constant buffer per shader, and the shaders will
> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
> index c574cb8..4c82713 100644
> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
> @@ -329,8 +329,8 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
>   		return 64; /* Max native temporaries. */
>   	case PIPE_SHADER_CAP_MAX_ADDRS:
>   		return 1; /* Max native address registers */
> -	case PIPE_SHADER_CAP_MAX_CONSTS:
> -		return (screen->gpu_id >= 300) ? 1024 : 64;
> +	case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +		return ((screen->gpu_id >= 300) ? 1024 : 64) * 16;
>   	case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>   		return 1;
>   	case PIPE_SHADER_CAP_MAX_PREDS:
> diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
> index 86a7a67..f40f2a4 100644
> --- a/src/gallium/drivers/i915/i915_screen.c
> +++ b/src/gallium/drivers/i915/i915_screen.c
> @@ -129,8 +129,8 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_sha
>            return 0;
>         case PIPE_SHADER_CAP_MAX_INPUTS:
>            return 10;
> -      case PIPE_SHADER_CAP_MAX_CONSTS:
> -         return 32;
> +      case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +         return 32 * 16;
>         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>            return 1;
>         case PIPE_SHADER_CAP_MAX_TEMPS:
> diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c
> index e2a0e23..4fff9b6 100644
> --- a/src/gallium/drivers/ilo/ilo_screen.c
> +++ b/src/gallium/drivers/ilo/ilo_screen.c
> @@ -115,8 +115,8 @@ ilo_get_shader_param(struct pipe_screen *screen, unsigned shader,
>      case PIPE_SHADER_CAP_MAX_INPUTS:
>         /* this is limited by how many attributes SF can remap */
>         return 16;
> -   case PIPE_SHADER_CAP_MAX_CONSTS:
> -      return 1024;
> +   case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +      return 1024 * 16;
>      case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>         return ILO_MAX_CONST_BUFFERS;
>      case PIPE_SHADER_CAP_MAX_TEMPS:
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> index 32f5523..fbc645c 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> @@ -198,8 +198,8 @@ nv30_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
>            return 0;
>         case PIPE_SHADER_CAP_MAX_INPUTS:
>            return 16;
> -      case PIPE_SHADER_CAP_MAX_CONSTS:
> -         return (eng3d->oclass >= NV40_3D_CLASS) ? (468 - 6): (256 - 6);
> +      case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +         return ((eng3d->oclass >= NV40_3D_CLASS) ? (468 - 6): (256 - 6)) * 16;
>         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>            return 1;
>         case PIPE_SHADER_CAP_MAX_TEMPS:
> @@ -235,8 +235,8 @@ nv30_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
>            return 0;
>         case PIPE_SHADER_CAP_MAX_INPUTS:
>            return 8; /* should be possible to do 10 with nv4x */
> -      case PIPE_SHADER_CAP_MAX_CONSTS:
> -         return (eng3d->oclass >= NV40_3D_CLASS) ? 224 : 32;
> +      case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +         return ((eng3d->oclass >= NV40_3D_CLASS) ? 224 : 32) * 16;
>         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>            return 1;
>         case PIPE_SHADER_CAP_MAX_TEMPS:
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> index fd63819..677f688 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> @@ -232,8 +232,8 @@ nv50_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
>         if (shader == PIPE_SHADER_VERTEX)
>            return 32;
>         return 15;
> -   case PIPE_SHADER_CAP_MAX_CONSTS:
> -      return 65536 / 16;
> +   case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +      return 65536;
>      case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>         return NV50_MAX_PIPE_CONSTBUFS;
>      case PIPE_SHADER_CAP_MAX_ADDRS:
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> index 3f444a4..24aee6b 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> @@ -238,8 +238,8 @@ nvc0_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
>          * and excludes 0x60 per-patch inputs.
>          */
>         return 0x200 / 16;
> -   case PIPE_SHADER_CAP_MAX_CONSTS:
> -      return 65536 / 16;
> +   case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +      return 65536;
>      case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>         if (shader == PIPE_SHADER_COMPUTE && class_3d >= NVE4_3D_CLASS)
>            return NVE4_MAX_PIPE_CONSTBUFS_COMPUTE;
> diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
> index efa69d3..8380897 100644
> --- a/src/gallium/drivers/r300/r300_screen.c
> +++ b/src/gallium/drivers/r300/r300_screen.c
> @@ -241,8 +241,8 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e
>                * additional texcoords but there is no two-sided color
>                * selection then. However the facing bit can be used instead. */
>               return 10;
> -        case PIPE_SHADER_CAP_MAX_CONSTS:
> -            return is_r500 ? 256 : 32;
> +        case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +            return (is_r500 ? 256 : 32) * 16;
>           case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>               return 1;
>           case PIPE_SHADER_CAP_MAX_TEMPS:
> @@ -289,8 +289,8 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e
>               return is_r500 ? 4 : 0; /* For loops; not sure about conditionals. */
>           case PIPE_SHADER_CAP_MAX_INPUTS:
>               return 16;
> -        case PIPE_SHADER_CAP_MAX_CONSTS:
> -            return 256;
> +        case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +            return 256 * 16;
>           case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>               return 1;
>           case PIPE_SHADER_CAP_MAX_TEMPS:
> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
> index 5bf9c00..ca038da 100644
> --- a/src/gallium/drivers/r600/r600_pipe.c
> +++ b/src/gallium/drivers/r600/r600_pipe.c
> @@ -419,7 +419,7 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
>   	case PIPE_SHADER_CAP_MAX_ADDRS:
>   		/* XXX Isn't this equal to TEMPS? */
>   		return 1; /* Max native address registers */
> -	case PIPE_SHADER_CAP_MAX_CONSTS:
> +	case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
>   		return R600_MAX_CONST_BUFFER_SIZE;
>   	case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>   		return R600_MAX_USER_CONST_BUFFERS;
> diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
> index 4585ace..fe6b9d9 100644
> --- a/src/gallium/drivers/r600/r600_pipe.h
> +++ b/src/gallium/drivers/r600/r600_pipe.h
> @@ -54,7 +54,7 @@
>   #define R600_BUFFER_INFO_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 2)
>   #define R600_GS_RING_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 3)
>
> -#define R600_MAX_CONST_BUFFER_SIZE 4096
> +#define R600_MAX_CONST_BUFFER_SIZE (4096 * 16)
>
>   #ifdef PIPE_ARCH_BIG_ENDIAN
>   #define R600_BIG_ENDIAN 1
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
> index 4f19268..5a9cedf 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.c
> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
> @@ -350,8 +350,8 @@ static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enu
>   	case PIPE_SHADER_CAP_MAX_ADDRS:
>   		/* FIXME Isn't this equal to TEMPS? */
>   		return 1; /* Max native address registers */
> -	case PIPE_SHADER_CAP_MAX_CONSTS:
> -		return 4096; /* actually only memory limits this */
> +	case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +		return 4096 * 16; /* actually only memory limits this */
>   	case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>   		return SI_NUM_USER_CONST_BUFFERS;
>   	case PIPE_SHADER_CAP_MAX_PREDS:
> diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
> index b213b04..b7fb68c 100644
> --- a/src/gallium/drivers/svga/svga_screen.c
> +++ b/src/gallium/drivers/svga/svga_screen.c
> @@ -313,8 +313,8 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en
>            return SVGA3D_MAX_NESTING_LEVEL;
>         case PIPE_SHADER_CAP_MAX_INPUTS:
>            return 10;
> -      case PIPE_SHADER_CAP_MAX_CONSTS:
> -         return 224;
> +      case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +         return 224 * 16;
>         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>            return 1;
>         case PIPE_SHADER_CAP_MAX_TEMPS:
> @@ -371,8 +371,8 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en
>            return SVGA3D_MAX_NESTING_LEVEL;
>         case PIPE_SHADER_CAP_MAX_INPUTS:
>            return 16;
> -      case PIPE_SHADER_CAP_MAX_CONSTS:
> -         return 256;
> +      case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
> +         return 256 * 16;
>         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
>            return 1;
>         case PIPE_SHADER_CAP_MAX_TEMPS:
> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
> index d9b6e5a..edc6b40 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -604,7 +604,7 @@ enum pipe_shader_cap
>      PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS,
>      PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH,
>      PIPE_SHADER_CAP_MAX_INPUTS,
> -   PIPE_SHADER_CAP_MAX_CONSTS,
> +   PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE,
>      PIPE_SHADER_CAP_MAX_CONST_BUFFERS,
>      PIPE_SHADER_CAP_MAX_TEMPS,
>      PIPE_SHADER_CAP_MAX_ADDRS,
> diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
> index b6078db..9684cf3 100644
> --- a/src/gallium/state_trackers/clover/core/device.cpp
> +++ b/src/gallium/state_trackers/clover/core/device.cpp
> @@ -136,7 +136,7 @@ device::max_mem_input() const {
>   cl_ulong
>   device::max_const_buffer_size() const {
>      return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
> -                                 PIPE_SHADER_CAP_MAX_CONSTS) * 16;
> +                                 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE);
>   }
>
>   cl_uint
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index aa59fbf..96f18ad 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -146,7 +146,7 @@ void st_init_limits(struct st_context *st)
>
>      c->MaxUniformBlockSize =
>         screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
> -                               PIPE_SHADER_CAP_MAX_CONSTS) * 16;
> +                               PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE);
>      if (c->MaxUniformBlockSize < 16384) {
>         can_ubo = FALSE;
>      }
> @@ -194,7 +194,8 @@ void st_init_limits(struct st_context *st)
>            _min(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS),
>                 MAX_PROGRAM_ADDRESS_REGS);
>         pc->MaxParameters      = pc->MaxNativeParameters      =
> -         screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS);
> +         screen->get_shader_param(screen, sh,
> +                                  PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) / 16;
>
>         pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS);
>
>

Looks good, but I wonder if we'd like to replace some of the instances 
of 16 with sizeof(float[4]).

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list