MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ submit_with_signal()

SemaphoreID MayaFlux::Portal::Graphics::ShaderFoundry::submit_with_signal ( CommandBufferID  cmd_id)

Submit command buffer asynchronously, returning a semaphore.

Parameters
cmd_idCommand buffer ID to submit
Returns
Semaphore ID to wait on later

Definition at line 986 of file ShaderFoundry.cpp.

987{
988 auto cmd_it = m_command_buffers.find(cmd_id);
989 if (cmd_it == m_command_buffers.end() || !cmd_it->second.is_active) {
990 return INVALID_SEMAPHORE;
991 }
992
993 cmd_it->second.cmd.end();
994
995 SemaphoreID semaphore_id = m_next_semaphore_id++;
996
997 vk::SemaphoreCreateInfo semaphore_info;
998 SemaphoreState& semaphore_state = m_semaphores[semaphore_id];
999 semaphore_state.semaphore = get_device().createSemaphore(semaphore_info);
1000
1001 vk::SubmitInfo submit_info;
1002 submit_info.commandBufferCount = 1;
1003 submit_info.pCommandBuffers = &cmd_it->second.cmd;
1004 submit_info.signalSemaphoreCount = 1;
1005 submit_info.pSignalSemaphores = &semaphore_state.semaphore;
1006
1007 vk::Queue queue;
1008 switch (cmd_it->second.type) {
1010 queue = m_graphics_queue;
1011 break;
1013 queue = m_compute_queue;
1014 break;
1016 queue = m_transfer_queue;
1017 break;
1018 }
1019
1020 if (queue.submit(1, &submit_info, nullptr) != vk::Result::eSuccess) {
1022 "Failed to submit command buffer");
1023 return INVALID_SEMAPHORE;
1024 }
1025
1026 cmd_it->second.is_active = false;
1027
1028 return semaphore_id;
1029}
#define MF_ERROR(comp, ctx,...)
vk::Device get_device() const
Get logical device handle.
std::unordered_map< CommandBufferID, CommandBufferState > m_command_buffers
std::unordered_map< SemaphoreID, SemaphoreState > m_semaphores
@ ShaderCompilation
Shader compilation tasks (Portal::Graphics::ShaderCompiler)
@ Portal
High-level user-facing API layer.
constexpr SemaphoreID INVALID_SEMAPHORE

References COMPUTE, get_device(), GRAPHICS, MayaFlux::Portal::Graphics::INVALID_SEMAPHORE, m_command_buffers, m_compute_queue, m_graphics_queue, m_next_semaphore_id, m_semaphores, m_transfer_queue, MF_ERROR, MayaFlux::Journal::Portal, MayaFlux::Portal::Graphics::ShaderFoundry::SemaphoreState::semaphore, MayaFlux::Journal::ShaderCompilation, and TRANSFER.

+ Here is the call graph for this function: