From e6f52bf46dee9fd37108626ec8c6285b1d35b3af Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Tue, 5 Nov 2024 09:21:47 -0500 Subject: [PATCH] move(naga)!: move WGSL-specific `diagnostic_filter` stuff to `naga::front::wgsl` --- naga/src/diagnostic_filter.rs | 33 -------------------- naga/src/front/wgsl/diagnostic_filter.rs | 38 ++++++++++++++++++++++++ naga/src/front/wgsl/mod.rs | 1 + 3 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 naga/src/front/wgsl/diagnostic_filter.rs diff --git a/naga/src/diagnostic_filter.rs b/naga/src/diagnostic_filter.rs index 80d841214..ca2c96fa5 100644 --- a/naga/src/diagnostic_filter.rs +++ b/naga/src/diagnostic_filter.rs @@ -27,22 +27,6 @@ pub enum Severity { } impl Severity { - const ERROR: &'static str = "error"; - const WARNING: &'static str = "warning"; - const INFO: &'static str = "info"; - const OFF: &'static str = "off"; - - /// Convert from a sentinel word in WGSL into its associated [`Severity`], if possible. - pub fn from_wgsl_ident(s: &str) -> Option { - Some(match s { - Self::ERROR => Self::Error, - Self::WARNING => Self::Warning, - Self::INFO => Self::Info, - Self::OFF => Self::Off, - _ => return None, - }) - } - /// Checks whether this severity is [`Self::Error`]. /// /// Naga does not yet support diagnostic items at lesser severities than @@ -79,23 +63,6 @@ pub enum FilterableTriggeringRule { } impl FilterableTriggeringRule { - const DERIVATIVE_UNIFORMITY: &'static str = "derivative_uniformity"; - - /// Convert from a sentinel word in WGSL into its associated [`FilterableTriggeringRule`], if possible. - pub fn from_wgsl_ident(s: &str) -> Option { - Some(match s { - Self::DERIVATIVE_UNIFORMITY => Self::DerivativeUniformity, - _ => return None, - }) - } - - /// Maps this [`FilterableTriggeringRule`] into the sentinel word associated with it in WGSL. - pub const fn to_wgsl_ident(self) -> &'static str { - match self { - Self::DerivativeUniformity => Self::DERIVATIVE_UNIFORMITY, - } - } - /// The default severity associated with this triggering rule. /// /// See for a table of default diff --git a/naga/src/front/wgsl/diagnostic_filter.rs b/naga/src/front/wgsl/diagnostic_filter.rs new file mode 100644 index 000000000..f505205b6 --- /dev/null +++ b/naga/src/front/wgsl/diagnostic_filter.rs @@ -0,0 +1,38 @@ +use crate::diagnostic_filter::{FilterableTriggeringRule, Severity}; + +impl Severity { + const ERROR: &'static str = "error"; + const WARNING: &'static str = "warning"; + const INFO: &'static str = "info"; + const OFF: &'static str = "off"; + + /// Convert from a sentinel word in WGSL into its associated [`Severity`], if possible. + pub fn from_wgsl_ident(s: &str) -> Option { + Some(match s { + Self::ERROR => Self::Error, + Self::WARNING => Self::Warning, + Self::INFO => Self::Info, + Self::OFF => Self::Off, + _ => return None, + }) + } +} + +impl FilterableTriggeringRule { + const DERIVATIVE_UNIFORMITY: &'static str = "derivative_uniformity"; + + /// Convert from a sentinel word in WGSL into its associated [`FilterableTriggeringRule`], if possible. + pub fn from_wgsl_ident(s: &str) -> Option { + Some(match s { + Self::DERIVATIVE_UNIFORMITY => Self::DerivativeUniformity, + _ => return None, + }) + } + + /// Maps this [`FilterableTriggeringRule`] into the sentinel word associated with it in WGSL. + pub const fn to_wgsl_ident(self) -> &'static str { + match self { + Self::DerivativeUniformity => Self::DERIVATIVE_UNIFORMITY, + } + } +} diff --git a/naga/src/front/wgsl/mod.rs b/naga/src/front/wgsl/mod.rs index a54fd66f0..3106bbb9b 100644 --- a/naga/src/front/wgsl/mod.rs +++ b/naga/src/front/wgsl/mod.rs @@ -4,6 +4,7 @@ Frontend for [WGSL][wgsl] (WebGPU Shading Language). [wgsl]: https://gpuweb.github.io/gpuweb/wgsl.html */ +mod diagnostic_filter; mod error; mod index; mod lower;