Fix render target clear when sizes mismatch (#2994)

This commit is contained in:
gdkchan
2022-01-11 16:15:17 -03:00
committed by GitHub
parent ef24c8983d
commit 6e0799580f
9 changed files with 181 additions and 25 deletions

View File

@ -339,6 +339,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
var scissor = _state.State.ScreenScissorState;
Size sizeHint = new Size(scissor.X + scissor.Width, scissor.Y + scissor.Height, 1);
int clipRegionWidth = int.MaxValue;
int clipRegionHeight = int.MaxValue;
bool changedScale = false;
for (int index = 0; index < Constants.TotalRenderTargets; index++)
@ -363,6 +366,19 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
sizeHint);
changedScale |= _channel.TextureManager.SetRenderTargetColor(index, color);
if (color != null)
{
if (clipRegionWidth > color.Width)
{
clipRegionWidth = color.Width;
}
if (clipRegionHeight > color.Height)
{
clipRegionHeight = color.Height;
}
}
}
bool dsEnable = _state.State.RtDepthStencilEnable;
@ -381,6 +397,19 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
samplesInX,
samplesInY,
sizeHint);
if (depthStencil != null)
{
if (clipRegionWidth > depthStencil.Width)
{
clipRegionWidth = depthStencil.Width;
}
if (clipRegionHeight > depthStencil.Height)
{
clipRegionHeight = depthStencil.Height;
}
}
}
changedScale |= _channel.TextureManager.SetRenderTargetDepthStencil(depthStencil);
@ -398,6 +427,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
UpdateScissorState();
}
}
_channel.TextureManager.SetClipRegion(clipRegionWidth, clipRegionHeight);
}
/// <summary>
@ -414,7 +445,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <summary>
/// Updates host scissor test state based on current GPU state.
/// </summary>
private void UpdateScissorState()
public void UpdateScissorState()
{
for (int index = 0; index < Constants.TotalViewports; index++)
{