28 auto& resources = grid->get_buffer_resources();
29 if (resources.back_buffers.size() < 2) {
38 const size_t bytes = grid->get_state_bytes();
39 foundry.update_descriptor_buffer(
41 resources.back_buffers[grid->front_index()].buffer, 0, bytes);
43 foundry.update_descriptor_buffer(
45 resources.back_buffers[grid->back_index()].buffer, 0, bytes);
86 .height =
m_grid->get_grid_height()
88 std::memcpy(data.data(), &extent,
sizeof(
GridExtent));
94 m_grid = std::dynamic_pointer_cast<RelaxationGridBuffer>(
buffer);
99 uint32_t gx = (
m_grid->get_grid_width() + 15) / 16;
100 uint32_t gy = (
m_grid->get_grid_height() + 15) / 16;
115 const std::shared_ptr<VKBuffer>&
buffer)
117 return std::dynamic_pointer_cast<RelaxationGridBuffer>(
buffer) !=
nullptr;
122 const std::shared_ptr<VKBuffer>& ,
138 if (!
m_grid->consume_snapshot_request()) {
142 const auto& front =
m_grid->get_buffer_resources().back_buffers[
m_grid->front_index()];
144 std::vector<uint8_t> bytes(
m_grid->get_state_bytes());
147 m_grid->snapshot_source()->signal(bytes);
std::shared_ptr< NetworkGeometryBuffer > buffer
virtual void on_attach(const std::shared_ptr< Buffer > &)
Called when this processor is attached to a buffer.
virtual void processing_function(const std::shared_ptr< Buffer > &buffer)=0
The core processing function that must be implemented by derived classes.
void set_workgroup_size(uint32_t x, uint32_t y=1, uint32_t z=1)
Set workgroup size (should match shader local_size)
void set_dispatch_mode(ShaderDispatchConfig::DispatchMode mode)
Set dispatch mode.
void set_manual_dispatch(uint32_t x, uint32_t y=1, uint32_t z=1)
Set manual dispatch group counts.
Specialized ShaderProcessor for Compute Pipelines.
void write_state_descriptors(const std::shared_ptr< RelaxationGridBuffer > &grid)
Issue direct ShaderFoundry descriptor writes for state_in and state_out against the grid's current fr...
void on_dispatch_complete(const std::shared_ptr< VKBuffer > &buffer) override
Serve a pending snapshot when a deferred dispatch completes.
void on_attach(const std::shared_ptr< Buffer > &buffer) override
Cover the grid with a 2D dispatch and write GridExtent.
StepPredicate m_step_predicate
Optional gate deciding whether a given cycle advances a generation.
std::shared_ptr< RelaxationGridBuffer > m_grid
The attached RelaxationGridBuffer, cached for descriptor writes and snapshot reads.
bool on_iteration(Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer, uint32_t index) override
Record that this cycle reached a dispatch.
void serve_snapshot()
Copy the front state buffer to the host and signal RelaxationGridBuffer::snapshot_source(),...
bool on_before_execute(Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer) override
Accept only a RelaxationGridBuffer.
std::shared_ptr< VKBuffer > m_snapshot_staging
Fallback staging buffer for download_back_buffer, unused while back_buffers stays HostVisible | HostC...
RelaxationStepProcessor(const std::string &shader_path, uint32_t workgroup_x=16)
Construct a step processor for the given rule shader file.
void processing_function(const std::shared_ptr< Buffer > &buffer) override
Run one cycle: evaluate the predicate, write the state descriptors, run the parent,...
bool m_dispatched
True when the current cycle recorded a dispatch.
void on_descriptors_created() override
Write the state_in / state_out descriptor bindings for the current front/back assignment.
void write_grid_extent_constants()
Size the push constant block to at least GridExtent and write the attached grid's dimensions into its...
const std::vector< uint8_t > & get_push_constant_data() const
Get current push constant data.
bool is_deferred_submission() const
Whether this processor submits asynchronously.
void set_push_constant_size()
Set push constant size from type.
bool are_descriptors_ready() const
Check if descriptors are initialized.
std::vector< Portal::Graphics::DescriptorSetID > m_descriptor_set_ids
void download_back_buffer(const VKBufferResources::GenerationSlot &slot, void *data, size_t size, std::shared_ptr< VKBuffer > &staging)
Download a raw back_buffers slot to host memory.
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.
Leading push constant fields every relaxation rule shader receives: grid width then height,...
Describes how a VKBuffer binds to a shader descriptor.
std::unordered_map< std::string, ShaderBinding > bindings
size_t push_constant_size
@ MANUAL
Use explicit group counts.
Complete declarative description of a generated compute shader.