Fix Pack and UnpackHalf2x16
This commit is contained in:
parent
f7e97a30af
commit
970914e2b4
3 changed files with 31 additions and 2 deletions
|
@ -145,6 +145,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
|||
return TextureQuerySamples(context, operation);
|
||||
case Instruction.TextureQuerySize:
|
||||
return TextureQuerySize(context, operation);
|
||||
case Instruction.PackHalf2x16:
|
||||
return PackHalf2x16(context, operation);
|
||||
case Instruction.UnpackHalf2x16:
|
||||
return UnpackHalf2x16(context, operation);
|
||||
case Instruction.VectorExtract:
|
||||
return VectorExtract(context, operation);
|
||||
case Instruction.VoteAllEqual:
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
|||
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.PackHalf2x16, InstType.Special);
|
||||
Add(Instruction.Maximum, InstType.CallBinary, "max");
|
||||
Add(Instruction.MaximumU32, InstType.CallBinary, "max");
|
||||
Add(Instruction.MemoryBarrier, InstType.Special);
|
||||
|
@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
|||
Add(Instruction.TextureQuerySize, 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.UnpackHalf2x16, InstType.Special);
|
||||
Add(Instruction.VectorExtract, InstType.Special);
|
||||
Add(Instruction.VoteAll, InstType.CallUnary, "simd_all");
|
||||
Add(Instruction.VoteAllEqual, InstType.Special);
|
||||
|
|
|
@ -394,5 +394,30 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
|||
|
||||
return texCall;
|
||||
}
|
||||
|
||||
public static string PackHalf2x16(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
IAstNode src0 = operation.GetSource(0);
|
||||
IAstNode src1 = operation.GetSource(1);
|
||||
|
||||
string src0Expr = GetSourceExpr(context, src0, GetSrcVarType(operation.Inst, 0));
|
||||
string src1Expr = GetSourceExpr(context, src1, GetSrcVarType(operation.Inst, 1));
|
||||
|
||||
return $"as_type<uint>(half2({src0Expr}, {src1Expr}))";
|
||||
}
|
||||
|
||||
public static string UnpackHalf2x16(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
IAstNode src = operation.GetSource(0);
|
||||
|
||||
string srcExpr = GetSourceExpr(context, src, GetSrcVarType(operation.Inst, 0));
|
||||
|
||||
return $"float2(as_type<half2>({srcExpr})){GetMask(operation.Index)}";
|
||||
}
|
||||
|
||||
private static string GetMask(int index)
|
||||
{
|
||||
return $".{"xy".AsSpan(index, 1)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue