Name Description Size
atomic_upgrade.rs Upgrade the types of scalars observed to be accessed as atomics to [`Atomic`] types. In SPIR-V, atomic operations can be applied to any scalar value, but in Naga IR atomic operations can only be applied to values of type [`Atomic`]. Naga IR's restriction matches Metal Shading Language and WGSL, so we don't want to relax that. Instead, when the SPIR-V front end observes a value being accessed using atomic instructions, it promotes the value's type from [`Scalar`] to [`Atomic`]. This module implements `Module::upgrade_atomics`, the function that makes that change. Atomics can only appear in global variables in the [`Storage`] and [`Workgroup`] address spaces. These variables can either have `Atomic` types themselves, or be [`Array`]s of such, or be [`Struct`]s containing such. So we only need to change the types of globals and struct fields. Naga IR [`Load`] expressions and [`Store`] statements can operate directly on [`Atomic`] values, retrieving and depositing ordinary [`Scalar`] values, so changing the types doesn't have much effect on the code that operates on those values. Future work: - Atomics in structs are not implemented yet. - The GLSL front end could use this transformation as well. [`Atomic`]: TypeInner::Atomic [`Scalar`]: TypeInner::Scalar [`Storage`]: crate::AddressSpace::Storage [`WorkGroup`]: crate::AddressSpace::WorkGroup [`Array`]: TypeInner::Array [`Struct`]: TypeInner::Struct [`Load`]: crate::Expression::Load [`Store`]: crate::Statement::Store 7442
glsl
interpolator.rs ! Interpolation defaults. 2788
mod.rs ! Frontend parsers that consume binary and text shaders and load them into [`Module`](super::Module)s. 12102
spv
type_gen.rs ! Type generators. 17032
wgsl