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 5, 2024
1 parent a30fcb3 commit a7a3ade
Show file tree
Hide file tree
Showing 2 changed files with 16 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 @@ -227,7 +225,6 @@ impl DiagnosticFilterNode {
/// is found, return the value of [`FilterableTriggeringRule::default_severity`].
///
/// When `triggering_rule` is not applicable to this node, its parent is consulted recursively.
#[allow(dead_code)]
pub(crate) fn search(
node: Option<Handle<Self>>,
arena: &Arena<Self>,
Expand Down
20 changes: 16 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 @@ -822,7 +822,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 @@ -846,8 +845,21 @@ 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_leaf,
diagnostic_filter_arena,
FilterableTriggeringRule::DerivativeUniformity,
);
severity.report_diag(
FunctionError::NonUniformControlFlow(req, expr, cause)
.with_span_handle(expr, expression_arena),
// TODO: Yes, this isn't contextualized with source, because
// the user is supposed to render what would normally be an
// error here. Once we actually support warning-level
// diagnostic items, then we won't need this non-compliant hack:
// <https://github.com/gfx-rs/wgpu/issues/6458>
|e, level| log::log!(level, "{e}"),
)?;
}
}
requirements |= req;
Expand Down

0 comments on commit a7a3ade

Please sign in to comment.