From 9f3f0fad5e75387d448318672b95406b875f206b Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 3 Aug 2023 12:23:41 -0400 Subject: [PATCH] Remaining functions --- .../CodeGen/Msl/Instructions/InstGenHelper.cs | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenHelper.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenHelper.cs index c549302ef1..632ad6bf2f 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenHelper.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenHelper.cs @@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions Add(Instruction.Absolute, InstType.AtomicBinary, "abs"); Add(Instruction.Add, InstType.OpBinaryCom, "+"); Add(Instruction.Ballot, InstType.Special); - Add(Instruction.Barrier, InstType.CallUnary, "threadgroup_barrier"); + Add(Instruction.Barrier, InstType.Special); Add(Instruction.BitCount, InstType.CallUnary, "popcount"); Add(Instruction.BitfieldExtractS32, InstType.CallTernary, "extract_bits"); Add(Instruction.BitfieldExtractU32, InstType.CallTernary, "extract_bits"); @@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions Add(Instruction.FindMSBU32, InstType.Special); Add(Instruction.Floor, InstType.CallUnary, "floor"); Add(Instruction.FusedMultiplyAdd, InstType.CallTernary, "fma"); - Add(Instruction.GroupMemoryBarrier, InstType.CallUnary, "threadgroup_barrier"); + Add(Instruction.GroupMemoryBarrier, InstType.Special); Add(Instruction.ImageLoad, InstType.Special); Add(Instruction.ImageStore, InstType.Special); Add(Instruction.ImageAtomic, InstType.Special); // Metal 3.1+ @@ -87,7 +87,45 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions Add(Instruction.LogicalOr, InstType.OpBinaryCom, "||"); Add(Instruction.LoopBreak, InstType.OpNullary, "break"); Add(Instruction.LoopContinue, InstType.OpNullary, "continue"); - + Add(Instruction.PackDouble2x32, 0); // MSL does not have a 64-bit FP + Add(Instruction.PackHalf2x16, InstType.CallUnary, "pack_half_to_unorm2x16"); + Add(Instruction.Maximum, InstType.CallBinary, "max"); + Add(Instruction.MaximumU32, InstType.CallBinary, "max"); + Add(Instruction.MemoryBarrier, InstType.Special); + Add(Instruction.Minimum, InstType.CallBinary, "min"); + Add(Instruction.MinimumU32, InstType.CallBinary, "min"); + Add(Instruction.Modulo, InstType.CallBinary, "%"); + Add(Instruction.Multiply, InstType.OpBinaryCom, "*"); + Add(Instruction.MultiplyHighS32, InstType.Special); + Add(Instruction.MultiplyHighU32, InstType.Special); + Add(Instruction.Negate, InstType.Special); + Add(Instruction.ReciprocalSquareRoot, InstType.CallUnary, "rsqrt"); + Add(Instruction.Return, InstType.OpNullary, "return"); + Add(Instruction.Round, InstType.CallUnary, "round"); + Add(Instruction.ShiftLeft, InstType.OpBinary, "<<"); + Add(Instruction.ShiftRightS32, InstType.OpBinary, ">>"); + Add(Instruction.ShiftRightU32, InstType.OpBinary, ">>"); + // TODO: Shuffle funcs + Add(Instruction.Shuffle, 0); + Add(Instruction.ShuffleDown, 0); + Add(Instruction.ShuffleUp, 0); + Add(Instruction.ShuffleXor, 0); + Add(Instruction.Sine, InstType.CallUnary, "sin"); + Add(Instruction.SquareRoot, InstType.CallUnary, "sqrt"); + Add(Instruction.Store, InstType.Special); + Add(Instruction.Subtract, InstType.OpBinary, "-"); + // TODO: Swizzle add + Add(Instruction.SwizzleAdd, InstType.Special); + Add(Instruction.TextureSample, InstType.Special); + Add(Instruction.TextureSize, InstType.Special); + Add(Instruction.Truncate, InstType.CallUnary, "trunc"); + Add(Instruction.UnpackDouble2x32, 0); // MSL does not have a 64-bit FP + Add(Instruction.UnpackHalf2x16, InstType.CallUnary, "unpack_unorm2x16_to_half"); + Add(Instruction.VectorExtract, InstType.Special); + Add(Instruction.VoteAll, InstType.CallUnary, "simd_all"); + // TODO: https://github.com/KhronosGroup/SPIRV-Cross/blob/bccaa94db814af33d8ef05c153e7c34d8bd4d685/reference/shaders-msl/comp/shader_group_vote.msl21.comp#L9 + Add(Instruction.VoteAllEqual, InstType.Special); + Add(Instruction.VoteAny, InstType.CallUnary, "simd_any"); #pragma warning restore IDE0055 }