82 void bind_push_constant(
83 const std::string&
name,
84 std::function<
float()> reader,
86 size_t size =
sizeof(
float));
101 void bind_push_constant(
102 const std::string&
name,
103 std::function<
float()> reader,
118 void bind_typed_push_constant(
119 const std::string&
name,
139 void bind_descriptor(
140 const std::string&
name,
141 std::function<
float()> reader,
142 const std::string& descriptor_name,
143 uint32_t binding_index,
162 template <
typename T>
164 const std::string&
name,
166 std::function<
float(T)> project,
168 size_t size =
sizeof(
float))
171 MF_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
172 "FormaBindingsProcessor::bind_push_constant: null state for '{}'",
name);
177 auto&
b = m_bindings[
name];
178 b.kind = TargetKind::PUSH_CONSTANT;
179 b.reader = [s = std::move(state), p = std::move(project)]() {
193 template <
typename T>
195 const std::string&
name,
197 std::function<
float(T)> project,
202 MF_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
203 "FormaBindingsProcessor::bind_push_constant: null state for '{}'",
name);
209 std::function<
float()>([s = std::move(state), p = std::move(project)]() {
236 template <
typename T>
238 const std::string&
name,
240 std::function<
float(T)> project,
241 const std::string& descriptor_name,
242 uint32_t binding_index,
247 MF_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
248 "FormaBindingsProcessor::bind_descriptor: null state for '{}'",
name);
253 auto gpu_buf = make_descriptor_buffer(role);
255 auto&
b = m_bindings[
name];
256 b.kind = TargetKind::DESCRIPTOR;
257 b.reader = [s = std::move(state), p = std::move(project)]() {
264 .binding_index = binding_index,
266 .gpu_buffer = gpu_buf,
267 .buffer_size =
sizeof(float),
270 bind_buffer(descriptor_name, gpu_buf);
271 m_needs_descriptor_rebuild =
true;
273 MF_DEBUG(Journal::Component::Buffers, Journal::Context::BufferProcessing,
274 "FormaBindingsProcessor::bind_descriptor: '{}' -> descriptor '{}' set={} binding={}",
275 name, descriptor_name, set, binding_index);
283 [[nodiscard]]
bool has_binding(
const std::string&
name)
const;
286 [[nodiscard]] std::vector<std::string> get_binding_names()
const;
292 bool unbind(
const std::string&
name);
295 void execute_shader(
const std::shared_ptr<VKBuffer>&
buffer)
override;
316 std::optional<Kakshya::GpuDataFormat>
format {};
332 std::optional<PushConstantTarget>
pc;
333 std::optional<DescriptorTarget>
desc;
339 void release(
const std::string&
name);
341 void remember_target(
const std::shared_ptr<VKBuffer>&
buffer);
348 const std::shared_ptr<VKBuffer>& attached);
350 [[nodiscard]]
static std::shared_ptr<VKBuffer> make_descriptor_buffer(
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::shared_ptr< NetworkGeometryBuffer > buffer
Abstract base class for shader-based buffer processing.
std::variant< float, glm::vec2, glm::vec3, glm::vec4, double, glm::dvec2, glm::dvec3, glm::dvec4, int32_t, uint32_t, uint8_t, uint16_t, glm::mat4 > GpuValue
One value of any GpuDataFormat.
GpuDataFormat
GPU data formats with explicit precision levels.
DescriptorRole
Semantic descriptor type — maps to Vulkan descriptor types internally.