[Mesa-dev] [PATCH] gallium/aux: Turn TGSI_CHAN_* into enum

Brian Paul brianp at vmware.com
Tue Jan 12 06:29:11 PST 2016


The prefix on the subject line could be "tgsi: "

Is this the first in a series?  There's quite a few other places where 
uint/unsigned could be replaced with enum tgsi_chan if you want to be 
consistent.

-Brian

On 01/12/2016 02:55 AM, Edward O'Callaghan wrote:
> Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
> ---
>   src/gallium/auxiliary/tgsi/tgsi_exec.h | 10 ++++++----
>   src/gallium/auxiliary/tgsi/tgsi_util.c | 16 ++++++++--------
>   2 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> index 26fec8e..7911fa8 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> @@ -37,10 +37,12 @@
>   extern "C" {
>   #endif
>
> -#define TGSI_CHAN_X 0
> -#define TGSI_CHAN_Y 1
> -#define TGSI_CHAN_Z 2
> -#define TGSI_CHAN_W 3
> +enum tgsi_chan {
> +   TGSI_CHAN_X,
> +   TGSI_CHAN_Y,
> +   TGSI_CHAN_Z,
> +   TGSI_CHAN_W,
> +};
>
>   #define TGSI_NUM_CHANNELS 4  /* R,G,B,A */
>   #define TGSI_QUAD_SIZE    4  /* 4 pixel/quad */
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c
> index 5fff3f0..0047db1 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_util.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_util.c
> @@ -52,7 +52,7 @@ tgsi_align_128bit(
>   unsigned
>   tgsi_util_get_src_register_swizzle(
>      const struct tgsi_src_register *reg,
> -   unsigned component )
> +   enum tgsi_chan component)
>   {
>      switch (component) {
>      case TGSI_CHAN_X:
> @@ -73,7 +73,7 @@ tgsi_util_get_src_register_swizzle(
>   unsigned
>   tgsi_util_get_full_src_register_swizzle(
>      const struct tgsi_full_src_register  *reg,
> -   unsigned component )
> +   enum tgsi_chan component)
>   {
>      return tgsi_util_get_src_register_swizzle(
>         &reg->Register,
> @@ -84,19 +84,19 @@ void
>   tgsi_util_set_src_register_swizzle(
>      struct tgsi_src_register *reg,
>      unsigned swizzle,
> -   unsigned component )
> +   enum tgsi_chan component)
>   {
> -   switch( component ) {
> -   case 0:
> +   switch (component) {
> +   case TGSI_CHAN_X:
>         reg->SwizzleX = swizzle;
>         break;
> -   case 1:
> +   case TGSI_CHAN_Y:
>         reg->SwizzleY = swizzle;
>         break;
> -   case 2:
> +   case TGSI_CHAN_Z:
>         reg->SwizzleZ = swizzle;
>         break;
> -   case 3:
> +   case TGSI_CHAN_W:
>         reg->SwizzleW = swizzle;
>         break;
>      default:
>



More information about the mesa-dev mailing list