From 7cabcad69ee8e8be65d4db438cfc1553f5dde857 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 25 May 2015 14:58:04 -0700 Subject: [PATCH] f5 now also clears cached framebuffers/targets. --- src/xenia/gpu/gl4/command_processor.cc | 19 +++++++++++++++++++ src/xenia/gpu/gl4/command_processor.h | 2 ++ src/xenia/gpu/gl4/gl4_graphics_system.cc | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) 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() {