Zebediah Figura : vkd3d-shader: Write SM1 reciprocal instructions.

Alexandre Julliard julliard at winehq.org
Fri Jun 18 14:43:57 CDT 2021


Module: vkd3d
Branch: master
Commit: abd6ceb4892c5a5547d4f029bfd7ffc21cfdc540
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=abd6ceb4892c5a5547d4f029bfd7ffc21cfdc540

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Mon May 31 21:41:12 2021 -0500

vkd3d-shader: Write SM1 reciprocal instructions.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/hlsl_codegen.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index aa1b8d5..3b1b19c 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -1106,6 +1106,13 @@ static unsigned int map_swizzle(unsigned int swizzle, unsigned int writemask)
 {
     unsigned int i, ret = 0;
 
+    /* Leave replicate swizzles alone; some instructions need them. */
+    if (swizzle == HLSL_SWIZZLE(X, X, X, X)
+            || swizzle == HLSL_SWIZZLE(Y, Y, Y, Y)
+            || swizzle == HLSL_SWIZZLE(Z, Z, Z, Z)
+            || swizzle == HLSL_SWIZZLE(W, W, W, W))
+        return swizzle;
+
     for (i = 0; i < 4; ++i)
     {
         if (writemask & (1 << i))
@@ -1750,6 +1757,7 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct bytecode_buffer *buffer,
     struct hlsl_ir_expr *expr = hlsl_ir_expr(instr);
     struct hlsl_ir_node *arg1 = expr->operands[0].node;
     struct hlsl_ir_node *arg2 = expr->operands[1].node;
+    unsigned int i;
 
     assert(instr->reg.allocated);
 
@@ -1777,6 +1785,17 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct bytecode_buffer *buffer,
             write_sm1_unary_op(ctx, buffer, D3DSIO_MOV, &instr->reg, &arg1->reg, D3DSPSM_NEG);
             break;
 
+        case HLSL_IR_UNOP_RCP:
+            for (i = 0; i < instr->data_type->dimx; ++i)
+            {
+                struct hlsl_reg src = arg1->reg, dst = instr->reg;
+
+                src.writemask = combine_writemasks(src.writemask, 1u << i);
+                dst.writemask = combine_writemasks(dst.writemask, 1u << i);
+                write_sm1_unary_op(ctx, buffer, D3DSIO_RCP, &dst, &src, 0);
+            }
+            break;
+
         default:
             FIXME("Unhandled op %u.\n", expr->op);
             break;




More information about the wine-cvs mailing list