vk: Add an alternate async queue scheduler

- This version violates spec but does not rely on CPU threads to keep the GPU from hanging. It's ironically much safer to use.
This commit is contained in:
kd-11 2021-03-08 20:22:02 +03:00 committed by kd-11
parent bd6c187fcd
commit 48d0f80a86

View file

@ -8,10 +8,15 @@
#include <vector> #include <vector>
#define WITH_CPU_SCHEDULER 1
namespace vk namespace vk
{ {
void AsyncTaskScheduler::operator()() void AsyncTaskScheduler::operator()()
{ {
#if WITH_CPU_SCHEDULER
thread_ctrl::set_native_priority(1);
add_ref(); add_ref();
while (thread_ctrl::state() != thread_state::aborting) while (thread_ctrl::state() != thread_state::aborting)
@ -24,6 +29,7 @@ namespace vk
} }
release(); release();
#endif
} }
void AsyncTaskScheduler::delayed_init() void AsyncTaskScheduler::delayed_init()
@ -61,9 +67,17 @@ namespace vk
sync_label->queue1_signal->signal(*m_current_cb, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0); sync_label->queue1_signal->signal(*m_current_cb, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0);
#if WITH_CPU_SCHEDULER
{
m_event_queue.push(sync_label); m_event_queue.push(sync_label);
m_sync_label = sync_label->queue2_signal.get(); m_sync_label = sync_label->queue2_signal.get();
} }
#else
{
m_sync_label = sync_label->queue1_signal.get();
}
#endif
}
AsyncTaskScheduler::~AsyncTaskScheduler() AsyncTaskScheduler::~AsyncTaskScheduler()
{ {