[GPU] Axe GraphicsSystem::Swap

This commit is contained in:
Dr. Chat 2018-05-15 11:48:51 -05:00
parent 4c99805cf2
commit 573d314140
6 changed files with 2 additions and 81 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -34,15 +34,6 @@ std::unique_ptr<CommandProcessor> NullGraphicsSystem::CreateCommandProcessor() {
new NullCommandProcessor(this, kernel_state_));
}
void NullGraphicsSystem::Swap(xe::ui::UIEvent* e) {
if (!command_processor_) {
return;
}
std::lock_guard<std::mutex> lock(swap_state_.mutex);
swap_state_.pending = false;
}
} // namespace null
} // namespace gpu
} // namespace xe

View File

@ -34,7 +34,6 @@ class NullGraphicsSystem : public GraphicsSystem {
private:
std::unique_ptr<CommandProcessor> CreateCommandProcessor() override;
void Swap(xe::ui::UIEvent* e) override;
SwapState swap_state_ = {};
};

View File

@ -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<VulkanCommandProcessor>(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<std::mutex> 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<VkImage>(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<int32_t>(swap_state_.width),
static_cast<int32_t>(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<int32_t>(swap_chain->surface_width()),
static_cast<int32_t>(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, &region,
VK_FILTER_LINEAR);
}
} // namespace vulkan
} // namespace gpu
} // namespace xe

View File

@ -49,7 +49,6 @@ class VulkanGraphicsSystem : public GraphicsSystem {
void DestroySwapImage();
std::unique_ptr<CommandProcessor> CreateCommandProcessor() override;
void Swap(xe::ui::UIEvent* e) override;
ui::vulkan::VulkanDevice* device_ = nullptr;
ui::vulkan::VulkanContext* display_context_ = nullptr;