MayaFlux 1.0.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 1141 of file ShaderFoundry.cpp.

1142{
1143 auto cmd_it = m_command_buffers.find(cmd_id);
1144 if (cmd_it == m_command_buffers.end() || !cmd_it->second.is_active) {
1145 return INVALID_SEMAPHORE;
1146 }
1147
1148 cmd_it->second.cmd.end();
1149
1150 SemaphoreID semaphore_id = m_next_semaphore_id++;
1151
1152 vk::SemaphoreCreateInfo semaphore_info;
1153 SemaphoreState& semaphore_state = m_semaphores[semaphore_id];
1154 semaphore_state.semaphore = get_device().createSemaphore(semaphore_info);
1155
1156 vk::SubmitInfo submit_info;
1157 submit_info.commandBufferCount = 1;
1158 submit_info.pCommandBuffers = &cmd_it->second.cmd;
1159 submit_info.signalSemaphoreCount = 1;
1160 submit_info.pSignalSemaphores = &semaphore_state.semaphore;
1161
1162 vk::Queue queue;
1163 switch (cmd_it->second.type) {
1165 queue = m_graphics_queue;
1166 break;
1168 queue = m_compute_queue;
1169 break;
1171 queue = m_transfer_queue;
1172 break;
1173 }
1174
1175 if (queue.submit(1, &submit_info, nullptr) != vk::Result::eSuccess) {
1177 "Failed to submit command buffer");
1178 return INVALID_SEMAPHORE;
1179 }
1180
1181 cmd_it->second.is_active = false;
1182
1183 return semaphore_id;
1184}
#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: