Skip to content

Commit

Permalink
Document AtomicOp and front::spv::Frontend::lookup_atomic.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy committed Jun 14, 2024
1 parent 46aff51 commit b8982b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions naga/src/front/atomic_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ pub(crate) enum AtomicOpInst {
AtomicIIncrement,
}

/// Information about some [`Atomic`][as] statement, for upgrading types.
///
/// SPIR-V doesn't have atomic types like Naga IR's [`Atomic`][at], it
/// just has atomic instructions that operate on pointers to ordinary
/// scalar values, so to build Naga IR from SPIR-V input, we must
/// observe which variables/arguments/fields the SPIR-V applies atomic
/// instructions to, and then update their types after the fact.
///
/// This type describes some [`Atomic`][as] statement we've generated,
/// along with enough information for us to find the items whose types
/// we need to upgrade.
///
/// [at]: crate::TypeInner::Atomic
/// [as]: crate::Statement::Atomic
#[allow(dead_code)]
#[derive(Clone, Copy, Debug)]
pub(crate) struct AtomicOp {
Expand Down
4 changes: 3 additions & 1 deletion naga/src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,9 @@ pub struct Frontend<I> {
future_member_decor: FastHashMap<(spirv::Word, MemberIndex), Decoration>,
lookup_member: FastHashMap<(Handle<crate::Type>, MemberIndex), LookupMember>,
handle_sampling: FastHashMap<Handle<crate::GlobalVariable>, image::SamplingFlags>,
// Used to upgrade types used in atomic ops to atomic types, keyed by pointer id

/// A table of all the [`Atomic`] statements we've generated, so
/// we can upgrade the types of their operands.
lookup_atomic: FastHashMap<spirv::Word, atomic_upgrade::AtomicOp>,
lookup_type: FastHashMap<spirv::Word, LookupType>,
lookup_void_type: Option<spirv::Word>,
Expand Down

0 comments on commit b8982b3

Please sign in to comment.