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

◆ ensure_shared_buffer()

void MayaFlux::Yantra::GpuResourceManager::ensure_shared_buffer ( uint32_t  set,
size_t  binding_index,
size_t  element_count,
GpuBufferBinding::ElementType  element_type,
Portal::Graphics::BufferUsageHint  usage_hint = Portal::Graphics::BufferUsageHint::COMPUTE_STORAGE 
)

Definition at line 437 of file GpuResourceManager.cpp.

440{
441 const size_t width = Portal::Graphics::element_type_bytes(element_type);
442 if (width == 0) {
443 error<std::runtime_error>(
446 std::source_location::current(),
447 "GpuResourceManager: ensure_shared_buffer requires a sized element_type");
448 }
449
450 auto& slot = m_shared->slots[{ set, binding_index }];
451 const size_t required_bytes = element_count * width;
452 if (slot.allocated_bytes >= required_bytes)
453 return;
454
455 auto& foundry = Portal::Graphics::get_shader_foundry();
456 const bool gpu_resident = usage_hint == Portal::Graphics::BufferUsageHint::DEVICE
458 allocate_slot(foundry.get_device(), foundry.get_physical_device(),
459 slot, required_bytes, Portal::Graphics::to_buffer_usage_flags(usage_hint), gpu_resident);
460}
uint32_t width
std::unique_ptr< SharedBuffers > m_shared
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.
size_t element_type_bytes(GpuBufferBinding::ElementType et) noexcept
Byte width of one GpuBufferBinding::ElementType element.
@ COMPUTE
Storage buffer for compute shaders (device-local)
@ DEVICE
Device-local GPU-only buffer.
vk::BufferUsageFlags to_buffer_usage_flags(BufferUsageHint hint)
Resolve the extra vk::BufferUsageFlags a BufferUsageHint requires, on top of whatever base usage the ...

References MayaFlux::Journal::BufferProcessing, MayaFlux::Portal::Graphics::COMPUTE, MayaFlux::Portal::Graphics::DEVICE, MayaFlux::Portal::Graphics::element_type_bytes(), MayaFlux::Portal::Graphics::get_shader_foundry(), m_shared, MayaFlux::Portal::Graphics::to_buffer_usage_flags(), width, and MayaFlux::Journal::Yantra.

+ Here is the call graph for this function: