[Mesa-dev] [PATCH 02/11] ureg: add buffer support to ureg

Ilia Mirkin imirkin at alum.mit.edu
Sat Sep 26 23:33:18 PDT 2015


Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 src/gallium/auxiliary/tgsi/tgsi_strings.c  |  3 ++-
 src/gallium/auxiliary/tgsi/tgsi_ureg.c     | 27 +++++++++++++++++++++++++++
 src/gallium/auxiliary/tgsi/tgsi_ureg.h     |  3 +++
 src/gallium/include/pipe/p_shader_tokens.h |  1 +
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
index 8271ea0..41a03e3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
@@ -55,7 +55,8 @@ static const char *tgsi_file_names[] =
    "PRED",
    "SV",
    "RES",
-   "SVIEW"
+   "SVIEW",
+   "BUFFER",
 };
 
 const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index ff3e4b7..13976c9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -164,6 +164,9 @@ struct ureg_program
    } image[PIPE_MAX_SHADER_IMAGES];
    unsigned nr_images;
 
+   struct ureg_src buffer[PIPE_MAX_SHADER_BUFFERS];
+   unsigned nr_buffers;
+
    struct util_bitmask *free_temps;
    struct util_bitmask *local_temps;
    struct util_bitmask *decl_temps;
@@ -688,6 +691,26 @@ ureg_DECL_image(struct ureg_program *ureg,
    return reg;
 }
 
+/* Allocate a new buffer.
+ */
+struct ureg_src ureg_DECL_buffer(struct ureg_program *ureg, unsigned nr)
+{
+   unsigned i;
+
+   for (i = 0; i < ureg->nr_buffers; i++)
+      if (ureg->buffer[i].Index == nr)
+         return ureg->buffer[i];
+
+   if (i < PIPE_MAX_SHADER_BUFFERS) {
+      ureg->buffer[i] = ureg_src_register(TGSI_FILE_BUFFER, nr);
+      ureg->nr_buffers++;
+      return ureg->buffer[i];
+   }
+
+   assert(0);
+   return ureg->buffer[0];
+}
+
 static int
 match_or_expand_immediate64( const unsigned *v,
                              int type,
@@ -1712,6 +1735,10 @@ static void emit_decls( struct ureg_program *ureg )
                       ureg->image[i].raw);
    }
 
+   for (i = 0; i < ureg->nr_buffers; i++) {
+      emit_decl_range(ureg, TGSI_FILE_BUFFER, ureg->buffer[i].Index, 1);
+   }
+
    if (ureg->const_decls.nr_constant_ranges) {
       for (i = 0; i < ureg->const_decls.nr_constant_ranges; i++) {
          emit_decl_range(ureg,
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index bba2afb..c4b19e2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -335,6 +335,9 @@ ureg_DECL_image(struct ureg_program *ureg,
                 boolean wr,
                 boolean raw);
 
+struct ureg_src
+ureg_DECL_buffer(struct ureg_program *ureg, unsigned nr);
+
 static inline struct ureg_src
 ureg_imm4f( struct ureg_program *ureg,
                        float a, float b,
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 5498ecd..341c345 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -78,6 +78,7 @@ enum tgsi_file_type {
    TGSI_FILE_SYSTEM_VALUE        =9,
    TGSI_FILE_IMAGE               =10,
    TGSI_FILE_SAMPLER_VIEW        =11,
+   TGSI_FILE_BUFFER              =12,
    TGSI_FILE_COUNT      /**< how many TGSI_FILE_ types */
 };
 
-- 
2.4.9



More information about the mesa-dev mailing list