diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc index ceb5aade4..ae5d09fb2 100644 --- a/src/xenia/gpu/gl4/command_processor.cc +++ b/src/xenia/gpu/gl4/command_processor.cc @@ -171,6 +171,25 @@ void CommandProcessor::CallInThread(std::function fn) { } } +void CommandProcessor::ClearCaches() { + texture_cache()->Clear(); + + for (auto& cached_framebuffer : cached_framebuffers_) { + glDeleteFramebuffers(1, &cached_framebuffer.framebuffer); + } + cached_framebuffers_.clear(); + + for (auto& cached_color_render_target : cached_color_render_targets_) { + glDeleteTextures(1, &cached_color_render_target.texture); + } + cached_color_render_targets_.clear(); + + for (auto& cached_depth_render_target : cached_depth_render_targets_) { + glDeleteTextures(1, &cached_depth_render_target.texture); + } + cached_depth_render_targets_.clear(); +} + void CommandProcessor::WorkerThreadMain() { xe::threading::set_name("GL4 Worker"); diff --git a/src/xenia/gpu/gl4/command_processor.h b/src/xenia/gpu/gl4/command_processor.h index fe045bf13..2f1b782cc 100644 --- a/src/xenia/gpu/gl4/command_processor.h +++ b/src/xenia/gpu/gl4/command_processor.h @@ -70,6 +70,8 @@ class CommandProcessor { void Shutdown(); void CallInThread(std::function fn); + void ClearCaches(); + void set_swap_mode(SwapMode swap_mode) { swap_mode_ = swap_mode; } void IssueSwap(); void IssueSwap(uint32_t frontbuffer_width, uint32_t frontbuffer_height); diff --git a/src/xenia/gpu/gl4/gl4_graphics_system.cc b/src/xenia/gpu/gl4/gl4_graphics_system.cc index 5838bc7df..26672b6b4 100644 --- a/src/xenia/gpu/gl4/gl4_graphics_system.cc +++ b/src/xenia/gpu/gl4/gl4_graphics_system.cc @@ -237,7 +237,7 @@ void GL4GraphicsSystem::PlayTrace(const uint8_t* trace_data, size_t trace_size, void GL4GraphicsSystem::ClearCaches() { command_processor_->CallInThread( - [&]() { command_processor_->texture_cache()->Clear(); }); + [&]() { command_processor_->ClearCaches(); }); } void GL4GraphicsSystem::MarkVblank() {