[Mesa-dev] [RFC PATCH 30/65] tgsi: add new Bindless flag to tgsi_instruction_memory

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri May 19 16:52:35 UTC 2017


Old-style images are identified using TGSI_FILE_IMAGE, but
bindless images 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 images.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/gallium/auxiliary/tgsi/tgsi_build.c    |  4 ++++
 src/gallium/auxiliary/tgsi/tgsi_ureg.c     | 10 +++++++---
 src/gallium/auxiliary/tgsi/tgsi_ureg.h     |  6 ++++--
 src/gallium/include/pipe/p_shader_tokens.h |  3 ++-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  4 ++--
 src/mesa/state_tracker/st_pbo.c            |  2 +-
 6 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index be1931e482..1aa2fd12d4 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -759,6 +759,7 @@ tgsi_default_instruction_memory( void )
    instruction_memory.Qualifier = 0;
    instruction_memory.Texture = 0;
    instruction_memory.Format = 0;
+   instruction_memory.Bindless = 0;
    instruction_memory.Padding = 0;
 
    return instruction_memory;
@@ -769,6 +770,7 @@ tgsi_build_instruction_memory(
    unsigned qualifier,
    unsigned texture,
    unsigned format,
+   unsigned bindless,
    struct tgsi_token *prev_token,
    struct tgsi_instruction *instruction,
    struct tgsi_header *header )
@@ -778,6 +780,7 @@ tgsi_build_instruction_memory(
    instruction_memory.Qualifier = qualifier;
    instruction_memory.Texture = texture;
    instruction_memory.Format = format;
+   instruction_memory.Bindless = bindless;
    instruction_memory.Padding = 0;
    instruction->Memory = 1;
 
@@ -1137,6 +1140,7 @@ tgsi_build_full_instruction(
          full_inst->Memory.Qualifier,
          full_inst->Memory.Texture,
          full_inst->Memory.Format,
+         full_inst->Memory.Bindless,
          prev_token,
          instruction,
          header );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 8efa95f009..faed1e2708 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1324,7 +1324,8 @@ ureg_emit_memory(struct ureg_program *ureg,
                  unsigned extended_token,
                  unsigned qualifier,
                  unsigned texture,
-                 unsigned format)
+                 unsigned format,
+                 unsigned bindless)
 {
    union tgsi_any_token *out, *insn;
 
@@ -1337,6 +1338,7 @@ ureg_emit_memory(struct ureg_program *ureg,
    out[0].insn_memory.Qualifier = qualifier;
    out[0].insn_memory.Texture = texture;
    out[0].insn_memory.Format = format;
+   out[0].insn_memory.Bindless = bindless;
 }
 
 void
@@ -1437,7 +1439,8 @@ ureg_memory_insn(struct ureg_program *ureg,
                  unsigned nr_src,
                  unsigned qualifier,
                  unsigned texture,
-                 unsigned format)
+                 unsigned format,
+                 unsigned bindless)
 {
    struct ureg_emit_insn_result insn;
    unsigned i;
@@ -1448,7 +1451,8 @@ ureg_memory_insn(struct ureg_program *ureg,
                          nr_dst,
                          nr_src);
 
-   ureg_emit_memory(ureg, insn.extended_token, qualifier, texture, format);
+   ureg_emit_memory(ureg, insn.extended_token, qualifier, texture, format,
+                    bindless);
 
    for (i = 0; i < nr_dst; i++)
       ureg_emit_dst(ureg, dst[i]);
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 9e30a41ff7..fe8620149a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -572,7 +572,8 @@ ureg_memory_insn(struct ureg_program *ureg,
                  unsigned nr_src,
                  unsigned qualifier,
                  unsigned texture,
-                 unsigned format);
+                 unsigned format,
+                 unsigned bindless);
 
 /***********************************************************************
  * Internal instruction helpers, don't call these directly:
@@ -610,7 +611,8 @@ ureg_emit_memory(struct ureg_program *ureg,
                  unsigned insn_token,
                  unsigned qualifier,
                  unsigned texture,
-                 unsigned format);
+                 unsigned format,
+                 unsigned bindless);
 
 void 
 ureg_emit_dst( struct ureg_program *ureg,
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 2665eb4235..a4c68b1dbb 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -797,7 +797,8 @@ struct tgsi_instruction_memory
    unsigned Qualifier : 3;  /* TGSI_MEMORY_ */
    unsigned Texture   : 8;  /* only for images: TGSI_TEXTURE_ */
    unsigned Format    : 10; /* only for images: PIPE_FORMAT_ */
-   unsigned Padding   : 11;
+   unsigned Bindless  : 1;  /* only for images: whether it's bindless */
+   unsigned Padding   : 10;
 };
 
 #define TGSI_MEMBAR_SHADER_BUFFER (1 << 0)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 4e6678c8ac..ef6597e083 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5904,7 +5904,7 @@ compile_tgsi_instruction(struct st_translate *t,
       assert(src[0].File != TGSI_FILE_NULL);
       ureg_memory_insn(ureg, inst->op, dst, num_dst, src, num_src,
                        inst->buffer_access,
-                       tex_target, inst->image_format);
+                       tex_target, inst->image_format, 0);
       break;
 
    case TGSI_OPCODE_STORE:
@@ -5922,7 +5922,7 @@ compile_tgsi_instruction(struct st_translate *t,
       assert(dst[0].File != TGSI_FILE_NULL);
       ureg_memory_insn(ureg, inst->op, dst, num_dst, src, num_src,
                        inst->buffer_access,
-                       tex_target, inst->image_format);
+                       tex_target, inst->image_format, 0);
       break;
 
    case TGSI_OPCODE_SCS:
diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c
index 303c8535b2..3dff1609e8 100644
--- a/src/mesa/state_tracker/st_pbo.c
+++ b/src/mesa/state_tracker/st_pbo.c
@@ -528,7 +528,7 @@ create_fs(struct st_context *st, bool download, enum pipe_texture_target target,
       op[0] = ureg_src(temp0);
       op[1] = ureg_src(temp1);
       ureg_memory_insn(ureg, TGSI_OPCODE_STORE, &out, 1, op, 2, 0,
-                             TGSI_TEXTURE_BUFFER, PIPE_FORMAT_NONE);
+                             TGSI_TEXTURE_BUFFER, PIPE_FORMAT_NONE, 0);
 
       ureg_release_temporary(ureg, temp1);
    } else {
-- 
2.13.0



More information about the mesa-dev mailing list