Skip to content

Commit

Permalink
Rename type flags to better align with the current WGSL spec.
Browse files Browse the repository at this point in the history
TypeFlags::INTERFACE -> TypeFlags::IO_SHARED
(WGSL §4.4.4's "IO-shareable types")

TypeFLags::HOST_SHARED -> TypeFlags::HOST_SHAREABLE
(WGSL §4.4.5's "Host-shareable types")
  • Loading branch information
jimblandy committed Apr 29, 2022
1 parent f76af4e commit a06b604
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
12 changes: 9 additions & 3 deletions src/valid/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ impl super::Validator {
));
}
}
(TypeFlags::DATA | TypeFlags::HOST_SHARED, true)
(TypeFlags::DATA | TypeFlags::HOST_SHAREABLE, true)
}
crate::AddressSpace::Uniform => {
if let Err((ty_handle, disalignment)) = type_info.uniform_layout {
Expand All @@ -377,7 +377,10 @@ impl super::Validator {
}
}
(
TypeFlags::DATA | TypeFlags::COPY | TypeFlags::SIZED | TypeFlags::HOST_SHARED,
TypeFlags::DATA
| TypeFlags::COPY
| TypeFlags::SIZED
| TypeFlags::HOST_SHAREABLE,
true,
)
}
Expand All @@ -402,7 +405,10 @@ impl super::Validator {
));
}
(
TypeFlags::DATA | TypeFlags::COPY | TypeFlags::HOST_SHARED | TypeFlags::SIZED,
TypeFlags::DATA
| TypeFlags::COPY
| TypeFlags::HOST_SHAREABLE
| TypeFlags::SIZED,
false,
)
}
Expand Down
36 changes: 19 additions & 17 deletions src/valid/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ bitflags::bitflags! {
/// The data can be copied around.
const COPY = 0x4;

/// Can be be used for interfacing between pipeline stages.
/// Can be be used for user-defined IO between pipeline stages.
///
/// This includes non-bool scalars and vectors, matrices, and structs
/// and arrays containing only interface types.
const INTERFACE = 0x8;
/// This covers anything that can be in [`Location`] binding:
/// non-bool scalars and vectors, matrices, and structs and
/// arrays containing only interface types.
const IO_SHAREABLE = 0x8;

/// Can be used for host-shareable structures.
const HOST_SHARED = 0x10;
const HOST_SHAREABLE = 0x10;

/// This type can be passed as a function argument.
const ARGUMENT = 0x40;
Expand Down Expand Up @@ -214,8 +215,8 @@ impl super::Validator {
TypeFlags::DATA
| TypeFlags::SIZED
| TypeFlags::COPY
| TypeFlags::INTERFACE
| TypeFlags::HOST_SHARED
| TypeFlags::IO_SHAREABLE
| TypeFlags::HOST_SHAREABLE
| TypeFlags::ARGUMENT,
width as u32,
)
Expand All @@ -229,8 +230,8 @@ impl super::Validator {
TypeFlags::DATA
| TypeFlags::SIZED
| TypeFlags::COPY
| TypeFlags::INTERFACE
| TypeFlags::HOST_SHARED
| TypeFlags::IO_SHAREABLE
| TypeFlags::HOST_SHAREABLE
| TypeFlags::ARGUMENT,
count * (width as u32),
)
Expand All @@ -248,8 +249,8 @@ impl super::Validator {
TypeFlags::DATA
| TypeFlags::SIZED
| TypeFlags::COPY
| TypeFlags::INTERFACE
| TypeFlags::HOST_SHARED
| TypeFlags::IO_SHAREABLE
| TypeFlags::HOST_SHAREABLE
| TypeFlags::ARGUMENT,
count * (width as u32),
)
Expand All @@ -263,7 +264,7 @@ impl super::Validator {
return Err(TypeError::InvalidAtomicWidth(kind, width));
}
TypeInfo::new(
TypeFlags::DATA | TypeFlags::SIZED | TypeFlags::HOST_SHARED,
TypeFlags::DATA | TypeFlags::SIZED | TypeFlags::HOST_SHAREABLE,
width as u32,
)
}
Expand Down Expand Up @@ -445,7 +446,8 @@ impl super::Validator {
}
};

let base_mask = TypeFlags::COPY | TypeFlags::HOST_SHARED | TypeFlags::INTERFACE;
let base_mask =
TypeFlags::COPY | TypeFlags::HOST_SHAREABLE | TypeFlags::IO_SHAREABLE;
TypeInfo {
flags: TypeFlags::DATA | (base_info.flags & base_mask) | sized_flag,
uniform_layout,
Expand All @@ -461,8 +463,8 @@ impl super::Validator {
TypeFlags::DATA
| TypeFlags::SIZED
| TypeFlags::COPY
| TypeFlags::HOST_SHARED
| TypeFlags::INTERFACE
| TypeFlags::HOST_SHAREABLE
| TypeFlags::IO_SHAREABLE
| TypeFlags::ARGUMENT,
1,
);
Expand All @@ -480,7 +482,7 @@ impl super::Validator {
if !base_info.flags.contains(TypeFlags::DATA) {
return Err(TypeError::InvalidData(member.ty));
}
if !base_info.flags.contains(TypeFlags::HOST_SHARED) {
if !base_info.flags.contains(TypeFlags::HOST_SHAREABLE) {
if ti.uniform_layout.is_ok() {
ti.uniform_layout = Err((member.ty, Disalignment::NonHostShareable));
}
Expand All @@ -495,7 +497,7 @@ impl super::Validator {
// to not bother with offsets/alignments if they are never
// used for host sharing.
if member.offset == 0 {
ti.flags.set(TypeFlags::HOST_SHARED, false);
ti.flags.set(TypeFlags::HOST_SHAREABLE, false);
} else {
return Err(TypeError::MemberOverlap {
index: i as u32,
Expand Down

0 comments on commit a06b604

Please sign in to comment.