vk_scheduler: Add api for defering operations (#311)
This commit is contained in:
parent
64459f1a76
commit
403a5a57b1
|
@ -100,6 +100,12 @@ void Scheduler::SubmitExecution(vk::Semaphore signal_semaphore, vk::Semaphore wa
|
||||||
master_semaphore.SubmitWork(current_cmdbuf, wait_semaphore, signal_semaphore, signal_value);
|
master_semaphore.SubmitWork(current_cmdbuf, wait_semaphore, signal_semaphore, signal_value);
|
||||||
master_semaphore.Refresh();
|
master_semaphore.Refresh();
|
||||||
AllocateWorkerCommandBuffers();
|
AllocateWorkerCommandBuffers();
|
||||||
|
|
||||||
|
// Apply pending operations
|
||||||
|
while (IsFree(pending_ops.back().gpu_tick)) {
|
||||||
|
pending_ops.back().callback();
|
||||||
|
pending_ops.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -71,6 +71,11 @@ public:
|
||||||
return &master_semaphore;
|
return &master_semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Defers an operation until the gpu has reached the current cpu tick.
|
||||||
|
void DeferOperation(auto&& func) {
|
||||||
|
pending_ops.emplace(func, CurrentTick());
|
||||||
|
}
|
||||||
|
|
||||||
std::mutex submit_mutex;
|
std::mutex submit_mutex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -84,6 +89,11 @@ private:
|
||||||
CommandPool command_pool;
|
CommandPool command_pool;
|
||||||
vk::CommandBuffer current_cmdbuf;
|
vk::CommandBuffer current_cmdbuf;
|
||||||
std::condition_variable_any event_cv;
|
std::condition_variable_any event_cv;
|
||||||
|
struct PendingOp {
|
||||||
|
std::function<void()> callback;
|
||||||
|
u64 gpu_tick;
|
||||||
|
};
|
||||||
|
std::queue<PendingOp> pending_ops;
|
||||||
RenderState render_state;
|
RenderState render_state;
|
||||||
bool is_rendering = false;
|
bool is_rendering = false;
|
||||||
tracy::VkCtxScope* profiler_scope{};
|
tracy::VkCtxScope* profiler_scope{};
|
||||||
|
|
Loading…
Reference in New Issue