[Mesa-dev] [PATCH v2 04/13] tgsi/ureg: add ureg_DECL_output_layout

Nicolai Hähnle nhaehnle at gmail.com
Mon Oct 10 08:32:16 UTC 2016


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

For specifying an exact location/component.
---
 src/gallium/auxiliary/tgsi/tgsi_ureg.c | 46 +++++++++++++++++++++++-----------
 src/gallium/auxiliary/tgsi/tgsi_ureg.h |  9 +++++++
 2 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 7b4b49e..323d43a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -398,61 +398,77 @@ ureg_DECL_system_value(struct ureg_program *ureg,
       ureg->nr_system_values++;
    } else {
       set_bad(ureg);
    }
 
 out:
    return ureg_src_register(TGSI_FILE_SYSTEM_VALUE, i);
 }
 
 
-struct ureg_dst 
-ureg_DECL_output_masked(struct ureg_program *ureg,
-                        unsigned name,
+struct ureg_dst
+ureg_DECL_output_layout(struct ureg_program *ureg,
+                        unsigned semantic_name,
+                        unsigned semantic_index,
                         unsigned index,
-                        unsigned usage_mask,
                         unsigned array_id,
-                        unsigned array_size)
+                        unsigned array_size,
+                        unsigned usage_mask)
 {
    unsigned i;
 
    assert(usage_mask != 0);
 
    for (i = 0; i < ureg->nr_outputs; i++) {
-      if (ureg->output[i].semantic_name == name &&
-          ureg->output[i].semantic_index == index) {
-         assert(ureg->output[i].array_id == array_id);
-         ureg->output[i].usage_mask |= usage_mask;
-         goto out;
+      if (ureg->output[i].semantic_name == semantic_name &&
+          ureg->output[i].semantic_index == semantic_index) {
+         if (ureg->output[i].array_id == array_id) {
+            ureg->output[i].usage_mask |= usage_mask;
+            goto out;
+         }
+         assert((ureg->output[i].usage_mask & usage_mask) == 0);
       }
    }
 
    if (ureg->nr_outputs < UREG_MAX_OUTPUT) {
-      ureg->output[i].semantic_name = name;
-      ureg->output[i].semantic_index = index;
+      ureg->output[i].semantic_name = semantic_name;
+      ureg->output[i].semantic_index = semantic_index;
       ureg->output[i].usage_mask = usage_mask;
-      ureg->output[i].first = ureg->nr_output_regs;
-      ureg->output[i].last = ureg->nr_output_regs + array_size - 1;
+      ureg->output[i].first = index;
+      ureg->output[i].last = index + array_size - 1;
       ureg->output[i].array_id = array_id;
-      ureg->nr_output_regs += array_size;
+      ureg->nr_output_regs = MAX2(ureg->nr_output_regs, index + array_size);
       ureg->nr_outputs++;
    }
    else {
       set_bad( ureg );
    }
 
 out:
    return ureg_dst_array_register(TGSI_FILE_OUTPUT, ureg->output[i].first,
                                   array_id);
 }
 
 
+struct ureg_dst
+ureg_DECL_output_masked(struct ureg_program *ureg,
+                        unsigned name,
+                        unsigned index,
+                        unsigned usage_mask,
+                        unsigned array_id,
+                        unsigned array_size)
+{
+   return ureg_DECL_output_layout(ureg, name, index,
+                                  ureg->nr_output_regs, array_id, array_size, usage_mask);
+}
+
+
 struct ureg_dst 
 ureg_DECL_output(struct ureg_program *ureg,
                  unsigned name,
                  unsigned index)
 {
    return ureg_DECL_output_masked(ureg, name, index, TGSI_WRITEMASK_XYZW,
                                   0, 1);
 }
 
 struct ureg_dst
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 9a914f0..4e5b894 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -241,20 +241,29 @@ ureg_DECL_input(struct ureg_program *,
                 unsigned semantic_index,
                 unsigned array_id,
                 unsigned array_size);
 
 struct ureg_src
 ureg_DECL_system_value(struct ureg_program *,
                        unsigned semantic_name,
                        unsigned semantic_index);
 
 struct ureg_dst
+ureg_DECL_output_layout(struct ureg_program *,
+                        unsigned semantic_name,
+                        unsigned semantic_index,
+                        unsigned index,
+                        unsigned array_id,
+                        unsigned array_size,
+                        unsigned usage_mask);
+
+struct ureg_dst
 ureg_DECL_output_masked(struct ureg_program *,
                         unsigned semantic_name,
                         unsigned semantic_index,
                         unsigned usage_mask,
                         unsigned array_id,
                         unsigned array_size);
 
 struct ureg_dst
 ureg_DECL_output(struct ureg_program *,
                  unsigned semantic_name,
-- 
2.7.4



More information about the mesa-dev mailing list