From f95b7c58779f01d9077996da67953d8d9acd058c Mon Sep 17 00:00:00 2001 From: gdkchan <gab.dark.100@gmail.com> Date: Sat, 29 Jul 2023 18:47:03 -0300 Subject: Fix incorrect fragment origin when YNegate is enabled (#4673) * 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 --- .../Memory/SupportBufferUpdater.cs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs') diff --git a/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs index 50c042fb..b236476e 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs @@ -112,6 +112,17 @@ namespace Ryujinx.Graphics.Gpu.Memory MarkDirty(SupportBuffer.ViewportInverseOffset, SupportBuffer.FieldSize); } + /// <summary> + /// Updates the viewport size vector. + /// </summary> + /// <param name="data">Viewport size vector</param> + private void UpdateViewportSize(Vector4<float> data) + { + _data.ViewportSize = data; + + MarkDirty(SupportBuffer.ViewportSizeOffset, SupportBuffer.FieldSize); + } + /// <summary> /// Sets the scale of all output render targets (they should all have the same scale). /// </summary> @@ -192,6 +203,25 @@ namespace Ryujinx.Graphics.Gpu.Memory } } + /// <summary> + /// Sets the viewport size, used to invert the fragment coordinates Y value. + /// </summary> + /// <param name="viewportWidth">Value used as viewport width</param> + /// <param name="viewportHeight">Value used as viewport height</param> + public void SetViewportSize(float viewportWidth, float viewportHeight) + { + if (_data.ViewportSize.X != viewportWidth || _data.ViewportSize.Y != viewportHeight) + { + UpdateViewportSize(new Vector4<float> + { + X = viewportWidth, + Y = viewportHeight, + Z = 1, + W = 0 + }); + } + } + /// <summary> /// Submits all pending buffer updates to the GPU. /// </summary> -- cgit v1.2.3-70-g09d2