[Mesa-dev] [PATCH 2/3] gallium: replace pipe_type enum with tgsi_type enum

Roland Scheidegger sroland at vmware.com
Mon Sep 22 10:48:09 PDT 2014


The series looks good to me, though could rename the (quite underused)
pipe_type enum to tgsi_return_type instead and leave tgsi_type alone?
Or for further clarity, rename both (to tgsi_opcode_type and
tgsi_ret_type or something). Either way though looks ok to me.

(That said, I don't understand what the tgsi return type is really good
for. This is a d3d10-ism obviously, but even there I don't get it. What
the hell does it do? The return type from sampling can't be something
like unorm anyway, and I can't see why it makes sense to have to
describe the pre-sampling channel type here, as that's going to be
determined by the actual format anyway, so if this really would describe
the pre-sampling channel type, it would mean you'd have to redeclare the
shader if you want to sample float vs. unorm texture etc. which doesn't
make much sense to me, is this really the case?. llvmpipe/gallivm
certainly don't care about that channel type one bit.)

Roland


Am 22.09.2014 17:44, schrieb Brian Paul:
> The only place the enum pipe_type was used is for the TGSI sampler
> view return type.  So make it a TGSI type.
> ---
>  src/gallium/auxiliary/tgsi/tgsi_build.c    |    8 ++++----
>  src/gallium/auxiliary/tgsi/tgsi_strings.c  |    3 ++-
>  src/gallium/auxiliary/tgsi/tgsi_strings.h  |    2 +-
>  src/gallium/auxiliary/tgsi/tgsi_text.c     |    4 ++--
>  src/gallium/include/pipe/p_format.h        |    9 ---------
>  src/gallium/include/pipe/p_shader_tokens.h |   17 +++++++++++++----
>  6 files changed, 22 insertions(+), 21 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
> index bef5c75..ffc4c61 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_build.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
> @@ -297,10 +297,10 @@ tgsi_default_declaration_sampler_view(void)
>     struct tgsi_declaration_sampler_view dsv;
>  
>     dsv.Resource = TGSI_TEXTURE_BUFFER;
> -   dsv.ReturnTypeX = PIPE_TYPE_UNORM;
> -   dsv.ReturnTypeY = PIPE_TYPE_UNORM;
> -   dsv.ReturnTypeZ = PIPE_TYPE_UNORM;
> -   dsv.ReturnTypeW = PIPE_TYPE_UNORM;
> +   dsv.ReturnTypeX = TGSI_TYPE_UNORM;
> +   dsv.ReturnTypeY = TGSI_TYPE_UNORM;
> +   dsv.ReturnTypeZ = TGSI_TYPE_UNORM;
> +   dsv.ReturnTypeW = TGSI_TYPE_UNORM;
>  
>     return dsv;
>  }
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
> index 3c108a8..fb19893 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
> @@ -125,7 +125,7 @@ const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
>     "VS_POSITION_WINDOW_SPACE"
>  };
>  
> -const char *tgsi_type_names[5] =
> +const char *tgsi_type_names[TGSI_TYPE_COUNT] =
>  {
>     "UNORM",
>     "SNORM",
> @@ -195,6 +195,7 @@ tgsi_strings_check(void)
>     STATIC_ASSERT(Elements(tgsi_property_names) == TGSI_PROPERTY_COUNT);
>     STATIC_ASSERT(Elements(tgsi_primitive_names) == PIPE_PRIM_MAX);
>     STATIC_ASSERT(Elements(tgsi_interpolate_names) == TGSI_INTERPOLATE_COUNT);
> +   STATIC_ASSERT(Elements(tgsi_type_names) == TGSI_TYPE_COUNT);
>     (void) tgsi_processor_type_names;
>     (void) tgsi_type_names;
>     (void) tgsi_immediate_type_names;
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.h b/src/gallium/auxiliary/tgsi/tgsi_strings.h
> index 1c37c29..1e96883 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_strings.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_strings.h
> @@ -46,7 +46,7 @@ extern const char *tgsi_texture_names[TGSI_TEXTURE_COUNT];
>  
>  extern const char *tgsi_property_names[TGSI_PROPERTY_COUNT];
>  
> -extern const char *tgsi_type_names[5];
> +extern const char *tgsi_type_names[TGSI_TYPE_COUNT];
>  
>  extern const char *tgsi_interpolate_names[TGSI_INTERPOLATE_COUNT];
>  
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
> index 7291145..296af2a 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_text.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
> @@ -1258,7 +1258,7 @@ static boolean parse_declaration( struct translate_ctx *ctx )
>           ++cur;
>           eat_opt_white( &cur );
>           for (j = 0; j < 4; ++j) {
> -            for (i = 0; i < PIPE_TYPE_COUNT; ++i) {
> +            for (i = 0; i < TGSI_TYPE_COUNT; ++i) {
>                 if (str_match_nocase_whole(&cur, tgsi_type_names[i])) {
>                    switch (j) {
>                    case 0:
> @@ -1279,7 +1279,7 @@ static boolean parse_declaration( struct translate_ctx *ctx )
>                    break;
>                 }
>              }
> -            if (i == PIPE_TYPE_COUNT) {
> +            if (i == TGSI_TYPE_COUNT) {
>                 if (j == 0 || j >  2) {
>                    report_error(ctx, "Expected type name");
>                    return FALSE;
> diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
> index 9c02464..b007229 100644
> --- a/src/gallium/include/pipe/p_format.h
> +++ b/src/gallium/include/pipe/p_format.h
> @@ -35,15 +35,6 @@ extern "C" {
>  
>  #include "p_config.h"
>  
> -enum pipe_type {
> -   PIPE_TYPE_UNORM = 0,
> -   PIPE_TYPE_SNORM,
> -   PIPE_TYPE_SINT,
> -   PIPE_TYPE_UINT,
> -   PIPE_TYPE_FLOAT,
> -   PIPE_TYPE_COUNT
> -};
> -
>  /**
>   * Texture/surface image formats (preliminary)
>   */
> diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
> index 8ab1ea8..b37eb7b 100644
> --- a/src/gallium/include/pipe/p_shader_tokens.h
> +++ b/src/gallium/include/pipe/p_shader_tokens.h
> @@ -192,12 +192,21 @@ struct tgsi_declaration_resource {
>     unsigned Padding     : 22;
>  };
>  
> +enum tgsi_type {
> +   TGSI_TYPE_UNORM = 0,
> +   TGSI_TYPE_SNORM,
> +   TGSI_TYPE_SINT,
> +   TGSI_TYPE_UINT,
> +   TGSI_TYPE_FLOAT,
> +   TGSI_TYPE_COUNT
> +};
> +
>  struct tgsi_declaration_sampler_view {
>     unsigned Resource    : 8; /**< one of TGSI_TEXTURE_ */
> -   unsigned ReturnTypeX : 6; /**< one of enum pipe_type */
> -   unsigned ReturnTypeY : 6; /**< one of enum pipe_type */
> -   unsigned ReturnTypeZ : 6; /**< one of enum pipe_type */
> -   unsigned ReturnTypeW : 6; /**< one of enum pipe_type */
> +   unsigned ReturnTypeX : 6; /**< one of enum tgsi_type */
> +   unsigned ReturnTypeY : 6; /**< one of enum tgsi_type */
> +   unsigned ReturnTypeZ : 6; /**< one of enum tgsi_type */
> +   unsigned ReturnTypeW : 6; /**< one of enum tgsi_type */
>  };
>  
>  struct tgsi_declaration_array {
> 



More information about the mesa-dev mailing list