26 const std::string& name,
27 std::function<
float()> reader,
33 b.reader = std::move(reader);
39 const std::string& name,
40 std::function<
float()> reader,
41 const std::string& descriptor_name,
42 uint32_t binding_index,
48 "FormaBindingsProcessor::bind_descriptor: null reader for '{}'", name);
54 b.reader = std::move(reader);
62 .binding_index = binding_index,
64 .gpu_buffer = gpu_buf,
65 .buffer_size =
sizeof(float),
83 std::vector<std::string> names;
105 "FormaBindingsProcessor: binding '{}' has no reader", name);
109 const float value =
b.reader();
130 const std::shared_ptr<VKBuffer>& buffer)
132 auto& entries = buffer->get_pipeline_context().push_constant_bindings;
134 auto it = std::ranges::find_if(entries, [&](
const auto& e) {
135 return e.offset == pc.
offset;
138 if (it == entries.end()) {
141 .data = std::vector<uint8_t>(pc.
size) });
142 it = std::prev(entries.end());
145 if (pc.
size ==
sizeof(
float)) {
146 std::memcpy(it->data.data(), &
value,
sizeof(
float));
147 }
else if (pc.
size ==
sizeof(
double)) {
148 auto promoted =
static_cast<double>(
value);
149 std::memcpy(it->data.data(), &promoted,
sizeof(
double));
153 "FormaBindingsProcessor: PC write offset={} value={}", pc.
offset,
value);
159 const std::shared_ptr<VKBuffer>& attached)
163 auto& bindings_list = attached->get_pipeline_context().descriptor_buffer_bindings;
165 for (
auto& entry : bindings_list) {
167 entry.buffer_info.buffer = desc.
gpu_buffer->get_buffer();
168 entry.buffer_info.offset = 0;
169 entry.buffer_info.range =
sizeof(float);
174 bindings_list.push_back({
178 ? vk::DescriptorType::eUniformBuffer
179 : vk::DescriptorType::eStorageBuffer,
180 .buffer_info = vk::DescriptorBufferInfo {
181 desc.
gpu_buffer->get_buffer(), 0,
sizeof(float) },
189 ? VKBuffer::Usage::UNIFORM
190 : VKBuffer::Usage::COMPUTE;
192 auto buf = std::make_shared<VKBuffer>(
201 error<std::runtime_error>(
204 std::source_location::current(),
205 "FormaBindingsProcessor: no BufferService available");
208 svc->initialize_buffer(buf);
#define MF_ERROR(comp, ctx,...)
#define MF_RT_WARN(comp, ctx,...)
#define MF_RT_DEBUG(comp, ctx,...)
bool m_needs_descriptor_rebuild
void bind_buffer(const std::string &descriptor_name, const std::shared_ptr< VKBuffer > &buffer)
Bind a VKBuffer to a named shader descriptor.
Abstract base class for shader-based buffer processing.
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
void upload_to_gpu(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging)
Upload raw data to GPU buffer (auto-detects host-visible vs device-local)
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
@ UNKNOWN
Unknown or undefined modality.
DescriptorRole
Semantic descriptor type — maps to Vulkan descriptor types internally.
@ UNIFORM
Small, read-only, frequently updated (scalars, param structs)
BufferUsageHint
Semantic usage hint for buffer allocation and memory properties.
Self-describing push constant fragment staged on a VKBuffer.
Backend buffer management service interface.