11class NetworkGeometryBuffer;
67 [[nodiscard]]
static std::optional<SpatialHashConfig>
from_network(
68 const std::shared_ptr<NetworkGeometryBuffer>& buffer,
float cell_size);
100 void declare_fields(
const std::shared_ptr<NetworkGeometryBuffer>& buffer)
const;
176 [[nodiscard]]
const std::shared_ptr<NetworkGeometryBuffer>&
get_network_buffer()
const {
return m_buffer; }
194 void on_attach(
const std::shared_ptr<Buffer>& buffer)
override;
197 void on_descriptors_created()
override;
211 void processing_function(
const std::shared_ptr<Buffer>& buffer)
override;
235 template <
typename T>
238 const uint32_t local_x = std::max(1U, get_dispatch_config().workgroup_x);
239 const uint32_t groups = std::max(1U, (element_count + local_x - 1) / local_x);
240 set_manual_dispatch(groups, 1, 1);
241 set_push_constant_data(params);
253 template <
typename F>
256 const std::shared_ptr<VKBuffer>& buffer,
257 uint64_t current_revision,
258 uint64_t& built_revision,
261 if (!NetworkStateFieldProcessor::on_before_execute(cmd_id, buffer)) {
264 if (current_revision != built_revision) {
265 std::forward<F>(reload)();
266 built_revision = current_revision;
273 void register_bindings();
279 bool validate_fields();
282 void write_field_descriptors();
303 void on_buffer_ready()
override;
337 void on_buffer_ready()
override;
361 void on_buffer_ready()
override;
389 void on_buffer_ready()
override;
442 std::shared_ptr<Nodes::Network::GpuFieldOperator> particle_op);
445 void on_buffer_ready()
override;
447 bool on_before_execute(
449 const std::shared_ptr<VKBuffer>& buffer)
override;
Specialized ShaderProcessor for Compute Pipelines.
Zeros the per-cell particle histogram before HashCountProcessor accumulates into it.
GridPushConstants m_params
Buckets each particle into its grid cell and accumulates a per-cell histogram via atomicAdd.
uint64_t m_built_revision
std::shared_ptr< Nodes::Network::GpuFieldOperator > m_particle_op
Colours each particle by local neighbour count, read from the completed hash: proof that the hash bui...
Sequential exclusive prefix sum over the per-cell histogram.
GridPushConstants m_params
Writes each particle's index into hash_particle_index at the slot its cell's atomic cursor claims.
std::shared_ptr< NetworkGeometryBuffer > m_buffer
std::vector< FieldBinding > m_bindings
virtual void on_buffer_ready()
Hook for subclass setup, called at the end of on_attach.
void dispatch_one_thread_per(uint32_t element_count, const T ¶ms)
Configure manual dispatch for one thread per element, and stage the given push constant data.
bool guard_and_resync(Portal::Graphics::CommandBufferID cmd_id, const std::shared_ptr< VKBuffer > &buffer, uint64_t current_revision, uint64_t &built_revision, F &&reload)
Base on_before_execute guard, then a revision-gated tuning reload.
const std::shared_ptr< NetworkGeometryBuffer > & get_network_buffer() const
The attached buffer, or null if attachment failed validation.
ComputeProcessor operating on named state fields of a NetworkGeometryBuffer, plus optionally the buff...
GridPushConstants make_grid_push_constants(const SpatialHashConfig &c)
Populate a GridPushConstants from grid config.
Uniform-grid push-constant block shared by the hash count/scatter and population-spawn kernels.
uint32_t cell_count_total
float density_saturation_count
uint32_t cell_count_total
std::string name
Shader binding name, as declared in ShaderConfig.
uint32_t binding
Binding index within set 0.
std::string field
State field name, or empty for the buffer's own vertex storage.
One shader binding and where it draws from.
static std::optional< SpatialHashConfig > from_network(const std::shared_ptr< NetworkGeometryBuffer > &buffer, float cell_size)
Build hash grid parameters from a NetworkGeometryBuffer's network and its primary operator.
void declare_fields(const std::shared_ptr< NetworkGeometryBuffer > &buffer) const
Declare the four state fields the hash build stages read and write, sized from this config.
uint32_t position_word_offset
uint32_t cell_count() const
Total cell count, grid_dims.x * grid_dims.y * grid_dims.z.
Uniform grid parameters shared by every stage of the hash build.
Complete declarative description of a generated compute shader.