21 config.resolution_x, config.resolution_y, config.resolution_z),
23 Kakshya::DataModality::VERTEX_POSITIONS_3D)
24 , m_res_x(
std::
max(config.resolution_x, 1U))
25 , m_res_y(
std::
max(config.resolution_y, 1U))
26 , m_res_z(
std::
max(config.resolution_z, 1U))
27 , m_bounds_min(config.bounds_min)
28 , m_bounds_max(config.bounds_max)
29 , m_iso_level(config.iso_level)
31 std::visit([
this](
auto&& source) {
32 using Source = std::remove_cvref_t<
decltype(source)>;
33 if constexpr (std::is_same_v<Source, Kinesis::SpatialField>) {
35 }
else if constexpr (std::is_same_v<Source, std::filesystem::path>) {
46 "ComputeMeshBuffer{}: {}x{}x{} grid, {:.1f} MB worst-case",
58 auto self = std::dynamic_pointer_cast<ComputeMeshBuffer>(shared_from_this());
61 layout.vertex_count =
static_cast<uint32_t
>(
67 chain = std::make_shared<BufferProcessingChain>();
70 chain->set_preferred_token(token);
128 ?
"mesh_textured.frag.spv"
129 :
"triangle.frag.spv";
138 sc.bindings[slot] =
ShaderBinding(0, 1, vk::DescriptorType::eCombinedImageSampler);
150 "ComputeMeshBuffer: rendering configured ({}textured)",
151 textured ?
"" :
"un");
#define MF_INFO(comp, ctx,...)
BufferProcessingChain * chain
void set_dirty()
Request a re-dispatch on the next graphics frame.
ComputeMeshBuffer(Config config)
std::shared_ptr< SDFMeshProcessor > m_sdf_processor
std::shared_ptr< SDFFieldProcessor > m_field_processor
Kinesis::SpatialField m_field
void set_bounds(const glm::vec3 &bounds_min, const glm::vec3 &bounds_max)
Replace the evaluation volume and mark dirty.
void set_texture(std::shared_ptr< Core::VKImage > image, std::string binding="diffuseTex")
Bind a diffuse texture sampled in the fragment shader.
std::string m_diffuse_binding
void setup_rendering(const RenderConfig &config)
Create the RenderProcessor and attach it to the processing chain.
static size_t worst_case_bytes(uint32_t res_x, uint32_t res_y, uint32_t res_z) noexcept
std::optional< uint32_t > get_live_vertex_count() const
The live vertex count from the most recent dispatch.
std::shared_ptr< Core::VKImage > m_diffuse_texture
std::shared_ptr< SDFPrepProcessor > m_prep_processor
std::string m_field_shader
void set_iso_level(float iso_level)
Replace the iso_level threshold and mark dirty.
void setup_processors(ProcessingToken token) override
Setup processors with a processing token.
void set_resolution(uint32_t res_x, uint32_t res_y, uint32_t res_z)
Replace the grid resolution.
std::optional< Kinesis::FieldSource > m_field_expression
void set_field(Kinesis::SpatialField field)
Replace the scalar field and mark dirty.
void set_vertex_layout(const Kakshya::VertexLayout &layout)
Set vertex layout for this buffer.
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
Vulkan-backed buffer wrapper used in processing chains.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
@ Init
Engine/subsystem initialization.
@ Buffers
Buffers, Managers, processors and processing chains.
BufferUsageHint
Semantic usage hint for buffer allocation and memory properties.
Describes how a VKBuffer binds to a shader descriptor.
Vertex type for indexed triangle mesh primitives (TRIANGLE_LIST topology)
static VertexLayout for_meshes(uint32_t stride=60)
Factory: layout for MeshVertex (position, color, weight, uv, normal, tangent)
Typed, composable, stateless callable from domain D to range R.
PrimitiveTopology topology
std::string vertex_shader
std::string fragment_shader
std::string default_texture_binding
Unified rendering configuration for graphics buffers.