naga_rust_rt/lib.rs
1//! This library provides types and functions which are used by the Rust code generated by
2//! [`naga_rust_back`] or [`naga_rust_embed`]. These types and functions implement vector arithmetic
3//! in the style expected by shader code, which differs from straightforward Rust in various ways.
4//!
5//! This library currently does not have a clean public API distinct from the API provided
6//! for the benefit of the code generator. Expect changes in future versions.
7//!
8//! [`naga_rust_back`]: https://docs.rs/naga-rust-back
9//! [`naga_rust_embed`]: https://docs.rs/naga-rust-embed
10
11#![no_std]
12
13#[cfg(feature = "std")]
14extern crate std;
15
16mod vector;
17
18pub use vector::*;
19
20// TODO: should probably be num_traits::Zero or something custom
21pub fn zero<T: Default>() -> T {
22 T::default()
23}
24
25pub fn discard() {
26 // Best we can do for now, until we implement a codegen option to return Result instead.
27 panic!("shader reached discard instruction");
28}
29
30pub use naga_rust_macros::dummy_attribute as compute;
31pub use naga_rust_macros::dummy_attribute as fragment;
32pub use naga_rust_macros::dummy_attribute as vertex;
33pub use naga_rust_macros::dummy_attribute as workgroup_size;