=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d-shader: Translate retc instructions.

Alexandre Julliard julliard at winehq.org
Thu Sep 27 18:25:03 CDT 2018


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

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Thu Sep 27 13:30:53 2018 +0200

vkd3d-shader: Translate retc instructions.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/spirv.c | 19 +++++++++++++++++++
 tests/d3d12.c             | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 62e1f3f..07ac808 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -4817,6 +4817,20 @@ static void vkd3d_dxbc_compiler_emit_return(struct vkd3d_dxbc_compiler *compiler
     vkd3d_spirv_build_op_return(builder);
 }
 
+static void vkd3d_dxbc_compiler_emit_retc(struct vkd3d_dxbc_compiler *compiler,
+        const struct vkd3d_shader_instruction *instruction)
+{
+    struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
+    uint32_t target_id, merge_block_id;
+
+    target_id = vkd3d_spirv_alloc_id(builder);
+    merge_block_id = vkd3d_dxbc_compiler_emit_conditional_branch(compiler, instruction, target_id);
+
+    vkd3d_spirv_build_op_label(builder, target_id);
+    vkd3d_dxbc_compiler_emit_return(compiler, instruction);
+    vkd3d_spirv_build_op_label(builder, merge_block_id);
+}
+
 static void vkd3d_dxbc_compiler_emit_kill(struct vkd3d_dxbc_compiler *compiler,
         const struct vkd3d_shader_instruction *instruction)
 {
@@ -5166,6 +5180,10 @@ static void vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_
                 cf_info->inside_block = false;
             break;
 
+        case VKD3DSIH_RETP:
+            vkd3d_dxbc_compiler_emit_retc(compiler, instruction);
+            break;
+
         case VKD3DSIH_TEXKILL:
             vkd3d_dxbc_compiler_emit_kill(compiler, instruction);
             break;
@@ -6369,6 +6387,7 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler
         case VKD3DSIH_IF:
         case VKD3DSIH_LOOP:
         case VKD3DSIH_RET:
+        case VKD3DSIH_RETP:
         case VKD3DSIH_SWITCH:
         case VKD3DSIH_TEXKILL:
             vkd3d_dxbc_compiler_emit_control_flow_instruction(compiler, instruction);
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 69b9fe7..9424ca1 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -5718,6 +5718,38 @@ static void test_shader_instructions(void)
         0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0100003e,
     };
     static const D3D12_SHADER_BYTECODE ps_continuec_nz = {ps_continuec_nz_code, sizeof(ps_continuec_nz_code)};
+    static const DWORD ps_retc_nz_code[] =
+    {
+#if 0
+        float src;
+
+        float4 main() : SV_TARGET
+        {
+            for (int i = 0; i < 255; ++i)
+            {
+                if (i == src)
+                    return float4(1, 0, 0, 0);
+            }
+
+            return 0;
+        }
+#endif
+        /* compiled with /Gfa */
+        0x43425844, 0xf829c302, 0xf21361cb, 0x963b87e9, 0x92f9470e, 0x00000001, 0x00000188, 0x00000003,
+        0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+        0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+        0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000110, 0x00000040, 0x00000044,
+        0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
+        0x00000001, 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x00000000, 0x01000030, 0x07000021,
+        0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x000000ff, 0x03040003, 0x0010001a,
+        0x00000000, 0x0500002b, 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x08000018, 0x00100022,
+        0x00000000, 0x0010001a, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x08000036, 0x001020f2,
+        0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, 0x0304003f, 0x0010001a,
+        0x00000000, 0x0700001e, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000001,
+        0x01000016, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000,
+        0x00000000, 0x0100003e,
+    };
+    static const D3D12_SHADER_BYTECODE ps_retc_nz = {ps_retc_nz_code, sizeof(ps_retc_nz_code)};
     static const DWORD ps_src_modifiers_code[] =
     {
 #if 0
@@ -6823,6 +6855,11 @@ static void test_shader_instructions(void)
         {&ps_continue,     {}, {{254.0f}}, TRUE},
         {&ps_continuec_nz, {}, {{509.0f}}},
 
+        {&ps_retc_nz, {{  0.0f}}, {{1.0f}}},
+        {&ps_retc_nz, {{ 10.0f}}, {{1.0f}}},
+        {&ps_retc_nz, {{ 99.0f}}, {{1.0f}}},
+        {&ps_retc_nz, {{300.0f}}, {{0.0f}}},
+
         {&ps_src_modifiers, {{ 1.0f,  1.0f,  1.0f,  2.0f}}, {{-1.0f, 1.0f, -1.0f, -2.0f}}},
         {&ps_src_modifiers, {{-1.0f, -1.0f, -1.0f, -2.0f}}, {{ 1.0f, 1.0f, -1.0f, -2.0f}}},
 




More information about the wine-cvs mailing list