Handle mismatching texture size with copy dependencies (#4364)

* Handle mismatching texture size with copy dependencies

* Create copy and render textures with the minimum possible size

* Only align width for comparisons, assume that height is always exact

* Fix IsExactMatch size check

* Allow sampler and copy textures to match textures with larger width

* Delete texture ChangeSize related code

* Move AdjustSize to TextureInfo and give it a better name, adjust usages

* Fix GetMinimumWidthInGob when minimumWidth > width

* Only update render targets that are actually cleared for clear

Avoids creating textures with incorrect sizes

* Delete UpdateRenderTargetState method that is not needed anymore

Clears now only ever sets the render targets that will be cleared rather than all of them
This commit is contained in:
gdkchan 2023-02-08 04:48:09 -03:00 committed by GitHub
parent 59755818ef
commit 96cf242bcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 271 additions and 406 deletions

View file

@ -725,10 +725,25 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
return;
}
bool clearDepth = (argument & 1) != 0;
bool clearStencil = (argument & 2) != 0;
uint componentMask = (uint)((argument >> 2) & 0xf);
int index = (argument >> 6) & 0xf;
int layer = (argument >> 10) & 0x3ff;
engine.UpdateRenderTargetState(useControl: false, layered: layer != 0 || layerCount > 1, singleUse: index);
RenderTargetUpdateFlags updateFlags = RenderTargetUpdateFlags.SingleColor;
if (layer != 0 || layerCount > 1)
{
updateFlags |= RenderTargetUpdateFlags.Layered;
}
if (clearDepth || clearStencil)
{
updateFlags |= RenderTargetUpdateFlags.UpdateDepthStencil;
}
engine.UpdateRenderTargetState(updateFlags, singleUse: componentMask != 0 ? index : -1);
// If there is a mismatch on the host clip region and the one explicitly defined by the guest
// on the screen scissor state, then we need to force only one texture to be bound to avoid
@ -788,18 +803,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_context.Renderer.Pipeline.SetScissors(scissors);
}
if (clipMismatch)
{
_channel.TextureManager.UpdateRenderTarget(index);
}
else
{
_channel.TextureManager.UpdateRenderTargets();
}
bool clearDepth = (argument & 1) != 0;
bool clearStencil = (argument & 2) != 0;
uint componentMask = (uint)((argument >> 2) & 0xf);
_channel.TextureManager.UpdateRenderTargets();
if (componentMask != 0)
{
@ -841,7 +845,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
engine.UpdateScissorState();
}
engine.UpdateRenderTargetState(useControl: true);
engine.UpdateRenderTargetState(RenderTargetUpdateFlags.UpdateAll);
if (renderEnable == ConditionalRenderEnabled.Host)
{