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

◆ release_fence()

void MayaFlux::Portal::Graphics::ShaderFoundry::release_fence ( FenceID  fence_id)

Destroy the fence and free its associated command buffer.

Must be called once per FenceID returned by submit_async, after is_fence_signaled returns true. Failure to call this leaks a VkFence and a command buffer slot every dispatch cycle.

Safe to call with INVALID_FENCE.

Parameters
fence_idFenceID returned by submit_async.

Definition at line 1227 of file ShaderFoundry.cpp.

1228{
1229 if (fence_id == INVALID_FENCE)
1230 return;
1231
1232 auto it = m_fences.find(fence_id);
1233 if (it == m_fences.end())
1234 return;
1235
1236 if (it->second.fence) {
1237 get_device().destroyFence(it->second.fence);
1238 it->second.fence = nullptr;
1239 }
1240
1241 const CommandBufferID cmd_id = it->second.cmd_id;
1242 m_fences.erase(it);
1243
1244 if (cmd_id != INVALID_COMMAND_BUFFER) {
1245 auto cmd_it = m_command_buffers.find(cmd_id);
1246 if (cmd_it != m_command_buffers.end()) {
1247 m_backend->get_command_manager().free_command_buffer(cmd_it->second.cmd);
1248 m_command_buffers.erase(cmd_it);
1249 }
1250 }
1251}
vk::Device get_device() const
Get logical device handle.
std::unordered_map< FenceID, FenceState > m_fences
std::unordered_map< CommandBufferID, CommandBufferState > m_command_buffers
std::shared_ptr< Core::VulkanBackend > m_backend
constexpr FenceID INVALID_FENCE
constexpr CommandBufferID INVALID_COMMAND_BUFFER

References get_device(), MayaFlux::Portal::Graphics::INVALID_COMMAND_BUFFER, MayaFlux::Portal::Graphics::INVALID_FENCE, m_backend, m_command_buffers, and m_fences.

+ Here is the call graph for this function: