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

◆ bind_host_vk_buffer()

void MayaFlux::Buffers::DescriptorBindingsProcessor::bind_host_vk_buffer ( const std::string &  name,
const std::shared_ptr< VKBuffer > &  buffer,
const std::string &  descriptor_name,
uint32_t  set,
Portal::Graphics::DescriptorRole  role = Portal::Graphics::DescriptorRole::STORAGE 
)

Bind a host-visible VKBuffer as a descriptor source.

Fails hard at bind time if the buffer is not host-visible. Reads mapped memory each cycle and uploads to the descriptor. Always treated as VECTOR binding.

Parameters
nameLogical binding name
bufferHost-visible VKBuffer to read from
descriptor_nameName in shader config bindings
setDescriptor set index
roleDescriptor role (default: STORAGE)

Definition at line 266 of file DescriptorBindingsProcessor.cpp.

272{
273 if (!buffer) {
275 "Cannot bind null VKBuffer '{}'", name);
276 return;
277 }
278
279 if (!buffer->is_host_visible()) {
281 "VKBuffer '{}' is device-local. Binding device-local buffers as descriptor "
282 "sources requires a GPU-side copy via compute shader, not CPU readback. "
283 "Use a host-visible buffer or restructure the pipeline.",
284 name);
285 return;
286 }
287
288 if (m_config.bindings.find(descriptor_name) == m_config.bindings.end()) {
290 "Descriptor '{}' not found in shader config", descriptor_name);
291 return;
292 }
293
294 const auto& binding_config = m_config.bindings[descriptor_name];
295 auto gpu_buffer = create_descriptor_buffer(buffer->get_size_bytes(), role);
296
297 auto [it, inserted] = m_bindings.try_emplace(name);
298 auto& binding = it->second;
299
300 binding.buffer = buffer;
301 binding.descriptor_name = descriptor_name;
302 binding.set_index = set;
303 binding.binding_index = binding_config.binding;
304 binding.role = role;
305 binding.binding_type = BindingType::VECTOR;
306 binding.source_type = SourceType::HOST_VK_BUFFER;
307 binding.gpu_buffer = gpu_buffer;
308 binding.buffer_offset = 0;
309 binding.buffer_size = buffer->get_size_bytes();
310
311 bind_buffer(descriptor_name, gpu_buffer);
313
315 "Bound host VKBuffer '{}' to descriptor '{}' ({} bytes)",
316 name, descriptor_name, buffer->get_size_bytes());
317}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::unordered_map< std::string, DescriptorBinding > m_bindings
std::shared_ptr< VKBuffer > create_descriptor_buffer(size_t size, Portal::Graphics::DescriptorRole role)
Create GPU buffer for a descriptor binding.
void bind_buffer(const std::string &descriptor_name, const std::shared_ptr< VKBuffer > &buffer)
Bind a VKBuffer to a named shader descriptor.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
std::unordered_map< std::string, ShaderBinding > bindings

References MayaFlux::Buffers::ShaderProcessor::bind_buffer(), MayaFlux::Buffers::ShaderConfig::bindings, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, create_descriptor_buffer(), HOST_VK_BUFFER, m_bindings, MayaFlux::Buffers::ShaderProcessor::m_config, MayaFlux::Buffers::ShaderProcessor::m_needs_descriptor_rebuild, MF_DEBUG, MF_ERROR, and VECTOR.

+ Here is the call graph for this function: