Expand description
Everything a model is written against: the model traits, their types, the helpers and the primitives.
Re-exports§
pub use bytemuck;
Modules§
- prelude
- Items a model’s source file imports whole.
- primitives
- Primitives that a kernel calls, each module named after its WGSL twin’s import path.
Structs§
- Binding
Decl - One
@group(0) @binding(n)declaration. Its position in a pass’s slice isn. - Buffer
Spec - One storage buffer of the model’s state.
- CaField
- Double-buffered
u8cells stepped byM’s neighbourhood rule. - Component
Stats - Summary of a component labelling.
- Deposits
- Deposit lanes, with one cell per agent and one value per agent and field.
- Display
Spec - The pass that turns state into the display texture, for a model that draws a grid layer.
- Extent
- The world rectangle every display layer stretches to.
- Geometry
- World that the parameters describe, resolved once at construction.
- GpuAgent
Action - A one-off pass the user can trigger.
- GpuGrid
Action - A one-off compute pass the user can trigger.
- Grid2D
- A double-buffered 2D grid of cells, stored row-major.
- Hash
Grid - Cell geometry on its own, for a caller that needs the grid without the buckets. A GPU model mirrors it into its step uniform so its query walks the same grid as the CPU sort.
- Network
- A network of nodes and edges.
- NoField
- The empty grid slot, for a model that is agents only.
- NoIndex
- An index that holds nothing, for a model whose agents never look at one another.
- NodeCtx
- The graph, hot parameters and extent, shared by every node kernel.
- Nodes
- Mutable access to the lanes, the graph and the model’s own state.
- PassCtx
- Values that a pass’s uniform block can need, besides the parameters.
- Pass
Spec - One compute pass of a step, run in declaration order.
- Reduce
Spec - The leaf of the stat reduction, which folds the population down to one value per lane.
- Scalar
Field S::FIELDSdouble bufferedf32grids over one shared scatter scratch.- Scalar
Read - The field as an agent kernel sees it.
- Spatial
Hash - Flat counting-sort grid over agent positions, rebuilt every tick.
- Spring
Params - Constants for the spring layout, in units of the mean spacing between nodes.
- StepCtx
- Context an agent kernel reads besides its own lanes.
Enums§
- Binding
Kind - Kind of resource a binding declares, as the engine needs it for a layout entry.
- Combine
- Rule for combining deposits that land in the same cell.
- Domain
- A pass’s invocation domain.
- Neighborhood
Kind - Neighbourhood a grid rule reads.
- PassId
- Pass for which
GpuAgentModel::pass_params_bytesreturns the uniform block.
Constants§
- AGENT_
INIT_ SEED - State an agent model’s random number generator (RNG) starts from when a run has no seed.
- AGENT_
PARAM_ BASE - Number of params the engine prepends, and the index of a model’s first own param.
- GRID_
INIT_ SEED - State a grid model’s random number generator (RNG) starts from when a run has no seed.
- GRID_
PARAM_ BASE - Number of params the engine prepends, and the index of a model’s first own param.
- NETWORK_
INIT_ SEED - State a network model’s random number generator (RNG) starts from when a run has no seed.
- NETWORK_
PARAM_ BASE - Number of params that the engine prepends.
- NUM_
AGENTS - Index of the population.
- NUM_
NODES - Index of the node count. Its id stays
num_agents, which the benchmark scripts look up. - STATS_
CHUNK - Cells or agents per chunk in a stats reduction.
- WORLD_
HEIGHT - Index of the world’s height.
- WORLD_
WIDTH - Index of the world’s width.
Traits§
- Agent
Lanes - Struct-of-arrays agent storage.
- Agent
Model - A population of agents, optionally over a field.
- Chunk
Tally - A per chunk reduction, merged in chunk order.
- Field
Layer - A layer of cells stepped once per tick.
- GpuAgent
Model - A population of agents stepped by compute shaders, with its state resident in GPU buffers.
- GpuGrid
Model - A grid model stepped by a compute shader, with its state resident in GPU storage buffers.
- Grid
Model - A cellular automaton over
u8cells. - Neighbor
Index - Neighbour lookup rebuilt from agent positions each tick.
- Network
Model - A population of nodes joined by edges.
- Scalar
Field Spec - Rules of a scalar field that only the model can supply.
Functions§
- agent_
init_ rng - Returns the state an agent model’s RNG starts from:
seedmixed, orAGENT_INIT_SEEDwhen it isNone. - agent_
model_ param_ descriptors - Returns the full descriptor list:
num_agents,world_widthandworld_height, then the model’s own params, then its field layer’s params. - bool_
param - Returns a descriptor for a live switch.
- choice_
param - Returns a descriptor for a choice among
options, starting at optiondefault. - extract_
bool - Returns the
boolatindex, ordefaultwhen the index is missing or holds another kind. - extract_
choice - Returns the index of the chosen option, or
defaultif the value is not a choice. - extract_
f32 - Returns the
f32atindex, ordefaultwhen the index is missing or holds another kind. - extract_
u32 - Returns the
u32atindex, ordefaultwhen the index is missing or holds another kind. - f32_
param - Returns a descriptor for a live
f32parameter, withstepas its slider step. - grid_
init_ rng - Returns the state a grid model’s RNG starts from:
seedmixed, orGRID_INIT_SEEDwhen it isNone. - label_
components - Labels every node with the lowest node index in its component.
- network_
model_ param_ descriptors - Returns the full descriptor list:
num_agents,world_widthandworld_height, then the model’s own params. - reduce_
chunks - Maps each chunk of
0..lenthen folds the results in chunk order. - register_
agent_ model - Returns an entry for the CPU agent model
A. - register_
gpu_ agent_ model - Returns an entry for the GPU agent model
M. - register_
gpu_ grid_ model - Returns an entry for the GPU grid model
M. - register_
grid_ model - Returns an entry for the CPU grid model
M. - register_
network_ model - Returns an entry for the CPU network model
N. - split_
params - Splits a composed parameter list into the model’s own parameters and its field layer’s parameters.
- stat
- Returns an entry holding a scalar.
- stat_
histogram - Returns an entry holding a histogram, in which
counts[i]counts the values in[edges[i], edges[i + 1]). - stat_
vec2 - Returns an entry holding a 2D vector.
- u32_
param - Returns a descriptor for a live
u32parameter.