From 139f3f978dd44b29354c68e71891da7a4f7e8980 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Wed, 4 Mar 2026 16:19:35 +0800 Subject: [PATCH] [Chore] (MG_Backend/DirectVulkan): get rid of unnecessary checks --- .../Renderer/VkRenderPassManager.cpp | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp index 289b0238..ad8316de 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp @@ -315,28 +315,26 @@ namespace MobileGL::MG_Backend::DirectVulkan { clearValue.color = {0.0f, 0.0f, 0.0f, 1.0f}; clearValue.depthStencil = {1.0f, 0}; } - if (s_clearManager) { - for (const auto& pending: renderPassEntry.pendingClearAttachments) { - if (!pending.texture || pending.attachmentIndex >= clearValues.size()) { - continue; - } - ClearAttachmentPayload clearPayload{}; - if (!s_clearManager->GetPendingClear(pending.texture, clearPayload)) { - continue; - } - if (clearPayload.attachmentType >= FramebufferAttachmentType::Color0 && - clearPayload.attachmentType <= FramebufferAttachmentType::Color31) { - clearValues[pending.attachmentIndex].color = { - clearPayload.color.x(), - clearPayload.color.y(), - clearPayload.color.z(), - clearPayload.color.w() - }; - } else if (clearPayload.attachmentType == FramebufferAttachmentType::Depth) { - clearValues[pending.attachmentIndex].depthStencil.depth = clearPayload.depth; - } else if (clearPayload.attachmentType == FramebufferAttachmentType::Stencil) { - clearValues[pending.attachmentIndex].depthStencil.stencil = clearPayload.stencil; - } + for (const auto& pending: renderPassEntry.pendingClearAttachments) { + if (!pending.texture || pending.attachmentIndex >= clearValues.size()) { + continue; + } + ClearAttachmentPayload clearPayload{}; + if (!s_clearManager->GetPendingClear(pending.texture, clearPayload)) { + continue; + } + if (clearPayload.attachmentType >= FramebufferAttachmentType::Color0 && + clearPayload.attachmentType <= FramebufferAttachmentType::Color31) { + clearValues[pending.attachmentIndex].color = { + clearPayload.color.x(), + clearPayload.color.y(), + clearPayload.color.z(), + clearPayload.color.w() + }; + } else if (clearPayload.attachmentType == FramebufferAttachmentType::Depth) { + clearValues[pending.attachmentIndex].depthStencil.depth = clearPayload.depth; + } else if (clearPayload.attachmentType == FramebufferAttachmentType::Stencil) { + clearValues[pending.attachmentIndex].depthStencil.stencil = clearPayload.stencil; } } @@ -344,10 +342,8 @@ namespace MobileGL::MG_Backend::DirectVulkan { renderPassBeginInfo.pClearValues = clearValues.data(); vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); - if (s_clearManager) { - for (const auto& pending: renderPassEntry.pendingClearAttachments) { - s_clearManager->PopPendingClear(pending.texture); - } + for (const auto& pending: renderPassEntry.pendingClearAttachments) { + s_clearManager->PopPendingClear(pending.texture); } s_activeRenderPass = &renderPassEntry;