11 std::shared_ptr<Nodes::GpuSync::GeometryWriterNode> node,
12 const std::string& binding_name,
13 float over_allocate_factor)
15 calculate_buffer_size(node, over_allocate_factor),
17 Kakshya::DataModality::VERTEX_POSITIONS_3D)
18 , m_geometry_node(
std::move(node))
19 , m_binding_name(binding_name)
22 error<std::invalid_argument>(
25 std::source_location::current(),
26 "Cannot create GeometryBuffer with null GeometryWriterNode");
30 "Created GeometryBuffer '{}' for {} vertices ({} bytes, stride: {})",
39 auto self = std::dynamic_pointer_cast<GeometryBuffer>(shared_from_this());
52 chain = std::make_shared<BufferProcessingChain>();
55 chain->set_preferred_token(token);
89#ifndef MAYAFLUX_PLATFORM_MACOS
109 ?
"mesh_textured.frag.spv"
110 :
"triangle.frag.spv";
121 const bool frag_samples_texture = resolved_config.
fragment_shader.find(
"textured") != std::string::npos;
123 if (textured && !frag_samples_texture) {
125 "GeometryBuffer::setup_rendering: texture supplied but fragment shader '{}' "
126 "does not sample a texture — texture will be ignored",
130 const bool apply_texture = textured && frag_samples_texture;
137 sc.bindings[slot] =
ShaderBinding(0, 1, vk::DescriptorType::eCombinedImageSampler);
163 const std::shared_ptr<Nodes::GpuSync::GeometryWriterNode>& node,
164 float over_allocate_factor)
170 size_t base_size = node->get_vertex_buffer_size_bytes();
172 if (base_size == 0) {
174 "GeometryWriterNode has zero-size vertex buffer. "
175 "Did you forget to call set_vertex_stride() or resize_vertex_buffer()?");
179 auto allocated_size =
static_cast<size_t>(
180 static_cast<float>(base_size) * over_allocate_factor);
182 if (over_allocate_factor > 1.0F) {
184 "Over-allocated geometry buffer: {} → {} bytes ({}x)",
185 base_size, allocated_size, over_allocate_factor);
188 return allocated_size;
#define MF_INFO(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::vector< std::pair< std::shared_ptr< Core::VKImage >, std::string > > m_pending_textures
std::shared_ptr< Core::VKImage > m_diffuse_texture
std::shared_ptr< Nodes::GpuSync::GeometryWriterNode > m_geometry_node
void setup_processors(ProcessingToken token) override
Initialize the buffer and its processors.
void setup_rendering(const RenderConfig &config)
Setup rendering with RenderProcessor.
std::string m_binding_name
static size_t calculate_buffer_size(const std::shared_ptr< Nodes::GpuSync::GeometryWriterNode > &node, float over_allocate_factor)
Calculate initial buffer size with optional over-allocation.
void set_texture(std::shared_ptr< Core::VKImage > image, std::string binding="diffuseTex")
Supply a diffuse texture, bound on the next graphics tick.
GeometryBuffer(std::shared_ptr< Nodes::GpuSync::GeometryWriterNode > node, const std::string &binding_name="geometry", float over_allocate_factor=1.5F)
Create geometry buffer from generative node.
std::string m_diffuse_binding
std::shared_ptr< GeometryBindingsProcessor > m_bindings_processor
std::shared_ptr< Buffers::BufferProcessingChain > get_processing_chain() override
Access the buffer's processing chain.
void set_default_processor(const std::shared_ptr< BufferProcessor > &processor) override
Set the buffer's default processor.
vk::DeviceSize get_size_bytes() const
void set_processing_chain(const std::shared_ptr< BufferProcessingChain > &chain, bool force=false) override
Replace the buffer's processing chain.
void apply_render_config(const RenderConfig &config, const ShaderConfig &shader_config)
Configure the internal m_render_processor from a RenderConfig.
std::shared_ptr< RenderProcessor > m_render_processor
void set_default_render_config(const RenderConfig &config)
Called by derived classes to set their context-specific defaults.
Vulkan-backed buffer wrapper used in processing chains.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
@ BufferManagement
Buffer Management (Buffers::BufferManager, creating buffers)
@ Init
Engine/subsystem initialization.
@ Buffers
Buffers, Managers, processors and processing chains.
Describes how a VKBuffer binds to a shader descriptor.
PrimitiveTopology topology
std::string vertex_shader
std::string fragment_shader
std::string default_texture_binding
std::string geometry_shader
Unified rendering configuration for graphics buffers.