MayaFlux 0.4.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 905 of file ShaderFoundry.cpp.

906{
907 auto cmd_it = m_command_buffers.find(cmd_id);
908 if (cmd_it == m_command_buffers.end() || !cmd_it->second.is_active) {
909 return INVALID_SEMAPHORE;
910 }
911
912 cmd_it->second.cmd.end();
913
914 SemaphoreID semaphore_id = m_next_semaphore_id++;
915
916 vk::SemaphoreCreateInfo semaphore_info;
917 SemaphoreState& semaphore_state = m_semaphores[semaphore_id];
918 semaphore_state.semaphore = get_device().createSemaphore(semaphore_info);
919
920 vk::SubmitInfo submit_info;
921 submit_info.commandBufferCount = 1;
922 submit_info.pCommandBuffers = &cmd_it->second.cmd;
923 submit_info.signalSemaphoreCount = 1;
924 submit_info.pSignalSemaphores = &semaphore_state.semaphore;
925
926 vk::Queue queue;
927 switch (cmd_it->second.type) {
929 queue = m_graphics_queue;
930 break;
932 queue = m_compute_queue;
933 break;
935 queue = m_transfer_queue;
936 break;
937 }
938
939 if (queue.submit(1, &submit_info, nullptr) != vk::Result::eSuccess) {
941 "Failed to submit command buffer");
942 return INVALID_SEMAPHORE;
943 }
944
945 cmd_it->second.is_active = false;
946
947 return semaphore_id;
948}
#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: