mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 21:32:50 +00:00
vk: Update async compute (fast) to use the new sync API
This commit is contained in:
parent
850166eca1
commit
715e3856f2
@ -10,7 +10,7 @@
|
||||
|
||||
namespace vk
|
||||
{
|
||||
AsyncTaskScheduler::AsyncTaskScheduler([[maybe_unused]] vk_gpu_scheduler_mode mode)
|
||||
AsyncTaskScheduler::AsyncTaskScheduler(vk_gpu_scheduler_mode mode, const VkDependencyInfoKHR& queue_dependency)
|
||||
{
|
||||
if (g_cfg.video.renderer != video_renderer::vulkan || !g_cfg.video.vk.asynchronous_texture_streaming)
|
||||
{
|
||||
@ -20,7 +20,7 @@ namespace vk
|
||||
return;
|
||||
}
|
||||
|
||||
init_config_options(mode);
|
||||
init_config_options(mode, queue_dependency);
|
||||
}
|
||||
|
||||
AsyncTaskScheduler::~AsyncTaskScheduler()
|
||||
@ -32,7 +32,7 @@ namespace vk
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncTaskScheduler::init_config_options(vk_gpu_scheduler_mode mode)
|
||||
void AsyncTaskScheduler::init_config_options(vk_gpu_scheduler_mode mode, const VkDependencyInfoKHR& queue_dependency)
|
||||
{
|
||||
std::lock_guard lock(m_config_mutex);
|
||||
if (std::exchange(m_options_initialized, true))
|
||||
@ -43,6 +43,8 @@ namespace vk
|
||||
|
||||
m_use_host_scheduler = (mode == vk_gpu_scheduler_mode::safe) || g_cfg.video.strict_rendering_mode;
|
||||
rsx_log.notice("Asynchronous task scheduler is active running in %s mode", m_use_host_scheduler? "'Safe'" : "'Fast'");
|
||||
|
||||
m_dependency_info = queue_dependency;
|
||||
}
|
||||
|
||||
void AsyncTaskScheduler::delayed_init()
|
||||
@ -76,7 +78,7 @@ namespace vk
|
||||
auto& sync_label = m_events_pool[m_next_event_id++ % events_pool_size];
|
||||
|
||||
sync_label->reset();
|
||||
sync_label->signal(*m_current_cb, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0);
|
||||
sync_label->signal(*m_current_cb, m_dependency_info);
|
||||
m_sync_label = sync_label.get();
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ namespace vk
|
||||
// Sync
|
||||
event* m_sync_label = nullptr;
|
||||
atomic_t<bool> m_sync_required = false;
|
||||
VkDependencyInfoKHR m_dependency_info{};
|
||||
|
||||
static constexpr u32 events_pool_size = 16384;
|
||||
std::vector<std::unique_ptr<vk::event>> m_events_pool;
|
||||
@ -39,12 +40,12 @@ namespace vk
|
||||
|
||||
shared_mutex m_submit_mutex;
|
||||
|
||||
void init_config_options(vk_gpu_scheduler_mode mode);
|
||||
void init_config_options(vk_gpu_scheduler_mode mode, const VkDependencyInfoKHR& queue_dependency);
|
||||
void delayed_init();
|
||||
void insert_sync_event();
|
||||
|
||||
public:
|
||||
AsyncTaskScheduler(vk_gpu_scheduler_mode mode); // This ctor stops default initialization by fxo
|
||||
AsyncTaskScheduler(vk_gpu_scheduler_mode mode, const VkDependencyInfoKHR& queue_dependency);
|
||||
~AsyncTaskScheduler();
|
||||
|
||||
command_buffer* get_current();
|
||||
|
@ -478,7 +478,7 @@ void VKGSRender::load_texture_env()
|
||||
// Sync any async scheduler tasks
|
||||
if (auto ev = async_task_scheduler.get_primary_sync_label())
|
||||
{
|
||||
ev->gpu_wait(*m_current_command_buffer, { .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO_KHR });
|
||||
ev->gpu_wait(*m_current_command_buffer, m_async_compute_dependency_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -822,8 +822,25 @@ VKGSRender::VKGSRender(utils::serial* ar) noexcept : GSRender(ar)
|
||||
|
||||
if (backend_config.supports_asynchronous_compute)
|
||||
{
|
||||
m_async_compute_memory_barrier =
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2_KHR,
|
||||
.pNext = nullptr,
|
||||
.srcStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT_KHR | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT_KHR,
|
||||
.srcAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT_KHR,
|
||||
.dstStageMask = VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT_KHR,
|
||||
.dstAccessMask = VK_ACCESS_2_SHADER_SAMPLED_READ_BIT_KHR
|
||||
};
|
||||
|
||||
m_async_compute_dependency_info =
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO_KHR,
|
||||
.memoryBarrierCount = 1,
|
||||
.pMemoryBarriers = &m_async_compute_memory_barrier
|
||||
};
|
||||
|
||||
// Run only if async compute can be used.
|
||||
g_fxo->init<vk::AsyncTaskScheduler>(g_cfg.video.vk.asynchronous_scheduler);
|
||||
g_fxo->init<vk::AsyncTaskScheduler>(g_cfg.video.vk.asynchronous_scheduler, m_async_compute_dependency_info);
|
||||
}
|
||||
|
||||
if (backend_config.supports_host_gpu_labels)
|
||||
|
@ -91,6 +91,9 @@ private:
|
||||
std::unique_ptr<vk::buffer_view> m_volatile_attribute_storage;
|
||||
std::unique_ptr<vk::buffer_view> m_vertex_layout_storage;
|
||||
|
||||
VkDependencyInfoKHR m_async_compute_dependency_info{};
|
||||
VkMemoryBarrier2KHR m_async_compute_memory_barrier{};
|
||||
|
||||
public:
|
||||
//vk::fbo draw_fbo;
|
||||
std::unique_ptr<vk::vertex_cache> m_vertex_cache;
|
||||
|
Loading…
x
Reference in New Issue
Block a user