aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Shader
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-05-27 20:03:07 -0300
committerGitHub <noreply@github.com>2020-05-28 09:03:07 +1000
commita15b951721d7c52c30a8e8864e91353ec6fc65f4 (patch)
treedaba23b1f6a22f4c72faa5268a73029e9fc665f7 /Ryujinx.Graphics.Gpu/Shader
parent83d94b21d077e2d31faee74711ff38e0c0499afa (diff)
Fix wrong face culling once and for all (#1277)
* Viewport swizzle support on NV and clip origin * Initialize default viewport swizzle state, emulate viewport swizzle on shaders when not supported * Address PR feedback
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader')
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
index 76b06ea5..2774b7d1 100644
--- a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
@@ -3,6 +3,7 @@ using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Gpu.State;
using Ryujinx.Graphics.Shader;
+using System;
namespace Ryujinx.Graphics.Gpu.Shader
{
@@ -188,6 +189,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
public bool QuerySupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset;
/// <summary>
+ /// Queries host GPU viewport swizzle support.
+ /// </summary>
+ /// <returns>True if the GPU and driver supports viewport swizzle, false otherwise</returns>
+ public bool QuerySupportsViewportSwizzle() => _context.Capabilities.SupportsViewportSwizzle;
+
+ /// <summary>
/// Queries texture format information, for shaders using image load or store.
/// </summary>
/// <remarks>
@@ -250,6 +257,24 @@ namespace Ryujinx.Graphics.Gpu.Shader
};
}
+ public int QueryViewportSwizzle(int component)
+ {
+ YControl yControl = _state.Get<YControl>(MethodOffset.YControl);
+
+ bool flipY = yControl.HasFlag(YControl.NegateY) ^ !yControl.HasFlag(YControl.TriangleRastFlip);
+
+ ViewportTransform transform = _state.Get<ViewportTransform>(MethodOffset.ViewportTransform, 0);
+
+ return component switch
+ {
+ 0 => (int)(transform.UnpackSwizzleX() ^ (transform.ScaleX < 0 ? ViewportSwizzle.NegativeFlag : 0)),
+ 1 => (int)(transform.UnpackSwizzleY() ^ (transform.ScaleY < 0 ? ViewportSwizzle.NegativeFlag : 0) ^ (flipY ? ViewportSwizzle.NegativeFlag : 0)),
+ 2 => (int)(transform.UnpackSwizzleZ() ^ (transform.ScaleZ < 0 ? ViewportSwizzle.NegativeFlag : 0)),
+ 3 => (int)transform.UnpackSwizzleW(),
+ _ => throw new ArgumentOutOfRangeException(nameof(component))
+ };
+ }
+
/// <summary>
/// Gets the texture descriptor for a given texture on the pool.
/// </summary>