diff --git a/Ryujinx.Graphics.Vulkan/FramebufferParams.cs b/Ryujinx.Graphics.Vulkan/FramebufferParams.cs index 5d9418491..e6b25ca85 100644 --- a/Ryujinx.Graphics.Vulkan/FramebufferParams.cs +++ b/Ryujinx.Graphics.Vulkan/FramebufferParams.cs @@ -10,12 +10,13 @@ namespace Ryujinx.Graphics.Vulkan { private readonly Device _device; private readonly Auto[] _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; diff --git a/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 41ffe3272..0fc0d46ce 100644 --- a/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -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; }