forked from Mirror/Ryujinx
Unscale textureSize when resolution scaling is used (#2441)
* Unscale textureSize when resolution scaling is used * Fix textureSize on compute * Flag texture size as needing res scale values too
This commit is contained in:
parent
b02719cf41
commit
59900d7f00
6 changed files with 40 additions and 8 deletions
|
@ -37,7 +37,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 = 2412;
|
private const ulong ShaderCodeGenVersion = 2439;
|
||||||
|
|
||||||
// Progress reporting helpers
|
// Progress reporting helpers
|
||||||
private volatile int _shaderCount;
|
private volatile int _shaderCount;
|
||||||
|
|
|
@ -7,3 +7,13 @@
|
||||||
}
|
}
|
||||||
return ivec2(vec2(inputVec) * scale);
|
return ivec2(vec2(inputVec) * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Helper_TextureSizeUnscale(int size, int samplerIndex)
|
||||||
|
{
|
||||||
|
float scale = cp_renderScale[samplerIndex];
|
||||||
|
if (scale == 1.0)
|
||||||
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
return int(float(size) / scale);
|
||||||
|
}
|
|
@ -14,3 +14,13 @@
|
||||||
return ivec2(vec2(inputVec) * scale);
|
return ivec2(vec2(inputVec) * scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Helper_TextureSizeUnscale(int size, int samplerIndex)
|
||||||
|
{
|
||||||
|
float scale = abs(fp_renderScale[1 + samplerIndex]);
|
||||||
|
if (scale == 1.0)
|
||||||
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
return int(float(size) / scale);
|
||||||
|
}
|
|
@ -55,15 +55,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||||
|
|
||||||
string ApplyScaling(string vector)
|
string ApplyScaling(string vector)
|
||||||
{
|
{
|
||||||
int index = context.FindImageDescriptorIndex(texOp);
|
|
||||||
|
|
||||||
if ((context.Config.Stage == ShaderStage.Fragment || context.Config.Stage == ShaderStage.Compute) &&
|
if ((context.Config.Stage == ShaderStage.Fragment || context.Config.Stage == ShaderStage.Compute) &&
|
||||||
texOp.Inst == Instruction.ImageLoad &&
|
texOp.Inst == Instruction.ImageLoad &&
|
||||||
!isBindless &&
|
!isBindless &&
|
||||||
!isIndexed)
|
!isIndexed)
|
||||||
{
|
{
|
||||||
// Image scales start after texture ones.
|
// Image scales start after texture ones.
|
||||||
int scaleIndex = context.Config.GetTextureDescriptors().Length + index;
|
int scaleIndex = context.Config.GetTextureDescriptors().Length + context.FindImageDescriptorIndex(texOp);
|
||||||
|
|
||||||
if (pCount == 3 && isArray)
|
if (pCount == 3 && isArray)
|
||||||
{
|
{
|
||||||
|
@ -461,12 +459,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||||
{
|
{
|
||||||
if (intCoords)
|
if (intCoords)
|
||||||
{
|
{
|
||||||
int index = context.FindTextureDescriptorIndex(texOp);
|
|
||||||
|
|
||||||
if ((context.Config.Stage == ShaderStage.Fragment || context.Config.Stage == ShaderStage.Compute) &&
|
if ((context.Config.Stage == ShaderStage.Fragment || context.Config.Stage == ShaderStage.Compute) &&
|
||||||
!isBindless &&
|
!isBindless &&
|
||||||
!isIndexed)
|
!isIndexed)
|
||||||
{
|
{
|
||||||
|
int index = context.FindTextureDescriptorIndex(texOp);
|
||||||
|
|
||||||
if (pCount == 3 && isArray)
|
if (pCount == 3 && isArray)
|
||||||
{
|
{
|
||||||
// The array index is not scaled, just x and y.
|
// The array index is not scaled, just x and y.
|
||||||
|
@ -608,7 +606,18 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $"textureSize({samplerName}, {lodExpr}){GetMask(texOp.Index)}";
|
string texCall = $"textureSize({samplerName}, {lodExpr}){GetMask(texOp.Index)}";
|
||||||
|
|
||||||
|
if ((context.Config.Stage == ShaderStage.Fragment || context.Config.Stage == ShaderStage.Compute) &&
|
||||||
|
!isBindless &&
|
||||||
|
!isIndexed)
|
||||||
|
{
|
||||||
|
int index = context.FindTextureDescriptorIndex(texOp);
|
||||||
|
|
||||||
|
texCall = "Helper_TextureSizeUnscale(" + texCall + ", " + index + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
return texCall;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1056,6 +1056,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.Config.SetUsedFeature(FeatureFlags.IntegerSampling);
|
||||||
|
|
||||||
TextureProperty property = (TextureProperty)op.RawOpCode.Extract(22, 6);
|
TextureProperty property = (TextureProperty)op.RawOpCode.Extract(22, 6);
|
||||||
|
|
||||||
// TODO: Validate and use property.
|
// TODO: Validate and use property.
|
||||||
|
|
|
@ -242,7 +242,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetUsedTextureOrImage(_usedTextures, cbufSlot, handle, type, TextureFormat.Unknown, flags.HasFlag(TextureFlags.IntCoords), false, accurateType);
|
bool intCoords = flags.HasFlag(TextureFlags.IntCoords) || inst == Instruction.TextureSize;
|
||||||
|
SetUsedTextureOrImage(_usedTextures, cbufSlot, handle, type, TextureFormat.Unknown, intCoords, false, accurateType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue