From 0c4e7fc178d1a96497ac36ad4471cd8821181cf9 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 18 Oct 2025 03:29:49 +0300 Subject: [PATCH] vk: Do not access async scheduler if not explicitly initialized --- rpcs3/Emu/RSX/VK/VKDraw.cpp | 11 ++++++----- rpcs3/Emu/RSX/VK/VKTexture.cpp | 2 +- rpcs3/Emu/RSX/VK/VKTextureCache.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/VKDraw.cpp b/rpcs3/Emu/RSX/VK/VKDraw.cpp index 3e97b292d3..6101aeb9de 100644 --- a/rpcs3/Emu/RSX/VK/VKDraw.cpp +++ b/rpcs3/Emu/RSX/VK/VKDraw.cpp @@ -505,16 +505,17 @@ void VKGSRender::load_texture_env() } } - if (g_cfg.video.vk.asynchronous_texture_streaming) + if (backend_config.supports_asynchronous_compute) { // We have to do this here, because we have to assume the CB will be dumped - auto& async_task_scheduler = g_fxo->get(); + auto async_task_scheduler = g_fxo->try_get(); - if (async_task_scheduler.is_recording() && - !async_task_scheduler.is_host_mode()) + if (async_task_scheduler && + async_task_scheduler->is_recording() && + !async_task_scheduler->is_host_mode()) { // Sync any async scheduler tasks - if (auto ev = async_task_scheduler.get_primary_sync_label()) + if (auto ev = async_task_scheduler->get_primary_sync_label()) { ev->gpu_wait(*m_current_command_buffer, m_async_compute_dependency_info); } diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index 23b76df52b..413333d500 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -867,7 +867,7 @@ namespace vk static const vk::command_buffer& prepare_for_transfer(const vk::command_buffer& primary_cb, vk::image* dst_image, rsx::flags32_t& flags) { AsyncTaskScheduler* async_scheduler = (flags & image_upload_options::upload_contents_async) - ? std::addressof(g_fxo->get()) + ? g_fxo->try_get() : nullptr; if (async_scheduler && (dst_image->aspect() & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))) diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.cpp b/rpcs3/Emu/RSX/VK/VKTextureCache.cpp index 4505528a34..b6743f1291 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.cpp +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.cpp @@ -1115,7 +1115,7 @@ namespace vk const bool upload_async = rsx::get_current_renderer()->get_backend_config().supports_asynchronous_compute; rsx::flags32_t create_flags = 0; - if (upload_async && g_fxo->get().is_host_mode()) + if (upload_async && ensure(g_fxo->try_get())->is_host_mode()) { create_flags |= texture_create_flags::do_not_reuse; if (m_device->get_graphics_queue() != m_device->get_transfer_queue())