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
This commit is contained in:
parent
83d94b21d0
commit
a15b951721
16 changed files with 202 additions and 53 deletions
|
@ -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
|
||||
{
|
||||
|
@ -187,6 +188,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <returns>True if the GPU and driver supports non-constant texture offsets, false otherwise</returns>
|
||||
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>
|
||||
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue