Skip to content

Commit

Permalink
Expose ImplementedLanguageExtension as WGSLLanguageExtension
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
  • Loading branch information
sagudev committed Jan 7, 2025
1 parent 0dab31a commit 619af2f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions naga/src/front/wgsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub use crate::front::wgsl::error::ParseError;
use crate::front::wgsl::lower::Lowerer;
use crate::Scalar;

pub use crate::front::wgsl::parse::directive::language_extension::ImplementedLanguageExtension as WGSLLanguageExtension;

pub struct Frontend {
parser: Parser,
}
Expand Down
22 changes: 19 additions & 3 deletions naga/src/front/wgsl/parse/directive/language_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl LanguageExtension {
/// Maps this [`LanguageExtension`] into the sentinel word associated with it in WGSL.
pub const fn to_ident(self) -> &'static str {
match self {
Self::Implemented(kind) => match kind {},
Self::Implemented(kind) => kind.to_ident(),
Self::Unimplemented(kind) => match kind {
UnimplementedLanguageExtension::ReadOnlyAndReadWriteStorageTextures => {
Self::READONLY_AND_READWRITE_STORAGE_TEXTURES
Expand All @@ -60,9 +60,25 @@ impl LanguageExtension {
}
}

/// A variant of [`LanguageExtension::Implemented`].
// A variant of [`LanguageExtension::Implemented`].
/// Enum of all WGSL extensions that are implemented
/// WGSL spec.: <https://www.w3.org/TR/WGSL/#language-extensions-sec>
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub(crate) enum ImplementedLanguageExtension {}
pub enum ImplementedLanguageExtension {}

impl ImplementedLanguageExtension {
const ALL: [ImplementedLanguageExtension; 0] = [];

/// Returns slice of all variants of [`ImplementedLanguageExtension`]
pub const fn all() -> &'static [Self] {
&Self::ALL
}

/// Maps this [`ImplementedLanguageExtension`] into the sentinel word associated with it in WGSL.
pub const fn to_ident(self) -> &'static str {
match self {}
}
}

/// A variant of [`LanguageExtension::Unimplemented`].
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
Expand Down

0 comments on commit 619af2f

Please sign in to comment.