vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
use crate::ir::model::program::BufferDecl;
use std::fmt::Write as _;

#[inline]
pub fn emit_storage_load_helper(
    out: &mut String,
    buf: &BufferDecl,
    ty: &str,
    zero: &str,
    uses_atomics: bool,
) {
    let load_expr = if uses_atomics {
        format!("atomicLoad(&{}.data[idx])", buf.name)
    } else {
        format!("{}.data[idx]", buf.name)
    };
    let _ = write!(
        out,
        "fn _vyre_load_{name}(idx: u32) -> {ty} {{\n\
         if (idx < arrayLength(&{name}.data)) {{ return {load_expr}; }}\n\
         return {zero};\n\
       }}\n\n",
        name = buf.name,
    );
}