pub struct IntGraph { /* private fields */ }Expand description
Integer expression graph with structural interning.
Implementations§
Source§impl IntGraph
impl IntGraph
Sourcepub fn to_wgsl_body(
&self,
outputs: &[IId],
params: &[&str],
dests: &[&str],
depth: usize,
) -> String
pub fn to_wgsl_body( &self, outputs: &[IId], params: &[&str], dests: &[&str], depth: usize, ) -> String
WGSL statements computing outputs: param i reads the expression
params[i], output k is assigned to dests[k]. Needs
WGSL_PRELUDE in the module when the graph uses MulHi; buffers are
referenced by their declared names.
Sourcepub fn to_wgsl_body_guarded(
&self,
outputs: &[IId],
params: &[&str],
dests: &[&str],
depth: usize,
) -> String
pub fn to_wgsl_body_guarded( &self, outputs: &[IId], params: &[&str], dests: &[&str], depth: usize, ) -> String
Self::to_wgsl_body with every load bounds-checked against
arrayLength (out of bounds reads 0, as in Program).
For untrusted graphs; buffers must be runtime-sized storage arrays.
Sourcepub fn to_wgsl_fn(&self, name: &str, outputs: &[IId]) -> String
pub fn to_wgsl_fn(&self, name: &str, outputs: &[IId]) -> String
A WGSL function fn name(p0: T0, …) -> name_out returning a struct of
the outputs (o0, o1, …).
Source§impl IntGraph
impl IntGraph
Sourcepub fn to_bytes(&self, outputs: &[IId]) -> Vec<u8> ⓘ
pub fn to_bytes(&self, outputs: &[IId]) -> Vec<u8> ⓘ
Serialize the whole graph with outputs (see the module docs).
Buffers are not named on the wire; the reader supplies the ABI.
Sourcepub fn from_bytes(
bytes: &[u8],
params: &[IType],
bufs: &[(&str, Elem)],
outs: &[IType],
lim: &Limits,
) -> Result<(IntGraph, Vec<IId>), WireError>
pub fn from_bytes( bytes: &[u8], params: &[IType], bufs: &[(&str, Elem)], outs: &[IType], lim: &Limits, ) -> Result<(IntGraph, Vec<IId>), WireError>
Read and verify an untrusted graph (see the module docs). params
gives the type of each parameter, bufs the name and element type of
each buffer, outs the output types. Returns the graph and its outputs.
Sourcepub fn from_bytes_rw(
bytes: &[u8],
params: &[IType],
bufs: &[(&str, Elem)],
rw: &[(&str, Elem, u32, &str)],
outs: &[IType],
lim: &Limits,
) -> Result<(IntGraph, Vec<IId>), WireError>
pub fn from_bytes_rw( bytes: &[u8], params: &[IType], bufs: &[(&str, Elem)], rw: &[(&str, Elem, u32, &str)], outs: &[IType], lim: &Limits, ) -> Result<(IntGraph, Vec<IId>), WireError>
Self::from_bytes with scratch buffers after the read-only ones:
(name, elem, length, WGSL base expression) each, all from the caller.
Source§impl IntGraph
impl IntGraph
Sourcepub fn buffer(&mut self, name: &str, elem: Elem) -> u16
pub fn buffer(&mut self, name: &str, elem: Elem) -> u16
Declare a read-only buffer; returns its index for load.
Sourcepub fn buffer_rw(&mut self, name: &str, elem: Elem, len: u32, base: &str) -> u16
pub fn buffer_rw(&mut self, name: &str, elem: Elem, len: u32, base: &str) -> u16
Declare a scratch buffer of len 32-bit elements (elem is I32 or
U32), at name[base + i] in WGSL.
Sourcepub fn load_rw(&mut self, buf: u16, index: IId, tok: IId) -> IId
pub fn load_rw(&mut self, buf: u16, index: IId, tok: IId) -> IId
buf[index] of a scratch buffer as of effect token tok.
Sourcepub fn store(&mut self, buf: u16, index: IId, value: IId, tok: IId) -> IId
pub fn store(&mut self, buf: u16, index: IId, value: IId, tok: IId) -> IId
buf[index] = value after tok; returns the next token.
Sourcepub fn clz(&mut self, a: IId) -> IId
pub fn clz(&mut self, a: IId) -> IId
Leading zero bits of a (firstLeadingBit(a) = 31 − clz(a) for a > 0).
Sourcepub fn while_loop(
&mut self,
init: &[IId],
body: impl FnOnce(&mut Self, &[IId]) -> (IId, Vec<IId>),
) -> Vec<IId>
pub fn while_loop( &mut self, init: &[IId], body: impl FnOnce(&mut Self, &[IId]) -> (IId, Vec<IId>), ) -> Vec<IId>
s = init; while cond(s) { s = next(s) }; returns the final states.
body gets the state nodes and returns (cond, next).
Sourcepub fn cap_loop(&mut self, out: IId, cap: u32)
pub fn cap_loop(&mut self, out: IId, cap: u32)
Cap the trip count of the loop that produced out (a loop result).