Fix shader compilation on shaders that uses rectangle textures (#2471)

This commit is contained in:
gdkchan 2021-07-12 16:20:33 -03:00 committed by GitHub
parent 40b21cc3c4
commit 9b08abc644
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 3 deletions

View file

@ -38,7 +38,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 = 2439; private const ulong ShaderCodeGenVersion = 2469;
// Progress reporting helpers // Progress reporting helpers
private volatile int _shaderCount; private volatile int _shaderCount;

View file

@ -16,18 +16,31 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
SamplerType type, SamplerType type,
TextureFormat format, TextureFormat format,
TextureFlags flags, TextureFlags flags,
int cbufSlot,
int handle, int handle,
int compIndex, int compIndex,
Operand dest, Operand dest,
params Operand[] sources) : base(inst, compIndex, dest, sources) Operand[] sources) : base(inst, compIndex, dest, sources)
{ {
Type = type; Type = type;
Format = format; Format = format;
Flags = flags; Flags = flags;
CbufSlot = DefaultCbufSlot; CbufSlot = cbufSlot;
Handle = handle; Handle = handle;
} }
public TextureOperation(
Instruction inst,
SamplerType type,
TextureFormat format,
TextureFlags flags,
int handle,
int compIndex,
Operand dest,
Operand[] sources) : this(inst, type, format, flags, DefaultCbufSlot, handle, compIndex, dest, sources)
{
}
public void TurnIntoIndexed(int handle) public void TurnIntoIndexed(int handle)
{ {
Type |= SamplerType.Indexed; Type |= SamplerType.Indexed;

View file

@ -291,6 +291,8 @@ namespace Ryujinx.Graphics.Shader.Translation
// We normalize by dividing the coords by the texture size. // We normalize by dividing the coords by the texture size.
if (isRect && !intCoords) if (isRect && !intCoords)
{ {
config.SetUsedFeature(FeatureFlags.IntegerSampling);
for (int index = 0; index < coordsCount; index++) for (int index = 0; index < coordsCount; index++)
{ {
Operand coordSize = Local(); Operand coordSize = Local();
@ -311,11 +313,14 @@ namespace Ryujinx.Graphics.Shader.Translation
texOp.Type, texOp.Type,
texOp.Format, texOp.Format,
texOp.Flags, texOp.Flags,
texOp.CbufSlot,
texOp.Handle, texOp.Handle,
index, index,
coordSize, coordSize,
texSizeSources)); texSizeSources));
config.SetUsedTexture(Instruction.TextureSize, texOp.Type, texOp.Format, texOp.Flags, texOp.CbufSlot, texOp.Handle);
Operand source = sources[coordsIndex + index]; Operand source = sources[coordsIndex + index];
Operand coordNormalized = Local(); Operand coordNormalized = Local();
@ -352,6 +357,8 @@ namespace Ryujinx.Graphics.Shader.Translation
} }
else else
{ {
config.SetUsedFeature(FeatureFlags.IntegerSampling);
Operand lod = Local(); Operand lod = Local();
node.List.AddBefore(node, new TextureOperation( node.List.AddBefore(node, new TextureOperation(
@ -359,6 +366,7 @@ namespace Ryujinx.Graphics.Shader.Translation
texOp.Type, texOp.Type,
texOp.Format, texOp.Format,
texOp.Flags, texOp.Flags,
texOp.CbufSlot,
texOp.Handle, texOp.Handle,
0, 0,
lod, lod,
@ -384,11 +392,14 @@ namespace Ryujinx.Graphics.Shader.Translation
texOp.Type, texOp.Type,
texOp.Format, texOp.Format,
texOp.Flags, texOp.Flags,
texOp.CbufSlot,
texOp.Handle, texOp.Handle,
index, index,
coordSize, coordSize,
texSizeSources)); texSizeSources));
config.SetUsedTexture(Instruction.TextureSize, texOp.Type, texOp.Format, texOp.Flags, texOp.CbufSlot, texOp.Handle);
Operand offset = Local(); Operand offset = Local();
Operand intOffset = offsets[index + (hasOffsets ? texOp.Index * coordsCount : 0)]; Operand intOffset = offsets[index + (hasOffsets ? texOp.Index * coordsCount : 0)];
@ -420,6 +431,7 @@ namespace Ryujinx.Graphics.Shader.Translation
texOp.Type, texOp.Type,
texOp.Format, texOp.Format,
texOp.Flags & ~(TextureFlags.Offset | TextureFlags.Offsets), texOp.Flags & ~(TextureFlags.Offset | TextureFlags.Offsets),
texOp.CbufSlot,
texOp.Handle, texOp.Handle,
componentIndex, componentIndex,
texOp.Dest, texOp.Dest,