mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 06:21:13 +01:00
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
//! Functions which export shader modules into binary and text formats.
|
|
|
|
#[cfg(feature = "dot-out")]
|
|
pub mod dot;
|
|
#[cfg(feature = "glsl-out")]
|
|
pub mod glsl;
|
|
#[cfg(feature = "msl-out")]
|
|
pub mod msl;
|
|
#[cfg(feature = "spv-out")]
|
|
pub mod spv;
|
|
|
|
impl crate::Expression {
|
|
/// Returns the ref count, upon reaching which this expression
|
|
/// should be considered for baking.
|
|
///
|
|
/// Note: we have to cache any expressions that depend on the control flow,
|
|
/// or otherwise they may be moved into a non-uniform contol flow, accidentally.
|
|
#[allow(dead_code)]
|
|
fn bake_ref_count(&self) -> usize {
|
|
match *self {
|
|
// accesses are never cached, only loads are
|
|
crate::Expression::Access { .. } | crate::Expression::AccessIndex { .. } => !0,
|
|
// sampling may use the control flow, and image ops look better by themselves
|
|
crate::Expression::ImageSample { .. } | crate::Expression::ImageLoad { .. } => 1,
|
|
// derivatives use the control flow
|
|
crate::Expression::Derivative { .. } => 1,
|
|
// cache expressions that are referenced multiple times
|
|
_ => 2,
|
|
}
|
|
}
|
|
}
|