Permalink
Browse files

Stop leaking framebuffers on shutdown. Fix other shutdown issues.

  • Loading branch information...
hrydgard committed Nov 1, 2017
1 parent 0e5b398 commit 8d0209c7e46b3662bcedd907ca38b38b70827581
@@ -118,6 +118,22 @@ FramebufferManagerCommon::FramebufferManagerCommon(Draw::DrawContext *draw)
}
FramebufferManagerCommon::~FramebufferManagerCommon() {
DecimateFBOs();
for (auto vfb : vfbs_) {
DestroyFramebuf(vfb);
}
vfbs_.clear();
for (auto &tempFB : tempFBOs_) {
tempFB.second.fbo->Release();
}
tempFBOs_.clear();
// Do the same for ReadFramebuffersToMemory's VFBs
for (auto vfb : bvfbs_) {
DestroyFramebuf(vfb);
}
bvfbs_.clear();
}
void FramebufferManagerCommon::Init() {
View
@@ -984,6 +984,8 @@ void EmuScreen::postRender() {
Draw::DrawContext *draw = screenManager()->getDrawContext();
if (!draw)
return;
if (invalid_)
draw->WipeQueue();
draw->EndFrame();
}
@@ -554,6 +554,14 @@ void VulkanRenderManager::Finish() {
vulkan_->EndFrame();
}
void VulkanRenderManager::Wipe() {
int curFrame = vulkan_->GetCurFrame();
for (auto iter : steps_) {
delete iter;
}
steps_.clear();
}
// Can be called multiple times with no bad side effects. This is so that we can either begin a frame the normal way,
// or stop it in the middle for a synchronous readback, then start over again mostly normally but without repeating
// the backbuffer image acquisition.
@@ -83,6 +83,9 @@ class VulkanRenderManager {
void Finish();
void Run(int frame);
// Zaps queued up commands. Use if you know there's a risk you've queued up stuff that has already been deleted. Can happen during in-game shutdown.
void Wipe();
void BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassAction color, VKRRenderPassAction depth, uint32_t clearColor, float clearDepth, uint8_t clearStencil);
VkImageView BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, int aspectBit, int attachment);
void CopyFramebufferToMemorySync(VKRFramebuffer *src, int aspectBits, int x, int y, int w, int h, Draw::DataFormat destFormat, uint8_t *pixels, int pixelStride);
@@ -609,6 +609,7 @@ class DrawContext {
// Frame management (for the purposes of sync and resource management, necessary with modern APIs). Default implementations here.
virtual void BeginFrame() {}
virtual void EndFrame() {}
virtual void WipeQueue() {}
// This should be avoided as much as possible, in favor of clearing when binding a render target, which is native
// on Vulkan.
@@ -418,6 +418,7 @@ class VKContext : public DrawContext {
void BeginFrame() override;
void EndFrame() override;
void WipeQueue() override;
void FlushState() override {
}
@@ -766,6 +767,10 @@ void VKContext::EndFrame() {
push_ = nullptr;
}
void VKContext::WipeQueue() {
renderManager_.Wipe();
}
VkDescriptorSet VKContext::GetOrCreateDescriptorSet(VkBuffer buf) {
DescriptorSetKey key;

0 comments on commit 8d0209c

Please sign in to comment.