Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
Add Capabilities::ATOMIC_COMPARE_EXCHANGE_WEAK.
Browse files Browse the repository at this point in the history
We haven't finished implementing WGSL's `atomicCompareExchangeWeak` on
all platforms (#1413). It's valuable to have some configuration of
validation that guarantees backends will succeed, and adding a
`Capabilities` bit that is included by default but can be turned off
accomplishes that.
  • Loading branch information
jimblandy committed Sep 25, 2023
1 parent 57bebbc commit 2b88d83
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit 2b88d83

Please sign in to comment.