From 24f959b48cc786891f1dafdf17d877e9adbe234b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Thu, 1 Oct 2026 21:57:18 +0200 Subject: [PATCH 1/2] fix(shader): select the written lane in v_writelane_b32 The WriteLane IR takes {value, lane, previous}, as the translation and the read-lane eliminator use it, but the SPIR-V emitter compared the lane id with the previous value and selected between the lane index and the value. Every v_writelane therefore wrote its value to all lanes (or the lane index to the lane whose old value happened to equal its id). Co-Authored-By: Claude --- .../tests/execution/WriteLane.cpp | 91 +++++++++++++++++++ .../src/SpirvAlu/SpirvAluEmitterMath.cpp | 5 +- 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 core/libs/prx/libSceAgcDriver/tests/execution/WriteLane.cpp diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/WriteLane.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/WriteLane.cpp new file mode 100644 index 000000000..65df5957a --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/tests/execution/WriteLane.cpp @@ -0,0 +1,91 @@ +#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 + +namespace { + +using AgcDriver::Graphics::Require; +using ShaderRecompiler::ShaderStage; + +constexpr std::uint32_t Threads = 32; +constexpr std::uint32_t Stride = 4; +alignas(256) std::array Input{}; +alignas(256) std::array Output{}; + +alignas(256) constexpr std::array WriteLaneCode{ + 0x34020082, 0xe0302000, 0x80000401, 0xe0302004, 0x80000501, 0x7e180300, 0xb0151234, 0xd761000c, + 0x00014a15, 0xbf8c3f70, 0xbe940380, 0xd7600008, 0x00002904, 0xd7600009, 0x00002905, 0x8096149f, + 0xd761000a, 0x00002c08, 0xd761000b, 0x00002809, 0x80148114, 0xbf0aa014, 0xbf85fff4, 0xe0702000, + 0x80010a01, 0xe0702004, 0x80010b01, 0xe0702008, 0x80010c01, 0xbf810000, +}; + +std::array BufferDescriptor(const void* data, std::uint32_t count) { + const auto address = reinterpret_cast(data); + return {static_cast(address), static_cast((address >> 32u) & 0xffffu) | (4u << 16u), count, 0x01016facu}; +} + +void Run(AgcDriver::VulkanDevice& device) { + for (std::uint32_t tid = 0; tid < Threads; ++tid) { + Input[tid * Stride] = 0xa0000000u + tid * 0x01010101u; + Input[tid * Stride + 1] = 0x50000000u ^ (tid * 0x00102030u); + } + Output.fill(0xdeadbeefu); + std::vector userData(8, 0u); + const auto input = BufferDescriptor(Input.data(), static_cast(Input.size())); + const auto output = BufferDescriptor(Output.data(), static_cast(Output.size())); + std::copy(input.begin(), input.end(), userData.begin()); + std::copy(output.begin(), output.end(), userData.begin() + 4); + const std::span code(WriteLaneCode); + const std::array memory{{{reinterpret_cast(code.data()), std::as_bytes(code)}}}; + const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0, {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::array expected{ + Input[(Threads - 1u - tid) * Stride], + Input[tid * Stride + 1], + tid == 5u ? 0x1234u : tid, + }; + for (std::uint32_t j = 0; j < expected.size(); ++j) { + const auto actual = Output[tid * Stride + j]; + Require(actual == expected[j], "write lane: lane " + std::to_string(tid) + " result " + std::to_string(j) + " is " + std::to_string(actual) + ", expected " + std::to_string(expected[j])); + } + } +} + +} + +int main() { + try { + const auto device = OpenVulkanTestDevice(); + if (!device) return VulkanTestSkipped; + if (device->Target().subgroupSize < Threads) { + std::printf("skipped, subgroup size %u cannot hold a wave32\n", device->Target().subgroupSize); + return VulkanTestSkipped; + } + Run(*device); + Check(); + std::puts("write lane tests passed"); + return 0; + } catch (const std::exception& error) { + std::cerr << error.what() << '\n'; + return 1; + } +} diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp index 163b24d7c..7c5c23704 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp @@ -536,9 +536,10 @@ std::uint32_t EmitReadLane(SpirvValueEmitContext& ctx, const IrValue& inst) { std::uint32_t EmitWriteLane(SpirvValueEmitContext& ctx, const IrValue& inst) { auto& state = ctx.state; + const auto lane = Binary(state, spv::OpBitwiseAnd, TypeU32(state), ctx.Arg(inst, 1), ConstantU32(state, state.program.WaveSize() - 1u)); const auto hit = state.module.AllocateId(); - state.module.AddFunction(spv::OpIEqual, TypeBool(state), hit, EmitSubgroupLocalInvocationId(state), ctx.Arg(inst, 2)); - return EmitNative(state, hit, ctx.Arg(inst, 1), ctx.Arg(inst, 0)); + state.module.AddFunction(spv::OpIEqual, TypeBool(state), hit, EmitSubgroupLocalInvocationId(state), lane); + return EmitNative(state, hit, ctx.Arg(inst, 0), ctx.Arg(inst, 2)); } std::uint32_t EmitPermlane16U32(SpirvValueEmitContext& ctx, const IrValue& inst) { From f3f9b4fff72089e105e78355720984e0212ca810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Thu, 1 Oct 2026 21:57:18 +0200 Subject: [PATCH 2/2] feat(shader): implement s_bcnt0_i32_b64, s_ff0_i32_b64, s_flbit_i32(_i64), s_quadmask_b32 The decoder threw for these SOP1 opcodes. The 64-bit find-first-zero and signed leading-bit counts reuse the existing 64-bit helpers with a flag; s_quadmask_b32 is the 32-bit half of s_quadmask_b64. s_bcnt0 and s_quadmask set SCC to result != 0; the find and leading-bit forms leave it. Co-Authored-By: Claude --- .../tests/execution/ScalarBitCount.cpp | 122 ++++++++++++++++++ .../include/RdnaDecoder/RdnaOpcode.hpp | 5 + .../recompiler/RdnaDecoder/src/RdnaOpcode.cpp | 5 + .../RdnaDecoder/src/RdnaScalarOpDecoder.cpp | 5 + .../Translation/TranslationContext.hpp | 6 +- .../Translation/src/IntegerInstructions.cpp | 24 +++- .../Translation/src/ScalarInstructions.cpp | 23 +++- 7 files changed, 179 insertions(+), 11 deletions(-) create mode 100644 core/libs/prx/libSceAgcDriver/tests/execution/ScalarBitCount.cpp diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/ScalarBitCount.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/ScalarBitCount.cpp new file mode 100644 index 000000000..0624c8e50 --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/tests/execution/ScalarBitCount.cpp @@ -0,0 +1,122 @@ +#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 + +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 = 8; +alignas(256) std::array Input{}; +alignas(256) std::array Output{}; + +alignas(256) constexpr std::array BitCountCode{ + 0x34020082, 0x34060083, 0xe0302000, 0x80000401, 0xe0302004, 0x80000501, 0xbf8c3f70, 0xbe940380, + 0xd7600008, 0x00002904, 0xd7600009, 0x00002905, 0xbe8a0e08, 0x850f8081, 0xbe8b1208, 0xbe8c1708, + 0xbe8d1808, 0xbe8e2c08, 0x85108081, 0xd761000a, 0x0000280a, 0xd761000b, 0x0000280b, 0xd761000c, + 0x0000280c, 0xd761000d, 0x0000280d, 0xd761000e, 0x0000280e, 0xd761000f, 0x0000280f, 0xd7610010, + 0x00002810, 0x80148114, 0xbf0aa014, 0xbf85ffe4, 0xe0702000, 0x80010a03, 0xe0702004, 0x80010b03, + 0xe0702008, 0x80010c03, 0xe070200c, 0x80010d03, 0xe0702010, 0x80010e03, 0xe0702014, 0x80010f03, + 0xe0702018, 0x80011003, 0xbf810000, +}; + +constexpr std::array Edges{ + 0u, ~0ull, 0xffffffff00000000ull, 0x00000000ffffffffull, 1u, 0x8000000000000000ull, + 0x7fffffffffffffffull, 0x00000000f0000000ull, 0xfffffffe7fffffffull, 0x0000000100000000ull, +}; + +void FillInput() { + std::uint64_t state = 0x9e3779b97f4a7c15ull; + for (std::uint32_t tid = 0; tid < Threads; ++tid) { + state = state * 6364136223846793005ull + 1442695040888963407ull; + const std::uint64_t value = tid < Edges.size() ? Edges[tid] : state >> (tid % 13u); + Input[tid * Inputs] = static_cast(value); + Input[tid * Inputs + 1] = static_cast(value >> 32u); + } +} + +std::array BufferDescriptor(const void* data, std::uint32_t count) { + const auto address = reinterpret_cast(data); + return {static_cast(address), static_cast((address >> 32u) & 0xffffu) | (4u << 16u), count, 0x01016facu}; +} + +void Run(AgcDriver::VulkanDevice& device) { + Output.fill(0xdeadbeefu); + std::vector userData(8, 0u); + const auto input = BufferDescriptor(Input.data(), static_cast(Input.size())); + const auto output = BufferDescriptor(Output.data(), static_cast(Output.size())); + std::copy(input.begin(), input.end(), userData.begin()); + std::copy(output.begin(), output.end(), userData.begin() + 4); + const std::span code(BitCountCode); + const std::array memory{{{reinterpret_cast(code.data()), std::as_bytes(code)}}}; + const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0, {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(); +} + +std::uint32_t SignedLeadingBits(std::uint64_t value, std::uint64_t sign, int width) { + const std::uint64_t folded = (value & sign) != 0u ? ~value & (sign | (sign - 1u)) : value; + return folded == 0u ? 0xffffffffu : static_cast(std::countl_zero(folded) - (64 - width)); +} + +void Check() { + for (std::uint32_t tid = 0; tid < Threads; ++tid) { + const std::uint64_t value = Input[tid * Inputs] | (static_cast(Input[tid * Inputs + 1]) << 32u); + const auto low = static_cast(value); + std::uint32_t quads = 0; + for (std::uint32_t quad = 0; quad < 8u; ++quad) quads |= ((low >> (quad * 4u)) & 0xfu) != 0u ? 1u << quad : 0u; + const auto zeros = static_cast(64 - std::popcount(value)); + const std::array expected{ + zeros, + ~value == 0u ? 0xffffffffu : static_cast(std::countr_one(value)), + SignedLeadingBits(low, 0x80000000u, 32), + SignedLeadingBits(value, 0x8000000000000000ull, 64), + quads, + zeros != 0u ? 1u : 0u, + quads != 0u ? 1u : 0u, + }; + const auto* out = &Output[tid * Results]; + for (std::uint32_t j = 0; j < expected.size(); ++j) { + Require(out[j] == expected[j], "scalar bit count: lane " + std::to_string(tid) + " result " + std::to_string(j) + " is " + std::to_string(out[j]) + ", expected " + std::to_string(expected[j])); + } + } +} + +} + +int main() { + try { + const auto device = OpenVulkanTestDevice(); + if (!device) return VulkanTestSkipped; + if (device->Target().subgroupSize < Threads) { + std::printf("skipped, subgroup size %u cannot hold a wave32\n", device->Target().subgroupSize); + return VulkanTestSkipped; + } + FillInput(); + Run(*device); + Check(); + std::puts("scalar bit count tests passed"); + return 0; + } catch (const std::exception& error) { + std::cerr << error.what() << '\n'; + return 1; + } +} diff --git a/core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaOpcode.hpp b/core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaOpcode.hpp index 4676f95ab..e8db97455 100644 --- a/core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaOpcode.hpp +++ b/core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaOpcode.hpp @@ -124,14 +124,19 @@ enum class RdnaOpcode : std::uint16_t { SSextI32I8, SSextI32I16, SBcnt0I32B32, + SBcnt0I32B64, SBcnt1I32B32, SBcnt1I32B64, SFf0I32B32, + SFf0I32B64, SFf1I32B32, SFf1I32B64, SFlbitI32B32, SFlbitI32B64, + SFlbitI32, + SFlbitI32I64, SBitreplicateB64B32, + SQuadmaskB32, SQuadmaskB64, SGetpcB64, SSubvectorLoopBegin, diff --git a/core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp b/core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp index e491e36af..6e8685542 100644 --- a/core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp +++ b/core/shader/recompiler/RdnaDecoder/src/RdnaOpcode.cpp @@ -46,14 +46,19 @@ bool IsScalarAluOpcode(RdnaOpcode opcode) { case RdnaOpcode::SSextI32I8: case RdnaOpcode::SSextI32I16: case RdnaOpcode::SBcnt0I32B32: + case RdnaOpcode::SBcnt0I32B64: case RdnaOpcode::SBcnt1I32B32: case RdnaOpcode::SBcnt1I32B64: case RdnaOpcode::SFf0I32B32: + case RdnaOpcode::SFf0I32B64: case RdnaOpcode::SFf1I32B32: case RdnaOpcode::SFf1I32B64: case RdnaOpcode::SFlbitI32B32: case RdnaOpcode::SFlbitI32B64: + case RdnaOpcode::SFlbitI32: + case RdnaOpcode::SFlbitI32I64: case RdnaOpcode::SBitreplicateB64B32: + case RdnaOpcode::SQuadmaskB32: case RdnaOpcode::SQuadmaskB64: case RdnaOpcode::SAndSaveexecB32: case RdnaOpcode::SOrSaveexecB32: diff --git a/core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp b/core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp index a48ae2d81..08b7b6567 100644 --- a/core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp +++ b/core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp @@ -20,13 +20,17 @@ RdnaOpcode decodeSop1Opcode(std::uint32_t opcode) { case 0x0bu: return RdnaOpcode::SBrevB32; case 0x0cu: return RdnaOpcode::SBrevB64; case 0x0du: return RdnaOpcode::SBcnt0I32B32; + case 0x0eu: return RdnaOpcode::SBcnt0I32B64; case 0x0fu: return RdnaOpcode::SBcnt1I32B32; case 0x10u: return RdnaOpcode::SBcnt1I32B64; case 0x11u: return RdnaOpcode::SFf0I32B32; + case 0x12u: return RdnaOpcode::SFf0I32B64; case 0x13u: return RdnaOpcode::SFf1I32B32; case 0x14u: return RdnaOpcode::SFf1I32B64; case 0x15u: return RdnaOpcode::SFlbitI32B32; case 0x16u: return RdnaOpcode::SFlbitI32B64; + case 0x17u: return RdnaOpcode::SFlbitI32; + case 0x18u: return RdnaOpcode::SFlbitI32I64; case 0x19u: return RdnaOpcode::SSextI32I8; case 0x1au: return RdnaOpcode::SSextI32I16; case 0x1bu: return RdnaOpcode::SBitset0B32; @@ -43,6 +47,7 @@ RdnaOpcode decodeSop1Opcode(std::uint32_t opcode) { case 0x29u: return RdnaOpcode::SNandSaveexecB64; case 0x2au: return RdnaOpcode::SNorSaveexecB64; case 0x2bu: return RdnaOpcode::SXnorSaveexecB64; + case 0x2cu: return RdnaOpcode::SQuadmaskB32; case 0x2du: return RdnaOpcode::SQuadmaskB64; case 0x34u: return RdnaOpcode::SAbsI32; case 0x37u: return RdnaOpcode::SAndn1SaveexecB64; diff --git a/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp b/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp index dc25013df..22a792dd3 100644 --- a/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp +++ b/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp @@ -166,9 +166,9 @@ private: bool vAndOrB32(const RdnaInstruction& inst); bool vOr3B32(const RdnaInstruction& inst); bool vXor3B32(const RdnaInstruction& inst); - bool sFf1I32B64(const RdnaInstruction& inst); + bool sFfI32B64(const RdnaInstruction& inst, bool zero); bool vFfbh32(const RdnaInstruction& inst, bool sign); - bool sFlbitI32B64(const RdnaInstruction& inst); + bool sFlbitI32B64(const RdnaInstruction& inst, bool sign); bool integer24(const RdnaInstruction& inst, bool sign, bool addend, bool high = false); bool vMadU64U32(const RdnaInstruction& inst); bool vSadU32(const RdnaInstruction& inst); @@ -178,7 +178,7 @@ private: bool vBcntU32B32(const RdnaInstruction& inst); bool vMbcntU32B32(const RdnaInstruction& inst, bool low); bool sBitreplicateB64B32(const RdnaInstruction& inst); - bool sQuadmaskB64(const RdnaInstruction& inst); + bool sQuadmask(const RdnaInstruction& inst, bool wide); bool bfmB32(const RdnaInstruction& inst); IrU32 rightMask32(IrU32 count); IrU64 rightMask64(IrU32 count); diff --git a/core/shader/recompiler/Translation/src/IntegerInstructions.cpp b/core/shader/recompiler/Translation/src/IntegerInstructions.cpp index cccf494d0..d89f8fb44 100644 --- a/core/shader/recompiler/Translation/src/IntegerInstructions.cpp +++ b/core/shader/recompiler/Translation/src/IntegerInstructions.cpp @@ -227,8 +227,11 @@ bool TranslationContext::vXor3B32(const RdnaInstruction& inst) { return true; } -bool TranslationContext::sFf1I32B64(const RdnaInstruction& inst) { - const std::array source = extractU64(readU64(sourceAt(inst, 0u))); +bool TranslationContext::sFfI32B64(const RdnaInstruction& inst, bool zero) { + std::array source = extractU64(readU64(sourceAt(inst, 0u))); + if (zero) { + source = {IrU32(ir.BitwiseNot(source[0].Value())), IrU32(ir.BitwiseNot(source[1].Value()))}; + } const IrU32 lowLsb(ir.Emit(IrOpcode::FindILsb32, IrType::U32, {&source[0].Value()})); const IrU32 highLsb(ir.Emit(IrOpcode::FindILsb32, IrType::U32, {&source[1].Value()})); const IrU32 highPosition(ir.IAdd(highLsb.Value(), ir.Constant(32u))); @@ -251,8 +254,13 @@ bool TranslationContext::vFfbh32(const RdnaInstruction& inst, bool sign) { return true; } -bool TranslationContext::sFlbitI32B64(const RdnaInstruction& inst) { - const IrU64 source = readU64(sourceAt(inst, 0u)); +bool TranslationContext::sFlbitI32B64(const RdnaInstruction& inst, bool sign) { + IrU64 source = readU64(sourceAt(inst, 0u)); + if (sign) { + const std::array halves = extractU64(source); + IrValue& mask = ir.ShiftRightArithmetic(halves[1].Value(), ir.Constant(31u)); + source = IrU64(ir.ConstructU64(ir.BitwiseXor(halves[0].Value(), mask), ir.BitwiseXor(halves[1].Value(), mask))); + } const IrU32 msb(ir.Emit(IrOpcode::FindUMsb64, IrType::U32, {&source.Value()})); const IrU32 position(ir.ISub(ir.Constant(63u), msb.Value())); const IrU1 nonZero(ir.Emit(IrOpcode::INotEqual64, IrType::U1, {&source.Value(), &ir.ConstantU64(0)})); @@ -386,7 +394,7 @@ bool TranslationContext::sBitreplicateB64B32(const RdnaInstruction& inst) { return true; } -bool TranslationContext::sQuadmaskB64(const RdnaInstruction& inst) { +bool TranslationContext::sQuadmask(const RdnaInstruction& inst, bool wide) { const auto compact = [&](IrU32 value) { IrU32 bits(ir.BitwiseOr(value.Value(), ir.ShiftRightLogical(value.Value(), ir.Constant(1u)))); bits = IrU32(ir.BitwiseOr(bits.Value(), ir.ShiftRightLogical(bits.Value(), ir.Constant(2u)))); @@ -395,6 +403,12 @@ bool TranslationContext::sQuadmaskB64(const RdnaInstruction& inst) { bits = IrU32(ir.BitwiseAnd(ir.BitwiseOr(bits.Value(), ir.ShiftRightLogical(bits.Value(), ir.Constant(6u))), ir.Constant(0x000f000fu))); return IrU32(ir.BitwiseAnd(ir.BitwiseOr(bits.Value(), ir.ShiftRightLogical(bits.Value(), ir.Constant(12u))), ir.Constant(0xffu))); }; + if (!wide) { + const IrU32 quads = compact(readU32(sourceAt(inst, 0u))); + writeOperand(inst.destination, &quads.Value()); + ir.SetScc(ir.INotEqual(quads.Value(), ir.Constant(0u))); + return true; + } const std::array source = readU32Pair(sourceAt(inst, 0u)); const IrU32 lowCompact = compact(source[0]); const IrU32 highCompact = compact(source[1]); diff --git a/core/shader/recompiler/Translation/src/ScalarInstructions.cpp b/core/shader/recompiler/Translation/src/ScalarInstructions.cpp index f4ae67ec0..05af0fc8b 100644 --- a/core/shader/recompiler/Translation/src/ScalarInstructions.cpp +++ b/core/shader/recompiler/Translation/src/ScalarInstructions.cpp @@ -275,6 +275,15 @@ bool TranslationContext::emitScalar(const RdnaInstruction& inst) { } return true; } + case RdnaOpcode::SBcnt0I32B64: { + const std::array source = extractU64(readU64(sourceAt(inst, 0u))); + auto& low = ir.Emit(IrOpcode::BitCount32, IrType::U32, {&ir.BitwiseNot(source[0].Value())}); + auto& high = ir.Emit(IrOpcode::BitCount32, IrType::U32, {&ir.BitwiseNot(source[1].Value())}); + auto& result = ir.IAdd(low, high); + writeOperand(inst.destination, &result); + ir.SetScc(ir.INotEqual(result, ir.Constant(0u))); + return true; + } case RdnaOpcode::SBcnt1I32B32: return simpleInteger(inst, IrOpcode::BitCount32, IrType::U32, false, false, true); case RdnaOpcode::SBcnt1I32B64: @@ -303,12 +312,18 @@ bool TranslationContext::emitScalar(const RdnaInstruction& inst) { return composedIntegerBinary(inst, IrOpcode::BitwiseOr32, false, true, true); case RdnaOpcode::SXnorB32: return composedIntegerBinary(inst, IrOpcode::BitwiseXor32, false, true, true); + case RdnaOpcode::SFf0I32B64: + return sFfI32B64(inst, true); case RdnaOpcode::SFf1I32B64: - return sFf1I32B64(inst); + return sFfI32B64(inst, false); case RdnaOpcode::SFlbitI32B32: return vFfbh32(inst, false); + case RdnaOpcode::SFlbitI32: + return vFfbh32(inst, true); case RdnaOpcode::SFlbitI32B64: - return sFlbitI32B64(inst); + return sFlbitI32B64(inst, false); + case RdnaOpcode::SFlbitI32I64: + return sFlbitI32B64(inst, true); case RdnaOpcode::SBitset0B32: return sBitsetB32(inst, false); case RdnaOpcode::SBitset1B32: @@ -319,8 +334,10 @@ bool TranslationContext::emitScalar(const RdnaInstruction& inst) { return sBitsetB64(inst, true); case RdnaOpcode::SBitreplicateB64B32: return sBitreplicateB64B32(inst); + case RdnaOpcode::SQuadmaskB32: + return sQuadmask(inst, false); case RdnaOpcode::SQuadmaskB64: - return sQuadmaskB64(inst); + return sQuadmask(inst, true); case RdnaOpcode::SBfmB32: return bfmB32(inst); case RdnaOpcode::SBfmB64: