Skip to content

Commit b6f1828

Browse files
feat(wgsl): recognize enable primitive-index;
1 parent c7fd582 commit b6f1828

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

naga/src/front/wgsl/parse/directive/enable_extension.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ impl EnableExtension {
7171
const CLIP_DISTANCES: &'static str = "clip_distances";
7272
const DUAL_SOURCE_BLENDING: &'static str = "dual_source_blending";
7373
const SUBGROUPS: &'static str = "subgroups";
74+
const PRIMITIVE_INDEX: &'static str = "primitive-index";
7475

7576
/// Convert from a sentinel word in WGSL into its associated [`EnableExtension`], if possible.
7677
pub(crate) fn from_ident(word: &str, span: Span) -> Result<'_, Self> {
@@ -81,6 +82,9 @@ impl EnableExtension {
8182
Self::Implemented(ImplementedEnableExtension::DualSourceBlending)
8283
}
8384
Self::SUBGROUPS => Self::Unimplemented(UnimplementedEnableExtension::Subgroups),
85+
Self::PRIMITIVE_INDEX => {
86+
Self::Unimplemented(UnimplementedEnableExtension::PrimitiveIndex)
87+
}
8488
_ => return Err(Box::new(Error::UnknownEnableExtension(span, word))),
8589
})
8690
}
@@ -95,6 +99,7 @@ impl EnableExtension {
9599
},
96100
Self::Unimplemented(kind) => match kind {
97101
UnimplementedEnableExtension::Subgroups => Self::SUBGROUPS,
102+
UnimplementedEnableExtension::PrimitiveIndex => Self::PRIMITIVE_INDEX,
98103
},
99104
}
100105
}
@@ -132,12 +137,19 @@ pub enum UnimplementedEnableExtension {
132137
///
133138
/// [`enable subgroups;`]: https://www.w3.org/TR/WGSL/#extension-subgroups
134139
Subgroups,
140+
/// Enables the `@builtin(primitive_index)` attribute in WGSL.
141+
///
142+
/// In the WGSL standard, this corresponds to [`enable primitive-index;`].
143+
///
144+
/// [`enable primitive-index;`]: https://www.w3.org/TR/WGSL/#extension-primitive_index
145+
PrimitiveIndex,
135146
}
136147

137148
impl UnimplementedEnableExtension {
138149
pub(crate) const fn tracking_issue_num(self) -> u16 {
139150
match self {
140151
Self::Subgroups => 5555,
152+
Self::PrimitiveIndex => 8236,
141153
}
142154
}
143155
}

0 commit comments

Comments
 (0)