82 void bind_push_constant(
83 const std::string& name,
84 std::function<
float()> reader,
86 size_t size =
sizeof(
float));
104 void bind_descriptor(
105 const std::string& name,
106 std::function<
float()> reader,
107 const std::string& descriptor_name,
108 uint32_t binding_index,
127 template <
typename T>
129 const std::string& name,
131 std::function<
float(T)> project,
133 size_t size =
sizeof(
float))
136 MF_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
137 "FormaBindingsProcessor::bind_push_constant: null state for '{}'", name);
141 auto&
b = m_bindings[name];
142 b.kind = TargetKind::PUSH_CONSTANT;
143 b.reader = [s = std::move(state), p = std::move(project)]() {
171 template <
typename T>
173 const std::string& name,
175 std::function<
float(T)> project,
176 const std::string& descriptor_name,
177 uint32_t binding_index,
182 MF_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
183 "FormaBindingsProcessor::bind_descriptor: null state for '{}'", name);
187 auto gpu_buf = make_descriptor_buffer(role);
189 auto&
b = m_bindings[name];
190 b.kind = TargetKind::DESCRIPTOR;
191 b.reader = [s = std::move(state), p = std::move(project)]() {
198 .binding_index = binding_index,
200 .gpu_buffer = gpu_buf,
201 .buffer_size =
sizeof(float),
204 bind_buffer(descriptor_name, gpu_buf);
205 m_needs_descriptor_rebuild =
true;
207 MF_DEBUG(Journal::Component::Buffers, Journal::Context::BufferProcessing,
208 "FormaBindingsProcessor::bind_descriptor: '{}' -> descriptor '{}' set={} binding={}",
209 name, descriptor_name, set, binding_index);
217 [[nodiscard]]
bool has_binding(
const std::string& name)
const;
220 [[nodiscard]] std::vector<std::string> get_binding_names()
const;
226 bool unbind(
const std::string& name);
229 void execute_shader(
const std::shared_ptr<VKBuffer>& buffer)
override;
256 std::optional<PushConstantTarget>
pc;
257 std::optional<DescriptorTarget>
desc;
262 void flush_push_constant(
float value,
const PushConstantTarget& pc,
const std::shared_ptr<VKBuffer>& buffer);
265 const std::shared_ptr<VKBuffer>& attached);
267 [[nodiscard]]
static std::shared_ptr<VKBuffer> make_descriptor_buffer(
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
Abstract base class for shader-based buffer processing.
DescriptorRole
Semantic descriptor type — maps to Vulkan descriptor types internally.