[Optimize] (MG_Backend/DirectVulkan): store textureResources in permanent scratch space rather than temp memory

This commit is contained in:
2026-03-05 09:44:03 +08:00
parent 139f3f978d
commit 668fa3033e
2 changed files with 4 additions and 7 deletions
@@ -116,7 +116,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
Vector<VkAttachmentDescription> attachmentDescriptions(validDrawBufCount); Vector<VkAttachmentDescription> attachmentDescriptions(validDrawBufCount);
Vector<VkAttachmentReference> colorAttachmentRefs(validDrawBufCount); Vector<VkAttachmentReference> colorAttachmentRefs(validDrawBufCount);
Vector<PendingClearAttachmentInfo> pendingClearAttachments; Vector<PendingClearAttachmentInfo> pendingClearAttachments;
Vector<VkTextureManager::TextureResource*> textureResources(validDrawBufCount, nullptr); auto& textureResources = RenderPassEntry::s_textureResourcesScratch;
textureResources.clear();
textureResources.resize(validDrawBufCount, nullptr);
Vector<VkImageView> attachmentViews(validDrawBufCount, VK_NULL_HANDLE); Vector<VkImageView> attachmentViews(validDrawBufCount, VK_NULL_HANDLE);
// This should automatically work on default & offscreen FBO // This should automatically work on default & offscreen FBO
// assuming default FBO has the right param // assuming default FBO has the right param
@@ -290,7 +292,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
renderPass, renderPass,
framebuffer, framebuffer,
compatibilityHash, compatibilityHash,
Move(textureResources),
Move(pendingClearAttachments), Move(pendingClearAttachments),
static_cast<Uint32>(attachmentViews.size()), static_cast<Uint32>(attachmentViews.size()),
extent, extent,
@@ -25,11 +25,10 @@ namespace MobileGL::MG_Backend::DirectVulkan {
struct RenderPassEntry { struct RenderPassEntry {
static inline VkDevice s_device; static inline VkDevice s_device;
static inline Vector<VkTextureManager::TextureResource*> s_textureResourcesScratch;
VkRenderPass renderPass = VK_NULL_HANDLE; VkRenderPass renderPass = VK_NULL_HANDLE;
VkFramebuffer framebuffer = VK_NULL_HANDLE; VkFramebuffer framebuffer = VK_NULL_HANDLE;
Uint64 compatibilityHash = 0; Uint64 compatibilityHash = 0;
// Should we hold pointer-to-resource here?
Vector<VkTextureManager::TextureResource*> textureResources;
Vector<PendingClearAttachmentInfo> pendingClearAttachments; Vector<PendingClearAttachmentInfo> pendingClearAttachments;
Uint32 attachmentCount = 0; Uint32 attachmentCount = 0;
IntVec2 extent = {0, 0}; IntVec2 extent = {0, 0};
@@ -41,7 +40,6 @@ namespace MobileGL::MG_Backend::DirectVulkan {
std::swap(renderPass, that.renderPass); std::swap(renderPass, that.renderPass);
std::swap(framebuffer, that.framebuffer); std::swap(framebuffer, that.framebuffer);
std::swap(compatibilityHash, that.compatibilityHash); std::swap(compatibilityHash, that.compatibilityHash);
std::swap(textureResources, that.textureResources);
std::swap(pendingClearAttachments, that.pendingClearAttachments); std::swap(pendingClearAttachments, that.pendingClearAttachments);
std::swap(attachmentCount, that.attachmentCount); std::swap(attachmentCount, that.attachmentCount);
std::swap(extent, that.extent); std::swap(extent, that.extent);
@@ -51,14 +49,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
VkRenderPass renderpass, VkRenderPass renderpass,
VkFramebuffer framebuffer, VkFramebuffer framebuffer,
Uint64 compatibilityHash, Uint64 compatibilityHash,
const std::vector<VkTextureManager::TextureResource*>& textureResources,
const Vector<PendingClearAttachmentInfo>& pendingClearAttachments, const Vector<PendingClearAttachmentInfo>& pendingClearAttachments,
Uint32 attachmentCount, Uint32 attachmentCount,
IntVec2 extent, int subpass): IntVec2 extent, int subpass):
renderPass(renderpass), renderPass(renderpass),
framebuffer(framebuffer), framebuffer(framebuffer),
compatibilityHash(compatibilityHash), compatibilityHash(compatibilityHash),
textureResources(Move(textureResources)),
pendingClearAttachments(Move(pendingClearAttachments)), pendingClearAttachments(Move(pendingClearAttachments)),
attachmentCount(attachmentCount), attachmentCount(attachmentCount),
extent(extent), extent(extent),