Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion naga/src/front/wgsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
12 changes: 12 additions & 0 deletions naga/src/front/wgsl/parse/directive/enable_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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))),
})
}
Expand All @@ -95,6 +99,7 @@ impl EnableExtension {
},
Self::Unimplemented(kind) => match kind {
UnimplementedEnableExtension::Subgroups => Self::SUBGROUPS,
UnimplementedEnableExtension::PrimitiveIndex => Self::PRIMITIVE_INDEX,
},
}
}
Expand Down Expand Up @@ -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,
}
}
}
40 changes: 40 additions & 0 deletions naga/tests/naga/wgsl_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/gfx-rs/wgpu/issues/5555>, 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 <https://github.com/gfx-rs/wgpu/issues/8236>, 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
Expand Down
Loading