Do not clear unbound framebuffer color attachments

This commit is contained in:
gdk 2022-04-13 22:46:51 -03:00 committed by riperiperi
parent de87ed3edc
commit 2713703d45
2 changed files with 11 additions and 3 deletions

View file

@ -10,12 +10,13 @@ namespace Ryujinx.Graphics.Vulkan
{
private readonly Device _device;
private readonly Auto<DisposableImageView>[] _attachments;
private uint _validColorAttachments;
public uint Width { get; }
public uint Height { get; }
public uint Layers { get; }
public uint[] AttachmentSamples { get; }
public uint[] AttachmentSamples { get; }
public VkFormat[] AttachmentFormats { get; }
public int[] AttachmentIndices { get; }
@ -34,6 +35,7 @@ namespace Ryujinx.Graphics.Vulkan
{
_device = device;
_attachments = new[] { view };
_validColorAttachments = 1u;
Width = width;
Height = height;
@ -77,6 +79,7 @@ namespace Ryujinx.Graphics.Vulkan
var texture = (TextureView)color;
_attachments[index] = texture.GetImageViewForAttachment();
_validColorAttachments |= 1u << bindIndex;
AttachmentSamples[index] = (uint)texture.Info.Samples;
AttachmentFormats[index] = texture.VkFormat;
@ -131,6 +134,11 @@ namespace Ryujinx.Graphics.Vulkan
return _attachments[index];
}
public bool IsVaidColorAttachment(int bindIndex)
{
return (uint)bindIndex < Constants.MaxRenderTargets && (_validColorAttachments & (1u << bindIndex)) != 0;
}
private static bool IsValidTextureView(ITexture texture)
{
return texture is TextureView view && view.Valid;

View file

@ -167,7 +167,7 @@ namespace Ryujinx.Graphics.Vulkan
public unsafe void ClearRenderTargetColor(int index, ColorF color)
{
if (_framebuffer == null)
if (FramebufferParams == null || !FramebufferParams.IsVaidColorAttachment(index))
{
return;
}
@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.Vulkan
{
// TODO: Use stencilMask (fully)
if (_framebuffer == null || !FramebufferParams.HasDepthStencil)
if (FramebufferParams == null || !FramebufferParams.HasDepthStencil)
{
return;
}