Hold reference for render targets in use (#2156)

This commit is contained in:
gdkchan 2021-04-02 11:33:39 -03:00 committed by GitHub
parent 9ae60207c4
commit f665e1b409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 29 deletions

View File

@ -1188,6 +1188,15 @@ namespace Ryujinx.Graphics.Gpu.Image
IsModified = true;
Group.SignalModifying(this, bound, !wasModified);
}
if (bound)
{
IncrementReferenceCount();
}
else
{
DecrementReferenceCount();
}
}
/// <summary>

View File

@ -197,6 +197,27 @@ namespace Ryujinx.Graphics.Gpu.Image
return changesScale || (hasValue && color.ScaleMode != TextureScaleMode.Blacklisted && color.ScaleFactor != GraphicsConfig.ResScale);
}
/// <summary>
/// Sets the render target depth-stencil buffer.
/// </summary>
/// <param name="depthStencil">The depth-stencil buffer texture</param>
/// <returns>True if render target scale must be updated.</returns>
public bool SetRenderTargetDepthStencil(Texture depthStencil)
{
bool hasValue = depthStencil != null;
bool changesScale = (hasValue != (_rtDepthStencil != null)) || (hasValue && RenderTargetScale != depthStencil.ScaleFactor);
if (_rtDepthStencil != depthStencil)
{
_rtDepthStencil?.SignalModifying(false);
depthStencil?.SignalModifying(true);
_rtDepthStencil = depthStencil;
}
return changesScale || (hasValue && depthStencil.ScaleMode != TextureScaleMode.Blacklisted && depthStencil.ScaleFactor != GraphicsConfig.ResScale);
}
/// <summary>
/// Gets the first available bound colour target, or the depth stencil target if not present.
/// </summary>
@ -290,27 +311,6 @@ namespace Ryujinx.Graphics.Gpu.Image
RenderTargetScale = targetScale;
}
/// <summary>
/// Sets the render target depth-stencil buffer.
/// </summary>
/// <param name="depthStencil">The depth-stencil buffer texture</param>
/// <returns>True if render target scale must be updated.</returns>
public bool SetRenderTargetDepthStencil(Texture depthStencil)
{
bool hasValue = depthStencil != null;
bool changesScale = (hasValue != (_rtDepthStencil != null)) || (hasValue && RenderTargetScale != depthStencil.ScaleFactor);
if (_rtDepthStencil != depthStencil)
{
_rtDepthStencil?.SignalModifying(false);
depthStencil?.SignalModifying(true);
_rtDepthStencil = depthStencil;
}
return changesScale || (hasValue && depthStencil.ScaleMode != TextureScaleMode.Blacklisted && depthStencil.ScaleFactor != GraphicsConfig.ResScale);
}
/// <summary>
/// Commits bindings on the compute pipeline.
/// </summary>