From 812f01c2e2de3e932e838d6b0208bd4e4a64724c Mon Sep 17 00:00:00 2001
From: Conor McCarthy <cmccarthy@codeweavers.com>
Date: Wed, 22 Nov 2023 00:38:19 +1000
Subject: [PATCH] vkd3d-shader/spirv: Handle ITOI and UTOU in
 spirv_compiler_map_alu_instruction().

These instructions perform integer casts to/from 64 bits.
---
 libs/vkd3d-shader/spirv.c          | 2 ++
 tests/hlsl/bitwise.shader_test     | 8 ++++----
 tests/hlsl/cast-64-bit.shader_test | 8 ++++----
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index a9a6e97f44..a6ececab34 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -6697,12 +6697,14 @@ static SpvOp spirv_compiler_map_alu_instruction(const struct vkd3d_shader_instru
         {VKD3DSIH_ISHR,       SpvOpShiftRightArithmetic},
         {VKD3DSIH_ITOD,       SpvOpConvertSToF},
         {VKD3DSIH_ITOF,       SpvOpConvertSToF},
+        {VKD3DSIH_ITOI,       SpvOpSConvert},
         {VKD3DSIH_MUL,        SpvOpFMul},
         {VKD3DSIH_NOT,        SpvOpNot},
         {VKD3DSIH_OR,         SpvOpBitwiseOr},
         {VKD3DSIH_USHR,       SpvOpShiftRightLogical},
         {VKD3DSIH_UTOD,       SpvOpConvertUToF},
         {VKD3DSIH_UTOF,       SpvOpConvertUToF},
+        {VKD3DSIH_UTOU,       SpvOpUConvert},
         {VKD3DSIH_XOR,        SpvOpBitwiseXor},
     };
     unsigned int i;
diff --git a/tests/hlsl/bitwise.shader_test b/tests/hlsl/bitwise.shader_test
index 7fc8f74487..34362fedad 100644
--- a/tests/hlsl/bitwise.shader_test
+++ b/tests/hlsl/bitwise.shader_test
@@ -183,11 +183,11 @@ float4 main() : sv_target
 [test]
 uniform 0 int64_t2 9223372036854775807 -1
 uniform 4 int4 34 66 0 0
-todo draw quad
+draw quad
 probe all rgba (0.0, 4.611686018e18, 536870912.0, 2.305843009e18) 1
 uniform 0 int64_t2 -1 -1
 uniform 4 int4 34 66 0 0
-todo draw quad
+draw quad
 probe all rgba (-1.0, -1.0, -1.0, -1.0) 1
 
 [pixel shader]
@@ -207,7 +207,7 @@ float4 main() : sv_target
 [test]
 uniform 0 uint64_t2 0xffffffffffffffff 1
 uniform 4 uint4 34 66 0 0
-todo draw quad
+draw quad
 probe all rgba (9.223372036e18, 1.0, 1073741823.0, 4.611686018e18) 1
 
 [pixel shader]
@@ -227,7 +227,7 @@ float4 main() : sv_target
 [test]
 uniform 0 uint64_t2 0x83 1
 uniform 4 uint4 34 66 0 0
-todo draw quad
+draw quad
 probe all rgba (262.0, 9.223372036e18, 2250562863104.0, 524.0) 1
 
 [pixel shader]
diff --git a/tests/hlsl/cast-64-bit.shader_test b/tests/hlsl/cast-64-bit.shader_test
index f2a0468b34..aa558ec9ea 100644
--- a/tests/hlsl/cast-64-bit.shader_test
+++ b/tests/hlsl/cast-64-bit.shader_test
@@ -37,8 +37,8 @@ float4 main() : sv_target
 [test]
 uniform 0 uint64_t2 0x500000001 0x100000002
 uniform 4 uint4 10 4 0 0
-todo draw quad
-todo probe all rgba (1.0, 2.0, 2147483648.0, 1073741824.0)
+draw quad
+probe all rgba (1.0, 2.0, 2147483648.0, 1073741824.0)
 
 
 [pixel shader]
@@ -55,5 +55,5 @@ float4 main() : sv_target
 [test]
 uniform 0 int64_t2 -21474836481 0x100000002
 uniform 4 int4 -20 8 0 0
-todo draw quad
-todo probe all rgba (-1.0, 2.0, 1073741824.0, 536870912.0)
+draw quad
+probe all rgba (-1.0, 2.0, 1073741824.0, 536870912.0)
-- 
GitLab