[Mesa-dev] [PATCH 02/11] tgsi/scan: get more information about arrays and handle arrays correctly

Roland Scheidegger sroland at vmware.com
Mon May 25 12:13:26 PDT 2015


Am 24.05.2015 um 13:19 schrieb Marek Olšák:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> ---
>  src/gallium/auxiliary/tgsi/tgsi_scan.c | 11 +++++++++--
>  src/gallium/auxiliary/tgsi/tgsi_scan.h |  2 ++
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
> index d821072..cd7eb9e 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
> @@ -167,13 +167,20 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
>                 = &parse.FullToken.FullDeclaration;
>              const uint file = fulldecl->Declaration.File;
>              uint reg;
> -            if (fulldecl->Declaration.Array)
> +
> +            if (fulldecl->Declaration.Array) {
> +               assert(fulldecl->Array.ArrayID < PIPE_MAX_SHADER_ARRAYS);
> +               info->array_first[file][fulldecl->Array.ArrayID] = fulldecl->Range.First;
> +               info->array_last[file][fulldecl->Array.ArrayID] = fulldecl->Range.Last;
>                 info->array_max[file] = MAX2(info->array_max[file], fulldecl->Array.ArrayID);
> +            }
> +
>              for (reg = fulldecl->Range.First;
>                   reg <= fulldecl->Range.Last;
>                   reg++) {
>                 unsigned semName = fulldecl->Semantic.Name;
> -               unsigned semIndex = fulldecl->Semantic.Index;
> +               unsigned semIndex =
> +                  fulldecl->Semantic.Index + (reg - fulldecl->Range.First);
>  
>                 /* only first 32 regs will appear in this bitfield */
>                 info->file_mask[file] |= (1 << reg);
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h
> index 0ea0e88..86a14e9 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
> @@ -65,6 +65,8 @@ struct tgsi_shader_info
>     int file_max[TGSI_FILE_COUNT];  /**< highest index of declared registers */
>     int const_file_max[PIPE_MAX_CONSTANT_BUFFERS];
>  
> +   unsigned array_first[TGSI_FILE_COUNT][PIPE_MAX_SHADER_ARRAYS];
> +   unsigned array_last[TGSI_FILE_COUNT][PIPE_MAX_SHADER_ARRAYS];
>     unsigned array_max[TGSI_FILE_COUNT];  /**< highest index array per register file */
>  
>     uint immediate_count; /**< number of immediates declared */
> 

I really wonder if that's generally useful. Even if it is though this
wastes quite a bit of memory (12 tgsi files (most of them can't even
have arrays) * 256 arrays * 4 bytes), 12 kB.
If it's useful, maybe should switch to dynamic allocation with the
ability to grow the list, that way you wouldn't need an array limit.
It would, however, mean there'd need to be a tgsi_destroy_shader_info()
or something similar (and of course whoever calls tgsi_scan_shader()
would need to call it).

Roland



More information about the mesa-dev mailing list