aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-07-29 18:47:03 -0300
committerGitHub <noreply@github.com>2023-07-29 18:47:03 -0300
commitf95b7c58779f01d9077996da67953d8d9acd058c (patch)
treeb0be466b2e52f966620aa2e0acb4524d28da1b22 /src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
parenteb528ae0f05f057e671eb9e92f44f1caa9bcc84b (diff)
Fix incorrect fragment origin when YNegate is enabled (#4673)1.1.970
* Fix incorrect fragment origin when YNegate is enabled * Shader cache version bump * Do not update support buffer if shader does not read gl_FragCoord * Pass unscaled viewport size to the support buffer
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs')
-rw-r--r--src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
index 1876847c..c7bd0fd6 100644
--- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
+++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
@@ -161,6 +161,18 @@ namespace Ryujinx.Graphics.Shader.Instructions
// FragCoord X/Y must be divided by the render target scale, if resolution scaling is active,
// because the shader code is not expecting scaled values.
res = context.FPDivide(res, context.Load(StorageKind.ConstantBuffer, SupportBuffer.Binding, Const((int)SupportBufferField.RenderScale), Const(0)));
+
+ if (op.Imm10 == AttributeConsts.PositionY && context.Config.Options.TargetApi != TargetApi.OpenGL)
+ {
+ // If YNegate is enabled, we need to flip the fragment coordinates vertically, unless
+ // the API supports changing the origin (only OpenGL does).
+ if (context.Config.GpuAccessor.QueryYNegateEnabled())
+ {
+ Operand viewportHeight = context.Load(StorageKind.ConstantBuffer, 0, Const((int)SupportBufferField.ViewportSize), Const(1));
+
+ res = context.FPSubtract(viewportHeight, res);
+ }
+ }
}
else if (op.Imm10 == AttributeConsts.FrontFacing && context.Config.GpuAccessor.QueryHostHasFrontFacingBug())
{