aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-11-14 21:37:07 -0300
committerGitHub <noreply@github.com>2021-11-14 21:37:07 -0300
commitb9d83cc97ee1cb8c60d9b01c162bab742567fe6e (patch)
tree7cfe5cffd688dd8ca5a06e91c85e5e4cfbcce9c6 /Ryujinx.Graphics.Shader/Translation
parent788aec511ffe64c9a22024d1b88334ec8e3b5ad6 (diff)
Fix shader integer from/to double conversion (#2831)
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs40
-rw-r--r--Ryujinx.Graphics.Shader/Translation/Rewriter.cs6
2 files changed, 33 insertions, 13 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs b/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs
index 5e607b44..6baf33e1 100644
--- a/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs
+++ b/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs
@@ -241,14 +241,24 @@ namespace Ryujinx.Graphics.Shader.Translation
return context.Add(fpType | Instruction.CompareLess, Local(), a, b);
}
- public static Operand FPConvertToS32(this EmitterContext context, Operand a)
+ public static Operand FP32ConvertToS32(this EmitterContext context, Operand a)
{
- return context.Add(Instruction.ConvertFPToS32, Local(), a);
+ return context.Add(Instruction.ConvertFP32ToS32, Local(), a);
}
- public static Operand FPConvertToU32(this EmitterContext context, Operand a)
+ public static Operand FP32ConvertToU32(this EmitterContext context, Operand a)
{
- return context.Add(Instruction.ConvertFPToU32, Local(), a);
+ return context.Add(Instruction.ConvertFP32ToU32, Local(), a);
+ }
+
+ public static Operand FP64ConvertToS32(this EmitterContext context, Operand a)
+ {
+ return context.Add(Instruction.ConvertFP64ToS32, Local(), a);
+ }
+
+ public static Operand FP64ConvertToU32(this EmitterContext context, Operand a)
+ {
+ return context.Add(Instruction.ConvertFP64ToU32, Local(), a);
}
public static Operand FPCosine(this EmitterContext context, Operand a)
@@ -281,9 +291,9 @@ namespace Ryujinx.Graphics.Shader.Translation
return context.Add(Instruction.FP32 | Instruction.LogarithmB2, Local(), a);
}
- public static Operand FPMaximum(this EmitterContext context, Operand a, Operand b)
+ public static Operand FPMaximum(this EmitterContext context, Operand a, Operand b, Instruction fpType = Instruction.FP32)
{
- return context.Add(Instruction.FP32 | Instruction.Maximum, Local(), a, b);
+ return context.Add(fpType | Instruction.Maximum, Local(), a, b);
}
public static Operand FPMinimum(this EmitterContext context, Operand a, Operand b)
@@ -461,14 +471,24 @@ namespace Ryujinx.Graphics.Shader.Translation
return context.Add(Instruction.CompareNotEqual, Local(), a, b);
}
- public static Operand IConvertS32ToFP(this EmitterContext context, Operand a)
+ public static Operand IConvertS32ToFP32(this EmitterContext context, Operand a)
+ {
+ return context.Add(Instruction.ConvertS32ToFP32, Local(), a);
+ }
+
+ public static Operand IConvertS32ToFP64(this EmitterContext context, Operand a)
+ {
+ return context.Add(Instruction.ConvertS32ToFP64, Local(), a);
+ }
+
+ public static Operand IConvertU32ToFP32(this EmitterContext context, Operand a)
{
- return context.Add(Instruction.ConvertS32ToFP, Local(), a);
+ return context.Add(Instruction.ConvertU32ToFP32, Local(), a);
}
- public static Operand IConvertU32ToFP(this EmitterContext context, Operand a)
+ public static Operand IConvertU32ToFP64(this EmitterContext context, Operand a)
{
- return context.Add(Instruction.ConvertU32ToFP, Local(), a);
+ return context.Add(Instruction.ConvertU32ToFP64, Local(), a);
}
public static Operand IMaximumS32(this EmitterContext context, Operand a, Operand b)
diff --git a/Ryujinx.Graphics.Shader/Translation/Rewriter.cs b/Ryujinx.Graphics.Shader/Translation/Rewriter.cs
index 02a0feda..910faf1c 100644
--- a/Ryujinx.Graphics.Shader/Translation/Rewriter.cs
+++ b/Ryujinx.Graphics.Shader/Translation/Rewriter.cs
@@ -286,7 +286,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
Operand res = Local();
- node.List.AddBefore(node, new Operation(Instruction.ConvertFPToS32, res, value));
+ node.List.AddBefore(node, new Operation(Instruction.ConvertFP32ToS32, res, value));
return res;
}
@@ -295,7 +295,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
Operand res = Local();
- node.List.AddBefore(node, new Operation(Instruction.ConvertS32ToFP, res, value));
+ node.List.AddBefore(node, new Operation(Instruction.ConvertS32ToFP32, res, value));
return res;
}
@@ -501,7 +501,7 @@ namespace Ryujinx.Graphics.Shader.Translation
// as replacement for SNORM (which is not supported).
INode[] uses = texOp.Dest.UseOps.ToArray();
- Operation convOp = new Operation(Instruction.ConvertS32ToFP, Local(), texOp.Dest);
+ Operation convOp = new Operation(Instruction.ConvertS32ToFP32, Local(), texOp.Dest);
Operation normOp = new Operation(Instruction.FP32 | Instruction.Multiply, Local(), convOp.Dest, ConstF(1f / maxPositive));
node = node.List.AddAfter(node, convOp);