vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::ir::model::program::BufferDecl;
use std::fmt::Write as _;

#[inline]
pub fn emit_storage_store_helper(out: &mut String, buf: &BufferDecl, ty: &str, uses_atomics: bool) {
    let store_stmt = if uses_atomics {
        format!("atomicStore(&{}.data[idx], value);", buf.name)
    } else {
        format!("{}.data[idx] = value;", buf.name)
    };
    let _ = write!(
        out,
        "fn _vyre_store_{name}(idx: u32, value: {ty}) {{\n\
         if (idx < arrayLength(&{name}.data)) {{ {store_stmt} }}\n\
       }}\n\n",
        name = buf.name,
    );
}