Old-style images are identified using TGSI_FILE_SAMPLER, but
bindless samplers can be TGSI_FILE_CONSTANT or TGSI_FILE_TEMPORARY.

To avoid backend compilers to be confused, this adds a new flag
that will only be set for bindless samplers.

Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
---
 src/gallium/auxiliary/tgsi/tgsi_build.c    |  4 ++++
 src/gallium/auxiliary/tgsi/tgsi_ureg.c     |  9 ++++++---
 src/gallium/auxiliary/tgsi/tgsi_ureg.h     | 10 ++++++----
 src/gallium/include/pipe/p_shader_tokens.h |  3 ++-
 src/mesa/state_tracker/st_atifs_to_tgsi.c  |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  2 +-
 src/mesa/state_tracker/st_mesa_to_tgsi.c   |  2 +-
 7 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 00843241f8..be1931e482 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -721,6 +721,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.Bindless = 0;
    instruction_texture.Padding = 0;
 
    return instruction_texture;
@@ -731,6 +732,7 @@ tgsi_build_instruction_texture(
    unsigned texture,
    unsigned num_offsets,
    unsigned return_type,
+   unsigned bindless,
    struct tgsi_token *prev_token,
    struct tgsi_instruction *instruction,
    struct tgsi_header *header )
@@ -740,6 +742,7 @@ tgsi_build_instruction_texture(
    instruction_texture.Texture = texture;
    instruction_texture.NumOffsets = num_offsets;
    instruction_texture.ReturnType = return_type;
+   instruction_texture.Bindless = bindless;
    instruction_texture.Padding = 0;
    instruction->Texture = 1;
 
@@ -1095,6 +1098,7 @@ tgsi_build_full_instruction(
          full_inst->Texture.Texture,
          full_inst->Texture.NumOffsets,
          full_inst->Texture.ReturnType,
+         full_inst->Texture.Bindless,
          prev_token,
          instruction,
          header   );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 5bd779728a..8efa95f009 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1289,7 +1289,8 @@ ureg_fixup_label(struct ureg_program *ureg,
 void
 ureg_emit_texture(struct ureg_program *ureg,
                   unsigned extended_token,
-                  unsigned target, unsigned return_type, unsigned num_offsets)
+                  unsigned target, unsigned return_type, unsigned num_offsets,
+                  unsigned bindless)
 {
    union tgsi_any_token *out, *insn;
 
@@ -1302,6 +1303,7 @@ ureg_emit_texture(struct ureg_program *ureg,
    out[0].insn_texture.Texture = target;
    out[0].insn_texture.NumOffsets = num_offsets;
    out[0].insn_texture.ReturnType = return_type;
+   out[0].insn_texture.Bindless = bindless;
 }
 
 void
@@ -1391,7 +1393,8 @@ ureg_tex_insn(struct ureg_program *ureg,
               const struct tgsi_texture_offset *texoffsets,
               unsigned nr_offset,
               const struct ureg_src *src,
-              unsigned nr_src )
+              unsigned nr_src,
+              unsigned bindless)
 {
    struct ureg_emit_insn_result insn;
    unsigned i;
@@ -1410,7 +1413,7 @@ ureg_tex_insn(struct ureg_program *ureg,
                          nr_src);
 
    ureg_emit_texture( ureg, insn.extended_token, target, return_type,
-                      nr_offset );
+                      nr_offset, bindless );
 
    for (i = 0; i < nr_offset; i++)
       ureg_emit_texture_offset( ureg, &texoffsets[i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 54f95ba565..9e30a41ff7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -559,7 +559,8 @@ ureg_tex_insn(struct ureg_program *ureg,
               const struct tgsi_texture_offset *texoffsets,
               unsigned nr_offset,
               const struct ureg_src *src,
-              unsigned nr_src );
+              unsigned nr_src,
+              unsigned bindless);
 
 
 void
@@ -597,7 +598,8 @@ ureg_emit_label(struct ureg_program *ureg,
 void
 ureg_emit_texture(struct ureg_program *ureg,
                   unsigned insn_token,
-                  unsigned target, unsigned return_type, unsigned num_offsets);
+                  unsigned target, unsigned return_type, unsigned num_offsets,
+                  unsigned bindless);
 
 void
 ureg_emit_texture_offset(struct ureg_program *ureg,
@@ -759,7 +761,7 @@ static inline void ureg_##op( struct ureg_program *ureg,    
            \
                          1,                                             \
                          2);                                            \
    ureg_emit_texture( ureg, insn.extended_token, target,                \
-                      return_type, 0 );                                 \
+                      return_type, 0, 0 );                              \
    ureg_emit_dst( ureg, dst );                                          \
    ureg_emit_src( ureg, src0 );                                         \
    ureg_emit_src( ureg, src1 );                                         \
@@ -809,7 +811,7 @@ static inline void ureg_##op( struct ureg_program *ureg,    
            \
                          1,                                             \
                          4);                                            \
    ureg_emit_texture( ureg, insn.extended_token, target,                \
-                      return_type, 0 );                                 \
+                      return_type, 0, 0 );                              \
    ureg_emit_dst( ureg, dst );                                          \
    ureg_emit_src( ureg, src0 );                                         \
    ureg_emit_src( ureg, src1 );                                         \
diff --git a/src/gallium/include/pipe/p_shader_tokens.h 
b/src/gallium/include/pipe/p_shader_tokens.h
index cb49e3b033..2665eb4235 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -696,7 +696,8 @@ struct tgsi_instruction_texture
    unsigned Texture  : 8;    /* TGSI_TEXTURE_ */
    unsigned NumOffsets : 4;
    unsigned ReturnType : 3; /* TGSI_RETURN_TYPE_x */
-   unsigned Padding : 17;
+   unsigned Bindless : 1;
+   unsigned Padding : 16;
 };
 
 /* for texture offsets in GLSL and DirectX.
diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c 
b/src/mesa/state_tracker/st_atifs_to_tgsi.c
index 338ced56ed..92e91f5ce5 100644
--- a/src/mesa/state_tracker/st_atifs_to_tgsi.c
+++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
@@ -334,7 +334,7 @@ compile_setupinst(struct st_translate *t,
       src[1] = t->samplers[r];
       /* the texture target is still unknown, it will be fixed in the draw 
call */
       ureg_tex_insn(t->ureg, TGSI_OPCODE_TEX, dst, 1, TGSI_TEXTURE_2D,
-                    TGSI_RETURN_TYPE_FLOAT, NULL, 0, src, 2);
+                    TGSI_RETURN_TYPE_FLOAT, NULL, 0, src, 2, 0);
    } else if (texinst->Opcode == ATI_FRAGMENT_SHADER_PASS_OP) {
       ureg_insn(t->ureg, TGSI_OPCODE_MOV, dst, 1, src, 1);
    }
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 7571e7d495..4e6678c8ac 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5873,7 +5873,7 @@ compile_tgsi_instruction(struct st_translate *t,
                     tex_target,
                     st_translate_texture_type(inst->tex_type),
                     texoffsets, inst->tex_offset_num_offset,
-                    src, num_src);
+                    src, num_src, 0);
       return;
 
    case TGSI_OPCODE_RESQ:
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c 
b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index aad3c5b04c..b5184c7a3b 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -558,7 +558,7 @@ compile_instruction(
                                                inst->TexShadow ),
                      TGSI_RETURN_TYPE_FLOAT,
                      NULL, 0,
-                     src, num_src );
+                     src, num_src, 0 );
       return;
 
    case OPCODE_SCS:
-- 
2.13.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to