aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-07-09 00:09:07 -0300
committerGitHub <noreply@github.com>2021-07-09 00:09:07 -0300
commit59900d7f00b14681acfc7ef5e8d1e18d53664e1c (patch)
tree7823b6bb6615ab21d194ba74de4f25181640a537 /Ryujinx.Graphics.Shader/CodeGen
parentb02719cf4173c0ca26e6d562424eba68965ce59c (diff)
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
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_cp.glsl10
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_fp.glsl10
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs21
3 files changed, 35 insertions, 6 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_cp.glsl b/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_cp.glsl
index 88d18246..abc3f428 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_cp.glsl
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_cp.glsl
@@ -6,4 +6,14 @@
return inputVec;
}
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);
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_fp.glsl b/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_fp.glsl
index 2e166a4b..c13e2368 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_fp.glsl
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/TexelFetchScale_fp.glsl
@@ -13,4 +13,14 @@
{
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);
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs
index cb99bdcc..f6aab74d 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs
@@ -55,15 +55,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
string ApplyScaling(string vector)
{
- int index = context.FindImageDescriptorIndex(texOp);
-
if ((context.Config.Stage == ShaderStage.Fragment || context.Config.Stage == ShaderStage.Compute) &&
texOp.Inst == Instruction.ImageLoad &&
!isBindless &&
!isIndexed)
{
// 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)
{
@@ -461,12 +459,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
{
if (intCoords)
{
- int index = context.FindTextureDescriptorIndex(texOp);
-
if ((context.Config.Stage == ShaderStage.Fragment || context.Config.Stage == ShaderStage.Compute) &&
!isBindless &&
!isIndexed)
{
+ int index = context.FindTextureDescriptorIndex(texOp);
+
if (pCount == 3 && isArray)
{
// The array index is not scaled, just x and y.
@@ -608,7 +606,18 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
}
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;
}
}