Blit Vulkan CP output to the main window's swap chain

This commit is contained in:
Dr. Chat 2016-03-10 13:01:39 -06:00
parent f839a1293f
commit f903a559b3
1 changed files with 21 additions and 8 deletions

View File

@ -19,14 +19,14 @@
#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/window.h"
namespace xe {
namespace gpu {
namespace vulkan {
VulkanGraphicsSystem::VulkanGraphicsSystem() = default;
VulkanGraphicsSystem::VulkanGraphicsSystem() {}
VulkanGraphicsSystem::~VulkanGraphicsSystem() = default;
X_STATUS VulkanGraphicsSystem::Setup(cpu::Processor* processor,
@ -74,12 +74,25 @@ void VulkanGraphicsSystem::Swap(xe::ui::UIEvent* e) {
return;
}
// Blit the frontbuffer.
// display_context_->blitter()->BlitTexture2D(
// static_cast<GLuint>(swap_state.front_buffer_texture),
// Rect2D(0, 0, swap_state.width, swap_state.height),
// Rect2D(0, 0, target_window_->width(), target_window_->height()),
// GL_LINEAR, false);
auto swap_chain = display_context_->swap_chain();
auto copy_cmd_buffer = swap_chain->copy_cmd_buffer();
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,
reinterpret_cast<VkImage>(swap_state.front_buffer_texture),
VK_IMAGE_LAYOUT_GENERAL, swap_chain->surface_image(),
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region,
VK_FILTER_LINEAR);
}
} // namespace vulkan