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

◆ allocate_set()

vk::DescriptorSet MayaFlux::Core::VKDescriptorManager::allocate_set ( vk::Device  device,
vk::DescriptorSetLayout  layout 
)

Allocate a descriptor set from the pool.

Parameters
deviceLogical device
layoutDescriptor set layout
Returns
Allocated descriptor set, or null on failure

Allocates from current pool. If pool is exhausted, creates a new pool automatically and retries allocation.

Sets are freed when their pool is destroyed (on cleanup()).

Definition at line 256 of file VKDescriptorManager.cpp.

259{
260 if (!layout) {
262 "Cannot allocate descriptor set with null layout");
263 return nullptr;
264 }
265
266 if (m_pools.empty()) {
268 "No descriptor pools available - call initialize() first");
269 return nullptr;
270 }
271
272 vk::DescriptorSetAllocateInfo alloc_info;
273 alloc_info.descriptorPool = m_pools[m_current_pool_index];
274 alloc_info.descriptorSetCount = 1;
275 alloc_info.pSetLayouts = &layout;
276
277 vk::DescriptorSet set;
278 try {
279 auto sets = device.allocateDescriptorSets(alloc_info);
280 set = sets[0];
282 } catch (const vk::OutOfPoolMemoryError&) {
284 "Descriptor pool {} exhausted, growing...", m_current_pool_index);
285
286 if (!grow_pools(device)) {
287 return nullptr;
288 }
289
290 alloc_info.descriptorPool = m_pools[m_current_pool_index];
291 try {
292 auto sets = device.allocateDescriptorSets(alloc_info);
293 set = sets[0];
295 } catch (const vk::SystemError& e) {
297 "Failed to allocate descriptor set after pool growth: {}", e.what());
298 return nullptr;
299 }
300 } catch (const vk::SystemError& e) {
302 "Failed to allocate descriptor set: {}", e.what());
303 return nullptr;
304 }
305
307 "Allocated descriptor set (total: {}/{})", m_allocated_count, m_pool_capacity);
308
309 return set;
310}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
uint32_t m_allocated_count
Total allocated sets.
uint32_t m_pool_capacity
Total capacity across all pools.
bool grow_pools(vk::Device device)
Grow pool capacity by allocating new pool.
std::vector< vk::DescriptorPool > m_pools
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Journal::GraphicsBackend, grow_pools(), m_allocated_count, m_current_pool_index, m_pool_capacity, m_pools, MF_DEBUG, and MF_ERROR.

+ Here is the call graph for this function: