Skip to content

Commit

Permalink
chore: revert removal of DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler authored Nov 13, 2024
1 parent b5986a9 commit efc15ba
Showing 1 changed file with 52 additions and 46 deletions.
98 changes: 52 additions & 46 deletions naga/src/valid/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ use std::ops;

pub type NonUniformResult = Option<Handle<crate::Expression>>;

const DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE: bool = true;

bitflags::bitflags! {
/// Kinds of expressions that require uniform control flow.
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct UniformityRequirements: u8 {
const WORK_GROUP_BARRIER = 0x1;
const DERIVATIVE = 0x2;
const IMPLICIT_LEVEL = 0x4;
const DERIVATIVE = if DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE { 0 } else { 0x2 };
const IMPLICIT_LEVEL = if DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE { 0 } else { 0x4 };
}
}

Expand Down Expand Up @@ -1350,52 +1352,56 @@ fn uniform_control_flow() {
&expressions,
&Arena::new(),
);
assert_eq!(
block_info,
Err(FunctionError::NonUniformControlFlow(
UniformityRequirements::DERIVATIVE,
derivative_expr,
UniformityDisruptor::Expression(non_uniform_global_expr)
)
.with_span()),
);
assert_eq!(info[derivative_expr].ref_count, 1);

// Test that the same thing passes when we disable the `derivative_uniformity`
let mut diagnostic_filters = Arena::new();
let diagnostic_filter_leaf = diagnostic_filters.append(
DiagnosticFilterNode {
inner: crate::diagnostic_filter::DiagnosticFilter {
new_severity: crate::diagnostic_filter::Severity::Off,
triggering_rule: FilterableTriggeringRule::DerivativeUniformity,
if DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE {
assert_eq!(info[derivative_expr].ref_count, 2);
} else {
assert_eq!(
block_info,
Err(FunctionError::NonUniformControlFlow(
UniformityRequirements::DERIVATIVE,
derivative_expr,
UniformityDisruptor::Expression(non_uniform_global_expr)
)
.with_span()),
);
assert_eq!(info[derivative_expr].ref_count, 1);

// Test that the same thing passes when we disable the `derivative_uniformity`
let mut diagnostic_filters = Arena::new();
let diagnostic_filter_leaf = diagnostic_filters.append(
DiagnosticFilterNode {
inner: crate::diagnostic_filter::DiagnosticFilter {
new_severity: crate::diagnostic_filter::Severity::Off,
triggering_rule: FilterableTriggeringRule::DerivativeUniformity,
},
parent: None,
},
parent: None,
},
crate::Span::default(),
);
let mut info = FunctionInfo {
diagnostic_filter_leaf: Some(diagnostic_filter_leaf),
..info.clone()
};
crate::Span::default(),
);
let mut info = FunctionInfo {
diagnostic_filter_leaf: Some(diagnostic_filter_leaf),
..info.clone()
};

let block_info = info.process_block(
&vec![stmt_emit2, stmt_if_non_uniform].into(),
&[],
None,
&expressions,
&diagnostic_filters,
);
assert_eq!(
block_info,
Ok(FunctionUniformity {
result: Uniformity {
non_uniform_result: None,
requirements: UniformityRequirements::DERIVATIVE,
},
exit: ExitFlags::empty()
}),
);
assert_eq!(info[derivative_expr].ref_count, 2);
let block_info = info.process_block(
&vec![stmt_emit2, stmt_if_non_uniform].into(),
&[],
None,
&expressions,
&diagnostic_filters,
);
assert_eq!(
block_info,
Ok(FunctionUniformity {
result: Uniformity {
non_uniform_result: None,
requirements: UniformityRequirements::DERIVATIVE,
},
exit: ExitFlags::empty()
}),
);
assert_eq!(info[derivative_expr].ref_count, 2);
}
}
assert_eq!(info[non_uniform_global], GlobalUse::READ);

Expand Down

0 comments on commit efc15ba

Please sign in to comment.