aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-12-08 18:36:09 -0300
committerGitHub <noreply@github.com>2021-12-08 18:36:09 -0300
commit119a3a188738c12a5ddbe76e67fe0cc38122ee7b (patch)
tree6979ad930fab866cf42d001575d97c269e4ddef0
parent00c69f2098bf78cecefd897599c95f68450d88a1 (diff)
Fix SUATOM and other texture shader instructions with RZ dest (#2885)
* Fix SUATOM and other texture shader instructions with RZ dest * Shader cache version bump
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs2
-rw-r--r--Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs4
-rw-r--r--Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs63
3 files changed, 51 insertions, 18 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index 87bc55bd..32a1e4bd 100644
--- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>
/// Version of the codegen (to be changed when codegen or guest format change).
/// </summary>
- private const ulong ShaderCodeGenVersion = 2845;
+ private const ulong ShaderCodeGenVersion = 2885;
// Progress reporting helpers
private volatile int _shaderCount;
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs
index 5959ac96..6d59b620 100644
--- a/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs
+++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs
@@ -219,9 +219,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest()
{
- if (dest > RegisterConsts.RegisterZeroIndex)
+ if (dest >= RegisterConsts.RegisterZeroIndex)
{
- return Const(0);
+ return null;
}
return Register(dest++, RegisterType.Gpr);
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs
index 33cc6af7..4d20a5ce 100644
--- a/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs
+++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs
@@ -306,9 +306,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest()
{
- if (rdIndex > RegisterConsts.RegisterZeroIndex)
+ if (rdIndex >= RegisterConsts.RegisterZeroIndex)
{
- return Const(0);
+ return null;
}
return Register(rdIndex++, RegisterType.Gpr);
@@ -322,6 +322,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
Operand dest = GetDest();
+ if (dest == null)
+ {
+ break;
+ }
+
TextureOperation operation = context.CreateTextureOperation(
Instruction.TextureSample,
type,
@@ -795,9 +800,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest()
{
- if (dest > RegisterConsts.RegisterZeroIndex)
+ if (dest >= RegisterConsts.RegisterZeroIndex)
{
- return Const(0);
+ return null;
}
return Register(dest++, RegisterType.Gpr);
@@ -809,13 +814,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
if ((compMask & 1) != 0)
{
+ Operand destOperand = GetDest();
+
+ if (destOperand == null)
+ {
+ break;
+ }
+
TextureOperation operation = context.CreateTextureOperation(
Instruction.TextureSample,
type,
flags,
handle,
compIndex,
- GetDest(),
+ destOperand,
sources);
context.Add(operation);
@@ -902,9 +914,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest()
{
- if (dest > RegisterConsts.RegisterZeroIndex)
+ if (dest >= RegisterConsts.RegisterZeroIndex)
{
- return Const(0);
+ return null;
}
return Register(dest++, RegisterType.Gpr);
@@ -916,11 +928,18 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
if ((compMask & 1) != 0)
{
+ Operand destOperand = GetDest();
+
+ if (destOperand == null)
+ {
+ break;
+ }
+
// Components z and w aren't standard, we return 0 in this case and add a comment.
if (compIndex >= 2)
{
context.Add(new CommentNode("Unsupported component z or w found"));
- context.Copy(GetDest(), Const(0));
+ context.Copy(destOperand, Const(0));
}
else
{
@@ -941,7 +960,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand fixedPointValue = context.FP32ConvertToS32(tempDest);
- context.Copy(GetDest(), fixedPointValue);
+ context.Copy(destOperand, fixedPointValue);
}
}
}
@@ -1055,9 +1074,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest()
{
- if (dest > RegisterConsts.RegisterZeroIndex)
+ if (dest >= RegisterConsts.RegisterZeroIndex)
{
- return Const(0);
+ return null;
}
return Register(dest++, RegisterType.Gpr);
@@ -1069,13 +1088,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
if ((compMask & 1) != 0)
{
+ Operand destOperand = GetDest();
+
+ if (destOperand == null)
+ {
+ break;
+ }
+
TextureOperation operation = context.CreateTextureOperation(
Instruction.TextureSample,
type,
flags,
handle,
compIndex,
- GetDest(),
+ destOperand,
sources);
context.Add(operation);
@@ -1126,9 +1152,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest()
{
- if (dest > RegisterConsts.RegisterZeroIndex)
+ if (dest >= RegisterConsts.RegisterZeroIndex)
{
- return Const(0);
+ return null;
}
return Register(dest++, RegisterType.Gpr);
@@ -1149,13 +1175,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
{
if ((compMask & 1) != 0)
{
+ Operand destOperand = GetDest();
+
+ if (destOperand == null)
+ {
+ break;
+ }
+
TextureOperation operation = context.CreateTextureOperation(
inst,
type,
flags,
imm,
compIndex,
- GetDest(),
+ destOperand,
sources);
context.Add(operation);