From 04bb94fb3fd36ef58065c4b7c156da3c463f7017 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 23 Aug 2024 13:45:19 -0400 Subject: [PATCH] feat: filter uniformity analysis errors with `derivative_uniformity` --- naga/src/diagnostic_filter.rs | 3 --- naga/src/valid/analyzer.rs | 15 +++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/naga/src/diagnostic_filter.rs b/naga/src/diagnostic_filter.rs index 19f4822eb1..1d5f7b9a74 100644 --- a/naga/src/diagnostic_filter.rs +++ b/naga/src/diagnostic_filter.rs @@ -48,7 +48,6 @@ impl Severity { /// Naga does not yet support diagnostic items at lesser severities than /// [`Severity::Error`]. When this is implemented, this method should be deleted, and the /// severity should be used directly for reporting diagnostics. - #[cfg(feature = "wgsl-in")] pub(crate) fn report_diag( self, err: E, @@ -101,7 +100,6 @@ impl FilterableTriggeringRule { /// /// See for a table of default /// severities. - #[allow(dead_code)] pub(crate) const fn default_severity(self) -> Severity { match self { FilterableTriggeringRule::DerivativeUniformity => Severity::Error, @@ -195,7 +193,6 @@ pub struct DiagnosticFilterNode { } impl DiagnosticFilterNode { - #[allow(dead_code)] pub(crate) fn search( node: Option>, arena: &Arena, diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs index 9d86db3996..4be6963cfc 100644 --- a/naga/src/valid/analyzer.rs +++ b/naga/src/valid/analyzer.rs @@ -6,7 +6,7 @@ //! - expression reference counts use super::{ExpressionError, FunctionError, ModuleInfo, ShaderStages, ValidationFlags}; -use crate::diagnostic_filter::DiagnosticFilterNode; +use crate::diagnostic_filter::{DiagnosticFilterNode, FilterableTriggeringRule}; use crate::span::{AddSpan as _, WithSpan}; use crate::{ arena::{Arena, Handle}, @@ -818,7 +818,6 @@ impl FunctionInfo { /// Returns a `NonUniformControlFlow` error if any of the expressions in the block /// require uniformity, but the current flow is non-uniform. #[allow(clippy::or_fun_call)] - #[allow(clippy::only_used_in_recursion)] fn process_block( &mut self, statements: &crate::Block, @@ -842,8 +841,16 @@ impl FunctionInfo { && !req.is_empty() { if let Some(cause) = disruptor { - return Err(FunctionError::NonUniformControlFlow(req, expr, cause) - .with_span_handle(expr, expression_arena)); + let severity = DiagnosticFilterNode::search( + self.diagnostic_filter_head, + diagnostic_filter_arena, + FilterableTriggeringRule::DerivativeUniformity, + ); + severity.report_diag( + FunctionError::NonUniformControlFlow(req, expr, cause) + .with_span_handle(expr, expression_arena), + |e, level| log::log!(level, "{e}"), + )?; } } requirements |= req;