use crate::action::ActionDescriptor;
use crate::authoring::model::binding::BindingDecl;
use crate::params::{ParamDescriptor, ParamValue};
use crate::view::{StatDescriptor, StatValue};
pub struct GpuGridAction {
pub desc: ActionDescriptor,
pub shader: &'static str,
pub bindings: &'static [BindingDecl],
}
impl std::fmt::Debug for GpuGridAction {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GpuGridAction")
.field("desc", &self.desc)
.field("shader_len", &self.shader.len())
.field("bindings", &self.bindings)
.finish_non_exhaustive()
}
}
pub trait GpuGridModel: Send + Sync + 'static {
const NAME: &'static str;
const ID: &'static str;
const DESCRIPTION: &'static str;
const PALETTE: &'static [[u8; 4]];
const WORKGROUP_SIZE: u32 = 16;
const STATS: &'static [StatDescriptor];
const ACTIONS: &'static [GpuGridAction] = &[];
const BUFFERS: &'static [&'static str];
const STEP_BINDINGS: &'static [BindingDecl];
const DISPLAY_BINDINGS: &'static [BindingDecl];
const REDUCE_BINDINGS: &'static [BindingDecl];
const STEP_SHADER: &'static str;
const DISPLAY_SHADER: &'static str;
const REDUCE_SHADER: &'static str;
const REPLAYS_EXACTLY: bool = true;
fn param_descriptors() -> Vec<ParamDescriptor>;
fn dims(params: &[ParamValue]) -> (u32, u32);
fn buffer_lens(width: u32, height: u32) -> Vec<usize> {
vec![(width as usize) * (height as usize); Self::BUFFERS.len()]
}
fn step_dims(width: u32, height: u32) -> (u32, u32) {
(width, height)
}
fn seed_buffers(width: u32, height: u32, params: &[ParamValue], seed: Option<u64>) -> Vec<Vec<u32>>;
fn step_params_bytes(width: u32, height: u32, params: &[ParamValue]) -> Vec<u8>;
fn action_params_bytes(_action: usize, width: u32, height: u32, params: &[ParamValue], _seed: u32) -> Vec<u8> {
Self::step_params_bytes(width, height, params)
}
fn stats(counts: &[u32]) -> Vec<StatValue>;
}