Re: [Mesa-dev] [PATCH v2 2/3] tgsi: store the sampler view type directly in the instruction

2017-05-17 Thread Samuel Pitoiset



On 05/17/2017 08:03 PM, Marek Olšák wrote:

mesa_to_tgsi is for the old Mesa IR. The return type is always FLOAT.
Same for atifs_to_tgsi.


Ah okay, I will change this.



Marek

On Wed, May 17, 2017 at 7:06 PM, Samuel Pitoiset
 wrote:

RadeonSI needs to do a special lowering for Gather4 with integer
formats, but with bindless samplers we just can't access the index.

Instead, store the return type in the instruction like the target.

v2: - fix padding
 - initialize default value of ReturnType
 - replace debug_assert() by assert()

Signed-off-by: Samuel Pitoiset 
---
  src/gallium/auxiliary/tgsi/tgsi_build.c|  6 +-
  src/gallium/auxiliary/tgsi/tgsi_ureg.c |  7 +--
  src/gallium/auxiliary/tgsi/tgsi_ureg.h | 11 ---
  src/gallium/include/pipe/p_shader_tokens.h |  4 +++-
  src/mesa/state_tracker/st_atifs_to_tgsi.c  |  2 +-
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 17 ++---
  src/mesa/state_tracker/st_mesa_to_tgsi.c   | 21 +
  src/mesa/state_tracker/st_mesa_to_tgsi.h   |  4 
  8 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 39c20b5e88..00843241f8 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -720,6 +720,7 @@ tgsi_default_instruction_texture( void )

 instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
 instruction_texture.NumOffsets = 0;
+   instruction_texture.ReturnType = TGSI_RETURN_TYPE_UNKNOWN;
 instruction_texture.Padding = 0;

 return instruction_texture;
@@ -729,6 +730,7 @@ static struct tgsi_instruction_texture
  tgsi_build_instruction_texture(
 unsigned texture,
 unsigned num_offsets,
+   unsigned return_type,
 struct tgsi_token *prev_token,
 struct tgsi_instruction *instruction,
 struct tgsi_header *header )
@@ -737,6 +739,7 @@ tgsi_build_instruction_texture(

 instruction_texture.Texture = texture;
 instruction_texture.NumOffsets = num_offsets;
+   instruction_texture.ReturnType = return_type;
 instruction_texture.Padding = 0;
 instruction->Texture = 1;

@@ -1090,7 +1093,8 @@ tgsi_build_full_instruction(

*instruction_texture = tgsi_build_instruction_texture(
   full_inst->Texture.Texture,
-full_inst->Texture.NumOffsets,
+ full_inst->Texture.NumOffsets,
+ full_inst->Texture.ReturnType,
   prev_token,
   instruction,
   header   );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 9eb00d0919..5bd779728a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1289,7 +1289,7 @@ ureg_fixup_label(struct ureg_program *ureg,
  void
  ureg_emit_texture(struct ureg_program *ureg,
unsigned extended_token,
-  unsigned target, unsigned num_offsets)
+  unsigned target, unsigned return_type, unsigned num_offsets)
  {
 union tgsi_any_token *out, *insn;

@@ -1301,6 +1301,7 @@ ureg_emit_texture(struct ureg_program *ureg,
 out[0].value = 0;
 out[0].insn_texture.Texture = target;
 out[0].insn_texture.NumOffsets = num_offsets;
+   out[0].insn_texture.ReturnType = return_type;
  }

  void
@@ -1386,6 +1387,7 @@ ureg_tex_insn(struct ureg_program *ureg,
const struct ureg_dst *dst,
unsigned nr_dst,
unsigned target,
+  unsigned return_type,
const struct tgsi_texture_offset *texoffsets,
unsigned nr_offset,
const struct ureg_src *src,
@@ -1407,7 +1409,8 @@ ureg_tex_insn(struct ureg_program *ureg,
   nr_dst,
   nr_src);

-   ureg_emit_texture( ureg, insn.extended_token, target, nr_offset );
+   ureg_emit_texture( ureg, insn.extended_token, target, return_type,
+  nr_offset );

 for (i = 0; i < nr_offset; i++)
ureg_emit_texture_offset( ureg, [i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 6d2f5c0e99..54f95ba565 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -555,6 +555,7 @@ ureg_tex_insn(struct ureg_program *ureg,
const struct ureg_dst *dst,
unsigned nr_dst,
unsigned target,
+  unsigned return_type,
const struct tgsi_texture_offset *texoffsets,
unsigned nr_offset,
const struct ureg_src *src,
@@ -596,7 +597,7 @@ ureg_emit_label(struct ureg_program *ureg,
  void
  ureg_emit_texture(struct ureg_program *ureg,
unsigned insn_token,
-  unsigned target, unsigned num_offsets);
+  unsigned target, unsigned return_type, 

Re: [Mesa-dev] [PATCH v2 2/3] tgsi: store the sampler view type directly in the instruction

2017-05-17 Thread Marek Olšák
mesa_to_tgsi is for the old Mesa IR. The return type is always FLOAT.
Same for atifs_to_tgsi.

Marek

On Wed, May 17, 2017 at 7:06 PM, Samuel Pitoiset
 wrote:
> RadeonSI needs to do a special lowering for Gather4 with integer
> formats, but with bindless samplers we just can't access the index.
>
> Instead, store the return type in the instruction like the target.
>
> v2: - fix padding
> - initialize default value of ReturnType
> - replace debug_assert() by assert()
>
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/gallium/auxiliary/tgsi/tgsi_build.c|  6 +-
>  src/gallium/auxiliary/tgsi/tgsi_ureg.c |  7 +--
>  src/gallium/auxiliary/tgsi/tgsi_ureg.h | 11 ---
>  src/gallium/include/pipe/p_shader_tokens.h |  4 +++-
>  src/mesa/state_tracker/st_atifs_to_tgsi.c  |  2 +-
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 17 ++---
>  src/mesa/state_tracker/st_mesa_to_tgsi.c   | 21 +
>  src/mesa/state_tracker/st_mesa_to_tgsi.h   |  4 
>  8 files changed, 49 insertions(+), 23 deletions(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
> b/src/gallium/auxiliary/tgsi/tgsi_build.c
> index 39c20b5e88..00843241f8 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_build.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
> @@ -720,6 +720,7 @@ tgsi_default_instruction_texture( void )
>
> instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
> instruction_texture.NumOffsets = 0;
> +   instruction_texture.ReturnType = TGSI_RETURN_TYPE_UNKNOWN;
> instruction_texture.Padding = 0;
>
> return instruction_texture;
> @@ -729,6 +730,7 @@ static struct tgsi_instruction_texture
>  tgsi_build_instruction_texture(
> unsigned texture,
> unsigned num_offsets,
> +   unsigned return_type,
> struct tgsi_token *prev_token,
> struct tgsi_instruction *instruction,
> struct tgsi_header *header )
> @@ -737,6 +739,7 @@ tgsi_build_instruction_texture(
>
> instruction_texture.Texture = texture;
> instruction_texture.NumOffsets = num_offsets;
> +   instruction_texture.ReturnType = return_type;
> instruction_texture.Padding = 0;
> instruction->Texture = 1;
>
> @@ -1090,7 +1093,8 @@ tgsi_build_full_instruction(
>
>*instruction_texture = tgsi_build_instruction_texture(
>   full_inst->Texture.Texture,
> -full_inst->Texture.NumOffsets,
> + full_inst->Texture.NumOffsets,
> + full_inst->Texture.ReturnType,
>   prev_token,
>   instruction,
>   header   );
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
> b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> index 9eb00d0919..5bd779728a 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
> @@ -1289,7 +1289,7 @@ ureg_fixup_label(struct ureg_program *ureg,
>  void
>  ureg_emit_texture(struct ureg_program *ureg,
>unsigned extended_token,
> -  unsigned target, unsigned num_offsets)
> +  unsigned target, unsigned return_type, unsigned 
> num_offsets)
>  {
> union tgsi_any_token *out, *insn;
>
> @@ -1301,6 +1301,7 @@ ureg_emit_texture(struct ureg_program *ureg,
> out[0].value = 0;
> out[0].insn_texture.Texture = target;
> out[0].insn_texture.NumOffsets = num_offsets;
> +   out[0].insn_texture.ReturnType = return_type;
>  }
>
>  void
> @@ -1386,6 +1387,7 @@ ureg_tex_insn(struct ureg_program *ureg,
>const struct ureg_dst *dst,
>unsigned nr_dst,
>unsigned target,
> +  unsigned return_type,
>const struct tgsi_texture_offset *texoffsets,
>unsigned nr_offset,
>const struct ureg_src *src,
> @@ -1407,7 +1409,8 @@ ureg_tex_insn(struct ureg_program *ureg,
>   nr_dst,
>   nr_src);
>
> -   ureg_emit_texture( ureg, insn.extended_token, target, nr_offset );
> +   ureg_emit_texture( ureg, insn.extended_token, target, return_type,
> +  nr_offset );
>
> for (i = 0; i < nr_offset; i++)
>ureg_emit_texture_offset( ureg, [i]);
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h 
> b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> index 6d2f5c0e99..54f95ba565 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
> @@ -555,6 +555,7 @@ ureg_tex_insn(struct ureg_program *ureg,
>const struct ureg_dst *dst,
>unsigned nr_dst,
>unsigned target,
> +  unsigned return_type,
>const struct tgsi_texture_offset *texoffsets,
>unsigned nr_offset,
>const struct ureg_src *src,
> @@ -596,7 +597,7 @@ ureg_emit_label(struct ureg_program *ureg,
>  void
>  ureg_emit_texture(struct ureg_program *ureg,
>unsigned insn_token,
> -  unsigned 

[Mesa-dev] [PATCH v2 2/3] tgsi: store the sampler view type directly in the instruction

2017-05-17 Thread Samuel Pitoiset
RadeonSI needs to do a special lowering for Gather4 with integer
formats, but with bindless samplers we just can't access the index.

Instead, store the return type in the instruction like the target.

v2: - fix padding
- initialize default value of ReturnType
- replace debug_assert() by assert()

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/auxiliary/tgsi/tgsi_build.c|  6 +-
 src/gallium/auxiliary/tgsi/tgsi_ureg.c |  7 +--
 src/gallium/auxiliary/tgsi/tgsi_ureg.h | 11 ---
 src/gallium/include/pipe/p_shader_tokens.h |  4 +++-
 src/mesa/state_tracker/st_atifs_to_tgsi.c  |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 17 ++---
 src/mesa/state_tracker/st_mesa_to_tgsi.c   | 21 +
 src/mesa/state_tracker/st_mesa_to_tgsi.h   |  4 
 8 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 39c20b5e88..00843241f8 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -720,6 +720,7 @@ tgsi_default_instruction_texture( void )
 
instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
instruction_texture.NumOffsets = 0;
+   instruction_texture.ReturnType = TGSI_RETURN_TYPE_UNKNOWN;
instruction_texture.Padding = 0;
 
return instruction_texture;
@@ -729,6 +730,7 @@ static struct tgsi_instruction_texture
 tgsi_build_instruction_texture(
unsigned texture,
unsigned num_offsets,
+   unsigned return_type,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
@@ -737,6 +739,7 @@ tgsi_build_instruction_texture(
 
instruction_texture.Texture = texture;
instruction_texture.NumOffsets = num_offsets;
+   instruction_texture.ReturnType = return_type;
instruction_texture.Padding = 0;
instruction->Texture = 1;
 
@@ -1090,7 +1093,8 @@ tgsi_build_full_instruction(
 
   *instruction_texture = tgsi_build_instruction_texture(
  full_inst->Texture.Texture,
-full_inst->Texture.NumOffsets,
+ full_inst->Texture.NumOffsets,
+ full_inst->Texture.ReturnType,
  prev_token,
  instruction,
  header   );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 9eb00d0919..5bd779728a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1289,7 +1289,7 @@ ureg_fixup_label(struct ureg_program *ureg,
 void
 ureg_emit_texture(struct ureg_program *ureg,
   unsigned extended_token,
-  unsigned target, unsigned num_offsets)
+  unsigned target, unsigned return_type, unsigned num_offsets)
 {
union tgsi_any_token *out, *insn;
 
@@ -1301,6 +1301,7 @@ ureg_emit_texture(struct ureg_program *ureg,
out[0].value = 0;
out[0].insn_texture.Texture = target;
out[0].insn_texture.NumOffsets = num_offsets;
+   out[0].insn_texture.ReturnType = return_type;
 }
 
 void
@@ -1386,6 +1387,7 @@ ureg_tex_insn(struct ureg_program *ureg,
   const struct ureg_dst *dst,
   unsigned nr_dst,
   unsigned target,
+  unsigned return_type,
   const struct tgsi_texture_offset *texoffsets,
   unsigned nr_offset,
   const struct ureg_src *src,
@@ -1407,7 +1409,8 @@ ureg_tex_insn(struct ureg_program *ureg,
  nr_dst,
  nr_src);
 
-   ureg_emit_texture( ureg, insn.extended_token, target, nr_offset );
+   ureg_emit_texture( ureg, insn.extended_token, target, return_type,
+  nr_offset );
 
for (i = 0; i < nr_offset; i++)
   ureg_emit_texture_offset( ureg, [i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 6d2f5c0e99..54f95ba565 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -555,6 +555,7 @@ ureg_tex_insn(struct ureg_program *ureg,
   const struct ureg_dst *dst,
   unsigned nr_dst,
   unsigned target,
+  unsigned return_type,
   const struct tgsi_texture_offset *texoffsets,
   unsigned nr_offset,
   const struct ureg_src *src,
@@ -596,7 +597,7 @@ ureg_emit_label(struct ureg_program *ureg,
 void
 ureg_emit_texture(struct ureg_program *ureg,
   unsigned insn_token,
-  unsigned target, unsigned num_offsets);
+  unsigned target, unsigned return_type, unsigned num_offsets);
 
 void
 ureg_emit_texture_offset(struct ureg_program *ureg,
@@ -748,6 +749,7 @@ static inline void ureg_##op( struct ureg_program *ureg,
\
   struct ureg_src src1 )\
 {