19 const glm::vec3& bounds_min,
20 const glm::vec3& bounds_max,
26 worst_case_bytes(res_x, res_y, res_z),
28 Kakshya::DataModality::VERTEX_POSITIONS_3D)
29 , m_res_x(
std::max(res_x, 1U))
30 , m_res_y(
std::max(res_y, 1U))
31 , m_res_z(
std::max(res_z, 1U))
32 , m_field(
std::move(field))
33 , m_bounds_min(bounds_min)
34 , m_bounds_max(bounds_max)
35 , m_iso_level(iso_level)
38 "ComputeMeshBuffer: {}x{}x{} grid, {:.1f} MB worst-case",
44 const glm::vec3& bounds_min,
45 const glm::vec3& bounds_max,
50 std::string field_shader)
52 worst_case_bytes(res_x, res_y, res_z),
54 Kakshya::DataModality::VERTEX_POSITIONS_3D)
55 , m_res_x(
std::max(res_x, 1U))
56 , m_res_y(
std::max(res_y, 1U))
57 , m_res_z(
std::max(res_z, 1U))
58 , m_bounds_min(bounds_min)
59 , m_bounds_max(bounds_max)
60 , m_iso_level(iso_level)
62 , m_field_shader(
std::move(field_shader))
65 "ComputeMeshBuffer (GPU field): {}x{}x{} grid, {:.1f} MB worst-case",
76 auto self = std::dynamic_pointer_cast<ComputeMeshBuffer>(shared_from_this());
79 layout.vertex_count =
static_cast<uint32_t
>(
85 chain = std::make_shared<BufferProcessingChain>();
88 chain->set_preferred_token(token);
138 ?
"mesh_textured.frag.spv"
139 :
"triangle.frag.spv";
148 sc.bindings[slot] =
ShaderBinding(0, 1, vk::DescriptorType::eCombinedImageSampler);
160 "ComputeMeshBuffer: rendering configured ({}textured)",
161 textured ?
"" :
"un");
#define MF_INFO(comp, ctx,...)
void set_dirty()
Request a re-dispatch on the next graphics frame.
ComputeMeshBuffer(Kinesis::SpatialField field, const glm::vec3 &bounds_min, const glm::vec3 &bounds_max, uint32_t res_x, uint32_t res_y, uint32_t res_z, float iso_level=0.0F)
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::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.
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.
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.