|
|
@ -130,7 +130,10 @@ void VKBlitScreen::Recreate() { |
|
|
CreateDynamicResources(); |
|
|
CreateDynamicResources(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, bool use_accelerated) { |
|
|
|
|
|
|
|
|
VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, |
|
|
|
|
|
const VkFramebuffer& host_framebuffer, |
|
|
|
|
|
const Layout::FramebufferLayout layout, VkExtent2D render_area, |
|
|
|
|
|
bool use_accelerated) { |
|
|
RefreshResources(framebuffer); |
|
|
RefreshResources(framebuffer); |
|
|
|
|
|
|
|
|
// Finish any pending renderpass
|
|
|
// Finish any pending renderpass
|
|
|
@ -145,8 +148,8 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, bool |
|
|
use_accelerated ? screen_info.image_view : *raw_image_views[image_index]); |
|
|
use_accelerated ? screen_info.image_view : *raw_image_views[image_index]); |
|
|
|
|
|
|
|
|
BufferData data; |
|
|
BufferData data; |
|
|
SetUniformData(data, framebuffer); |
|
|
|
|
|
SetVertexData(data, framebuffer); |
|
|
|
|
|
|
|
|
SetUniformData(data, layout); |
|
|
|
|
|
SetVertexData(data, framebuffer, layout); |
|
|
|
|
|
|
|
|
const std::span<u8> mapped_span = buffer_commit.Map(); |
|
|
const std::span<u8> mapped_span = buffer_commit.Map(); |
|
|
std::memcpy(mapped_span.data(), &data, sizeof(data)); |
|
|
std::memcpy(mapped_span.data(), &data, sizeof(data)); |
|
|
@ -220,7 +223,8 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, bool |
|
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, write_barrier); |
|
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, write_barrier); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
scheduler.Record([this, image_index, size = swapchain.GetSize()](vk::CommandBuffer cmdbuf) { |
|
|
|
|
|
|
|
|
scheduler.Record( |
|
|
|
|
|
[this, host_framebuffer, image_index, size = render_area](vk::CommandBuffer cmdbuf) { |
|
|
const f32 bg_red = Settings::values.bg_red.GetValue() / 255.0f; |
|
|
const f32 bg_red = Settings::values.bg_red.GetValue() / 255.0f; |
|
|
const f32 bg_green = Settings::values.bg_green.GetValue() / 255.0f; |
|
|
const f32 bg_green = Settings::values.bg_green.GetValue() / 255.0f; |
|
|
const f32 bg_blue = Settings::values.bg_blue.GetValue() / 255.0f; |
|
|
const f32 bg_blue = Settings::values.bg_blue.GetValue() / 255.0f; |
|
|
@ -231,7 +235,7 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, bool |
|
|
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
|
|
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, |
|
|
.pNext = nullptr, |
|
|
.pNext = nullptr, |
|
|
.renderPass = *renderpass, |
|
|
.renderPass = *renderpass, |
|
|
.framebuffer = *framebuffers[image_index], |
|
|
|
|
|
|
|
|
.framebuffer = host_framebuffer, |
|
|
.renderArea = |
|
|
.renderArea = |
|
|
{ |
|
|
{ |
|
|
.offset = {0, 0}, |
|
|
.offset = {0, 0}, |
|
|
@ -266,6 +270,14 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, bool |
|
|
return *semaphores[image_index]; |
|
|
return *semaphores[image_index]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
VkSemaphore VKBlitScreen::DrawToSwapchain(const Tegra::FramebufferConfig& framebuffer, |
|
|
|
|
|
bool use_accelerated) { |
|
|
|
|
|
const std::size_t image_index = swapchain.GetImageIndex(); |
|
|
|
|
|
const VkExtent2D render_area = swapchain.GetSize(); |
|
|
|
|
|
const Layout::FramebufferLayout layout = render_window.GetFramebufferLayout(); |
|
|
|
|
|
return Draw(framebuffer, *framebuffers[image_index], layout, render_area, use_accelerated); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void VKBlitScreen::CreateStaticResources() { |
|
|
void VKBlitScreen::CreateStaticResources() { |
|
|
CreateShaders(); |
|
|
CreateShaders(); |
|
|
CreateSemaphores(); |
|
|
CreateSemaphores(); |
|
|
@ -752,15 +764,13 @@ void VKBlitScreen::UpdateDescriptorSet(std::size_t image_index, VkImageView imag |
|
|
device.GetLogical().UpdateDescriptorSets(std::array{ubo_write, sampler_write}, {}); |
|
|
device.GetLogical().UpdateDescriptorSets(std::array{ubo_write, sampler_write}, {}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void VKBlitScreen::SetUniformData(BufferData& data, |
|
|
|
|
|
const Tegra::FramebufferConfig& framebuffer) const { |
|
|
|
|
|
const auto& layout = render_window.GetFramebufferLayout(); |
|
|
|
|
|
|
|
|
void VKBlitScreen::SetUniformData(BufferData& data, const Layout::FramebufferLayout layout) const { |
|
|
data.uniform.modelview_matrix = |
|
|
data.uniform.modelview_matrix = |
|
|
MakeOrthographicMatrix(static_cast<f32>(layout.width), static_cast<f32>(layout.height)); |
|
|
MakeOrthographicMatrix(static_cast<f32>(layout.width), static_cast<f32>(layout.height)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void VKBlitScreen::SetVertexData(BufferData& data, |
|
|
|
|
|
const Tegra::FramebufferConfig& framebuffer) const { |
|
|
|
|
|
|
|
|
void VKBlitScreen::SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer, |
|
|
|
|
|
const Layout::FramebufferLayout layout) const { |
|
|
const auto& framebuffer_transform_flags = framebuffer.transform_flags; |
|
|
const auto& framebuffer_transform_flags = framebuffer.transform_flags; |
|
|
const auto& framebuffer_crop_rect = framebuffer.crop_rect; |
|
|
const auto& framebuffer_crop_rect = framebuffer.crop_rect; |
|
|
|
|
|
|
|
|
@ -798,7 +808,7 @@ void VKBlitScreen::SetVertexData(BufferData& data, |
|
|
static_cast<f32>(screen_info.height); |
|
|
static_cast<f32>(screen_info.height); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const auto& screen = render_window.GetFramebufferLayout().screen; |
|
|
|
|
|
|
|
|
const auto& screen = layout.screen; |
|
|
const auto x = static_cast<f32>(screen.left); |
|
|
const auto x = static_cast<f32>(screen.left); |
|
|
const auto y = static_cast<f32>(screen.top); |
|
|
const auto y = static_cast<f32>(screen.top); |
|
|
const auto w = static_cast<f32>(screen.GetWidth()); |
|
|
const auto w = static_cast<f32>(screen.GetWidth()); |
|
|
|