MayaFlux 0.4.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 172 of file FormaBindingsProcessor.hpp.

180 {
181 if (!state) {
183 "FormaBindingsProcessor::bind_descriptor: null state for '{}'", name);
184 return;
185 }
186
187 auto gpu_buf = make_descriptor_buffer(role);
188
189 auto& b = m_bindings[name];
191 b.reader = [s = std::move(state), p = std::move(project)]() {
192 return p(s->value);
193 };
194 b.pc.reset();
195 b.desc = DescriptorTarget {
196 .descriptor_name = descriptor_name,
197 .set_index = set,
198 .binding_index = binding_index,
199 .role = role,
200 .gpu_buffer = gpu_buf,
201 .buffer_size = sizeof(float),
202 };
203
204 bind_buffer(descriptor_name, gpu_buf);
206
208 "FormaBindingsProcessor::bind_descriptor: '{}' -> descriptor '{}' set={} binding={}",
209 name, descriptor_name, set, binding_index);
210 }
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
size_t b
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, and MF_ERROR.