[Fix] (MG_Backend/DirectVulkan): materialize mid-pass pending color clears at the subpass color slot index, not the compacted description index

This commit is contained in:
2026-07-16 21:18:00 -04:00
parent 5184901a5b
commit 37ef2cb600
3 changed files with 9 additions and 1 deletions
@@ -718,6 +718,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
if (hasClear) {
pendingClearAttachments.emplace_back(PendingClearAttachmentInfo {
.attachmentIndex = attachmentIndex,
.colorAttachmentSlot = i,
.key = VkClearManager::MakePendingClearKey(att)
});
}
@@ -27,7 +27,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
};
struct PendingClearAttachmentInfo {
// Index into the render pass attachment descriptions (VkRenderPassBeginInfo::pClearValues space).
Uint32 attachmentIndex = 0;
// Index into the subpass pColorAttachments (VkClearAttachment::colorAttachment space) — the GL
// draw-buffer slot. Differs from attachmentIndex when earlier slots are GL_NONE/incomplete.
// Only meaningful for color clears.
Uint32 colorAttachmentSlot = 0;
PendingClearKey key{};
MG_State::GLState::RenderbufferObject* renderbuffer = nullptr;
Bool hasInlinePayload = false;
@@ -6908,7 +6908,9 @@ void main() {
clearAttachment.clearValue.depthStencil = {1.0f, 0};
if ((clearPayload.mask & GL_COLOR_BUFFER_BIT) != 0) {
clearAttachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
clearAttachment.colorAttachment = pending.attachmentIndex;
// VkClearAttachment::colorAttachment indexes the subpass pColorAttachments (draw-buffer
// slot space, with UNUSED holes), not the compacted attachment descriptions.
clearAttachment.colorAttachment = pending.colorAttachmentSlot;
clearAttachment.clearValue.color = {
clearPayload.color.x(),
clearPayload.color.y(),