mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 18:29:23 +00:00
writer/hlsl: Implement atomics
Storage buffers are emitted as `ByteAddressBuffer`s in HLSL, so we have to jump through hoops to support atomic ops on storage buffer atomics. Workgroup atomics are far more conventional, but very little code can be shared between these two code paths. Bug: tint:892 Change-Id: If10ea866e3b67a093e87aca689d34065fd49b705 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54651 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
@@ -88,6 +88,19 @@ bool IsBarrierIntrinsic(IntrinsicType i) {
|
||||
i == IntrinsicType::kStorageBarrier;
|
||||
}
|
||||
|
||||
bool IsAtomicIntrinsic(IntrinsicType i) {
|
||||
return i == sem::IntrinsicType::kAtomicLoad ||
|
||||
i == sem::IntrinsicType::kAtomicStore ||
|
||||
i == sem::IntrinsicType::kAtomicAdd ||
|
||||
i == sem::IntrinsicType::kAtomicMax ||
|
||||
i == sem::IntrinsicType::kAtomicMin ||
|
||||
i == sem::IntrinsicType::kAtomicAnd ||
|
||||
i == sem::IntrinsicType::kAtomicOr ||
|
||||
i == sem::IntrinsicType::kAtomicXor ||
|
||||
i == sem::IntrinsicType::kAtomicExchange ||
|
||||
i == sem::IntrinsicType::kAtomicCompareExchangeWeak;
|
||||
}
|
||||
|
||||
Intrinsic::Intrinsic(IntrinsicType type,
|
||||
sem::Type* return_type,
|
||||
const ParameterList& parameters,
|
||||
@@ -136,5 +149,9 @@ bool Intrinsic::IsBarrier() const {
|
||||
return IsBarrierIntrinsic(type_);
|
||||
}
|
||||
|
||||
bool Intrinsic::IsAtomic() const {
|
||||
return IsAtomicIntrinsic(type_);
|
||||
}
|
||||
|
||||
} // namespace sem
|
||||
} // namespace tint
|
||||
|
||||
@@ -69,6 +69,11 @@ bool IsDataUnpackingIntrinsic(IntrinsicType i);
|
||||
/// @returns true if the given `i` is a barrier intrinsic
|
||||
bool IsBarrierIntrinsic(IntrinsicType i);
|
||||
|
||||
/// Determines if the given `i` is a atomic intrinsic
|
||||
/// @param i the intrinsic
|
||||
/// @returns true if the given `i` is a atomic intrinsic
|
||||
bool IsAtomicIntrinsic(IntrinsicType i);
|
||||
|
||||
/// Intrinsic holds the semantic information for an intrinsic function.
|
||||
class Intrinsic : public Castable<Intrinsic, CallTarget> {
|
||||
public:
|
||||
@@ -129,6 +134,9 @@ class Intrinsic : public Castable<Intrinsic, CallTarget> {
|
||||
/// @returns true if intrinsic is a barrier intrinsic
|
||||
bool IsBarrier() const;
|
||||
|
||||
/// @returns true if intrinsic is a atomic intrinsic
|
||||
bool IsAtomic() const;
|
||||
|
||||
private:
|
||||
IntrinsicType const type_;
|
||||
PipelineStageSet const supported_stages_;
|
||||
|
||||
Reference in New Issue
Block a user