naga/front/wgsl/parse/directive/
language_extension.rs1use strum::VariantArray;
6
7#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
11pub enum LanguageExtension {
12 #[allow(unused)]
13 Implemented(ImplementedLanguageExtension),
14 Unimplemented(UnimplementedLanguageExtension),
15}
16
17impl LanguageExtension {
18 const READONLY_AND_READWRITE_STORAGE_TEXTURES: &'static str =
19 "readonly_and_readwrite_storage_textures";
20 const PACKED4X8_INTEGER_DOT_PRODUCT: &'static str = "packed_4x8_integer_dot_product";
21 const UNRESTRICTED_POINTER_PARAMETERS: &'static str = "unrestricted_pointer_parameters";
22 const POINTER_COMPOSITE_ACCESS: &'static str = "pointer_composite_access";
23
24 pub fn from_ident(s: &str) -> Option<Self> {
26 Some(match s {
27 Self::READONLY_AND_READWRITE_STORAGE_TEXTURES => Self::Unimplemented(
28 UnimplementedLanguageExtension::ReadOnlyAndReadWriteStorageTextures,
29 ),
30 Self::PACKED4X8_INTEGER_DOT_PRODUCT => {
31 Self::Unimplemented(UnimplementedLanguageExtension::Packed4x8IntegerDotProduct)
32 }
33 Self::UNRESTRICTED_POINTER_PARAMETERS => {
34 Self::Unimplemented(UnimplementedLanguageExtension::UnrestrictedPointerParameters)
35 }
36 Self::POINTER_COMPOSITE_ACCESS => {
37 Self::Unimplemented(UnimplementedLanguageExtension::PointerCompositeAccess)
38 }
39 _ => return None,
40 })
41 }
42
43 pub const fn to_ident(self) -> &'static str {
45 match self {
46 Self::Implemented(kind) => kind.to_ident(),
47 Self::Unimplemented(kind) => match kind {
48 UnimplementedLanguageExtension::ReadOnlyAndReadWriteStorageTextures => {
49 Self::READONLY_AND_READWRITE_STORAGE_TEXTURES
50 }
51 UnimplementedLanguageExtension::Packed4x8IntegerDotProduct => {
52 Self::PACKED4X8_INTEGER_DOT_PRODUCT
53 }
54 UnimplementedLanguageExtension::UnrestrictedPointerParameters => {
55 Self::UNRESTRICTED_POINTER_PARAMETERS
56 }
57 UnimplementedLanguageExtension::PointerCompositeAccess => {
58 Self::POINTER_COMPOSITE_ACCESS
59 }
60 },
61 }
62 }
63}
64
65#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, VariantArray)]
67pub enum ImplementedLanguageExtension {}
68
69impl ImplementedLanguageExtension {
70 pub const fn all() -> &'static [Self] {
72 Self::VARIANTS
73 }
74
75 pub const fn to_ident(self) -> &'static str {
77 match self {}
78 }
79}
80
81#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
83pub enum UnimplementedLanguageExtension {
84 ReadOnlyAndReadWriteStorageTextures,
85 Packed4x8IntegerDotProduct,
86 UnrestrictedPointerParameters,
87 PointerCompositeAccess,
88}
89
90impl UnimplementedLanguageExtension {
91 pub(crate) const fn tracking_issue_num(self) -> u16 {
92 match self {
93 Self::ReadOnlyAndReadWriteStorageTextures => 6204,
94 Self::Packed4x8IntegerDotProduct => 6445,
95 Self::UnrestrictedPointerParameters => 5158,
96 Self::PointerCompositeAccess => 6192,
97 }
98 }
99}