aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs33
1 files changed, 17 insertions, 16 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs
index b13a74f4..22c8623c 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs
@@ -1,6 +1,7 @@
using Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.StructuredIr;
+using Ryujinx.Graphics.Shader.Translation;
using System;
namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
@@ -10,8 +11,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
public static string ReinterpretCast(
CodeGenContext context,
IAstNode node,
- VariableType srcType,
- VariableType dstType)
+ AggregateType srcType,
+ AggregateType dstType)
{
if (node is AstOperand operand && operand.Type == OperandType.Constant)
{
@@ -26,46 +27,46 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
return ReinterpretCast(expr, node, srcType, dstType);
}
- private static string ReinterpretCast(string expr, IAstNode node, VariableType srcType, VariableType dstType)
+ private static string ReinterpretCast(string expr, IAstNode node, AggregateType srcType, AggregateType dstType)
{
if (srcType == dstType)
{
return expr;
}
- if (srcType == VariableType.F32)
+ if (srcType == AggregateType.FP32)
{
switch (dstType)
{
- case VariableType.Bool: return $"(floatBitsToInt({expr}) != 0)";
- case VariableType.S32: return $"floatBitsToInt({expr})";
- case VariableType.U32: return $"floatBitsToUint({expr})";
+ case AggregateType.Bool: return $"(floatBitsToInt({expr}) != 0)";
+ case AggregateType.S32: return $"floatBitsToInt({expr})";
+ case AggregateType.U32: return $"floatBitsToUint({expr})";
}
}
- else if (dstType == VariableType.F32)
+ else if (dstType == AggregateType.FP32)
{
switch (srcType)
{
- case VariableType.Bool: return $"intBitsToFloat({ReinterpretBoolToInt(expr, node, VariableType.S32)})";
- case VariableType.S32: return $"intBitsToFloat({expr})";
- case VariableType.U32: return $"uintBitsToFloat({expr})";
+ case AggregateType.Bool: return $"intBitsToFloat({ReinterpretBoolToInt(expr, node, AggregateType.S32)})";
+ case AggregateType.S32: return $"intBitsToFloat({expr})";
+ case AggregateType.U32: return $"uintBitsToFloat({expr})";
}
}
- else if (srcType == VariableType.Bool)
+ else if (srcType == AggregateType.Bool)
{
return ReinterpretBoolToInt(expr, node, dstType);
}
- else if (dstType == VariableType.Bool)
+ else if (dstType == AggregateType.Bool)
{
expr = InstGenHelper.Enclose(expr, node, Instruction.CompareNotEqual, isLhs: true);
return $"({expr} != 0)";
}
- else if (dstType == VariableType.S32)
+ else if (dstType == AggregateType.S32)
{
return $"int({expr})";
}
- else if (dstType == VariableType.U32)
+ else if (dstType == AggregateType.U32)
{
return $"uint({expr})";
}
@@ -73,7 +74,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
throw new ArgumentException($"Invalid reinterpret cast from \"{srcType}\" to \"{dstType}\".");
}
- private static string ReinterpretBoolToInt(string expr, IAstNode node, VariableType dstType)
+ private static string ReinterpretBoolToInt(string expr, IAstNode node, AggregateType dstType)
{
string trueExpr = NumberFormatter.FormatInt(IrConsts.True, dstType);
string falseExpr = NumberFormatter.FormatInt(IrConsts.False, dstType);