mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
feat(wgsl): recognize enable primitive-index; (#8237)
This commit is contained in:
parent
d0bcb7e62d
commit
06fc6f7345
@ -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
|
||||
|
||||
@ -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::{
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user