mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-18 17:16:39 +00:00
Implement Force Early Z Register (#1755)
This commit is contained in:
parent
e383c41b6e
commit
461c24092a
8 changed files with 60 additions and 2 deletions
|
@ -332,6 +332,23 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builds gpu state flags using information from the given gpu accessor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gpuAccessor">The gpu accessor</param>
|
||||||
|
/// <returns>The gpu state flags</returns>
|
||||||
|
private static GuestGpuStateFlags GetGpuStateFlags(IGpuAccessor gpuAccessor)
|
||||||
|
{
|
||||||
|
GuestGpuStateFlags flags = 0;
|
||||||
|
|
||||||
|
if (gpuAccessor.QueryEarlyZForce())
|
||||||
|
{
|
||||||
|
flags |= GuestGpuStateFlags.EarlyZForce;
|
||||||
|
}
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new instance of <see cref="GuestGpuAccessorHeader"/> from an gpu accessor.
|
/// Create a new instance of <see cref="GuestGpuAccessorHeader"/> from an gpu accessor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -347,6 +364,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
|
||||||
ComputeLocalMemorySize = gpuAccessor.QueryComputeLocalMemorySize(),
|
ComputeLocalMemorySize = gpuAccessor.QueryComputeLocalMemorySize(),
|
||||||
ComputeSharedMemorySize = gpuAccessor.QueryComputeSharedMemorySize(),
|
ComputeSharedMemorySize = gpuAccessor.QueryComputeSharedMemorySize(),
|
||||||
PrimitiveTopology = gpuAccessor.QueryPrimitiveTopology(),
|
PrimitiveTopology = gpuAccessor.QueryPrimitiveTopology(),
|
||||||
|
StateFlags = GetGpuStateFlags(gpuAccessor)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache.Definition
|
||||||
public ushort Reserved2;
|
public ushort Reserved2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unused/reserved.
|
/// GPU boolean state that can influence shader compilation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte Reserved3;
|
public GuestGpuStateFlags StateFlags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.Graphics.Gpu.Shader.Cache.Definition
|
||||||
|
{
|
||||||
|
[Flags]
|
||||||
|
enum GuestGpuStateFlags : byte
|
||||||
|
{
|
||||||
|
EarlyZForce = 1 << 0
|
||||||
|
}
|
||||||
|
}
|
|
@ -150,5 +150,14 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
|
|
||||||
return textureDescriptor;
|
return textureDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Queries if host state forces early depth testing.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if early depth testing is forced</returns>
|
||||||
|
public bool QueryEarlyZForce()
|
||||||
|
{
|
||||||
|
return (_header.StateFlags & GuestGpuStateFlags.EarlyZForce) != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,5 +196,14 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
return _context.Methods.TextureManager.GetGraphicsTextureDescriptor(_state, _stageIndex, handle);
|
return _context.Methods.TextureManager.GetGraphicsTextureDescriptor(_state, _stageIndex, handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Queries if host state forces early depth testing.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if early depth testing is forced</returns>
|
||||||
|
public bool QueryEarlyZForce()
|
||||||
|
{
|
||||||
|
return _state.Get<bool>(MethodOffset.EarlyZForce);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Ryujinx.Graphics.Gpu.State
|
||||||
LaunchDma = 0x6c,
|
LaunchDma = 0x6c,
|
||||||
LoadInlineData = 0x6d,
|
LoadInlineData = 0x6d,
|
||||||
CopyDstTexture = 0x80,
|
CopyDstTexture = 0x80,
|
||||||
|
EarlyZForce = 0x84,
|
||||||
CopySrcTexture = 0x8c,
|
CopySrcTexture = 0x8c,
|
||||||
DispatchParamsAddress = 0xad,
|
DispatchParamsAddress = 0xad,
|
||||||
Dispatch = 0xaf,
|
Dispatch = 0xaf,
|
||||||
|
|
|
@ -141,6 +141,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||||
{
|
{
|
||||||
if (context.Config.Stage == ShaderStage.Fragment)
|
if (context.Config.Stage == ShaderStage.Fragment)
|
||||||
{
|
{
|
||||||
|
if (context.Config.GpuAccessor.QueryEarlyZForce())
|
||||||
|
{
|
||||||
|
context.AppendLine("layout(early_fragment_tests) in;");
|
||||||
|
context.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
context.AppendLine($"uniform bool {DefaultNames.IsBgraName}[8];");
|
context.AppendLine($"uniform bool {DefaultNames.IsBgraName}[8];");
|
||||||
context.AppendLine();
|
context.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,5 +78,10 @@
|
||||||
{
|
{
|
||||||
return TextureFormat.R8G8B8A8Unorm;
|
return TextureFormat.R8G8B8A8Unorm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QueryEarlyZForce()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue