Implement GPU scissors (#1058)

* Implement GPU scissors

* Remove unused using

* Add missing changes for Clear
This commit is contained in:
gdkchan 2020-03-29 00:02:58 -03:00 committed by GitHub
parent 06bf25521f
commit ab4867505e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 107 additions and 7 deletions

View file

@ -117,6 +117,11 @@ namespace Ryujinx.Graphics.Gpu.Engine
UpdateRenderTargetState(state, useControl: true);
}
if (state.QueryModified(MethodOffset.ScissorState))
{
UpdateScissorState(state);
}
if (state.QueryModified(MethodOffset.DepthTestEnable,
MethodOffset.DepthWriteEnable,
MethodOffset.DepthTestFunc))
@ -321,6 +326,27 @@ namespace Ryujinx.Graphics.Gpu.Engine
return colorState.Format != 0 && colorState.WidthOrStride != 0;
}
/// <summary>
/// Updates host scissor test state based on current GPU state.
/// </summary>
/// <param name="state">Current GPU state</param>
private void UpdateScissorState(GpuState state)
{
for (int index = 0; index < Constants.TotalViewports; index++)
{
ScissorState scissor = state.Get<ScissorState>(MethodOffset.ScissorState, index);
bool enable = scissor.Enable && (scissor.X1 != 0 || scissor.Y1 != 0 || scissor.X2 != 0xffff || scissor.Y2 != 0xffff);
_context.Renderer.Pipeline.SetScissorEnable(index, enable);
if (enable)
{
_context.Renderer.Pipeline.SetScissor(index, scissor.X1, scissor.Y1, scissor.X2 - scissor.X1, scissor.Y2 - scissor.Y1);
}
}
}
/// <summary>
/// Updates host depth test state based on current GPU state.
/// </summary>