MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / allocate_buffer_impl

Method allocate_buffer_impl

framework/rendering/render_frame.h:225–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223
224template <vkb::BindingType bindingType>
225inline vkb::BufferAllocationCpp RenderFrame<bindingType>::allocate_buffer_impl(vk::BufferUsageFlags usage, vk::DeviceSize size, size_t thread_index)
226{
227 // Find a pool for this usage
228 auto buffer_pool_it = buffer_pools.find(usage);
229 if (buffer_pool_it == buffer_pools.end())
230 {
231 LOGE("No buffer pool for buffer usage {} ", vk::to_string(usage));
232 return vkb::BufferAllocationCpp{};
233 }
234
235 assert(thread_index < buffer_pool_it->second.size());
236 auto &buffer_pool = buffer_pool_it->second[thread_index].first;
237 auto &buffer_block = buffer_pool_it->second[thread_index].second;
238
239 bool want_minimal_block = (buffer_allocation_strategy == BufferAllocationStrategy::OneAllocationPerBuffer);
240
241 if (want_minimal_block || !buffer_block || !buffer_block->can_allocate(size))
242 {
243 // If we are creating a buffer for each allocation of there is no block associated with the pool or the current block is too small
244 // for this allocation, request a new buffer block
245 buffer_block = &buffer_pool.request_buffer_block(size, want_minimal_block);
246 }
247
248 return buffer_block->allocate(to_u32(size));
249}
250
251template <vkb::BindingType bindingType>
252inline void RenderFrame<bindingType>::clear_descriptors()

Callers

nothing calls this directly

Calls 6

to_u32Function · 0.85
endMethod · 0.80
sizeMethod · 0.80
can_allocateMethod · 0.80
to_stringFunction · 0.50
allocateMethod · 0.45

Tested by

no test coverage detected