Skip to content

Commit

Permalink
feat(wgsl-in): filter unif. analysis errors with derivative_uniformity
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Nov 1, 2024
1 parent 223d5b2 commit 07202fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 0 additions & 3 deletions naga/src/diagnostic_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<E>(
self,
err: E,
Expand Down Expand Up @@ -101,7 +100,6 @@ impl FilterableTriggeringRule {
///
/// See <https://www.w3.org/TR/WGSL/#filterable-triggering-rules> for a table of default
/// severities.
#[allow(dead_code)]
pub(crate) const fn default_severity(self) -> Severity {
match self {
FilterableTriggeringRule::DerivativeUniformity => Severity::Error,
Expand Down Expand Up @@ -195,7 +193,6 @@ pub struct DiagnosticFilterNode {
}

impl DiagnosticFilterNode {
#[allow(dead_code)]
pub(crate) fn search(
node: Option<Handle<Self>>,
arena: &Arena<Self>,
Expand Down
15 changes: 11 additions & 4 deletions naga/src/valid/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 07202fc

Please sign in to comment.