9class RelaxationStepProcessor;
10class RelaxationEmitProcessor;
60 using ShaderSource = std::variant<std::string, Portal::Graphics::ShaderSpec>;
91 using Constant = std::variant<uint32_t, int32_t, float>;
98 std::optional<Kakshya::GpuDataFormat>
state;
107 float extent { 1.0F };
108 float point_size { 2.0F };
129 size_t cell_stride_bytes,
130 ShaderSource rule_source,
131 ShaderSource emit_source);
186 return static_cast<size_t>(m_width) * m_height * m_cell_stride_bytes;
212 void seed_state(
const void* data,
size_t size);
218 [[nodiscard]] uint32_t
front_index()
const {
return m_front_is_a ? 0 : 1; }
224 [[nodiscard]] uint32_t
back_index()
const {
return m_front_is_a ? 1 : 0; }
244 [[nodiscard]] std::shared_ptr<Vruta::BroadcastSource<std::vector<uint8_t>>>
snapshot_source()
const
246 return m_snapshot_source;
250 [[nodiscard]] std::shared_ptr<RelaxationStepProcessor>
step_processor()
const {
return m_step_processor; }
253 [[nodiscard]] std::shared_ptr<RelaxationEmitProcessor>
emit_processor()
const {
return m_emit_processor; }
274 return m_snapshot_requested.exchange(
false, std::memory_order_acq_rel);
280 std::shared_ptr<Vruta::BroadcastSource<std::vector<uint8_t>>> m_snapshot_source {
281 std::make_shared<Vruta::BroadcastSource<std::vector<uint8_t>>>()
289 float m_extent { 1.0F };
290 float m_point_size { 2.0F };
295 bool m_front_is_a {
true };
296 std::atomic<bool> m_snapshot_requested {
false };
ComputeProcessor that reads the current front generation's raw state buffer from a RelaxationGridBuff...
~RelaxationGridBuffer() override=default
Destructor.
const ShaderSource & rule_source() const
The rule source this buffer was constructed with: either a hand-written shader path or a generated Sh...
std::vector< GridConfig::Constant > m_rule_constants
Rule constants from GridConfig, written at setup_processors.
std::vector< GridConfig::Constant > m_emit_constants
Emit constants from GridConfig, written at setup_processors.
std::shared_ptr< RelaxationEmitProcessor > m_emit_processor
Emit stage, retained for parameter access.
ShaderSource m_emit_source
Either a path to a hand-written emit shader or a generated ShaderSpec.
bool consume_snapshot_request()
std::shared_ptr< RelaxationEmitProcessor > emit_processor() const
The attached emit-stage processor, valid after setup_processors().
uint32_t get_cell_count() const
Total cell count, width * height.
uint32_t get_grid_width() const
Grid width in cells.
std::shared_ptr< RelaxationStepProcessor > m_step_processor
Rule stage, retained for parameter access.
size_t get_state_bytes() const
Total byte size of one generation's state buffer.
size_t get_cell_stride_bytes() const
Size in bytes of one cell's state, fixed at construction.
size_t m_cell_stride_bytes
Size in bytes of one cell's state, fixed at construction.
std::shared_ptr< RelaxationStepProcessor > step_processor() const
The attached rule-stage processor, valid after setup_processors().
uint32_t m_width
Grid width in cells.
ShaderSource m_rule_source
Either a path to a hand-written rule shader or a generated ShaderSpec.
std::variant< std::string, Portal::Graphics::ShaderSpec > ShaderSource
Either a shader file path or a generated ShaderSpec, resolved at construction time by setup_processor...
std::shared_ptr< Vruta::BroadcastSource< std::vector< uint8_t > > > snapshot_source() const
BroadcastSource of completed generation snapshots.
uint32_t back_index() const
Index into m_resources.back_buffers currently serving as the write target for the next rule dispatch.
uint32_t front_index() const
Index into m_resources.back_buffers currently holding the most recently completed generation's state.
uint32_t get_grid_height() const
Grid height in cells.
void request_snapshot()
Request a snapshot of the next completed generation.
uint32_t m_height
Grid height in cells.
const ShaderSource & emit_source() const
The emit source this buffer was constructed with.
GPU-resident, double-buffered SSBO state for synchronous local-rule systems evaluated over a fixed 2D...
ComputeProcessor driving one generation step of a RelaxationGridBuffer per dispatch.
Vulkan-backed buffer wrapper used in processing chains.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
std::optional< Kakshya::GpuDataFormat > state
Format of one cell as this stage reads it. Nullopt derives it from the ShaderSpec binding ("state_in"...
std::vector< Constant > constants
Initial words after the stage's fixed prefix (GridExtent for a rule, EmitParams for an emit),...
ShaderSource shader
Hand-written shader path or generated ShaderSpec.
One compute stage of the grid, rule or emit.
uint32_t width
Grid width in cells. Required.
Stage emit
Required. Reads "cell_state", writes packed vertices.
uint32_t height
Grid height in cells. Required.
Stage rule
Required. Reads "state_in", writes "state_out".
std::variant< uint32_t, int32_t, float > Constant
One 4-byte push constant word, in the scalar types a shader block can hold.
Arrangement of a relaxation grid: extent, the update rule, the emit stage that draws it,...
Unified rendering configuration for graphics buffers.