MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
SDFPrepProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::Buffers {
6
7/**
8 * @class SDFPrepProcessor
9 * @brief Default processor for the GPU-field marching-cubes chain.
10 *
11 * Owns the SDF corner grid buffer and the atomic vertex counter buffer.
12 * Zeros both on each frame so downstream processors start from a clean state.
13 * Performs no shader dispatch of its own.
14 *
15 * Active chain order:
16 * default — SDFPrepProcessor (this, owns + zeros grid/counter)
17 * pre — SDFFieldProcessor (writes grid via sdf_field.comp)
18 * flat[0] — SDFMeshProcessor (mc_emit, reads grid, emits verts)
19 * final — RenderProcessor
20 *
21 * @see SDFFieldProcessor
22 * @see SDFMeshProcessor
23 */
24class MAYAFLUX_API SDFPrepProcessor : public VKBufferProcessor {
25public:
26 /**
27 * @param res_x Cell count along X.
28 * @param res_y Cell count along Y.
29 * @param res_z Cell count along Z.
30 */
31 SDFPrepProcessor(uint32_t res_x, uint32_t res_y, uint32_t res_z);
32
33 ~SDFPrepProcessor() override = default;
34
35 /**
36 * @brief Rebuild owned buffers to match a new resolution.
37 *
38 * Must be called before the next frame when resolution changes.
39 */
40 void set_resolution(uint32_t res_x, uint32_t res_y, uint32_t res_z);
41
42 /** @brief Grid buffer written by SDFFieldProcessor, read by SDFMeshProcessor. */
43 [[nodiscard]] std::shared_ptr<VKBuffer> grid_buf() const { return m_grid_buf; }
44
45 /** @brief Counter buffer zeroed here, written by mc_emit, read back by SDFMeshProcessor. */
46 [[nodiscard]] std::shared_ptr<VKBuffer> counter_buf() const { return m_counter_buf; }
47
48 void on_attach(const std::shared_ptr<Buffer>& buffer) override;
49 void processing_function(const std::shared_ptr<Buffer>& buffer) override;
50
51private:
52 uint32_t m_res_x;
53 uint32_t m_res_y;
54 uint32_t m_res_z;
55
56 std::shared_ptr<VKBuffer> m_grid_buf;
57 std::shared_ptr<VKBuffer> m_counter_buf;
58
59 void rebuild_buffers();
60
61 [[nodiscard]] uint32_t corner_count() const noexcept
62 {
63 return (m_res_x + 1) * (m_res_y + 1) * (m_res_z + 1);
64 }
65};
66
67} // namespace MayaFlux::Buffers
uint32_t corner_count() const noexcept
std::shared_ptr< VKBuffer > m_counter_buf
std::shared_ptr< VKBuffer > m_grid_buf
~SDFPrepProcessor() override=default
std::shared_ptr< VKBuffer > grid_buf() const
Grid buffer written by SDFFieldProcessor, read by SDFMeshProcessor.
std::shared_ptr< VKBuffer > counter_buf() const
Counter buffer zeroed here, written by mc_emit, read back by SDFMeshProcessor.
Default processor for the GPU-field marching-cubes chain.