=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d-shader: Promote immediate scalar constants to vectors.

Alexandre Julliard julliard at winehq.org
Mon Sep 24 12:22:04 CDT 2018


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

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Mon Sep 24 10:25:17 2018 +0200

vkd3d-shader: Promote immediate scalar constants to vectors.

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 |  4 ++--
 tests/d3d12.c             | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 964bc49..6fabeb2 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2537,8 +2537,8 @@ static uint32_t vkd3d_dxbc_compiler_emit_load_constant(struct vkd3d_dxbc_compile
 
     if (reg->immconst_type == VKD3D_IMMCONST_SCALAR)
     {
-        assert(component_count == 1);
-        values[0] = *reg->u.immconst_uint;
+        for (i = 0; i < component_count; ++i)
+            values[i] = *reg->u.immconst_uint;
     }
     else
     {
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 808562e..9bb6861 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -6136,6 +6136,24 @@ static void test_shader_instructions(void)
         0x00000001, 0x0100003e,
     };
     static const D3D12_SHADER_BYTECODE ps_ishl = {ps_ishl_code, sizeof(ps_ishl_code)};
+    static const DWORD ps_ishl_const_code[] =
+    {
+#if 0
+        uint4 src;
+
+        void main(out uint4 dst : SV_Target)
+        {
+            dst = src << 2;
+        }
+#endif
+        0x43425844, 0x5b749bf4, 0xe24de3dc, 0xbbd75bc9, 0xc6fc9eca, 0x00000001, 0x000000c0, 0x00000003,
+        0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+        0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+        0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000048, 0x00000040, 0x00000012,
+        0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x08000029,
+        0x001020f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00004001, 0x00000002, 0x0100003e,
+    };
+    static const D3D12_SHADER_BYTECODE ps_ishl_const = {ps_ishl_const_code, sizeof(ps_ishl_const_code)};
     static const DWORD ps_not_code[] =
     {
 #if 0
@@ -6956,6 +6974,11 @@ static void test_shader_instructions(void)
         {&ps_ishl, {{{0x00000001, 0x00000001, 0x00000001, 0x800feac1}, {    31, 7, 15, 11}}},
                    {{0x80000000, 0x00000080, 0x00008000, 0x7f560800}}},
 
+        {&ps_ishl_const, {{{0x00000000, 0x00000000, 0x00000000, 0x00000000}}},
+                          {{0x00000000, 0x00000000, 0x00000000, 0x00000000}}},
+        {&ps_ishl_const, {{{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}}},
+                          {{0xfffffffc, 0xfffffffc, 0xfffffffc, 0xfffffffc}}},
+
         {&ps_not, {{{0x00000000, 0xffffffff}}}, {{0xffffffff, 0x00000000, 0x00000000, 0xffffffff}}},
         {&ps_not, {{{0xf0f0f0f0, 0x0f0f0f0f}}}, {{0x0f0f0f0f, 0xf0f0f0f0, 0xf0f0f0f0, 0x0f0f0f0f}}},
 




More information about the wine-cvs mailing list