From 573d31414099ba2c23c2a5bb3e5b0a2b0d5df07d Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Tue, 15 May 2018 11:48:51 -0500 Subject: [PATCH] [GPU] Axe GraphicsSystem::Swap --- src/xenia/gpu/graphics_system.cc | 2 +- src/xenia/gpu/graphics_system.h | 2 - src/xenia/gpu/null/null_graphics_system.cc | 9 --- src/xenia/gpu/null/null_graphics_system.h | 1 - .../gpu/vulkan/vulkan_graphics_system.cc | 68 +------------------ src/xenia/gpu/vulkan/vulkan_graphics_system.h | 1 - 6 files changed, 2 insertions(+), 81 deletions(-) diff --git a/src/xenia/gpu/graphics_system.cc b/src/xenia/gpu/graphics_system.cc index 08d3107a9..7c13b7864 100644 --- a/src/xenia/gpu/graphics_system.cc +++ b/src/xenia/gpu/graphics_system.cc @@ -17,8 +17,8 @@ #include "xenia/base/threading.h" #include "xenia/gpu/command_processor.h" #include "xenia/gpu/gpu_flags.h" +#include "xenia/ui/graphics_context.h" #include "xenia/ui/graphics_provider.h" -#include "xenia/ui/loop.h" namespace xe { namespace gpu { diff --git a/src/xenia/gpu/graphics_system.h b/src/xenia/gpu/graphics_system.h index c2ee28dcd..05d245fd3 100644 --- a/src/xenia/gpu/graphics_system.h +++ b/src/xenia/gpu/graphics_system.h @@ -19,7 +19,6 @@ #include "xenia/gpu/register_file.h" #include "xenia/kernel/xthread.h" #include "xenia/memory.h" -#include "xenia/ui/window.h" #include "xenia/xbox.h" namespace xe { @@ -112,7 +111,6 @@ class GraphicsSystem { void WriteRegister(uint32_t addr, uint32_t value); void MarkVblank(); - virtual void Swap(xe::ui::UIEvent* e) = 0; Memory* memory_ = nullptr; cpu::Processor* processor_ = nullptr; diff --git a/src/xenia/gpu/null/null_graphics_system.cc b/src/xenia/gpu/null/null_graphics_system.cc index 914a604e3..61de2b4d0 100644 --- a/src/xenia/gpu/null/null_graphics_system.cc +++ b/src/xenia/gpu/null/null_graphics_system.cc @@ -34,15 +34,6 @@ std::unique_ptr NullGraphicsSystem::CreateCommandProcessor() { new NullCommandProcessor(this, kernel_state_)); } -void NullGraphicsSystem::Swap(xe::ui::UIEvent* e) { - if (!command_processor_) { - return; - } - - std::lock_guard lock(swap_state_.mutex); - swap_state_.pending = false; -} - } // namespace null } // namespace gpu } // namespace xe \ No newline at end of file diff --git a/src/xenia/gpu/null/null_graphics_system.h b/src/xenia/gpu/null/null_graphics_system.h index 45ce71ad9..4f82dd7fd 100644 --- a/src/xenia/gpu/null/null_graphics_system.h +++ b/src/xenia/gpu/null/null_graphics_system.h @@ -34,7 +34,6 @@ class NullGraphicsSystem : public GraphicsSystem { private: std::unique_ptr CreateCommandProcessor() override; - void Swap(xe::ui::UIEvent* e) override; SwapState swap_state_ = {}; }; diff --git a/src/xenia/gpu/vulkan/vulkan_graphics_system.cc b/src/xenia/gpu/vulkan/vulkan_graphics_system.cc index 5c90ede3b..91c1979fd 100644 --- a/src/xenia/gpu/vulkan/vulkan_graphics_system.cc +++ b/src/xenia/gpu/vulkan/vulkan_graphics_system.cc @@ -18,10 +18,7 @@ #include "xenia/gpu/gpu_flags.h" #include "xenia/gpu/vulkan/vulkan_command_processor.h" #include "xenia/gpu/vulkan/vulkan_gpu_flags.h" -#include "xenia/ui/vulkan/vulkan_provider.h" -#include "xenia/ui/vulkan/vulkan_swap_chain.h" -#include "xenia/ui/vulkan/vulkan_util.h" -#include "xenia/ui/window.h" +#include "xenia/ui/vulkan/vulkan_context.h" namespace xe { namespace gpu { @@ -323,69 +320,6 @@ VulkanGraphicsSystem::CreateCommandProcessor() { return std::make_unique(this, kernel_state_); } -void VulkanGraphicsSystem::Swap(xe::ui::UIEvent* e) { - if (!command_processor_) { - return; - } - - // Check for pending swap. - if (display_context_->WasLost()) { - // We're crashing. Cheese it. - swap_state_.pending = false; - return; - } - - { - std::lock_guard lock(swap_state_.mutex); - if (!swap_state_.pending) { - // return; - } - - swap_state_.pending = false; - } - - if (!swap_state_.front_buffer_texture) { - // Not yet ready. - return; - } - - auto swap_chain = display_context_->swap_chain(); - auto copy_cmd_buffer = swap_chain->copy_cmd_buffer(); - auto front_buffer = - reinterpret_cast(swap_state_.front_buffer_texture); - - VkImageMemoryBarrier barrier; - std::memset(&barrier, 0, sizeof(VkImageMemoryBarrier)); - barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; - barrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL; - barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; - barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.image = front_buffer; - barrier.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; - vkCmdPipelineBarrier(copy_cmd_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, - nullptr, 1, &barrier); - - VkImageBlit region; - region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; - region.srcOffsets[0] = {0, 0, 0}; - region.srcOffsets[1] = {static_cast(swap_state_.width), - static_cast(swap_state_.height), 1}; - - region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; - region.dstOffsets[0] = {0, 0, 0}; - region.dstOffsets[1] = {static_cast(swap_chain->surface_width()), - static_cast(swap_chain->surface_height()), - 1}; - vkCmdBlitImage(copy_cmd_buffer, front_buffer, VK_IMAGE_LAYOUT_GENERAL, - swap_chain->surface_image(), - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion, - VK_FILTER_LINEAR); -} - } // namespace vulkan } // namespace gpu } // namespace xe diff --git a/src/xenia/gpu/vulkan/vulkan_graphics_system.h b/src/xenia/gpu/vulkan/vulkan_graphics_system.h index f4953260e..0462be017 100644 --- a/src/xenia/gpu/vulkan/vulkan_graphics_system.h +++ b/src/xenia/gpu/vulkan/vulkan_graphics_system.h @@ -49,7 +49,6 @@ class VulkanGraphicsSystem : public GraphicsSystem { void DestroySwapImage(); std::unique_ptr CreateCommandProcessor() override; - void Swap(xe::ui::UIEvent* e) override; ui::vulkan::VulkanDevice* device_ = nullptr; ui::vulkan::VulkanContext* display_context_ = nullptr;