Implement user-defined clipping on GL state pipeline (#1118)

This commit is contained in:
mageven 2020-05-04 07:34:49 +05:30 committed by GitHub
parent 12399b8aea
commit 53369e79bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 0 deletions

View file

@ -125,6 +125,11 @@ namespace Ryujinx.Graphics.Gpu.Engine
UpdateShaderState(state);
}
if (state.QueryModified(MethodOffset.ClipDistanceEnable))
{
UpdateUserClipState(state);
}
if (state.QueryModified(MethodOffset.RasterizeEnable))
{
UpdateRasterizerState(state);
@ -902,6 +907,20 @@ namespace Ryujinx.Graphics.Gpu.Engine
_context.Renderer.Pipeline.SetProgram(gs.HostProgram);
}
/// <summary>
/// Updates user-defined clipping based on the guest GPU state.
/// </summary>
/// <param name="state">Current GPU state</param>
private void UpdateUserClipState(GpuState state)
{
int clipMask = state.Get<int>(MethodOffset.ClipDistanceEnable);
for (int i = 0; i < Constants.TotalClipDistances; ++i)
{
_context.Renderer.Pipeline.SetUserClipDistance(i, (clipMask & (1 << i)) != 0);
}
}
/// <summary>
/// Gets texture target from a sampler type.
/// </summary>