MayaFlux 1.0.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 219 of file ShaderProcessor.cpp.

220{
221 if (!source) {
223 "feed: null source for '{}'", name);
224 return;
225 }
226
227 if (m_config.bindings.contains(name)) {
228 auto& entry = m_feeds[name];
229 entry.source = std::move(source);
230 entry.is_storage = true;
231 entry.offset = 0;
232 entry.size = 0;
233 entry.format.reset();
234 entry.descriptor_name = name;
235 entry.buffer.reset();
236 entry.mismatch_logged = false;
237 entry.early = true;
238 return;
239 }
240
242 for (size_t i = 0; i < m_config.pc_fields.size(); ++i) {
243 const auto& field = m_config.pc_fields[i];
244 if (field.name == name) {
245 auto& entry = m_feeds[name];
246 entry.source = std::move(source);
247 entry.is_storage = false;
248 entry.offset = layout.offsets[i];
249 entry.size = Kakshya::gpu_data_format_bytes(field.format);
250 entry.format = field.format;
251 entry.descriptor_name.clear();
252 entry.buffer.reset();
253 entry.mismatch_logged = false;
254 entry.early = true;
255 return;
256 }
257 }
258
260 "feed: '{}' matches no descriptor and no push constant field. "
261 "File-shader processors must supply an explicit offset.",
262 name);
263}
#define MF_ERROR(comp, ctx,...)
std::string name
Definition VKDevice.cpp:123
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.
Kakshya::GpuBlockLayout push_constant_layout(const std::vector< PushConstantField > &fields)
Offsets and total size of a push constant block, under std430.
std::unordered_map< std::string, ShaderBinding > bindings
std::vector< Portal::Graphics::PushConstantField > pc_fields
Retained from a ShaderSpec so feeds can resolve a field name to an offset. Empty for file shaders.

References MayaFlux::Buffers::ShaderConfig::bindings, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Kakshya::gpu_data_format_bytes(), m_config, m_feeds, MF_ERROR, name, MayaFlux::Buffers::ShaderConfig::pc_fields, and MayaFlux::Portal::Graphics::push_constant_layout().

+ Here is the call graph for this function: