mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
fix(vulkan): defer resource frees until frame fence
This commit is contained in:
parent
edd934a3e3
commit
6cfb439fd6
4 changed files with 118 additions and 49 deletions
|
|
@ -57,6 +57,15 @@ public:
|
|||
void pollUploadBatches(); // Check completed async uploads, free staging buffers
|
||||
void waitAllUploads(); // Block until all in-flight uploads complete
|
||||
|
||||
// Defer resource destruction until it is safe with multiple frames in flight.
|
||||
//
|
||||
// This queues work to run after the fence for the *current frame slot* has
|
||||
// signaled the next time we enter beginFrame() for that slot (i.e. after
|
||||
// MAX_FRAMES_IN_FLIGHT submissions). Use this for resources that may still
|
||||
// be referenced by command buffers submitted in the previous frame(s),
|
||||
// such as descriptor sets and buffers freed during streaming/unload.
|
||||
void deferAfterFrameFence(std::function<void()>&& fn);
|
||||
|
||||
// Accessors
|
||||
VkInstance getInstance() const { return instance; }
|
||||
VkPhysicalDevice getPhysicalDevice() const { return physicalDevice; }
|
||||
|
|
@ -173,6 +182,9 @@ private:
|
|||
};
|
||||
std::vector<InFlightBatch> inFlightBatches_;
|
||||
|
||||
void runDeferredCleanup(uint32_t frameIndex);
|
||||
std::vector<std::function<void()>> deferredCleanup_[MAX_FRAMES_IN_FLIGHT];
|
||||
|
||||
// Depth buffer (shared across all framebuffers)
|
||||
VkImage depthImage = VK_NULL_HANDLE;
|
||||
VkImageView depthImageView = VK_NULL_HANDLE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue