diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index fcaab2b320..28d38c8881 100644 --- a/src/audio_core/audio_core.cpp +++ b/src/audio_core/audio_core.cpp @@ -8,10 +8,11 @@ namespace AudioCore { -AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique()} { +AudioCore::AudioCore(Core::System& system) { + audio_manager.emplace(); CreateSinks(); // Must be created after the sinks - adsp = std::make_unique(system, *output_sink); + adsp.emplace(system, *output_sink); } AudioCore ::~AudioCore() { diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h index e4e27fc661..e4771d7656 100644 --- a/src/audio_core/audio_core.h +++ b/src/audio_core/audio_core.h @@ -15,10 +15,7 @@ class System; namespace AudioCore { -class AudioManager; -/** - * Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP. - */ +/// @brief Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP. class AudioCore { public: explicit AudioCore(Core::System& system); @@ -50,27 +47,22 @@ public: */ Sink::Sink& GetInputSink(); - /** - * Get the ADSP. - * - * @return Ref to the ADSP. - */ + /// @brief Get the ADSP. + /// @return Ref to the ADSP. ADSP::ADSP& ADSP(); private: - /** - * Create the sinks on startup. - */ + /// @brief Create the sinks on startup. void CreateSinks(); /// Main audio manager for audio in/out - std::unique_ptr audio_manager; + std::optional audio_manager; /// Sink used for audio renderer and audio out std::unique_ptr output_sink; /// Sink used for audio input std::unique_ptr input_sink; /// The ADSP in the sysmodule - std::unique_ptr adsp; + std::optional adsp; }; } // namespace AudioCore diff --git a/src/audio_core/audio_in_manager.cpp b/src/audio_core/audio_in_manager.cpp index 63b064922a..c11e88b317 100644 --- a/src/audio_core/audio_in_manager.cpp +++ b/src/audio_core/audio_in_manager.cpp @@ -41,8 +41,7 @@ void Manager::ReleaseSessionId(const size_t session_id) { Result Manager::LinkToManager() { std::scoped_lock l{mutex}; if (!linked_to_manager) { - AudioManager& manager{system.AudioCore().GetAudioManager()}; - manager.SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this)); + system.AudioCore().GetAudioManager().SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this)); linked_to_manager = true; } diff --git a/src/audio_core/audio_out_manager.cpp b/src/audio_core/audio_out_manager.cpp index 316ea7c817..dee3d493e5 100644 --- a/src/audio_core/audio_out_manager.cpp +++ b/src/audio_core/audio_out_manager.cpp @@ -40,8 +40,7 @@ void Manager::ReleaseSessionId(const size_t session_id) { Result Manager::LinkToManager() { std::scoped_lock l{mutex}; if (!linked_to_manager) { - AudioManager& manager{system.AudioCore().GetAudioManager()}; - manager.SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this)); + system.AudioCore().GetAudioManager().SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this)); linked_to_manager = true; } diff --git a/src/core/core.cpp b/src/core/core.cpp index 9db4589ceb..6ec656cf8c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -347,7 +347,7 @@ struct System::Impl { // Register with applet manager // All threads are started, begin main process execution, now that we're in the clear - applet_manager.CreateAndInsertByFrontendAppletParameters(std::move(process), params); + applet_manager.CreateAndInsertByFrontendAppletParameters(std::make_unique(*std::move(process)), params); if (Settings::values.gamecard_inserted) { if (Settings::values.gamecard_current_game) { diff --git a/src/core/hle/service/am/applet_manager.cpp b/src/core/hle/service/am/applet_manager.cpp index c2920f91ae..2bedce03cb 100644 --- a/src/core/hle/service/am/applet_manager.cpp +++ b/src/core/hle/service/am/applet_manager.cpp @@ -268,7 +268,7 @@ void AppletManager::SetWindowSystem(WindowSystem* window_system) { if (Settings::values.enable_overlay && m_window_system->GetOverlayDisplayApplet() == nullptr) { if (auto overlay_process = CreateProcess(m_system, static_cast(AppletProgramId::OverlayDisplay), 0, 0)) { - auto overlay_applet = std::make_shared(m_system, std::move(overlay_process), false); + auto overlay_applet = std::make_shared(m_system, std::make_unique(*std::move(overlay_process)), false); overlay_applet->program_id = static_cast(AppletProgramId::OverlayDisplay); overlay_applet->applet_id = AppletId::OverlayDisplay; overlay_applet->type = AppletType::OverlayApplet; diff --git a/src/core/hle/service/am/process_creation.cpp b/src/core/hle/service/am/process_creation.cpp index b5e31353a2..cd537062d7 100644 --- a/src/core/hle/service/am/process_creation.cpp +++ b/src/core/hle/service/am/process_creation.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "core/core.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/nca_metadata.h" @@ -36,31 +37,23 @@ FileSys::StorageId GetStorageIdForFrontendSlot( } } -std::unique_ptr CreateProcessImpl(std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index) { +std::optional CreateProcessImpl(std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { // Get the appropriate loader to parse this NCA. out_loader = Loader::GetLoader(system, file, program_id, program_index); - // Ensure we have a loader which can parse the NCA. - if (!out_loader) { - return nullptr; - } - - // Try to load the process. - auto process = std::make_unique(system); - if (process->Initialize(*out_loader, out_load_result)) { - return process; + if (out_loader) { + // Try to load the process. + auto process = std::optional(system); + if (process->Initialize(*out_loader, out_load_result)) { + return process; + } } - - return nullptr; + return std::nullopt; } } // Anonymous namespace -std::unique_ptr CreateProcess(Core::System& system, u64 program_id, - u8 minimum_key_generation, u8 maximum_key_generation) { +std::optional CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation) { // Attempt to load program NCA. FileSys::VirtualFile nca_raw{}; @@ -70,7 +63,7 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, // Ensure we retrieved a program NCA. if (!nca_raw) { - return nullptr; + return std::nullopt; } // Ensure we have a suitable version. @@ -79,9 +72,8 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, if (nca.GetStatus() == Loader::ResultStatus::Success && (nca.GetKeyGeneration() < minimum_key_generation || nca.GetKeyGeneration() > maximum_key_generation)) { - LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, - nca.GetKeyGeneration()); - return nullptr; + LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, nca.GetKeyGeneration()); + return std::nullopt; } } @@ -90,15 +82,10 @@ std::unique_ptr CreateProcess(Core::System& system, u64 program_id, return CreateProcessImpl(loader, status, system, nca_raw, program_id, 0); } -std::unique_ptr CreateApplicationProcess(std::vector& out_control, - std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index) { - auto process = - CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); +std::optional CreateApplicationProcess(std::vector& out_control, std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) { + auto process = CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); if (!process) { - return nullptr; + return std::nullopt; } FileSys::NACP nacp; @@ -118,13 +105,10 @@ std::unique_ptr CreateApplicationProcess(std::vector& out_control, // TODO(DarkLordZach): When FSController/Game Card Support is added, if // current_process_game_card use correct StorageId - launch.base_game_storage_id = GetStorageIdForFrontendSlot( - storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program)); - launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry( - FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); + launch.base_game_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(launch.title_id, FileSys::ContentRecordType::Program)); + launch.update_storage_id = GetStorageIdForFrontendSlot(storage.GetSlotForEntry(FileSys::GetUpdateTitleID(launch.title_id), FileSys::ContentRecordType::Program)); system.GetARPManager().Register(launch.title_id, launch, out_control); - return process; } diff --git a/src/core/hle/service/am/process_creation.h b/src/core/hle/service/am/process_creation.h index 8cfb9e0c9e..40c3d36aff 100644 --- a/src/core/hle/service/am/process_creation.h +++ b/src/core/hle/service/am/process_creation.h @@ -24,12 +24,7 @@ class Process; namespace Service::AM { -std::unique_ptr CreateProcess(Core::System& system, u64 program_id, - u8 minimum_key_generation, u8 maximum_key_generation); -std::unique_ptr CreateApplicationProcess(std::vector& out_control, - std::unique_ptr& out_loader, - Loader::ResultStatus& out_load_result, - Core::System& system, FileSys::VirtualFile file, - u64 program_id, u64 program_index); +std::optional CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation); +std::optional CreateApplicationProcess(std::vector& out_control, std::unique_ptr& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index); } // namespace Service::AM diff --git a/src/core/hle/service/am/service/application_creator.cpp b/src/core/hle/service/am/service/application_creator.cpp index d16fd7dd84..4fece53119 100644 --- a/src/core/hle/service/am/service/application_creator.cpp +++ b/src/core/hle/service/am/service/application_creator.cpp @@ -21,8 +21,7 @@ namespace Service::AM { namespace { -Result CreateGuestApplication(SharedPointer* out_application_accessor, - Core::System& system, WindowSystem& window_system, u64 program_id) { +Result CreateGuestApplication(SharedPointer* out_application_accessor, Core::System& system, WindowSystem& window_system, u64 program_id) { FileSys::VirtualFile nca_raw{}; // Get the program NCA from storage. @@ -35,11 +34,10 @@ Result CreateGuestApplication(SharedPointer* out_applicati std::vector control; std::unique_ptr loader; Loader::ResultStatus result; - auto process = - CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0); - R_UNLESS(process != nullptr, ResultUnknown); + auto process = CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0); + R_UNLESS(process != std::nullopt, ResultUnknown); - const auto applet = std::make_shared(system, std::move(process), true); + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), true); applet->program_id = program_id; applet->applet_id = AppletId::Application; applet->type = AppletType::Application; @@ -47,8 +45,7 @@ Result CreateGuestApplication(SharedPointer* out_applicati window_system.TrackApplet(applet, true); - *out_application_accessor = - std::make_shared(system, applet, window_system); + *out_application_accessor = std::make_shared(system, applet, window_system); R_SUCCEED(); } @@ -90,12 +87,10 @@ Result IApplicationCreator::CreateSystemApplication( std::vector control; std::unique_ptr loader; + auto process = CreateProcess(system, application_id, 1, 21); + R_UNLESS(process != std::nullopt, ResultUnknown); - auto process = - CreateProcess(system, application_id, 1, 21); - R_UNLESS(process != nullptr, ResultUnknown); - - const auto applet = std::make_shared(system, std::move(process), true); + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), true); applet->program_id = application_id; applet->applet_id = AppletId::Starter; applet->type = AppletType::LibraryApplet; @@ -103,8 +98,7 @@ Result IApplicationCreator::CreateSystemApplication( m_window_system.TrackApplet(applet, true); - *out_application_accessor = - std::make_shared(system, applet, m_window_system); + *out_application_accessor = std::make_shared(system, applet, m_window_system); Core::LaunchTimestampCache::SaveLaunchTimestamp(application_id); R_SUCCEED(); } diff --git a/src/core/hle/service/am/service/library_applet_creator.cpp b/src/core/hle/service/am/service/library_applet_creator.cpp index e38729e70a..17db4b35d3 100644 --- a/src/core/hle/service/am/service/library_applet_creator.cpp +++ b/src/core/hle/service/am/service/library_applet_creator.cpp @@ -121,26 +121,23 @@ std::shared_ptr CreateGuestApplet(Core::System& system, }; auto process = CreateProcess(system, program_id, Firmware1400, Firmware2100); - if (!process) { - // Couldn't initialize the guest process - return {}; + if (process) { + const auto applet = std::make_shared(system, std::make_unique(*std::move(process)), false); + applet->program_id = program_id; + applet->applet_id = applet_id; + applet->type = AppletType::LibraryApplet; + applet->library_applet_mode = mode; + applet->window_visible = mode != LibraryAppletMode::AllForegroundInitiallyHidden; + + auto broker = std::make_shared(system); + applet->caller_applet = caller_applet; + applet->caller_applet_broker = broker; + caller_applet->child_applets.push_back(applet); + window_system.TrackApplet(applet, false); + return std::make_shared(system, broker, applet); } - - const auto applet = std::make_shared(system, std::move(process), false); - applet->program_id = program_id; - applet->applet_id = applet_id; - applet->type = AppletType::LibraryApplet; - applet->library_applet_mode = mode; - applet->window_visible = mode != LibraryAppletMode::AllForegroundInitiallyHidden; - - auto broker = std::make_shared(system); - applet->caller_applet = caller_applet; - applet->caller_applet_broker = broker; - caller_applet->child_applets.push_back(applet); - - window_system.TrackApplet(applet, false); - - return std::make_shared(system, broker, applet); + // Couldn't initialize the guest process + return {}; } std::shared_ptr CreateFrontendApplet(Core::System& system, diff --git a/src/core/hle/service/audio/audio_out_manager.cpp b/src/core/hle/service/audio/audio_out_manager.cpp index 0a8e1ec256..a5a05a1b76 100644 --- a/src/core/hle/service/audio/audio_out_manager.cpp +++ b/src/core/hle/service/audio/audio_out_manager.cpp @@ -14,7 +14,9 @@ namespace Service::Audio { using namespace AudioCore::AudioOut; IAudioOutManager::IAudioOutManager(Core::System& system_) - : ServiceFramework{system_, "audout:u"}, impl{std::make_unique(system_)} { + : ServiceFramework{system_, "audout:u"} + , impl(system_) +{ // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioOutManager::ListAudioOuts>, "ListAudioOuts"}, diff --git a/src/core/hle/service/audio/audio_out_manager.h b/src/core/hle/service/audio/audio_out_manager.h index 791274d5e9..57d1eb1e58 100644 --- a/src/core/hle/service/audio/audio_out_manager.h +++ b/src/core/hle/service/audio/audio_out_manager.h @@ -43,7 +43,7 @@ private: AudioCore::AudioOut::AudioOutParameter parameter, InCopyHandle process_handle, ClientAppletResourceUserId aruid); - std::unique_ptr impl; + std::optional impl; }; } // namespace Service::Audio diff --git a/src/core/hle/service/audio/audio_renderer_manager.cpp b/src/core/hle/service/audio/audio_renderer_manager.cpp index 6a1345c074..4f0bf0f3b9 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.cpp +++ b/src/core/hle/service/audio/audio_renderer_manager.cpp @@ -15,7 +15,9 @@ namespace Service::Audio { using namespace AudioCore::Renderer; IAudioRendererManager::IAudioRendererManager(Core::System& system_) - : ServiceFramework{system_, "audren:u"}, impl{std::make_unique(system_)} { + : ServiceFramework{system_, "audren:u"} + , impl(system_) +{ // clang-format off static const FunctionInfo functions[] = { {0, D<&IAudioRendererManager::OpenAudioRenderer>, "OpenAudioRenderer"}, diff --git a/src/core/hle/service/audio/audio_renderer_manager.h b/src/core/hle/service/audio/audio_renderer_manager.h index 69eee664c3..3f25ad6df1 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.h +++ b/src/core/hle/service/audio/audio_renderer_manager.h @@ -30,7 +30,7 @@ private: Result GetAudioDeviceServiceWithRevisionInfo(Out> out_audio_device, u32 revision, ClientAppletResourceUserId aruid); - std::unique_ptr impl; + std::optional impl; u32 num_audio_devices{0}; }; diff --git a/src/core/hle/service/os/process.cpp b/src/core/hle/service/os/process.cpp index 0dbadc315e..ec00af1433 100644 --- a/src/core/hle/service/os/process.cpp +++ b/src/core/hle/service/os/process.cpp @@ -10,14 +10,6 @@ namespace Service { -Process::Process(Core::System& system) - : m_system(system), m_process(), m_main_thread_priority(), m_main_thread_stack_size(), - m_process_started() {} - -Process::~Process() { - this->Finalize(); -} - bool Process::Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result) { // First, ensure we are not holding another process. this->Finalize(); diff --git a/src/core/hle/service/os/process.h b/src/core/hle/service/os/process.h index 9109b7d0a5..cec61c76c7 100644 --- a/src/core/hle/service/os/process.h +++ b/src/core/hle/service/os/process.h @@ -22,8 +22,8 @@ namespace Service { class Process { public: - explicit Process(Core::System& system); - ~Process(); + inline explicit Process(Core::System& system) noexcept : m_system(system) {} + inline ~Process() { this->Finalize(); } bool Initialize(Loader::AppLoader& loader, Loader::ResultStatus& out_load_result); void Finalize(); @@ -50,8 +50,8 @@ public: private: Core::System& m_system; Kernel::KProcess* m_process{}; - s32 m_main_thread_priority{}; u64 m_main_thread_stack_size{}; + s32 m_main_thread_priority{}; bool m_process_started{}; }; diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index 7cdb3acadd..7bb632cedc 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -126,16 +126,14 @@ public: current_query = nullptr; amend_value = 0; accumulation_value = 0; - queries_prefix_scan_pass = std::make_unique( - device, scheduler, descriptor_pool, compute_pass_descriptor_queue); + queries_prefix_scan_pass.emplace(device, scheduler, descriptor_pool, compute_pass_descriptor_queue); const VkBufferCreateInfo buffer_ci = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, .flags = 0, .size = 8, - .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | - VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, + .usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, .sharingMode = VK_SHARING_MODE_EXCLUSIVE, .queueFamilyIndexCount = 0, .pQueueFamilyIndices = nullptr, @@ -592,8 +590,7 @@ private: VideoCommon::HostQueryBase* current_query; bool has_started{}; std::mutex flush_guard; - - std::unique_ptr queries_prefix_scan_pass; + std::optional queries_prefix_scan_pass; }; // Transform feedback queries @@ -1176,35 +1173,21 @@ private: } // namespace struct QueryCacheRuntimeImpl { - QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_, - Tegra::MaxwellDeviceMemoryManager& device_memory_, - Vulkan::BufferCache& buffer_cache_, const Device& device_, - const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, - StagingBufferPool& staging_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue, - DescriptorPool& descriptor_pool, TextureCache& texture_cache_) - : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_}, - device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, - staging_pool{staging_pool_}, guest_streamer(0, runtime), - sample_streamer(static_cast(QueryType::ZPassPixelCount64), runtime, rasterizer, - texture_cache_, device, scheduler, memory_allocator, - compute_pass_descriptor_queue, descriptor_pool), - tfb_streamer(static_cast(QueryType::StreamingByteCount), runtime, device, - scheduler, memory_allocator, staging_pool), - primitives_succeeded_streamer( - static_cast(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, - device_memory_), - primitives_needed_minus_succeeded_streamer( - static_cast(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u), - hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} { + QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_, Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool, TextureCache& texture_cache_) + : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_} + , device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_} + , staging_pool{staging_pool_}, guest_streamer(0, runtime) + , sample_streamer(size_t(QueryType::ZPassPixelCount64), runtime, rasterizer, texture_cache_, device, scheduler, memory_allocator, compute_pass_descriptor_queue, descriptor_pool) + , tfb_streamer(size_t(QueryType::StreamingByteCount), runtime, device, scheduler, memory_allocator, staging_pool) + , primitives_succeeded_streamer(size_t(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, device_memory_) + , primitives_needed_minus_succeeded_streamer(size_t(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u) + , hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} { hcr_setup.sType = VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT; hcr_setup.pNext = nullptr; hcr_setup.flags = 0; - conditional_resolve_pass = std::make_unique( - device, scheduler, descriptor_pool, compute_pass_descriptor_queue); - + conditional_resolve_pass.emplace(device, scheduler, descriptor_pool, compute_pass_descriptor_queue); const VkBufferCreateInfo buffer_ci = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = nullptr, @@ -1241,7 +1224,7 @@ struct QueryCacheRuntimeImpl { std::vector> copies_setup; // Host conditional rendering data - std::unique_ptr conditional_resolve_pass; + std::optional conditional_resolve_pass; vk::Buffer hcr_resolve_buffer; VkConditionalRenderingBeginInfoEXT hcr_setup; VkBuffer hcr_buffer; @@ -1253,13 +1236,7 @@ struct QueryCacheRuntimeImpl { Maxwell3D* maxwell3d; }; -QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, - Tegra::MaxwellDeviceMemoryManager& device_memory_, - Vulkan::BufferCache& buffer_cache_, const Device& device_, - const MemoryAllocator& memory_allocator_, - Scheduler& scheduler_, StagingBufferPool& staging_pool_, - ComputePassDescriptorQueue& compute_pass_descriptor_queue, - DescriptorPool& descriptor_pool, TextureCache& texture_cache_) { +QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool, TextureCache& texture_cache_) { impl = std::make_unique( *this, rasterizer, device_memory_, buffer_cache_, device_, memory_allocator_, scheduler_, staging_pool_, compute_pass_descriptor_queue, descriptor_pool, texture_cache_); @@ -1484,13 +1461,11 @@ void QueryCacheRuntime::Barriers(bool is_prebarrier) { impl->scheduler.RequestOutsideRenderPassOperationContext(); if (is_prebarrier) { impl->scheduler.Record([](vk::CommandBuffer cmdbuf) { - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, 0, READ_BARRIER); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, READ_BARRIER); }); } else { impl->scheduler.Record([](vk::CommandBuffer cmdbuf) { - cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, - VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, WRITE_BARRIER); + cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, WRITE_BARRIER); }); } } @@ -1583,8 +1558,7 @@ void QueryCacheRuntime::SyncValues(std::span values, VkBuffer ba } impl->scheduler.RequestOutsideRenderPassOperationContext(); - impl->scheduler.Record([src_buffer, dst_buffers = std::move(impl->buffers_to_upload_to), - vk_copies = std::move(impl->copies_setup)](vk::CommandBuffer cmdbuf) { + impl->scheduler.Record([src_buffer, dst_buffers = std::move(impl->buffers_to_upload_to), vk_copies = std::move(impl->copies_setup)](vk::CommandBuffer cmdbuf) { size_t size = dst_buffers.size(); for (size_t i = 0; i < size; i++) { cmdbuf.CopyBuffer(src_buffer, dst_buffers[i].first, vk_copies[i]); diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h index 82fce298da..3a1343e02e 100644 --- a/src/video_core/renderer_vulkan/vk_update_descriptor.h +++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h @@ -12,20 +12,15 @@ namespace Vulkan { class Device; class Scheduler; -struct DescriptorUpdateEntry { - struct Empty {}; - +union DescriptorUpdateEntry { DescriptorUpdateEntry() = default; DescriptorUpdateEntry(VkDescriptorImageInfo image_) : image{image_} {} DescriptorUpdateEntry(VkDescriptorBufferInfo buffer_) : buffer{buffer_} {} DescriptorUpdateEntry(VkBufferView texel_buffer_) : texel_buffer{texel_buffer_} {} - - union { - Empty empty{}; - VkDescriptorImageInfo image; - VkDescriptorBufferInfo buffer; - VkBufferView texel_buffer; - }; + std::monostate empty{}; + VkDescriptorImageInfo image; + VkDescriptorBufferInfo buffer; + VkBufferView texel_buffer; }; class UpdateDescriptorQueue final {