From f08e691b22d9217b56ec81ce42fd6818ee3d9b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Sun, 4 Oct 2026 17:09:47 +0200 Subject: [PATCH] fix(shader): saturate v_cvt_pk_u16_u32/i16_i32; test VOP3 integer ops Co-Authored-By: Claude --- .../tests/execution/Vop3IntegerAlu.cpp | 181 ++++++++++++++++++ .../Translation/TranslationContext.hpp | 1 + .../Translation/src/IntegerInstructions.cpp | 13 ++ .../Translation/src/VectorInstructions.cpp | 3 +- 4 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 core/libs/prx/libSceAgcDriver/tests/execution/Vop3IntegerAlu.cpp diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/Vop3IntegerAlu.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/Vop3IntegerAlu.cpp new file mode 100644 index 000000000..38c609632 --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/tests/execution/Vop3IntegerAlu.cpp @@ -0,0 +1,181 @@ +#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp" +#include "prx/libSceAgcDriver/Graphics/include/Draw.hpp" +#include "Recompiler.hpp" +#include "VulkanTestDevice.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +using AgcDriver::Graphics::Require; +using ShaderRecompiler::ShaderStage; + +constexpr std::uint32_t Threads = 32; +constexpr std::uint32_t Inputs = 4; +constexpr std::uint32_t Results = 64; +alignas(256) std::array Input{}; +alignas(256) std::array Output{}; + +alignas(256) constexpr std::array Code{ + 0x34020084, 0x34060088, 0xe0381000, 0x80000401, 0xbf8c3f70, 0xd76d000a, 0x041a0b04, 0xd747000b, + 0x041a0b04, 0xd771000c, 0x041a0b04, 0xd772000d, 0x041a0b04, 0xd578000e, 0x041a0b04, 0xd745000f, + 0x041a0b04, 0xd7460010, 0x041a0b04, 0xd76f0011, 0x041a0b04, 0xd5480012, 0x041a0b04, 0xd5490013, + 0x041a0b04, 0xd54a0014, 0x041a0b04, 0xd7630015, 0x02020b04, 0xd7440016, 0x041a0b04, 0xd54e0017, + 0x041a0b04, 0xd54f0018, 0x041a0b04, 0xd5690019, 0x02020b04, 0xd56a001a, 0x02020b04, 0xd56c001b, + 0x02020b04, 0xd542001c, 0x041a0b04, 0xd764001d, 0x02020b04, 0xd6ff001e, 0x02020b04, 0xd7000020, + 0x02020b04, 0xd7010022, 0x02020b04, 0xd5520024, 0x041a0b04, 0xd5550025, 0x041a0b04, 0xd5580026, + 0x041a0b04, 0xd5530027, 0x041a0b04, 0xd5560028, 0x041a0b04, 0xd5590029, 0x041a0b04, 0xd76a002a, + 0x02020b04, 0xd76b002b, 0x02020b04, 0x7e580307, 0xd703002c, 0x02020b04, 0x7e5a0307, 0xd704002d, + 0x02020b04, 0x7e5c0307, 0xd70d002e, 0x02020b04, 0x7e5e0307, 0xd70e002f, 0x02020b04, 0x7e600307, + 0xd7140030, 0x02020b04, 0x7e620307, 0xd7070031, 0x02020b04, 0x7e640307, 0xd7080032, 0x02020b04, + 0x7e660307, 0xd70b0033, 0x02020b04, 0x7e680307, 0xd7090034, 0x02020b04, 0x7e6a0307, 0xd70c0035, + 0x02020b04, 0x7e6c0307, 0xd70a0036, 0x02020b04, 0xd70f0837, 0x02020b04, 0xd5010038, 0x00210280, + 0xd7100839, 0x02020b04, 0xd501003a, 0x00210280, 0xd719083b, 0x02020b04, 0xd501003c, 0x00210280, + 0xe0781000, 0x80010a03, 0xe0781010, 0x80010e03, 0xe0781020, 0x80011203, 0xe0781030, 0x80011603, + 0xe0781040, 0x80011a03, 0xe0781050, 0x80011e03, 0xe0781060, 0x80012203, 0xe0781070, 0x80012603, + 0xe0781080, 0x80012a03, 0xe0781090, 0x80012e03, 0xe07810a0, 0x80013203, 0xe07810b0, 0x80013603, + 0xe07810c0, 0x80013a03, 0xbf810000, +}; + +constexpr std::uint32_t Rows[32][4] = { + {0xf0000000u, 0x0000001cu, 0x00000008u, 0x12345678u}, + {0x80000000u, 0x0000001fu, 0x00000002u, 0xdeadbeefu}, + {0xc0000000u, 0x0000001eu, 0x0000001fu, 0x00000000u}, + {0xabcdef01u, 0x00000000u, 0x00000000u, 0xffffffffu}, + {0x8000ffffu, 0x00000010u, 0x0000001fu, 0xffff0000u}, + {0x7fffffffu, 0x00000001u, 0x0000001fu, 0x55555555u}, + {0x01020304u, 0x05060708u, 0x0c0b0a09u, 0x00000000u}, + {0x80ff7f01u, 0x81827f80u, 0x03020100u, 0x00000001u}, + {0xffff8000u, 0xffff7fffu, 0x08090a0bu, 0xaaaa5555u}, + {0x0000ffffu, 0x00010000u, 0x0d0e0f10u, 0x00000002u}, + {0x00008000u, 0xffffffffu, 0xffff0000u, 0x00000000u}, + {0x00000000u, 0x00000000u, 0x0000ffffu, 0x25c717e5u}, + {0x00008000u, 0xffff8000u, 0x0000001fu, 0x00000020u}, + {0xdce177fdu, 0xffffffffu, 0x80000000u, 0x000001ffu}, + {0x7fffffffu, 0x00000000u, 0x80000001u, 0x0000001fu}, + {0x80008000u, 0x7fff7fffu, 0xffffffffu, 0x00000040u}, + {0x00000010u, 0xfffffffeu, 0x00000000u, 0x80000001u}, + {0x00010000u, 0xffff0000u, 0x9c015d97u, 0x00000018u}, + {0x00000040u, 0x00000020u, 0x00008000u, 0x4b64789cu}, + {0x00008001u, 0xc7fde805u, 0x040e050fu, 0x309d6b79u}, + {0x0000003fu, 0xffff8000u, 0x07060103u, 0xa66b0d38u}, + {0x00ffffffu, 0x7fff7fffu, 0x84e55160u, 0x7fffffffu}, + {0x75139237u, 0x6822a6b2u, 0xfee5a5b2u, 0x154cd2aau}, + {0x0000003fu, 0x00000001u, 0x0000000fu, 0x7fffffffu}, + {0xd8e94b15u, 0x36a80bdfu, 0x00000003u, 0xffff8000u}, + {0x00000020u, 0x45100358u, 0x80000001u, 0xffff7fffu}, + {0x00000040u, 0x02cdf2afu, 0x0c0c0406u, 0x00008001u}, + {0x00000021u, 0x7fff7fffu, 0x00000001u, 0xffff8000u}, + {0x93b3a3d9u, 0x00000017u, 0xffffffffu, 0x0000001fu}, + {0x00000007u, 0x00000021u, 0x00000040u, 0x00007fffu}, + {0x7fff7fffu, 0x80008000u, 0x00010000u, 0x00000017u}, + {0x0000001fu, 0x00000020u, 0x0000003fu, 0x3253b562u} +}; +constexpr std::uint32_t Expected[32][51] = { + {0xf0000024u, 0x00001c00u, 0x00000008u, 0xf000001cu, 0xf0000014u, 0xf0000024u, 0x00000008u, 0x00000008u, 0x0000000fu, 0xffffffffu, 0x00000008u, 0x00000000u, 0x1c1c1c00u, 0x00000000u, 0x0000001cu, 0x40000000u, 0x0000001au, 0xfffffffeu, 0x00000008u, 0x00000020u, 0x0000001cu, 0x00000008u, 0x0000001cu, 0x00000008u, 0x0000001cu, 0x00000008u, 0xf0000000u, 0x0000001cu, 0x00000008u, 0x00000008u, 0xf0000000u, 0x0000001cu, 0x001cffffu, 0x001c8000u, 0x1234001cu, 0x1234ffe4u, 0x1234001cu, 0x1234ffe4u, 0x1234001cu, 0x1234001cu, 0x1234001cu, 0x12340000u, 0x1234001cu, 0x12340000u, 0x1234001cu, 0xf000001cu, 0x00000000u, 0xefffffe4u, 0x00000000u, 0x1000001cu, 0x00000001u}, + {0x80000021u, 0x0000007cu, 0x00000002u, 0x8000001fu, 0x8000001du, 0x80000021u, 0x00000002u, 0x00000002u, 0x00000001u, 0xffffffffu, 0x00000002u, 0x00000000u, 0x1f1f1f00u, 0x00000007u, 0x00000000u, 0x80000000u, 0x0000000fu, 0xfffffff0u, 0x00000002u, 0x00000020u, 0x0000001fu, 0x00000002u, 0x0000001fu, 0x00000002u, 0x0000001fu, 0x00000002u, 0x80000000u, 0x0000001fu, 0x00000002u, 0x00000002u, 0x80000000u, 0x0000001fu, 0x001fffffu, 0x001f8000u, 0xdead001fu, 0xdeadffe1u, 0xdead001fu, 0xdeadffe1u, 0xdead001fu, 0xdead001fu, 0xdead001fu, 0xdead0000u, 0xdead001fu, 0xdead0000u, 0xdead001fu, 0x8000001fu, 0x00000000u, 0x7fffffe1u, 0x00000000u, 0x8000001fu, 0x00000001u}, + {0xc000003du, 0x00000000u, 0x0000001fu, 0xc000001fu, 0xc0000001u, 0xc000003du, 0x0000001fu, 0x0000001fu, 0x00000003u, 0xffffffffu, 0x0000001fu, 0x00000000u, 0x1e1e1effu, 0x80000000u, 0x00000000u, 0x80000000u, 0x00000016u, 0xfffffff8u, 0x0000001fu, 0x00000020u, 0x0000001eu, 0x0000001fu, 0x0000001eu, 0x0000001fu, 0x0000001eu, 0x0000001fu, 0xc0000000u, 0x0000001fu, 0x0000001eu, 0x0000001eu, 0xc0000000u, 0x0000001fu, 0x001effffu, 0x001e8000u, 0x0000001eu, 0x0000ffe2u, 0x0000001eu, 0x0000ffe2u, 0x0000001eu, 0x0000001eu, 0x0000001eu, 0x00000000u, 0x0000001eu, 0x00000000u, 0x0000001eu, 0xc000001eu, 0x00000000u, 0xbfffffe2u, 0x00000000u, 0x4000001eu, 0x00000001u}, + {0xabcdef01u, 0xabcdef01u, 0x00000000u, 0xabcdef01u, 0xabcdef01u, 0xabcdef01u, 0xabcdef01u, 0xabcdef01u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000001u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000012u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0xabcdef01u, 0x00000000u, 0x00000000u, 0x00000000u, 0xabcdef01u, 0x00000000u, 0x0000ffffu, 0x00008000u, 0xffffef01u, 0xffffef01u, 0xffffef01u, 0xffffef01u, 0xffff0000u, 0xffff0000u, 0xffff0000u, 0xffff0000u, 0xffffef01u, 0xffffef01u, 0xffff0000u, 0xabcdef01u, 0x00000000u, 0xabcdef01u, 0x00000000u, 0x543210ffu, 0x00000001u}, + {0x8001002eu, 0x80000000u, 0x0000001fu, 0x8000ffffu, 0x8000fff0u, 0x8001000eu, 0xffff001fu, 0xffff001fu, 0x00008000u, 0xffff8000u, 0x00000010u, 0xffff0000u, 0x101010ffu, 0x0001fffeu, 0x00ffff00u, 0x000ffff0u, 0x00000008u, 0xfffffff8u, 0x0010000fu, 0x00000021u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x8000ffffu, 0x0000001fu, 0x00000010u, 0x00000010u, 0x8000ffffu, 0x0000001fu, 0x0010ffffu, 0x00108000u, 0xffff000fu, 0xffffffefu, 0xffff000fu, 0xffffffefu, 0xffff0000u, 0xffff0000u, 0xffff0000u, 0xffff0010u, 0xffffffffu, 0xffffffffu, 0xffff0010u, 0x8001000fu, 0x00000000u, 0x8000ffefu, 0x00000000u, 0x7fff0011u, 0x00000001u}, + {0x8000001fu, 0x00000000u, 0x0000001fu, 0x7fffffffu, 0x7fffffe1u, 0x8000001du, 0x0000001du, 0xffffffffu, 0x3fffffffu, 0x3fffffffu, 0x00000001u, 0xfffffffeu, 0x010101ffu, 0xfffffffeu, 0xffffff00u, 0x7fffffffu, 0x00000000u, 0x00000000u, 0x0000001eu, 0x00000020u, 0x00000000u, 0x80000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000001u, 0x7fffffffu, 0x0000001fu, 0x00000001u, 0x7fffffffu, 0x0000001fu, 0x0001ffffu, 0x00017fffu, 0x55550000u, 0x5555fffeu, 0x55550000u, 0x5555fffeu, 0x55558000u, 0x55550000u, 0x55550000u, 0x55550001u, 0x5555ffffu, 0x5555ffffu, 0x55550001u, 0x80000000u, 0x00000000u, 0x7ffffffeu, 0x00000000u, 0x80000002u, 0x00000001u}, + {0x12131415u, 0x10141800u, 0x0d0b0b09u, 0x0d0f0f0du, 0x080f0e05u, 0x100f0e15u, 0x0e0e0e09u, 0x0e0b0e09u, 0x00000003u, 0x00000003u, 0x0d0b0b09u, 0x00000f00u, 0x00000000u, 0x82028303u, 0x04050607u, 0x3c3d3420u, 0x00051022u, 0x00051022u, 0x2c483e29u, 0x0506070du, 0x50607080u, 0xc0b0a090u, 0x90506070u, 0x00c0b0a0u, 0x90506070u, 0x00c0b0a0u, 0x01020304u, 0x0c0b0a09u, 0x05060708u, 0x01020304u, 0x0c0b0a09u, 0x05060708u, 0xffffffffu, 0x7fff7fffu, 0x00000a0cu, 0x0000fbfcu, 0x00000a0cu, 0x0000fbfcu, 0x00007080u, 0x00000070u, 0x00000070u, 0x00000304u, 0x00000708u, 0x00000304u, 0x00000708u, 0x06080a0cu, 0x00000000u, 0xfbfbfbfcu, 0x00000001u, 0x04040404u, 0x00000000u}, + {0x0583ff81u, 0x0281fe81u, 0x83827f00u, 0x83ff7f81u, 0x027f0181u, 0x047f0181u, 0x84018001u, 0x83ff7f01u, 0x00000000u, 0x00000000u, 0x83827f00u, 0x00000001u, 0x81827f80u, 0x81827f80u, 0x81827f80u, 0x3f42ff80u, 0x414280fdu, 0x3ec0827cu, 0x40450080u, 0x81827f91u, 0x0304ff00u, 0x06040201u, 0x40c13fc0u, 0x01810080u, 0x40c13fc0u, 0x01810080u, 0x80ff7f01u, 0x03020100u, 0x81827f80u, 0x03020100u, 0x81827f80u, 0x80ff7f01u, 0xffffffffu, 0x80008000u, 0x0000fe81u, 0x0000ff81u, 0x0000fe81u, 0x0000ff81u, 0x0000ff00u, 0x00003fc0u, 0x00003fc0u, 0x00007f01u, 0x00007f80u, 0x00007f01u, 0x00007f80u, 0x0281fe81u, 0x00000001u, 0xff7cff81u, 0x00000001u, 0x0083007fu, 0x00000000u}, + {0x08080a0au, 0xf7fff800u, 0xffff0a0bu, 0xffffffffu, 0x0809f5f4u, 0x080a0a0au, 0x08090a0bu, 0x08090a0bu, 0x00000001u, 0xffffffffu, 0xffff0a0bu, 0x00000000u, 0x00ffffffu, 0x001fffefu, 0xff8000ffu, 0x40008000u, 0xfffeffffu, 0x00000000u, 0x48098a0bu, 0xffff8010u, 0xffff7fffu, 0x08090a0bu, 0xffff7fffu, 0x08090a0bu, 0xffff7fffu, 0x08090a0bu, 0xffff7fffu, 0x08090a0bu, 0xffff8000u, 0x08090a0bu, 0xffff8000u, 0xffff7fffu, 0xffffffffu, 0x80008000u, 0xaaaaffffu, 0xaaaa0001u, 0xaaaaffffu, 0xaaaa0001u, 0xaaaa7fffu, 0xaaaa7fffu, 0xaaaa7fffu, 0xaaaa7fffu, 0xaaaa8000u, 0xaaaa8000u, 0xaaaa7fffu, 0xfffeffffu, 0x00000001u, 0x00000001u, 0x00000000u, 0xffffffffu, 0x00000001u}, + {0x0d100f0fu, 0xffff0000u, 0x0d0e0f10u, 0x0d0fffffu, 0x0d0ff0efu, 0x0d100f0fu, 0x0d0f0f0fu, 0x0d0effffu, 0x0000ffffu, 0xffffffffu, 0x0d0e0000u, 0x7fffffffu, 0xffffffffu, 0xffff0001u, 0x00010000u, 0xffff0000u, 0x00000000u, 0x00000000u, 0x0d0d0f10u, 0x00010010u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x0000ffffu, 0x0d0e0f10u, 0x00010000u, 0x0000ffffu, 0x0d0e0f10u, 0x00010000u, 0xffffffffu, 0x7fff7fffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x0000ffffu, 0x0000ffffu, 0x00000000u, 0x0001ffffu, 0x00000000u, 0xffffffffu, 0x00000001u, 0x00000001u, 0x00000000u}, + {0xffff7fffu, 0x00007fffu, 0xffff8000u, 0xffffffffu, 0x00007fffu, 0xfffe7fffu, 0xffff0000u, 0xffff0000u, 0x00000000u, 0x00000000u, 0xffff8000u, 0x00000000u, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffff8000u, 0x00007fffu, 0xffffffffu, 0xfffe8000u, 0x00000000u, 0xffffffffu, 0xffff0000u, 0xffffffffu, 0xffff0000u, 0xffffffffu, 0xffff0000u, 0xffff0000u, 0x00008000u, 0xffffffffu, 0x00008000u, 0xffffffffu, 0xffff0000u, 0xffff8000u, 0xffff7fffu, 0x00007fffu, 0x00008001u, 0x00007fffu, 0x00008001u, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x00008000u, 0x0000ffffu, 0x00008000u, 0x0000ffffu, 0x00007fffu, 0x00000001u, 0x00008001u, 0x00000001u, 0xffff7fffu, 0x00000000u}, + {0x0000ffffu, 0x00000000u, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x00000000u, 0x00000000u, 0x0000ffffu, 0x00000000u, 0x0000ffffu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x0000ffffu, 0x00000000u, 0x00000000u, 0x0000ffffu, 0x00000000u, 0x0000ffffu, 0x00000000u, 0x0000ffffu, 0x00000000u, 0x0000ffffu, 0x00000000u, 0x00000000u, 0x0000ffffu, 0x00000000u, 0x00000000u, 0x00000000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x25c70000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u}, + {0x0000001fu, 0x00000000u, 0x0000801fu, 0xffff801fu, 0xffff001fu, 0xffff001fu, 0x0000801fu, 0x0000801fu, 0x00008000u, 0x00008000u, 0x0000801fu, 0x00000000u, 0x000000ffu, 0x00010001u, 0x008000ffu, 0xc0000000u, 0x00007fffu, 0xffffffffu, 0xc000001fu, 0xffff8001u, 0xffff8000u, 0x0000001fu, 0xffff8000u, 0x0000001fu, 0xffff8000u, 0x0000001fu, 0xffff8000u, 0x00008000u, 0x0000001fu, 0x0000001fu, 0xffff8000u, 0x00008000u, 0xffff8000u, 0x80007fffu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00008000u, 0x00008000u, 0x00008000u, 0x00008000u, 0x00008000u, 0x00008000u, 0x00008000u, 0x00000000u, 0x00000001u, 0x00010000u, 0x00000001u, 0xffff0000u, 0x00000000u}, + {0x5ce177fcu, 0xdce177fcu, 0xdce177fdu, 0xffffffffu, 0xa31e8802u, 0xa31e8802u, 0x00000000u, 0x80000000u, 0x00000000u, 0x00000000u, 0xdce177fdu, 0x80000000u, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0x231e8803u, 0xdce177fcu, 0x00000000u, 0x801e8803u, 0x00000015u, 0x00000000u, 0xe0000000u, 0x00000004u, 0x00000000u, 0xfffffffcu, 0xffffffffu, 0x80000000u, 0xffffffffu, 0xdce177fdu, 0x80000000u, 0xffffffffu, 0xdce177fdu, 0xffffffffu, 0xffff8000u, 0x000077fcu, 0x000077feu, 0x000077fcu, 0x000077feu, 0x0000e000u, 0x00000007u, 0x0000ffffu, 0x000077fdu, 0x0000ffffu, 0x0000ffffu, 0x000077fdu, 0xdce177fcu, 0x00000001u, 0xdce177feu, 0x00000001u, 0x231e8802u, 0x00000000u}, + {0x00000000u, 0xfffffffeu, 0x80000001u, 0xffffffffu, 0xfffffffeu, 0x00000000u, 0x00000000u, 0xffffffffu, 0x00000001u, 0xffffffffu, 0x80000000u, 0x7fffffffu, 0xff000000u, 0x80000000u, 0xff000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x80000001u, 0x0000001fu, 0x00000000u, 0x00000000u, 0x00000001u, 0x00000000u, 0xffffffffu, 0xffffffffu, 0x80000001u, 0x7fffffffu, 0x00000000u, 0x00000000u, 0x80000001u, 0x7fffffffu, 0x0000ffffu, 0x00007fffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x0000ffffu, 0x0000ffffu, 0x00000000u, 0x7fffffffu, 0x00000000u, 0x7fffffffu, 0x00000000u, 0x80000001u, 0x00000001u}, + {0xfffffffeu, 0x80000000u, 0xffffffffu, 0xffffffffu, 0x00000000u, 0xfffffffeu, 0xffffffffu, 0xffffffffu, 0x00000001u, 0xffffffffu, 0x7fff7fffu, 0x00000000u, 0xffffffffu, 0x00010000u, 0x0080007fu, 0x3fff8000u, 0x3fffffffu, 0xc0008000u, 0xbfff7fffu, 0x7fff8001u, 0x7fff7fffu, 0xffffffffu, 0x7fff7fffu, 0xffffffffu, 0x7fff7fffu, 0xffffffffu, 0x80008000u, 0x7fff7fffu, 0xffffffffu, 0x7fff7fffu, 0xffffffffu, 0x80008000u, 0xffffffffu, 0x7fff8000u, 0x0000ffffu, 0x00000001u, 0x0000ffffu, 0x00000001u, 0x00007fffu, 0x00007fffu, 0x00007fffu, 0x00007fffu, 0x00008000u, 0x00008000u, 0x00007fffu, 0xffffffffu, 0x00000000u, 0x00010001u, 0x00000000u, 0xfffeffffu, 0x00000001u}, + {0x0000000eu, 0x0000000eu, 0x00000010u, 0xfffffffeu, 0xffffffeeu, 0xffffffeeu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000010u, 0xc0000000u, 0xfefefefeu, 0xfffffffeu, 0xfffffffeu, 0xffffffe0u, 0x0000000fu, 0xffffffffu, 0xffffffe0u, 0xffffffffu, 0xfffe0000u, 0x0000ffffu, 0x0000ffffu, 0x00000000u, 0x0000ffffu, 0x00000000u, 0xfffffffeu, 0x00000010u, 0x00000000u, 0x00000000u, 0xfffffffeu, 0x00000010u, 0xffff0010u, 0xfffe0010u, 0x8000000eu, 0x80000012u, 0x8000000eu, 0x80000012u, 0x8000fffeu, 0x8000fffeu, 0x8000fffeu, 0x80000010u, 0x8000fffeu, 0x8000fffeu, 0x80000010u, 0x0000000eu, 0x00000001u, 0x00000012u, 0x00000001u, 0xffffffeeu, 0x00000000u}, + {0x9c015d97u, 0x00000000u, 0x9c015d97u, 0xffff5d97u, 0x63ff5d97u, 0x9bff5d97u, 0x9c025d97u, 0x9c015d97u, 0x00010000u, 0x00010000u, 0x9c015d97u, 0x00000000u, 0xff00ffffu, 0x020001ffu, 0x010000ffu, 0x00000000u, 0x0000ffffu, 0xffffffffu, 0x9c015d97u, 0xffff0001u, 0xffff0000u, 0x9c015d97u, 0xffff0000u, 0x9c015d97u, 0xffff0000u, 0x9c015d97u, 0x9c015d97u, 0x00010000u, 0xffff0000u, 0x00010000u, 0xffff0000u, 0x9c015d97u, 0xffffffffu, 0x80007fffu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000001u, 0x00020000u, 0x00000001u, 0xfffe0000u, 0x00000000u}, + {0x00008060u, 0x00000060u, 0x00008000u, 0x00008060u, 0x00008060u, 0x00008060u, 0x00008040u, 0x00008040u, 0x00000000u, 0x00000000u, 0x00008000u, 0x00000000u, 0x2020ff20u, 0x00000020u, 0x00000020u, 0x00000800u, 0x00000000u, 0x00000000u, 0x00008800u, 0x00000021u, 0x00000020u, 0x00008000u, 0x00000020u, 0x00008000u, 0x00000020u, 0x00008000u, 0x00000020u, 0x00008000u, 0x00000040u, 0x00000020u, 0x00008000u, 0x00000040u, 0x00200040u, 0x00200040u, 0x4b640060u, 0x4b640020u, 0x4b640060u, 0x4b640020u, 0x4b640020u, 0x4b640020u, 0x4b640020u, 0x4b640020u, 0x4b640040u, 0x4b640020u, 0x4b640040u, 0x00000060u, 0x00000000u, 0x00000020u, 0x00000000u, 0xffffffe0u, 0x00000001u}, + {0xcc0c6d15u, 0x34030000u, 0x040e850fu, 0xc7ffed0fu, 0xc3f36d0bu, 0xcc0b6d13u, 0x041e052fu, 0x041e052fu, 0x00000400u, 0x00000400u, 0x040e850fu, 0x00000020u, 0x01ff80ffu, 0x00038ffbu, 0x008001c7u, 0xbc006805u, 0x000063ffu, 0xffffe3feu, 0xf80e6d14u, 0xc7fde807u, 0x8ffbd00au, 0x081c0a1fu, 0xe3fef402u, 0x02070287u, 0xe3fef402u, 0x02070287u, 0xc7fde805u, 0x040e050fu, 0x00008001u, 0x00008001u, 0xc7fde805u, 0x040e050fu, 0xffff8001u, 0x80007fffu, 0x309d6806u, 0x309d97fcu, 0x309d6806u, 0x309d97fcu, 0x309dd00au, 0x309d7402u, 0x309df402u, 0x309d8001u, 0x309de805u, 0x309d8001u, 0x309de805u, 0xc7fe6806u, 0x00000000u, 0x380297fcu, 0x00000001u, 0xc7fd6804u, 0x00000000u}, + {0x07058142u, 0xfffc01f8u, 0x07060103u, 0xffff813fu, 0xf8f9813cu, 0x07058142u, 0x07060142u, 0x0706013fu, 0x00000007u, 0xffffffffu, 0x07060100u, 0x7fffffffu, 0x000080ffu, 0xfffff000u, 0x00003fffu, 0xffe08000u, 0x0000003eu, 0xffffffffu, 0x06e68103u, 0xffff8006u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0xffff8000u, 0x07060103u, 0x0000003fu, 0x0000003fu, 0xffff8000u, 0x07060103u, 0xffff003fu, 0x8000003fu, 0xa66b803fu, 0xa66b803fu, 0xa66b803fu, 0xa66b803fu, 0xa66b0000u, 0xa66b0001u, 0xa66bffffu, 0xa66b003fu, 0xa66b8000u, 0xa66b8000u, 0xa66b003fu, 0xffff803fu, 0x00000000u, 0x0000803fu, 0x00000001u, 0xffff7fc1u, 0x00000000u}, + {0x05e4d15eu, 0x80ff7ffeu, 0x84ff7fffu, 0xffffffffu, 0xfbe5d160u, 0x03e5d160u, 0x04e55160u, 0x84e55160u, 0x00000000u, 0x00000000u, 0x84ff7fffu, 0x80000000u, 0xffffffffu, 0x7fff7fffu, 0x7fff7fffu, 0x7f008001u, 0x007fff7fu, 0x007fff7fu, 0x84e5d161u, 0x7fff8017u, 0x00000000u, 0x80000000u, 0x00000001u, 0x00000000u, 0xffffffffu, 0xffffffffu, 0x84e55160u, 0x7fff7fffu, 0x00ffffffu, 0x00ffffffu, 0x84e55160u, 0x7fff7fffu, 0xffffffffu, 0x7fff7fffu, 0x7fff7ffeu, 0x7fff8000u, 0x7fff7ffeu, 0x7fff8000u, 0x7fff8000u, 0x7fff0000u, 0x7fff0000u, 0x7fff7fffu, 0x7fffffffu, 0x7fffffffu, 0x7fff7fffu, 0x80ff7ffeu, 0x00000000u, 0x81008000u, 0x00000001u, 0x7eff8000u, 0x00000000u}, + {0xdc1bde9bu, 0xe3a40000u, 0xfee7a7b2u, 0xfff7b7b7u, 0xe3d49137u, 0x1c16da37u, 0x47c1a5b2u, 0xfefda5b2u, 0x00001d44u, 0x00001d44u, 0xeae6a7b2u, 0xfffc0000u, 0xffffffffu, 0xe48dda08u, 0x92376822u, 0xdbb9543eu, 0x2f9fcc3bu, 0x2f9fcc3bu, 0x289ef9f0u, 0x6822a6c2u, 0x00000000u, 0x59000000u, 0x000001fdu, 0x00000000u, 0xfffffffdu, 0xffffffffu, 0xfee5a5b2u, 0x75139237u, 0x6822a6b2u, 0x6822a6b2u, 0xfee5a5b2u, 0x75139237u, 0xffffffffu, 0x7fff7fffu, 0x154c38e9u, 0x154ceb85u, 0x154c38e9u, 0x154ceb85u, 0x154c5900u, 0x154c014du, 0x154cff4du, 0x154c9237u, 0x154ca6b2u, 0x154c9237u, 0x154ca6b2u, 0xdd3638e9u, 0x00000000u, 0x0cf0eb85u, 0x00000000u, 0xf30f147bu, 0x00000001u}, + {0x0000004fu, 0x00200000u, 0x0000000fu, 0x0000003fu, 0x00000031u, 0x0000004du, 0x0000008du, 0x0000007fu, 0x0000001fu, 0x0000001fu, 0x00000001u, 0xfffffffeu, 0x010101ffu, 0x007e0000u, 0x00003f00u, 0x0000003fu, 0x00000000u, 0x00000000u, 0x0000004eu, 0x00000007u, 0x00000000u, 0x80000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000001u, 0x0000003fu, 0x0000000fu, 0x00000001u, 0x0000003fu, 0x0000000fu, 0x0001003fu, 0x0001003fu, 0x7fff0040u, 0x7fff003eu, 0x7fff0040u, 0x7fff003eu, 0x7fff8000u, 0x7fff0000u, 0x7fff0000u, 0x7fff0001u, 0x7fff003fu, 0x7fff0001u, 0x7fff003fu, 0x00000040u, 0x00000000u, 0x0000003eu, 0x00000000u, 0xffffffc2u, 0x00000001u}, + {0x0f9156f7u, 0x7c8ab7a0u, 0x10a80b17u, 0xfee94bdfu, 0xee4140c9u, 0xee4140cdu, 0x80000003u, 0x80000003u, 0x00000001u, 0xffffffffu, 0x10a80b17u, 0x80000000u, 0xdfdfdf36u, 0xa6d5017bu, 0xe94b1536u, 0xad3a4e4bu, 0x2e4f98feu, 0xf7a78d1fu, 0x233a4e4eu, 0x36a80befu, 0x7be00000u, 0x0066d501u, 0x000019b5u, 0x00000000u, 0x000019b5u, 0x00000000u, 0xd8e94b15u, 0x36a80bdfu, 0x00000003u, 0x00000003u, 0xd8e94b15u, 0x36a80bdfu, 0xffffffffu, 0x7fff8000u, 0xffff56f4u, 0xffff3f36u, 0xffff56f4u, 0xffff3f36u, 0xffff7be0u, 0xffff005eu, 0xffff005eu, 0xffff0bdfu, 0xffff4b15u, 0xffff0bdfu, 0xffff4b15u, 0x0f9156f4u, 0x00000001u, 0xa2413f36u, 0x00000000u, 0x5dbec0cau, 0x00000001u}, + {0xc5100379u, 0x8a2006f0u, 0x80000001u, 0xc5100379u, 0xc5100379u, 0xc5100379u, 0xa0000001u, 0xa0000001u, 0x00000000u, 0x00000000u, 0x80000001u, 0x00000000u, 0xff585803u, 0x228801acu, 0x20451003u, 0xa2006b00u, 0x00000008u, 0x00000008u, 0x82006b01u, 0x45100359u, 0x00000000u, 0x45100358u, 0x80000001u, 0x00000000u, 0x80000001u, 0xffffffffu, 0x80000001u, 0x45100358u, 0x00000020u, 0x00000020u, 0x80000001u, 0x45100358u, 0xffff0020u, 0x7fff0020u, 0xffff0378u, 0xfffffcc8u, 0xffff0378u, 0xfffffcc8u, 0xffff0358u, 0xffff0358u, 0xffff0358u, 0xffff0020u, 0xffff0358u, 0xffff0020u, 0xffff0358u, 0x45100378u, 0x00000000u, 0xbaeffcc8u, 0x00000001u, 0x45100338u, 0x00000000u}, + {0x0ed9f6f5u, 0xb37cbbc0u, 0x0c0c0406u, 0x0ecdf6efu, 0x0ec1f6e9u, 0x0ed9f6f5u, 0x0c2c0406u, 0x0c2c0406u, 0x00000000u, 0x00000000u, 0x0c0c0406u, 0x00000000u, 0x00004000u, 0x000b37cau, 0x004002cdu, 0xb37cabc0u, 0x00000000u, 0x00000000u, 0xff88afc6u, 0x02cdf2b0u, 0x02cdf2afu, 0x0c0c0406u, 0x02cdf2afu, 0x0c0c0406u, 0x02cdf2afu, 0x0c0c0406u, 0x00000040u, 0x0c0c0406u, 0x02cdf2afu, 0x00000040u, 0x0c0c0406u, 0x02cdf2afu, 0xffff0040u, 0x7fff0040u, 0x0000f2efu, 0x00000d91u, 0x0000f2efu, 0x00000d91u, 0x0000f2afu, 0x0000f2afu, 0x0000f2afu, 0x00000040u, 0x0000f2afu, 0x0000f2afu, 0x00000040u, 0x02cdf2efu, 0x00000000u, 0xfd320d91u, 0x00000001u, 0x02cdf26fu, 0x00000000u}, + {0x7fff8021u, 0xffff0040u, 0x00000021u, 0x7fff7fffu, 0x7fff7fdfu, 0x7fff7fdfu, 0x80000001u, 0x80000001u, 0x00000000u, 0x00000000u, 0x00000021u, 0x80000000u, 0xffffff7fu, 0xbfffbfffu, 0x217fff7fu, 0x7fef7fdfu, 0x00000010u, 0x00000010u, 0xffef7fe0u, 0x7fff8001u, 0x00000000u, 0xfffefffeu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000001u, 0x7fff7fffu, 0x00000021u, 0x00000001u, 0x7fff7fffu, 0x00000021u, 0xffff0021u, 0x7fff0021u, 0xffff8020u, 0xffff8022u, 0xffff8020u, 0xffff8022u, 0xfffffffeu, 0xffff3fffu, 0xffff3fffu, 0xffff0021u, 0xffff7fffu, 0xffff0021u, 0xffff7fffu, 0x7fff8020u, 0x00000000u, 0x80008022u, 0x00000001u, 0x7fff7fdeu, 0x00000000u}, + {0x93b3a3efu, 0x00000000u, 0xffffffffu, 0xffffffffu, 0x6c4c5c31u, 0x93b3a3cdu, 0xec7fffffu, 0xffffffffu, 0x00000127u, 0xffffff27u, 0x6c4c5c37u, 0xff800000u, 0xffffffffu, 0x276747b2u, 0xb3a3d900u, 0x4523b87fu, 0x0000000du, 0xfffffff6u, 0xf923b87eu, 0x00000029u, 0x2e000000u, 0xfe000000u, 0xffffff80u, 0x0000007fu, 0xffffff80u, 0xffffffffu, 0x93b3a3d9u, 0x00000017u, 0xffffffffu, 0x00000017u, 0xffffffffu, 0x93b3a3d9u, 0x0017ffffu, 0x00178000u, 0x0000a3f0u, 0x0000a3c2u, 0x0000a3f0u, 0x0000a3c2u, 0x00002e00u, 0x00000000u, 0x00000000u, 0x00000017u, 0x0000a3d9u, 0x0000a3d9u, 0x00000017u, 0x93b3a3f0u, 0x00000000u, 0x93b3a3c2u, 0x00000000u, 0x6c4c5c3eu, 0x00000001u}, + {0x00000068u, 0x00000028u, 0x00000041u, 0x00000067u, 0x00000066u, 0x00000066u, 0x0000004eu, 0x0000004eu, 0x00000000u, 0x00000000u, 0x00000041u, 0x000000feu, 0x212121ffu, 0x00000021u, 0x00000021u, 0x000000e7u, 0x00000000u, 0x00000000u, 0x00000127u, 0x00000024u, 0x00001080u, 0x00002000u, 0x80000000u, 0x00000000u, 0x80000000u, 0x00000000u, 0x00000007u, 0x00000040u, 0x00000021u, 0x00000007u, 0x00000040u, 0x00000021u, 0x00210007u, 0x00210007u, 0x00000028u, 0x0000ffe6u, 0x00000028u, 0x0000ffe6u, 0x00001080u, 0x00000000u, 0x00000000u, 0x00000007u, 0x00000021u, 0x00000007u, 0x00000021u, 0x00000028u, 0x00000000u, 0xffffffe6u, 0x00000001u, 0x0000001au, 0x00000000u}, + {0x0000ffffu, 0xffffffffu, 0x00010000u, 0xffffffffu, 0xfffeffffu, 0x0000ffffu, 0x80007fffu, 0x7fff7fffu, 0x00000000u, 0x00000000u, 0x00000000u, 0x7fffffffu, 0x00800000u, 0x80008000u, 0x80008000u, 0x3fff8000u, 0x3fffffffu, 0xc0008000u, 0xc0008000u, 0x8000801eu, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x00000000u, 0x80008000u, 0x7fff7fffu, 0x00010000u, 0x00010000u, 0x80008000u, 0x7fff7fffu, 0xffffffffu, 0x80007fffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x0000ffffu, 0x00000000u, 0x00000001u, 0x0000ffffu, 0x00007fffu, 0x00008000u, 0x00008000u, 0x00007fffu, 0xffffffffu, 0x00000000u, 0xfffeffffu, 0x00000001u, 0x00010001u, 0x00000000u}, + {0x0000007eu, 0x80000000u, 0x0000003fu, 0x0000003fu, 0x00000000u, 0x0000007eu, 0x0000005eu, 0x0000003fu, 0x0000001fu, 0x0000001fu, 0x00000020u, 0x7fffffffu, 0x202020ffu, 0x0000003eu, 0x00001f00u, 0x000003e0u, 0x00000000u, 0x00000000u, 0x0000041fu, 0x00000025u, 0x00000000u, 0x80000010u, 0x0000007eu, 0x00000000u, 0x0000007eu, 0x00000000u, 0x0000001fu, 0x0000003fu, 0x00000020u, 0x0000001fu, 0x0000003fu, 0x00000020u, 0x0020001fu, 0x0020001fu, 0x3253003fu, 0x3253ffffu, 0x3253003fu, 0x3253ffffu, 0x32530000u, 0x32530000u, 0x32530000u, 0x3253001fu, 0x32530020u, 0x3253001fu, 0x32530020u, 0x0000003fu, 0x00000000u, 0xffffffffu, 0x00000001u, 0x00000001u, 0x00000000u} +}; +constexpr const char* Names[51] = {"add3_u32", "add_lshl_u32", "and_or_b32", "or3_b32", "xor3_b32", "xad_u32", "lshl_add_u32", "lshl_or_b32", "bfe_u32", "bfe_i32", "bfi_b32", "bfm_b32", "perm_b32", "alignbit_b32", "alignbyte_b32", "mul_lo_u32", "mul_hi_u32", "mul_hi_i32", "mad_i32_i24", "bcnt_u32_b32", "lshlrev_b64 lo", "lshlrev_b64 hi", "lshrrev_b64 lo", "lshrrev_b64 hi", "ashrrev_i64 lo", "ashrrev_i64 hi", "min3_i32", "max3_i32", "med3_i32", "min3_u32", "max3_u32", "med3_u32", "cvt_pk_u16_u32", "cvt_pk_i16_i32", "add_nc_u16", "sub_nc_u16", "add_nc_i16", "sub_nc_i16", "lshlrev_b16", "lshrrev_b16", "ashrrev_i16", "min_u16", "max_u16", "min_i16", "max_i16", "add_co_u32", "add_co_u32 carry", "sub_co_u32", "sub_co_u32 carry", "subrev_co_u32", "subrev_co_u32 carry"}; + +void Fill(std::uint32_t tid, std::uint32_t* words) { + std::copy(std::begin(Rows[tid]), std::end(Rows[tid]), words); +} + +std::array BufferDescriptor(const void* data, std::uint32_t bytes) { + const auto address = reinterpret_cast(data); + return {static_cast(address), static_cast((address >> 32u) & 0xffffu), bytes, 0x01016facu}; +} + +std::string Hex(std::uint32_t value) { + char text[16]; + std::snprintf(text, sizeof(text), "0x%08x", value); + return text; +} + +void Expect(std::uint32_t tid, std::uint32_t actual, std::uint32_t expected, const char* name) { + Require(actual == expected, std::string("vop3 integer alu: lane ") + std::to_string(tid) + " " + name + " is " + Hex(actual) + ", expected " + Hex(expected)); +} + +void Run(AgcDriver::VulkanDevice& device) { + for (std::uint32_t tid = 0; tid < Threads; ++tid) Fill(tid, &Input[tid * Inputs]); + Output.fill(0xdeadbeefu); + std::vector userData(8, 0u); + const auto input = BufferDescriptor(Input.data(), static_cast(Input.size() * 4u)); + const auto output = BufferDescriptor(Output.data(), static_cast(Output.size() * 4u)); + std::copy(input.begin(), input.end(), userData.begin()); + std::copy(output.begin(), output.end(), userData.begin() + 4); + const std::span code(Code); + const std::array memory{{{reinterpret_cast(code.data()), std::as_bytes(code)}}}; + const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0u, {false, false, false}, false, 1}; + ShaderRecompiler::RecompileRequest request{ + {ShaderStage::Compute, reinterpret_cast(code.data()), code, 0, {}}, + {32, 0, userData, compute, std::nullopt, std::nullopt, memory}, + device.Target(), + {0, 0, 0, 128} + }; + request.useCache = false; + const auto result = ShaderRecompiler::Recompile(request); + device.Dispatch(result, 1, 1, 1, {}, reinterpret_cast(code.data())); + device.WaitIdle(); +} + +void Check() { + for (std::uint32_t tid = 0; tid < Threads; ++tid) { + const std::uint32_t* in = &Input[tid * Inputs]; + const std::uint32_t* out = &Output[tid * Results]; + for (std::uint32_t i = 0; i < 51; ++i) Expect(tid, out[i], Expected[tid][i], Names[i]); + } +} + +} + +int main() { + try { + const auto device = OpenVulkanTestDevice(); + if (!device) return VulkanTestSkipped; + Run(*device); + Check(); + std::puts("vop3 integer alu tests passed"); + return 0; + } catch (const std::exception& error) { + std::cerr << error.what() << '\n'; + return 1; + } +} diff --git a/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp b/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp index 4be3e2626..95d686744 100644 --- a/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp +++ b/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp @@ -229,6 +229,7 @@ private: bool integerDot(const RdnaInstruction& inst, std::uint32_t elementBits, bool sign, bool accumulator); bool vCndmaskB32(const RdnaInstruction& inst); bool packB16(const RdnaInstruction& inst, bool high0, bool high1); + bool vCvtPk16I32(const RdnaInstruction& inst, bool sign); void sSubvectorLoop(const RdnaInstruction& inst, bool begin); void sSaveexec(const RdnaInstruction& inst, IrOpcode operation, bool negateExec, bool negateSource, bool write64, bool negateResult = false, bool writeDestination = true); void addU32(const RdnaInstruction& inst, bool vector, bool useCarryIn); diff --git a/core/shader/recompiler/Translation/src/IntegerInstructions.cpp b/core/shader/recompiler/Translation/src/IntegerInstructions.cpp index 7d80dca18..9ef0149ac 100644 --- a/core/shader/recompiler/Translation/src/IntegerInstructions.cpp +++ b/core/shader/recompiler/Translation/src/IntegerInstructions.cpp @@ -812,6 +812,19 @@ bool TranslationContext::packB16(const RdnaInstruction& inst, bool high0, bool h return true; } +bool TranslationContext::vCvtPk16I32(const RdnaInstruction& inst, bool sign) { + const auto saturate = [&](std::uint32_t index) { + const IrU32 source = readU32(sourceAt(inst, index)); + if (sign) { + return IrU32(ir.Emit(IrOpcode::SMax32, IrType::U32, {&ir.Emit(IrOpcode::SMin32, IrType::U32, {&source.Value(), &ir.Constant(0x7fffu)}), &ir.Constant(0xffff8000u)})); + } + return IrU32(ir.Emit(IrOpcode::UMin32, IrType::U32, {&source.Value(), &ir.Constant(0xffffu)})); + }; + const IrU32 result = packU16Lanes(saturate(0u), saturate(1u)); + writeOperand(inst.destination, &result.Value()); + return true; +} + void TranslateIntegerInstruction(TranslationContext& context, const RdnaInstruction& instruction) { throw std::runtime_error("TranslateIntegerInstruction not implemented"); } diff --git a/core/shader/recompiler/Translation/src/VectorInstructions.cpp b/core/shader/recompiler/Translation/src/VectorInstructions.cpp index 2782618ee..93280d9f6 100644 --- a/core/shader/recompiler/Translation/src/VectorInstructions.cpp +++ b/core/shader/recompiler/Translation/src/VectorInstructions.cpp @@ -720,8 +720,9 @@ bool TranslationContext::emitVector(const RdnaInstruction& inst) { vPackB32F16(inst); return true; case RdnaOpcode::VCvtPkU16U32: + return vCvtPk16I32(inst, false); case RdnaOpcode::VCvtPkI16I32: - return packB16(inst, false, false); + return vCvtPk16I32(inst, true); case RdnaOpcode::VLshlrevB16: return integer16Shift(inst, IrOpcode::ShiftLeftLogical32, false); case RdnaOpcode::VLshrrevB16: