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

◆ bind_descriptor() [2/2]

template<typename T >
void MayaFlux::Buffers::FormaBindingsProcessor::bind_descriptor ( const std::string &  name,
std::shared_ptr< Portal::Forma::MappedState< T > >  state,
std::function< float(T)>  project,
const std::string &  descriptor_name,
uint32_t  binding_index,
uint32_t  set,
Portal::Graphics::DescriptorRole  role = Portal::Graphics::DescriptorRole::UNIFORM 
)
inline

Bind a MappedState<T> to a descriptor binding on the attached buffer.

Creates an owned host-visible GPU buffer sized to sizeof(float). Each tick the projected value is uploaded into this buffer and registered in the attached buffer's descriptor_buffer_bindings, following the same path as DescriptorBindingsProcessor.

Parameters
nameLogical binding name.
stateMappedState whose value is read each graphics tick.
projectProjection from T to float. Called every tick.
descriptor_nameDescriptor name in the shader config.
binding_indexVulkan binding index within the descriptor set.
setDescriptor set index.
roleUNIFORM for UBO, STORAGE for SSBO.
Template Parameters
TMappedState value type.

Definition at line 237 of file FormaBindingsProcessor.hpp.

245 {
246 if (!state) {
248 "FormaBindingsProcessor::bind_descriptor: null state for '{}'", name);
249 return;
250 }
251
252 release(name);
253 auto gpu_buf = make_descriptor_buffer(role);
254
255 auto& b = m_bindings[name];
257 b.reader = [s = std::move(state), p = std::move(project)]() {
258 return p(s->value);
259 };
260 b.pc.reset();
261 b.desc = DescriptorTarget {
262 .descriptor_name = descriptor_name,
263 .set_index = set,
264 .binding_index = binding_index,
265 .role = role,
266 .gpu_buffer = gpu_buf,
267 .buffer_size = sizeof(float),
268 };
269
270 bind_buffer(descriptor_name, gpu_buf);
272
274 "FormaBindingsProcessor::bind_descriptor: '{}' -> descriptor '{}' set={} binding={}",
275 name, descriptor_name, set, binding_index);
276 }
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
size_t b
std::string name
Definition VKDevice.cpp:123
static std::shared_ptr< VKBuffer > make_descriptor_buffer(Portal::Graphics::DescriptorRole role)
std::unordered_map< std::string, Binding > m_bindings
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.

References b, MayaFlux::Buffers::FormaBindingsProcessor::DescriptorTarget::descriptor_name, MF_DEBUG, MF_ERROR, and name.