0
0
Fork 0

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
This commit is contained in:
gdkchan 2021-12-08 18:36:09 -03:00 committed by GitHub
parent 00c69f2098
commit 119a3a1887
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 18 deletions

View file

@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary> /// <summary>
/// Version of the codegen (to be changed when codegen or guest format change). /// Version of the codegen (to be changed when codegen or guest format change).
/// </summary> /// </summary>
private const ulong ShaderCodeGenVersion = 2845; private const ulong ShaderCodeGenVersion = 2885;
// Progress reporting helpers // Progress reporting helpers
private volatile int _shaderCount; private volatile int _shaderCount;

View file

@ -219,9 +219,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest() Operand GetDest()
{ {
if (dest > RegisterConsts.RegisterZeroIndex) if (dest >= RegisterConsts.RegisterZeroIndex)
{ {
return Const(0); return null;
} }
return Register(dest++, RegisterType.Gpr); return Register(dest++, RegisterType.Gpr);

View file

@ -306,9 +306,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest() Operand GetDest()
{ {
if (rdIndex > RegisterConsts.RegisterZeroIndex) if (rdIndex >= RegisterConsts.RegisterZeroIndex)
{ {
return Const(0); return null;
} }
return Register(rdIndex++, RegisterType.Gpr); return Register(rdIndex++, RegisterType.Gpr);
@ -322,6 +322,11 @@ namespace Ryujinx.Graphics.Shader.Instructions
{ {
Operand dest = GetDest(); Operand dest = GetDest();
if (dest == null)
{
break;
}
TextureOperation operation = context.CreateTextureOperation( TextureOperation operation = context.CreateTextureOperation(
Instruction.TextureSample, Instruction.TextureSample,
type, type,
@ -795,9 +800,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest() Operand GetDest()
{ {
if (dest > RegisterConsts.RegisterZeroIndex) if (dest >= RegisterConsts.RegisterZeroIndex)
{ {
return Const(0); return null;
} }
return Register(dest++, RegisterType.Gpr); return Register(dest++, RegisterType.Gpr);
@ -809,13 +814,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
{ {
if ((compMask & 1) != 0) if ((compMask & 1) != 0)
{ {
Operand destOperand = GetDest();
if (destOperand == null)
{
break;
}
TextureOperation operation = context.CreateTextureOperation( TextureOperation operation = context.CreateTextureOperation(
Instruction.TextureSample, Instruction.TextureSample,
type, type,
flags, flags,
handle, handle,
compIndex, compIndex,
GetDest(), destOperand,
sources); sources);
context.Add(operation); context.Add(operation);
@ -902,9 +914,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest() Operand GetDest()
{ {
if (dest > RegisterConsts.RegisterZeroIndex) if (dest >= RegisterConsts.RegisterZeroIndex)
{ {
return Const(0); return null;
} }
return Register(dest++, RegisterType.Gpr); return Register(dest++, RegisterType.Gpr);
@ -916,11 +928,18 @@ namespace Ryujinx.Graphics.Shader.Instructions
{ {
if ((compMask & 1) != 0) 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. // Components z and w aren't standard, we return 0 in this case and add a comment.
if (compIndex >= 2) if (compIndex >= 2)
{ {
context.Add(new CommentNode("Unsupported component z or w found")); context.Add(new CommentNode("Unsupported component z or w found"));
context.Copy(GetDest(), Const(0)); context.Copy(destOperand, Const(0));
} }
else else
{ {
@ -941,7 +960,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand fixedPointValue = context.FP32ConvertToS32(tempDest); Operand fixedPointValue = context.FP32ConvertToS32(tempDest);
context.Copy(GetDest(), fixedPointValue); context.Copy(destOperand, fixedPointValue);
} }
} }
} }
@ -1055,9 +1074,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest() Operand GetDest()
{ {
if (dest > RegisterConsts.RegisterZeroIndex) if (dest >= RegisterConsts.RegisterZeroIndex)
{ {
return Const(0); return null;
} }
return Register(dest++, RegisterType.Gpr); return Register(dest++, RegisterType.Gpr);
@ -1069,13 +1088,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
{ {
if ((compMask & 1) != 0) if ((compMask & 1) != 0)
{ {
Operand destOperand = GetDest();
if (destOperand == null)
{
break;
}
TextureOperation operation = context.CreateTextureOperation( TextureOperation operation = context.CreateTextureOperation(
Instruction.TextureSample, Instruction.TextureSample,
type, type,
flags, flags,
handle, handle,
compIndex, compIndex,
GetDest(), destOperand,
sources); sources);
context.Add(operation); context.Add(operation);
@ -1126,9 +1152,9 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand GetDest() Operand GetDest()
{ {
if (dest > RegisterConsts.RegisterZeroIndex) if (dest >= RegisterConsts.RegisterZeroIndex)
{ {
return Const(0); return null;
} }
return Register(dest++, RegisterType.Gpr); return Register(dest++, RegisterType.Gpr);
@ -1149,13 +1175,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
{ {
if ((compMask & 1) != 0) if ((compMask & 1) != 0)
{ {
Operand destOperand = GetDest();
if (destOperand == null)
{
break;
}
TextureOperation operation = context.CreateTextureOperation( TextureOperation operation = context.CreateTextureOperation(
inst, inst,
type, type,
flags, flags,
imm, imm,
compIndex, compIndex,
GetDest(), destOperand,
sources); sources);
context.Add(operation); context.Add(operation);