[PATCH vkd3d v2 3/6] vkd3d-shader: Allocate temporary registers for anonymous expressions.

Zebediah Figura zfigura at codeweavers.com
Sun Apr 4 23:32:02 CDT 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 libs/vkd3d-shader/hlsl.h         |  1 +
 libs/vkd3d-shader/hlsl_codegen.c | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index e642fee1..a1549304 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -171,6 +171,7 @@ struct hlsl_ir_node
      * true even for loops, since currently we can't have a reference to a
      * value generated in an earlier iteration of the loop. */
     unsigned int index, last_read;
+    struct hlsl_reg reg;
 };
 
 struct hlsl_src
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index a7007886..81f4f39f 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -745,6 +745,18 @@ static void allocate_temp_registers_recurse(struct list *instrs, struct liveness
 
     LIST_FOR_EACH_ENTRY(instr, instrs, struct hlsl_ir_node, entry)
     {
+        if (!instr->reg.allocated && instr->last_read)
+        {
+            if (instr->data_type->reg_size > 1)
+                instr->reg = allocate_range(liveness, instr->index,
+                        instr->last_read, instr->data_type->reg_size);
+            else
+                instr->reg = allocate_register(liveness, instr->index,
+                        instr->last_read, instr->data_type->dimx);
+            TRACE("Allocated anonymous expression @%u to %s (liveness %u-%u).\n", instr->index,
+                    debug_register('r', instr->reg, instr->data_type), instr->index, instr->last_read);
+        }
+
         switch (instr->type)
         {
             case HLSL_IR_IF:
-- 
2.31.0




More information about the wine-devel mailing list