VoteAllEqual, FindLSB/MSB
This commit is contained in:
committed by
Isaac Marovitz
parent
b094d34575
commit
a71b5f1a3a
@@ -4,6 +4,7 @@ using Ryujinx.Graphics.Shader.Translation;
|
||||
using System;
|
||||
using System.Text;
|
||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenBallot;
|
||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenBarrier;
|
||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenCall;
|
||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenHelper;
|
||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenMemory;
|
||||
@@ -123,19 +124,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
case Instruction.Ballot:
|
||||
return Ballot(context, operation);
|
||||
case Instruction.Barrier:
|
||||
return "threadgroup_barrier(mem_flags::mem_threadgroup)";
|
||||
return Barrier(context, operation);
|
||||
case Instruction.Call:
|
||||
return Call(context, operation);
|
||||
case Instruction.FSIBegin:
|
||||
return "|| FSI BEGIN ||";
|
||||
case Instruction.FSIEnd:
|
||||
return "|| FSI END ||";
|
||||
case Instruction.FindLSB:
|
||||
return "|| FIND LSB ||";
|
||||
case Instruction.FindMSBS32:
|
||||
return "|| FIND MSB S32 ||";
|
||||
case Instruction.FindMSBU32:
|
||||
return "|| FIND MSB U32 ||";
|
||||
case Instruction.GroupMemoryBarrier:
|
||||
return "|| FIND GROUP MEMORY BARRIER ||";
|
||||
case Instruction.ImageLoad:
|
||||
@@ -152,6 +147,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
return "|| MEMORY BARRIER ||";
|
||||
case Instruction.Store:
|
||||
return Store(context, operation);
|
||||
case Instruction.SwizzleAdd:
|
||||
return "|| SWIZZLE ADD ||";
|
||||
case Instruction.TextureSample:
|
||||
return TextureSample(context, operation);
|
||||
case Instruction.TextureQuerySamples:
|
||||
@@ -165,7 +162,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
case Instruction.VectorExtract:
|
||||
return VectorExtract(context, operation);
|
||||
case Instruction.VoteAllEqual:
|
||||
return "|| VOTE ALL EQUAL ||";
|
||||
return VoteAllEqual(context, operation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,5 +17,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
|
||||
return $"uint4(as_type<uint2>((simd_vote::vote_t)simd_ballot({arg})), 0, 0).{component}";
|
||||
}
|
||||
|
||||
public static string VoteAllEqual(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
AggregateType dstType = GetSrcVarType(operation.Inst, 0);
|
||||
|
||||
string arg = GetSourceExpr(context, operation.GetSource(0), dstType);
|
||||
|
||||
return $"simd_all({arg}) || !simd_any({arg})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
|
||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenHelper;
|
||||
using static Ryujinx.Graphics.Shader.StructuredIr.InstructionInfo;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
{
|
||||
static class InstGenBarrier
|
||||
{
|
||||
public static string Barrier(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
return "threadgroup_barrier(mem_flags::mem_threadgroup)";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,10 +71,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
Add(Instruction.ExponentB2, InstType.CallUnary, "exp2");
|
||||
Add(Instruction.FSIBegin, InstType.Special);
|
||||
Add(Instruction.FSIEnd, InstType.Special);
|
||||
// TODO: LSB and MSB Implementations https://github.com/KhronosGroup/SPIRV-Cross/blob/bccaa94db814af33d8ef05c153e7c34d8bd4d685/reference/shaders-msl-no-opt/asm/comp/bitscan.asm.comp#L8
|
||||
Add(Instruction.FindLSB, InstType.Special);
|
||||
Add(Instruction.FindMSBS32, InstType.Special);
|
||||
Add(Instruction.FindMSBU32, InstType.Special);
|
||||
Add(Instruction.FindLSB, InstType.CallUnary, HelperFunctionNames.FindLSB);
|
||||
Add(Instruction.FindMSBS32, InstType.CallUnary, HelperFunctionNames.FindMSBS32);
|
||||
Add(Instruction.FindMSBU32, InstType.CallUnary, HelperFunctionNames.FindMSBU32);
|
||||
Add(Instruction.Floor, InstType.CallUnary, "floor");
|
||||
Add(Instruction.FusedMultiplyAdd, InstType.CallTernary, "fma");
|
||||
Add(Instruction.GroupMemoryBarrier, InstType.Special);
|
||||
@@ -117,7 +116,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||
Add(Instruction.SquareRoot, InstType.CallUnary, "sqrt");
|
||||
Add(Instruction.Store, InstType.Special);
|
||||
Add(Instruction.Subtract, InstType.OpBinary, "-", 2);
|
||||
Add(Instruction.SwizzleAdd, InstType.CallTernary, HelperFunctionNames.SwizzleAdd);
|
||||
Add(Instruction.SwizzleAdd, InstType.Special);
|
||||
Add(Instruction.TextureSample, InstType.Special);
|
||||
Add(Instruction.TextureQuerySamples, InstType.Special);
|
||||
Add(Instruction.TextureQuerySize, InstType.Special);
|
||||
|
||||
Reference in New Issue
Block a user