[PATCH vkd3d 2/5] vkd3d-shader/hlsl: Write SM4 loops.

Giovanni Mascellani gmascellani at codeweavers.com
Tue Nov 2 04:33:14 CDT 2021


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---
 libs/vkd3d-shader/hlsl_sm4.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c
index 0a9aac2a..c022b5dd 100644
--- a/libs/vkd3d-shader/hlsl_sm4.c
+++ b/libs/vkd3d-shader/hlsl_sm4.c
@@ -23,6 +23,8 @@
 #include "vkd3d_d3dcommon.h"
 #include "sm4.h"
 
+static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_block *block);
+
 bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic,
         bool output, enum vkd3d_sm4_register_type *type, bool *has_idx)
 {
@@ -1375,6 +1377,22 @@ static void write_sm4_load(struct hlsl_ctx *ctx,
     write_sm4_instruction(buffer, &instr);
 }
 
+static void write_sm4_loop(struct hlsl_ctx *ctx,
+        struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_loop *loop)
+{
+    struct sm4_instruction instr =
+    {
+        .opcode = VKD3D_SM4_OP_LOOP,
+    };
+
+    write_sm4_instruction(buffer, &instr);
+
+    write_sm4_block(ctx, buffer, &loop->body);
+
+    instr.opcode = VKD3D_SM4_OP_ENDLOOP;
+    write_sm4_instruction(buffer, &instr);
+}
+
 static void write_sm4_store(struct hlsl_ctx *ctx,
         struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_store *store)
 {
@@ -1459,6 +1477,10 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *
                 write_sm4_load(ctx, buffer, hlsl_ir_load(instr));
                 break;
 
+            case HLSL_IR_LOOP:
+                write_sm4_loop(ctx, buffer, hlsl_ir_loop(instr));
+                break;
+
             case HLSL_IR_STORE:
                 write_sm4_store(ctx, buffer, hlsl_ir_store(instr));
                 break;
-- 
2.33.1




More information about the wine-devel mailing list