[Mesa-dev] [PATCH 02/13] gallium: rework some utilities functions to support 2d indexing

Brian Paul brianp at vmware.com
Mon Nov 14 08:33:09 PST 2011


On 11/12/2011 02:11 PM, vlj wrote:
>     This patch adds a 2d ureg_src constructor, and add a field in
>     st_src_reg inside glsl_to_tgsi that hold potential 2d index.
>     2d indexing is required at least for uniform buffer object
>     support
> ---
>   src/gallium/auxiliary/tgsi/tgsi_ureg.h     |   12 ++++++++++++
>   src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    8 ++++++--
>   2 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> index 8f5f22e..4e4fce6 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> @@ -998,6 +998,18 @@ ureg_src_register(unsigned file,
>   }
>
>   static INLINE struct ureg_src
> +ureg_src_register2d(unsigned file,
> +                  unsigned index, unsigned index2d)
> +{
> +   struct ureg_src src = ureg_src_register(file,index);
> +
> +   src.Dimension = 1;
> +   src.DimensionIndex = index2d;
> +
> +   return src;
> +}
> +
> +static INLINE struct ureg_src
>   ureg_src( struct ureg_dst dst )
>   {
>      struct ureg_src src;
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 35fd1ff..235a074 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -94,7 +94,7 @@ static int swizzle_for_size(int size);
>    */
>   class st_src_reg {
>   public:
> -   st_src_reg(gl_register_file file, int index, const glsl_type *type)
> +   st_src_reg(gl_register_file file, int index, const glsl_type *type, int index2d = 0)
>      {
>         this->file = file;
>         this->index = index;
> @@ -105,9 +105,10 @@ public:
>         this->negate = 0;
>         this->type = type ? type->base_type : GLSL_TYPE_ERROR;
>         this->reladdr = NULL;
> +      this->index2d = index2d;
>      }
>
> -   st_src_reg(gl_register_file file, int index, int type)
> +   st_src_reg(gl_register_file file, int index, int type, int index2d = 0)
>      {
>         this->type = type;
>         this->file = file;
> @@ -115,6 +116,7 @@ public:
>         this->swizzle = SWIZZLE_XYZW;
>         this->negate = 0;
>         this->reladdr = NULL;
> +      this->index2d = index2d;
>      }
>
>      st_src_reg()
> @@ -125,12 +127,14 @@ public:
>         this->swizzle = 0;
>         this->negate = 0;
>         this->reladdr = NULL;
> +      this->index2d = 0;
>      }
>
>      explicit st_src_reg(st_dst_reg reg);
>
>      gl_register_file file; /**<  PROGRAM_* from Mesa */
>      int index; /**<  temporary index, VERT_ATTRIB_*, FRAG_ATTRIB_*, etc. */
> +   int index2d;
>      GLuint swizzle; /**<  SWIZZLE_XYZWONEZERO swizzles from Mesa. */
>      int negate; /**<  NEGATE_XYZW mask from mesa */
>      int type; /** GLSL_TYPE_* from GLSL IR (enum glsl_base_type) */

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

Looks OK to me.  I think the 2nd TGSI index was added by Zack for 
geometry shader support...

-Brian




More information about the mesa-dev mailing list