Fix MSL Reinterpret Casts

This commit is contained in:
Isaac Marovitz 2024-03-19 16:14:37 -04:00
parent 0de46a3a70
commit f7c9d77968
No known key found for this signature in database
GPG Key ID: 97250B2B09A132E1
1 changed files with 7 additions and 6 deletions

View File

@ -3,6 +3,7 @@ using Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions;
using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.StructuredIr; using Ryujinx.Graphics.Shader.StructuredIr;
using Ryujinx.Graphics.Shader.Translation; using Ryujinx.Graphics.Shader.Translation;
using System;
namespace Ryujinx.Graphics.Shader.CodeGen.Msl namespace Ryujinx.Graphics.Shader.CodeGen.Msl
{ {
@ -39,11 +40,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
switch (dstType) switch (dstType)
{ {
case AggregateType.Bool: case AggregateType.Bool:
return $"(floatBitsToInt({expr}) != 0)"; return $"(as_type<int>({expr}) != 0)";
case AggregateType.S32: case AggregateType.S32:
return $"floatBitsToInt({expr})"; return $"as_type<int>({expr})";
case AggregateType.U32: case AggregateType.U32:
return $"floatBitsToUint({expr})"; return $"as_type<uint>({expr})";
} }
} }
else if (dstType == AggregateType.FP32) else if (dstType == AggregateType.FP32)
@ -51,11 +52,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
switch (srcType) switch (srcType)
{ {
case AggregateType.Bool: case AggregateType.Bool:
return $"intBitsToFloat({ReinterpretBoolToInt(expr, node, AggregateType.S32)})"; return $"as_type<float>({ReinterpretBoolToInt(expr, node, AggregateType.S32)})";
case AggregateType.S32: case AggregateType.S32:
return $"intBitsToFloat({expr})"; return $"as_type<float>({expr})";
case AggregateType.U32: case AggregateType.U32:
return $"uintBitsToFloat({expr})"; return $"as_type<float>({expr})";
} }
} }
else if (srcType == AggregateType.Bool) else if (srcType == AggregateType.Bool)