diff options
| author | 2020-01-20 18:29:54 -0300 | |
|---|---|---|
| committer | 2020-01-20 18:43:11 -0300 | |
| commit | a665581684b612afb225485d2e93f07b2274eb16 (patch) | |
| tree | 0b2afa047d8fff452643fedc306cd81dabb3e04e | |
| parent | vk_blit_screen: Initial implementation (diff) | |
| download | yuzu-a665581684b612afb225485d2e93f07b2274eb16.tar.gz yuzu-a665581684b612afb225485d2e93f07b2274eb16.tar.xz yuzu-a665581684b612afb225485d2e93f07b2274eb16.zip | |
vk_blit_screen: Address feedback
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.cpp | 28 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.h | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_swapchain.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_swapchain.h | 10 |
4 files changed, 25 insertions, 22 deletions
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index 7c8bff5d2..855cfc883 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp | |||
| @@ -226,7 +226,7 @@ std::tuple<VKFence&, vk::Semaphore> VKBlitScreen::Draw(const Tegra::FramebufferC | |||
| 226 | // Finish any pending renderpass | 226 | // Finish any pending renderpass |
| 227 | scheduler.RequestOutsideRenderPassOperationContext(); | 227 | scheduler.RequestOutsideRenderPassOperationContext(); |
| 228 | 228 | ||
| 229 | const u32 image_index = swapchain.GetImageIndex(); | 229 | const std::size_t image_index = swapchain.GetImageIndex(); |
| 230 | watches[image_index]->Watch(scheduler.GetFence()); | 230 | watches[image_index]->Watch(scheduler.GetFence()); |
| 231 | 231 | ||
| 232 | VKImage* blit_image = use_accelerated ? screen_info.image : raw_images[image_index].get(); | 232 | VKImage* blit_image = use_accelerated ? screen_info.image : raw_images[image_index].get(); |
| @@ -345,10 +345,11 @@ void VKBlitScreen::CreateSemaphores() { | |||
| 345 | 345 | ||
| 346 | void VKBlitScreen::CreateDescriptorPool() { | 346 | void VKBlitScreen::CreateDescriptorPool() { |
| 347 | const std::array<vk::DescriptorPoolSize, 2> pool_sizes{ | 347 | const std::array<vk::DescriptorPoolSize, 2> pool_sizes{ |
| 348 | vk::DescriptorPoolSize{vk::DescriptorType::eUniformBuffer, image_count}, | 348 | vk::DescriptorPoolSize{vk::DescriptorType::eUniformBuffer, static_cast<u32>(image_count)}, |
| 349 | vk::DescriptorPoolSize{vk::DescriptorType::eCombinedImageSampler, image_count}}; | 349 | vk::DescriptorPoolSize{vk::DescriptorType::eCombinedImageSampler, |
| 350 | const vk::DescriptorPoolCreateInfo pool_ci({}, image_count, static_cast<u32>(pool_sizes.size()), | 350 | static_cast<u32>(image_count)}}; |
| 351 | pool_sizes.data()); | 351 | const vk::DescriptorPoolCreateInfo pool_ci( |
| 352 | {}, static_cast<u32>(image_count), static_cast<u32>(pool_sizes.size()), pool_sizes.data()); | ||
| 352 | const auto dev = device.GetLogical(); | 353 | const auto dev = device.GetLogical(); |
| 353 | descriptor_pool = dev.createDescriptorPoolUnique(pool_ci, nullptr, device.GetDispatchLoader()); | 354 | descriptor_pool = dev.createDescriptorPoolUnique(pool_ci, nullptr, device.GetDispatchLoader()); |
| 354 | } | 355 | } |
| @@ -397,7 +398,7 @@ void VKBlitScreen::CreateDescriptorSets() { | |||
| 397 | const auto& dld = device.GetDispatchLoader(); | 398 | const auto& dld = device.GetDispatchLoader(); |
| 398 | 399 | ||
| 399 | descriptor_sets.resize(image_count); | 400 | descriptor_sets.resize(image_count); |
| 400 | for (u32 i = 0; i < image_count; ++i) { | 401 | for (std::size_t i = 0; i < image_count; ++i) { |
| 401 | const vk::DescriptorSetLayout layout = *descriptor_set_layout; | 402 | const vk::DescriptorSetLayout layout = *descriptor_set_layout; |
| 402 | const vk::DescriptorSetAllocateInfo descriptor_set_ai(*descriptor_pool, 1, &layout); | 403 | const vk::DescriptorSetAllocateInfo descriptor_set_ai(*descriptor_pool, 1, &layout); |
| 403 | const vk::Result result = | 404 | const vk::Result result = |
| @@ -487,7 +488,7 @@ void VKBlitScreen::CreateFramebuffers() { | |||
| 487 | const auto dev = device.GetLogical(); | 488 | const auto dev = device.GetLogical(); |
| 488 | const auto& dld = device.GetDispatchLoader(); | 489 | const auto& dld = device.GetDispatchLoader(); |
| 489 | 490 | ||
| 490 | for (u32 i = 0; i < image_count; ++i) { | 491 | for (std::size_t i = 0; i < image_count; ++i) { |
| 491 | const vk::ImageView image_view{swapchain.GetImageViewIndex(i)}; | 492 | const vk::ImageView image_view{swapchain.GetImageViewIndex(i)}; |
| 492 | const vk::FramebufferCreateInfo framebuffer_ci({}, *renderpass, 1, &image_view, size.width, | 493 | const vk::FramebufferCreateInfo framebuffer_ci({}, *renderpass, 1, &image_view, size.width, |
| 493 | size.height, 1); | 494 | size.height, 1); |
| @@ -496,7 +497,7 @@ void VKBlitScreen::CreateFramebuffers() { | |||
| 496 | } | 497 | } |
| 497 | 498 | ||
| 498 | void VKBlitScreen::ReleaseRawImages() { | 499 | void VKBlitScreen::ReleaseRawImages() { |
| 499 | for (u32 i = 0; i < static_cast<u32>(raw_images.size()); ++i) { | 500 | for (std::size_t i = 0; i < raw_images.size(); ++i) { |
| 500 | watches[i]->Wait(); | 501 | watches[i]->Wait(); |
| 501 | } | 502 | } |
| 502 | raw_images.clear(); | 503 | raw_images.clear(); |
| @@ -523,7 +524,7 @@ void VKBlitScreen::CreateRawImages(const Tegra::FramebufferConfig& framebuffer) | |||
| 523 | raw_buffer_commits.resize(image_count); | 524 | raw_buffer_commits.resize(image_count); |
| 524 | 525 | ||
| 525 | const auto format = GetFormat(framebuffer); | 526 | const auto format = GetFormat(framebuffer); |
| 526 | for (u32 i = 0; i < image_count; ++i) { | 527 | for (std::size_t i = 0; i < image_count; ++i) { |
| 527 | const vk::ImageCreateInfo image_ci( | 528 | const vk::ImageCreateInfo image_ci( |
| 528 | {}, vk::ImageType::e2D, format, {framebuffer.width, framebuffer.height, 1}, 1, 1, | 529 | {}, vk::ImageType::e2D, format, {framebuffer.width, framebuffer.height, 1}, 1, 1, |
| 529 | vk::SampleCountFlagBits::e1, vk::ImageTiling::eOptimal, | 530 | vk::SampleCountFlagBits::e1, vk::ImageTiling::eOptimal, |
| @@ -536,7 +537,7 @@ void VKBlitScreen::CreateRawImages(const Tegra::FramebufferConfig& framebuffer) | |||
| 536 | } | 537 | } |
| 537 | } | 538 | } |
| 538 | 539 | ||
| 539 | void VKBlitScreen::UpdateDescriptorSet(u32 image_index, vk::ImageView image_view) const { | 540 | void VKBlitScreen::UpdateDescriptorSet(std::size_t image_index, vk::ImageView image_view) const { |
| 540 | const vk::DescriptorSet descriptor_set = descriptor_sets[image_index]; | 541 | const vk::DescriptorSet descriptor_set = descriptor_sets[image_index]; |
| 541 | 542 | ||
| 542 | const vk::DescriptorBufferInfo buffer_info(*buffer, offsetof(BufferData, uniform), | 543 | const vk::DescriptorBufferInfo buffer_info(*buffer, offsetof(BufferData, uniform), |
| @@ -568,7 +569,7 @@ void VKBlitScreen::SetVertexData(BufferData& data, | |||
| 568 | const auto& framebuffer_transform_flags = framebuffer.transform_flags; | 569 | const auto& framebuffer_transform_flags = framebuffer.transform_flags; |
| 569 | const auto& framebuffer_crop_rect = framebuffer.crop_rect; | 570 | const auto& framebuffer_crop_rect = framebuffer.crop_rect; |
| 570 | 571 | ||
| 571 | const Common::Rectangle<f32> texcoords{0.f, 0.f, 1.f, 1.f}; | 572 | static constexpr Common::Rectangle<f32> texcoords{0.f, 0.f, 1.f, 1.f}; |
| 572 | auto left = texcoords.left; | 573 | auto left = texcoords.left; |
| 573 | auto right = texcoords.right; | 574 | auto right = texcoords.right; |
| 574 | 575 | ||
| @@ -591,7 +592,8 @@ void VKBlitScreen::SetVertexData(BufferData& data, | |||
| 591 | 592 | ||
| 592 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering | 593 | // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering |
| 593 | // (e.g. handheld mode) on a 1920x1080 framebuffer. | 594 | // (e.g. handheld mode) on a 1920x1080 framebuffer. |
| 594 | f32 scale_u = 1.0f, scale_v = 1.0f; | 595 | f32 scale_u = 1.0f; |
| 596 | f32 scale_v = 1.0f; | ||
| 595 | if (framebuffer_crop_rect.GetWidth() > 0) { | 597 | if (framebuffer_crop_rect.GetWidth() > 0) { |
| 596 | scale_u = static_cast<f32>(framebuffer_crop_rect.GetWidth()) / | 598 | scale_u = static_cast<f32>(framebuffer_crop_rect.GetWidth()) / |
| 597 | static_cast<f32>(screen_info.width); | 599 | static_cast<f32>(screen_info.width); |
| @@ -617,7 +619,7 @@ u64 VKBlitScreen::CalculateBufferSize(const Tegra::FramebufferConfig& framebuffe | |||
| 617 | } | 619 | } |
| 618 | 620 | ||
| 619 | u64 VKBlitScreen::GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer, | 621 | u64 VKBlitScreen::GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer, |
| 620 | u32 image_index) const { | 622 | std::size_t image_index) const { |
| 621 | constexpr auto first_image_offset = static_cast<u64>(sizeof(BufferData)); | 623 | constexpr auto first_image_offset = static_cast<u64>(sizeof(BufferData)); |
| 622 | return first_image_offset + GetSizeInBytes(framebuffer) * image_index; | 624 | return first_image_offset + GetSizeInBytes(framebuffer) * image_index; |
| 623 | } | 625 | } |
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.h b/src/video_core/renderer_vulkan/vk_blit_screen.h index 743bb0317..ea680b3f5 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.h +++ b/src/video_core/renderer_vulkan/vk_blit_screen.h | |||
| @@ -74,12 +74,13 @@ private: | |||
| 74 | void CreateStagingBuffer(const Tegra::FramebufferConfig& framebuffer); | 74 | void CreateStagingBuffer(const Tegra::FramebufferConfig& framebuffer); |
| 75 | void CreateRawImages(const Tegra::FramebufferConfig& framebuffer); | 75 | void CreateRawImages(const Tegra::FramebufferConfig& framebuffer); |
| 76 | 76 | ||
| 77 | void UpdateDescriptorSet(u32 image_index, vk::ImageView image_view) const; | 77 | void UpdateDescriptorSet(std::size_t image_index, vk::ImageView image_view) const; |
| 78 | void SetUniformData(BufferData& data, const Tegra::FramebufferConfig& framebuffer) const; | 78 | void SetUniformData(BufferData& data, const Tegra::FramebufferConfig& framebuffer) const; |
| 79 | void SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer) const; | 79 | void SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer) const; |
| 80 | 80 | ||
| 81 | u64 CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const; | 81 | u64 CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const; |
| 82 | u64 GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer, u32 image_index) const; | 82 | u64 GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer, |
| 83 | std::size_t image_index) const; | ||
| 83 | 84 | ||
| 84 | Core::System& system; | 85 | Core::System& system; |
| 85 | Core::Frontend::EmuWindow& render_window; | 86 | Core::Frontend::EmuWindow& render_window; |
| @@ -89,7 +90,7 @@ private: | |||
| 89 | VKMemoryManager& memory_manager; | 90 | VKMemoryManager& memory_manager; |
| 90 | VKSwapchain& swapchain; | 91 | VKSwapchain& swapchain; |
| 91 | VKScheduler& scheduler; | 92 | VKScheduler& scheduler; |
| 92 | const u32 image_count; | 93 | const std::size_t image_count; |
| 93 | const VKScreenInfo& screen_info; | 94 | const VKScreenInfo& screen_info; |
| 94 | 95 | ||
| 95 | UniqueShaderModule vertex_shader; | 96 | UniqueShaderModule vertex_shader; |
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index ebc68f030..f47b691a8 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp | |||
| @@ -123,7 +123,7 @@ bool VKSwapchain::Present(vk::Semaphore render_semaphore, VKFence& fence) { | |||
| 123 | 123 | ||
| 124 | ASSERT(fences[image_index] == nullptr); | 124 | ASSERT(fences[image_index] == nullptr); |
| 125 | fences[image_index] = &fence; | 125 | fences[image_index] = &fence; |
| 126 | frame_index = (frame_index + 1) % image_count; | 126 | frame_index = (frame_index + 1) % static_cast<u32>(image_count); |
| 127 | return recreated; | 127 | return recreated; |
| 128 | } | 128 | } |
| 129 | 129 | ||
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.h b/src/video_core/renderer_vulkan/vk_swapchain.h index a1e7938d2..2f3b2ccd5 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.h +++ b/src/video_core/renderer_vulkan/vk_swapchain.h | |||
| @@ -40,19 +40,19 @@ public: | |||
| 40 | return extent; | 40 | return extent; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | u32 GetImageCount() const { | 43 | std::size_t GetImageCount() const { |
| 44 | return image_count; | 44 | return image_count; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | u32 GetImageIndex() const { | 47 | std::size_t GetImageIndex() const { |
| 48 | return image_index; | 48 | return image_index; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | vk::Image GetImageIndex(u32 index) const { | 51 | vk::Image GetImageIndex(std::size_t index) const { |
| 52 | return images[index]; | 52 | return images[index]; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | vk::ImageView GetImageViewIndex(u32 index) const { | 55 | vk::ImageView GetImageViewIndex(std::size_t index) const { |
| 56 | return *image_views[index]; | 56 | return *image_views[index]; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -77,7 +77,7 @@ private: | |||
| 77 | 77 | ||
| 78 | UniqueSwapchainKHR swapchain; | 78 | UniqueSwapchainKHR swapchain; |
| 79 | 79 | ||
| 80 | u32 image_count{}; | 80 | std::size_t image_count{}; |
| 81 | std::vector<vk::Image> images; | 81 | std::vector<vk::Image> images; |
| 82 | std::vector<UniqueImageView> image_views; | 82 | std::vector<UniqueImageView> image_views; |
| 83 | std::vector<UniqueFramebuffer> framebuffers; | 83 | std::vector<UniqueFramebuffer> framebuffers; |