[vulkan] send full attachements at all times (including unused ones) to clear potential stale/invalid descriptors getting left out

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2026-04-25 00:40:05 +00:00
parent 91058d7383
commit c1ae0b2f0b

View file

@ -75,28 +75,26 @@ VkRenderPass RenderPassCache::Get(const RenderPassKey& key) {
if (!is_new) { if (!is_new) {
return *pair->second; return *pair->second;
} }
boost::container::static_vector<VkAttachmentDescription, 9> descriptions; boost::container::static_vector<VkAttachmentDescription, MaxwellToVK::Maxwell::NumRenderTargets + 1> descriptions;
std::array<VkAttachmentReference, 8> references{}; std::array<VkAttachmentReference, MaxwellToVK::Maxwell::NumRenderTargets> references{};
u32 num_attachments{}; std::ranges::fill(references, VkAttachmentReference{
u32 num_colors{}; .attachment = VK_ATTACHMENT_UNUSED,
for (size_t index = 0; index < key.color_formats.size(); ++index) { .layout = VK_IMAGE_LAYOUT_GENERAL
const PixelFormat format{key.color_formats[index]}; });
const bool is_valid{format != PixelFormat::Invalid}; for (size_t i = 0; i < key.color_formats.size(); ++i) {
references[index] = VkAttachmentReference{ if (auto const format = key.color_formats[i]; format != PixelFormat::Invalid) {
.attachment = is_valid ? num_colors : VK_ATTACHMENT_UNUSED, references[i] = VkAttachmentReference{
.layout = VK_IMAGE_LAYOUT_GENERAL, .attachment = u32(descriptions.size()),
}; .layout = VK_IMAGE_LAYOUT_GENERAL,
if (is_valid) { };
descriptions.push_back(AttachmentDescription(*device, format, key.samples)); descriptions.push_back(AttachmentDescription(*device, format, key.samples));
num_attachments = static_cast<u32>(index + 1);
++num_colors;
} }
} }
const bool has_depth{key.depth_format != PixelFormat::Invalid}; const bool has_depth{key.depth_format != PixelFormat::Invalid};
VkAttachmentReference depth_reference{}; VkAttachmentReference depth_reference{};
if (key.depth_format != PixelFormat::Invalid) { if (key.depth_format != PixelFormat::Invalid) {
depth_reference = VkAttachmentReference{ depth_reference = VkAttachmentReference{
.attachment = num_colors, .attachment = u32(descriptions.size()),
.layout = VK_IMAGE_LAYOUT_GENERAL, .layout = VK_IMAGE_LAYOUT_GENERAL,
}; };
descriptions.push_back(AttachmentDescription(*device, key.depth_format, key.samples)); descriptions.push_back(AttachmentDescription(*device, key.depth_format, key.samples));
@ -106,7 +104,7 @@ VkRenderPass RenderPassCache::Get(const RenderPassKey& key) {
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.inputAttachmentCount = 0, .inputAttachmentCount = 0,
.pInputAttachments = nullptr, .pInputAttachments = nullptr,
.colorAttachmentCount = num_attachments, .colorAttachmentCount = u32(references.size()),
.pColorAttachments = references.data(), .pColorAttachments = references.data(),
.pResolveAttachments = nullptr, .pResolveAttachments = nullptr,
.pDepthStencilAttachment = has_depth ? &depth_reference : nullptr, .pDepthStencilAttachment = has_depth ? &depth_reference : nullptr,