From 20b067fbf409569411ae9d1a3aff6a24c7212440 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Thu, 14 Dec 2023 07:35:48 +0100 Subject: [PATCH] early-access version 4019 --- README.md | 2 +- .../renderer_vulkan/vk_present_manager.cpp | 17 +++++++++-------- .../renderer_vulkan/vk_present_manager.h | 6 ++---- .../renderer_vulkan/vk_update_descriptor.h | 4 +++- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6b4f3b578..9e373a748 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 4018. +This is the source code for early-access 4019. ## Legal Notice diff --git a/src/video_core/renderer_vulkan/vk_present_manager.cpp b/src/video_core/renderer_vulkan/vk_present_manager.cpp index 3a598b2e7..eee837c91 100755 --- a/src/video_core/renderer_vulkan/vk_present_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_present_manager.cpp @@ -102,8 +102,8 @@ PresentManager::PresentManager(const vk::Instance& instance_, memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_}, surface{surface_}, blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())}, - use_present_thread{Settings::values.async_presentation.GetValue()}, - image_count{swapchain.GetImageCount()} { + use_present_thread{Settings::values.async_presentation.GetValue()} { + SetImageCount(); auto& dld = device.GetLogical(); cmdpool = dld.CreateCommandPool({ @@ -165,12 +165,6 @@ void PresentManager::Present(Frame* frame) { return; } - { - // If we have run too far ahead of command processing, wait. - std::unique_lock lock{queue_mutex}; - frame_cv.wait(lock, [&] { return present_queue.size() < FRAMES_IN_FLIGHT - 1; }); - } - scheduler.Record([this, frame](vk::CommandBuffer) { std::unique_lock lock{queue_mutex}; present_queue.push(frame); @@ -298,6 +292,13 @@ void PresentManager::RecreateSwapchain(Frame* frame) { image_count = swapchain.GetImageCount(); } +void PresentManager::SetImageCount() { + // We cannot have more than 5 images in flight at any given time. + // FRAMES_IN_FLIGHT is 7, and the cache TICKS_TO_DESTROY is 6. + // Mali drivers will give us 6. + image_count = std::min(swapchain.GetImageCount(), 5); +} + void PresentManager::CopyToSwapchain(Frame* frame) { bool requires_recreation = false; diff --git a/src/video_core/renderer_vulkan/vk_present_manager.h b/src/video_core/renderer_vulkan/vk_present_manager.h index 493f0aae2..23ee61c8c 100755 --- a/src/video_core/renderer_vulkan/vk_present_manager.h +++ b/src/video_core/renderer_vulkan/vk_present_manager.h @@ -22,10 +22,6 @@ class Device; class Scheduler; class Swapchain; -// This should be plenty for the vast majority of cases. Most desktop platforms only -// provide up to 3 swapchain images. -constexpr size_t FRAMES_IN_FLIGHT = 7; - struct Frame { u32 width; u32 height; @@ -66,6 +62,8 @@ private: void RecreateSwapchain(Frame* frame); + void SetImageCount(); + private: const vk::Instance& instance; Core::Frontend::EmuWindow& render_window; diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index c4d832ae9..2b74d740c 100755 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h @@ -5,7 +5,6 @@ #include -#include "video_core/renderer_vulkan/vk_present_manager.h" #include "video_core/vulkan_common/vulkan_wrapper.h" namespace Vulkan { @@ -30,6 +29,9 @@ struct DescriptorUpdateEntry { }; class UpdateDescriptorQueue final { + // This should be plenty for the vast majority of cases. Most desktop platforms only + // provide up to 3 swapchain images. + static constexpr size_t FRAMES_IN_FLIGHT = 7; static constexpr size_t FRAME_PAYLOAD_SIZE = 0x20000; static constexpr size_t PAYLOAD_SIZE = FRAME_PAYLOAD_SIZE * FRAMES_IN_FLIGHT;