[Mesa-dev] [PATCH v2 02/12] tgsi/ureg: always emit constants (and their decls) as 2D

Nicolai Hähnle nhaehnle at gmail.com
Mon Aug 28 08:58:10 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Acked-by: Roland Scheidegger <sroland at vmware.com>
Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de>
---
 src/gallium/auxiliary/tgsi/tgsi_ureg.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index ca31bc4a75a..b26434ccbde 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -173,22 +173,21 @@ struct ureg_program
    unsigned nr_buffers;
 
    struct util_bitmask *free_temps;
    struct util_bitmask *local_temps;
    struct util_bitmask *decl_temps;
    unsigned nr_temps;
 
    unsigned array_temps[UREG_MAX_ARRAY_TEMPS];
    unsigned nr_array_temps;
 
-   struct const_decl const_decls;
-   struct const_decl const_decls2D[PIPE_MAX_CONSTANT_BUFFERS];
+   struct const_decl const_decls[PIPE_MAX_CONSTANT_BUFFERS];
 
    unsigned properties[TGSI_PROPERTY_COUNT];
 
    unsigned nr_addrs;
    unsigned nr_instructions;
 
    struct ureg_tokens domain[2];
 
    bool use_memory[TGSI_MEMORY_TYPE_COUNT];
 };
@@ -500,21 +499,21 @@ ureg_DECL_output_array(struct ureg_program *ureg,
  * There is nothing in this code to bind this constant to any tracked
  * value or manage any constant_buffer contents -- that's the
  * resposibility of the calling code.
  */
 void
 ureg_DECL_constant2D(struct ureg_program *ureg,
                      unsigned first,
                      unsigned last,
                      unsigned index2D)
 {
-   struct const_decl *decl = &ureg->const_decls2D[index2D];
+   struct const_decl *decl = &ureg->const_decls[index2D];
 
    assert(index2D < PIPE_MAX_CONSTANT_BUFFERS);
 
    if (decl->nr_constant_ranges < UREG_MAX_CONSTANT_RANGE) {
       uint i = decl->nr_constant_ranges++;
 
       decl->constant_range[i].first = first;
       decl->constant_range[i].last = last;
    }
 }
@@ -522,21 +521,21 @@ ureg_DECL_constant2D(struct ureg_program *ureg,
 
 /* A one-dimensional, deprecated version of ureg_DECL_constant2D().
  *
  * Constant operands declared with this function must be addressed
  * with a one-dimensional index.
  */
 struct ureg_src
 ureg_DECL_constant(struct ureg_program *ureg,
                    unsigned index)
 {
-   struct const_decl *decl = &ureg->const_decls;
+   struct const_decl *decl = &ureg->const_decls[0];
    unsigned minconst = index, maxconst = index;
    unsigned i;
 
    /* Inside existing range?
     */
    for (i = 0; i < decl->nr_constant_ranges; i++) {
       if (decl->constant_range[i].first <= index &&
           decl->constant_range[i].last >= index) {
          goto out;
       }
@@ -572,21 +571,23 @@ ureg_DECL_constant(struct ureg_program *ureg,
     */
    i = 0;
    decl->constant_range[0].first = minconst;
    decl->constant_range[0].last = maxconst;
    decl->nr_constant_ranges = 1;
 
 out:
    assert(i < decl->nr_constant_ranges);
    assert(decl->constant_range[i].first <= index);
    assert(decl->constant_range[i].last >= index);
-   return ureg_src_register(TGSI_FILE_CONSTANT, index);
+
+   struct ureg_src src = ureg_src_register(TGSI_FILE_CONSTANT, index);
+   return ureg_src_dimension(src, 0);
 }
 
 static struct ureg_dst alloc_temporary( struct ureg_program *ureg,
                                         boolean local )
 {
    unsigned i;
 
    /* Look for a released temporary.
     */
    for (i = util_bitmask_get_first_index(ureg->free_temps);
@@ -1884,31 +1885,22 @@ static void emit_decls( struct ureg_program *ureg )
 
    for (i = 0; i < ureg->nr_buffers; i++) {
       emit_decl_buffer(ureg, ureg->buffer[i].index, ureg->buffer[i].atomic);
    }
 
    for (i = 0; i < TGSI_MEMORY_TYPE_COUNT; i++) {
       if (ureg->use_memory[i])
          emit_decl_memory(ureg, i);
    }
 
-   if (ureg->const_decls.nr_constant_ranges) {
-      for (i = 0; i < ureg->const_decls.nr_constant_ranges; i++) {
-         emit_decl_range(ureg,
-                         TGSI_FILE_CONSTANT,
-                         ureg->const_decls.constant_range[i].first,
-                         ureg->const_decls.constant_range[i].last - ureg->const_decls.constant_range[i].first + 1);
-      }
-   }
-
    for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) {
-      struct const_decl *decl = &ureg->const_decls2D[i];
+      struct const_decl *decl = &ureg->const_decls[i];
 
       if (decl->nr_constant_ranges) {
          uint j;
 
          for (j = 0; j < decl->nr_constant_ranges; j++) {
             emit_decl_range2D(ureg,
                               TGSI_FILE_CONSTANT,
                               decl->constant_range[j].first,
                               decl->constant_range[j].last,
                               i);
-- 
2.11.0



More information about the mesa-dev mailing list