Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Capabilities::ATOMIC_COMPARE_EXCHANGE_WEAK. #2503

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/valid/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,19 @@ impl super::Validator {
}

if let crate::AtomicFunction::Exchange { compare: Some(cmp) } = *fun {
if !self
.capabilities
.contains(super::Capabilities::ATOMIC_COMPARE_EXCHANGE_WEAK)
{
return Err(FunctionError::Expression {
handle: result,
source: ExpressionError::MissingCapabilities(
super::Capabilities::ATOMIC_COMPARE_EXCHANGE_WEAK,
),
}
.with_span_handle(result, context.expressions));
}

if context.resolve_type(cmp, &self.valid_expression_set)? != value_inner {
log::error!("Atomic exchange comparison has a different type from the value");
return Err(AtomicError::InvalidOperand(cmp)
Expand Down
8 changes: 7 additions & 1 deletion src/valid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,18 @@ bitflags::bitflags! {
const RAY_QUERY = 0x1000;
/// Support for generating two sources for blending from fragement shaders
const DUAL_SOURCE_BLENDING = 0x2000;
/// Support for WGSL atomicCompareExchangeWeak
///
/// This is part of the WGSL standard, but it's not implemented yet for
/// some backends (#1413). Our benchmark harness would like to be able
/// to filter out modules we can't process successfully.
const ATOMIC_COMPARE_EXCHANGE_WEAK = 0x4000;
}
}

impl Default for Capabilities {
fn default() -> Self {
Self::MULTISAMPLED_SHADING
Self::MULTISAMPLED_SHADING | Self::ATOMIC_COMPARE_EXCHANGE_WEAK
}
}

Expand Down