aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2022-12-29 12:09:34 -0300
committerGitHub <noreply@github.com>2022-12-29 16:09:34 +0100
commit9dfe81770a8337a7a469eb3bac0ae9599cc0f61c (patch)
treee0c470a0ae67984394037f72fb7e16250674ba7e /Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs
parent52c115a1f8f98dcd0a1f9da3d176f4a100f825b4 (diff)
Use vector outputs for texture operations (#3939)
* Change AggregateType to include vector type counts * Replace VariableType uses with AggregateType and delete VariableType * Support new local vector types on SPIR-V and GLSL * Start using vector outputs for texture operations * Use vectors on more texture operations * Use vector output for ImageLoad operations * Replace all uses of single destination texture constructors with multi destination ones * Update textureGatherOffsets replacement to split vector operations * Shader cache version bump Co-authored-by: Ac_K <Acoustik666@gmail.com>
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);