[Mesa-dev] [PATCH 01/10] tgsi: add Texture and Format to tgsi_instruction_memory

Ilia Mirkin imirkin at alum.mit.edu
Sun Mar 20 20:17:23 UTC 2016


Hi Nicolai,

Looks like this results in uninitialized formats when parsing text, so
a shader which looks like this:

COMP
DCL SV[0], BLOCK_ID
DCL SV[1], GRID_SIZE
DCL SAMP[0]
DCL SAMP[1]
DCL SAMP[2]
DCL SAMP[3]
DCL SAMP[4]
DCL SAMP[5]
DCL SAMP[6]
DCL SAMP[7]
DCL BUFFER[16]
DCL BUFFER[17]
DCL CONST[8..11]
DCL TEMP[0..3], LOCAL
DCL ADDR[0..2]
IMM[0] UINT32 {16, 64, 32, 48}
  0: UMUL TEMP[0].x, SV[1].xxxx, SV[1].yyyy
  1: UMUL TEMP[0].x, TEMP[0].xxxx, SV[0].zzzz
  2: UMAD TEMP[0].x, SV[1].xxxx, SV[0].yyyy, TEMP[0].xxxx
  3: UADD TEMP[0].x, TEMP[0].xxxx, SV[0].xxxx
  4: UMUL TEMP[1].x, TEMP[0].xxxx, IMM[0].xxxx
  5: LOAD TEMP[1].xyz, BUFFER[17], TEMP[1].xxxx
  6: UMUL TEMP[2].x, TEMP[0].xxxx, IMM[0].yyyy
  7: MOV TEMP[3].xyz, TEMP[1].xyzz
  8: UARL ADDR[2].x, CONST[8].xxxx
  9: TEX TEMP[3], TEMP[3], SAMP[ADDR[2].x], 2D_ARRAY
 10: STORE BUFFER[16], TEMP[2].xxxx, TEMP[3]
 11: UMAD TEMP[2].x, TEMP[0].xxxx, IMM[0].yyyy, IMM[0].xxxx
 12: MOV TEMP[3].xyz, TEMP[1].xyzz
 13: UARL ADDR[2].x, CONST[9].xxxx
 14: TEX TEMP[3], TEMP[3], SAMP[ADDR[2].x], 2D_ARRAY
 15: STORE BUFFER[16], TEMP[2].xxxx, TEMP[3]
 16: UMAD TEMP[2].x, TEMP[0].xxxx, IMM[0].yyyy, IMM[0].zzzz
 17: MOV TEMP[3].xyz, TEMP[1].xyzz
 18: UARL ADDR[2].x, CONST[10].xxxx
 19: TEX TEMP[3], TEMP[3], SAMP[ADDR[2].x], 2D_ARRAY
 20: STORE BUFFER[16], TEMP[2].xxxx, TEMP[3]
 21: UMAD TEMP[0].x, TEMP[0].xxxx, IMM[0].yyyy, IMM[0].wwww
 22: MOV TEMP[1].xyz, TEMP[1].xyzz
 23: UARL ADDR[2].x, CONST[11].xxxx
 24: TEX TEMP[1], TEMP[1], SAMP[ADDR[2].x], 2D_ARRAY
 25: STORE BUFFER[16], TEMP[0].xxxx, TEMP[1]
 26: END

No longer loads properly (or rather, fails when dumped again). Can you
fix this up so that the round trip works as expected? You can test
locally with ./src/gallium/drivers/nouveau/nouveau_compiler -a c0 (or
-a e4), which accepts a TGSI file argument (or - for stdin).

Thanks,

  -ilia

On Sun, Mar 13, 2016 at 10:29 AM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Frontends should have this information readily available, and it simplifies
> image LOAD/STORE/ATOM* handling especially with indirect image access.
> ---
>  src/gallium/auxiliary/tgsi/tgsi_dump.c     | 8 ++++++++
>  src/gallium/include/pipe/p_shader_tokens.h | 4 +++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
> index f232f38..c8b91bb 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
> @@ -637,6 +637,14 @@ iter_instruction(
>           TXT(", ");
>           ENM(bit, tgsi_memory_names);
>        }
> +      if (inst->Memory.Texture) {
> +         TXT( ", " );
> +         ENM( inst->Memory.Texture, tgsi_texture_names );
> +      }
> +      if (inst->Memory.Format) {
> +         TXT( ", " );
> +         TXT( util_format_name(inst->Memory.Format) );
> +      }
>     }
>
>     switch (inst->Instruction.Opcode) {
> diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
> index 9d4a96a..34e491e 100644
> --- a/src/gallium/include/pipe/p_shader_tokens.h
> +++ b/src/gallium/include/pipe/p_shader_tokens.h
> @@ -743,7 +743,9 @@ struct tgsi_dst_register
>  struct tgsi_instruction_memory
>  {
>     unsigned Qualifier : 3;  /* TGSI_MEMORY_ */
> -   unsigned Padding   : 29;
> +   unsigned Texture   : 8;  /* only for images: TGSI_TEXTURE_ */
> +   unsigned Format    : 10; /* only for images: PIPE_FORMAT_ */
> +   unsigned Padding   : 11;
>  };
>
>  #define TGSI_MEMBAR_SHADER_BUFFER (1 << 0)
> --
> 2.5.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list