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

◆ feed() [1/2]

void MayaFlux::Buffers::ShaderProcessor::feed ( const std::string &  name,
FeedSource  source 
)

Supply a shader input from a callable, resolved by name.

Parameters
nameA name already declared on this shader: a descriptor in config.bindings, or a push constant field from the ShaderSpec this processor was constructed from.
sourceCallable pulled each cycle. Returns a DataVariant for a descriptor name, a double for a push constant field.

Resolution happens once, here. Descriptor names take precedence; a name matching neither is an error and registers nothing. File-shader processors have no record of push constant field names, so their constant feeds must use the explicit overload.

Definition at line 212 of file ShaderProcessor.cpp.

213{
214 if (!source) {
216 "feed: null source for '{}'", name);
217 return;
218 }
219
220 if (m_config.bindings.contains(name)) {
221 auto& entry = m_feeds[name];
222 entry.source = std::move(source);
223 entry.is_storage = true;
224 entry.offset = 0;
225 entry.size = 0;
226 entry.descriptor_name = name;
227 entry.buffer.reset();
228 entry.mismatch_logged = false;
229 return;
230 }
231
232 uint32_t offset = 0;
233 for (const auto& field : m_config.pc_fields) {
234 const size_t width = Kakshya::gpu_data_format_bytes(field.format);
235 if (field.name == name) {
236 auto& entry = m_feeds[name];
237 entry.source = std::move(source);
238 entry.is_storage = false;
239 entry.offset = offset;
240 entry.size = width;
241 entry.descriptor_name.clear();
242 entry.buffer.reset();
243 entry.mismatch_logged = false;
244 return;
245 }
246 offset += static_cast<uint32_t>(width);
247 }
248
250 "feed: '{}' matches no descriptor and no push constant field. "
251 "File-shader processors must supply an explicit offset.",
252 name);
253}
#define MF_ERROR(comp, ctx,...)
float offset
uint32_t width
std::unordered_map< std::string, Feed > m_feeds
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
size_t gpu_data_format_bytes(GpuDataFormat fmt) noexcept
Byte size of one element of a GpuDataFormat.
Definition NDData.cpp:9
std::unordered_map< std::string, ShaderBinding > bindings

References MayaFlux::Buffers::ShaderConfig::bindings, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Kakshya::gpu_data_format_bytes(), m_config, m_feeds, MF_ERROR, offset, MayaFlux::Buffers::ShaderConfig::pc_fields, and width.

+ Here is the call graph for this function: