diff --git a/CHANGELOG.md b/CHANGELOG.md index f19f87586b7..efd9a2c5e02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -166,6 +166,10 @@ By @cwfitzgerald in [#8162](https://github.com/gfx-rs/wgpu/pull/8162). - Added support for external textures based on WebGPU's [`GPUExternalTexture`](https://www.w3.org/TR/webgpu/#gpuexternaltexture). These allow shaders to transparently operate on potentially multiplanar source texture data in either RGB or YCbCr formats via WGSL's `texture_external` type. This is gated behind the `Features::EXTERNAL_TEXTURE` feature, which is currently only supported on DX12. By @jamienicol in [#4386](https://github.com/gfx-rs/wgpu/issues/4386). +#### naga + +- Expose `naga::front::wgsl::UnimplementedEnableExtension`. By @ErichDonGubler in [#8237](https://github.com/gfx-rs/wgpu/pull/8237). + ### Changes #### General diff --git a/naga/src/front/wgsl/mod.rs b/naga/src/front/wgsl/mod.rs index 2c3387e9cdd..ba41dc80128 100644 --- a/naga/src/front/wgsl/mod.rs +++ b/naga/src/front/wgsl/mod.rs @@ -11,7 +11,9 @@ mod parse; #[cfg(test)] mod tests; -pub use parse::directive::enable_extension::{EnableExtension, ImplementedEnableExtension}; +pub use parse::directive::enable_extension::{ + EnableExtension, ImplementedEnableExtension, UnimplementedEnableExtension, +}; pub use crate::front::wgsl::error::ParseError; pub use crate::front::wgsl::parse::directive::language_extension::{ diff --git a/naga/src/front/wgsl/parse/directive/enable_extension.rs b/naga/src/front/wgsl/parse/directive/enable_extension.rs index e614d19b6fe..38d6d6719ca 100644 --- a/naga/src/front/wgsl/parse/directive/enable_extension.rs +++ b/naga/src/front/wgsl/parse/directive/enable_extension.rs @@ -71,6 +71,7 @@ impl EnableExtension { const CLIP_DISTANCES: &'static str = "clip_distances"; const DUAL_SOURCE_BLENDING: &'static str = "dual_source_blending"; const SUBGROUPS: &'static str = "subgroups"; + const PRIMITIVE_INDEX: &'static str = "primitive_index"; /// Convert from a sentinel word in WGSL into its associated [`EnableExtension`], if possible. pub(crate) fn from_ident(word: &str, span: Span) -> Result<'_, Self> { @@ -81,6 +82,9 @@ impl EnableExtension { Self::Implemented(ImplementedEnableExtension::DualSourceBlending) } Self::SUBGROUPS => Self::Unimplemented(UnimplementedEnableExtension::Subgroups), + Self::PRIMITIVE_INDEX => { + Self::Unimplemented(UnimplementedEnableExtension::PrimitiveIndex) + } _ => return Err(Box::new(Error::UnknownEnableExtension(span, word))), }) } @@ -95,6 +99,7 @@ impl EnableExtension { }, Self::Unimplemented(kind) => match kind { UnimplementedEnableExtension::Subgroups => Self::SUBGROUPS, + UnimplementedEnableExtension::PrimitiveIndex => Self::PRIMITIVE_INDEX, }, } } @@ -132,12 +137,19 @@ pub enum UnimplementedEnableExtension { /// /// [`enable subgroups;`]: https://www.w3.org/TR/WGSL/#extension-subgroups Subgroups, + /// Enables the `@builtin(primitive_index)` attribute in WGSL. + /// + /// In the WGSL standard, this corresponds to [`enable primitive-index;`]. + /// + /// [`enable primitive-index;`]: https://www.w3.org/TR/WGSL/#extension-primitive_index + PrimitiveIndex, } impl UnimplementedEnableExtension { pub(crate) const fn tracking_issue_num(self) -> u16 { match self { Self::Subgroups => 5555, + Self::PrimitiveIndex => 8236, } } } diff --git a/naga/tests/naga/wgsl_errors.rs b/naga/tests/naga/wgsl_errors.rs index c1e8421ace1..675f52b94e1 100644 --- a/naga/tests/naga/wgsl_errors.rs +++ b/naga/tests/naga/wgsl_errors.rs @@ -4098,6 +4098,46 @@ fn invalid_clip_distances() { } } +#[test] +fn recognized_but_unimplemented_enable_extension() { + for extension in [ + naga::front::wgsl::UnimplementedEnableExtension::Subgroups, + naga::front::wgsl::UnimplementedEnableExtension::PrimitiveIndex, + ] { + // NOTE: We match exhaustively here to help maintainers add or remove variants to the above + // array. + let snapshot = match extension { + naga::front::wgsl::UnimplementedEnableExtension::Subgroups => "\ +error: the `subgroups` enable-extension is not yet supported + ┌─ wgsl:1:8 + │ +1 │ enable subgroups; + │ ^^^^^^^^^ this enable-extension specifies standard functionality which is not yet implemented in Naga + │ + = note: Let Naga maintainers know that you ran into this at , so they can prioritize it! + +", + naga::front::wgsl::UnimplementedEnableExtension::PrimitiveIndex => "\ +error: the `primitive_index` enable-extension is not yet supported + ┌─ wgsl:1:8 + │ +1 │ enable primitive_index; + │ ^^^^^^^^^^^^^^^ this enable-extension specifies standard functionality which is not yet implemented in Naga + │ + = note: Let Naga maintainers know that you ran into this at , so they can prioritize it! + +", + }; + + let shader = { + let extension = naga::front::wgsl::EnableExtension::Unimplemented(extension); + format!("enable {};", extension.to_ident()) + }; + + check(&shader, snapshot); + } +} + #[test] fn max_type_size_large_array() { // The total size of an array is not resolved until validation. Type aliases