Use typed integers for the Fence FenceAPISerial
This will prevent mixing it up with other serial types in the future. Bug: dawn:442 Change-Id: I1cdb35ee01be3c771183003bc357c84d46aa5745 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28922 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
53cdbead78
commit
306fc502cf
|
@ -60,12 +60,14 @@ namespace dawn_native {
|
|||
if (IsError()) {
|
||||
return 0;
|
||||
}
|
||||
return mCompletedValue;
|
||||
return uint64_t(mCompletedValue);
|
||||
}
|
||||
|
||||
void Fence::OnCompletion(uint64_t value,
|
||||
void Fence::OnCompletion(uint64_t apiValue,
|
||||
wgpu::FenceOnCompletionCallback callback,
|
||||
void* userdata) {
|
||||
FenceAPISerial value(apiValue);
|
||||
|
||||
WGPUFenceCompletionStatus status;
|
||||
if (GetDevice()->ConsumedError(ValidateOnCompletion(value, &status))) {
|
||||
callback(status, userdata);
|
||||
|
@ -84,7 +86,7 @@ namespace dawn_native {
|
|||
mRequests.Enqueue(std::move(request), value);
|
||||
}
|
||||
|
||||
uint64_t Fence::GetSignaledValue() const {
|
||||
FenceAPISerial Fence::GetSignaledValue() const {
|
||||
ASSERT(!IsError());
|
||||
return mSignalValue;
|
||||
}
|
||||
|
@ -94,13 +96,13 @@ namespace dawn_native {
|
|||
return mQueue.Get();
|
||||
}
|
||||
|
||||
void Fence::SetSignaledValue(uint64_t signalValue) {
|
||||
void Fence::SetSignaledValue(FenceAPISerial signalValue) {
|
||||
ASSERT(!IsError());
|
||||
ASSERT(signalValue > mSignalValue);
|
||||
mSignalValue = signalValue;
|
||||
}
|
||||
|
||||
void Fence::SetCompletedValue(uint64_t completedValue) {
|
||||
void Fence::SetCompletedValue(FenceAPISerial completedValue) {
|
||||
ASSERT(!IsError());
|
||||
ASSERT(completedValue <= mSignalValue);
|
||||
ASSERT(completedValue > mCompletedValue);
|
||||
|
@ -116,7 +118,7 @@ namespace dawn_native {
|
|||
mRequests.ClearUpTo(mCompletedValue);
|
||||
}
|
||||
|
||||
MaybeError Fence::ValidateOnCompletion(uint64_t value,
|
||||
MaybeError Fence::ValidateOnCompletion(FenceAPISerial value,
|
||||
WGPUFenceCompletionStatus* status) const {
|
||||
*status = WGPUFenceCompletionStatus_DeviceLost;
|
||||
DAWN_TRY(GetDevice()->ValidateIsAlive());
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "common/SerialMap.h"
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/IntegerTypes.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
@ -34,7 +35,7 @@ namespace dawn_native {
|
|||
|
||||
static Fence* MakeError(DeviceBase* device);
|
||||
|
||||
uint64_t GetSignaledValue() const;
|
||||
FenceAPISerial GetSignaledValue() const;
|
||||
const QueueBase* GetQueue() const;
|
||||
|
||||
// Dawn API
|
||||
|
@ -44,24 +45,25 @@ namespace dawn_native {
|
|||
protected:
|
||||
friend class QueueBase;
|
||||
friend class FenceSignalTracker;
|
||||
void SetSignaledValue(uint64_t signalValue);
|
||||
void SetCompletedValue(uint64_t completedValue);
|
||||
void SetSignaledValue(FenceAPISerial signalValue);
|
||||
void SetCompletedValue(FenceAPISerial completedValue);
|
||||
|
||||
private:
|
||||
Fence(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
~Fence() override;
|
||||
|
||||
MaybeError ValidateOnCompletion(uint64_t value, WGPUFenceCompletionStatus* status) const;
|
||||
MaybeError ValidateOnCompletion(FenceAPISerial value,
|
||||
WGPUFenceCompletionStatus* status) const;
|
||||
|
||||
struct OnCompletionData {
|
||||
wgpu::FenceOnCompletionCallback completionCallback = nullptr;
|
||||
void* userdata = nullptr;
|
||||
};
|
||||
|
||||
uint64_t mSignalValue;
|
||||
uint64_t mCompletedValue;
|
||||
FenceAPISerial mSignalValue;
|
||||
FenceAPISerial mCompletedValue;
|
||||
Ref<QueueBase> mQueue;
|
||||
SerialMap<Serial, OnCompletionData> mRequests;
|
||||
SerialMap<FenceAPISerial, OnCompletionData> mRequests;
|
||||
};
|
||||
|
||||
} // namespace dawn_native
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace dawn_native {
|
|||
ASSERT(mFencesInFlight.Empty());
|
||||
}
|
||||
|
||||
void FenceSignalTracker::UpdateFenceOnComplete(Fence* fence, uint64_t value) {
|
||||
void FenceSignalTracker::UpdateFenceOnComplete(Fence* fence, FenceAPISerial value) {
|
||||
// Because we currently only have a single queue, we can simply update
|
||||
// the fence completed value once the last submitted serial has passed.
|
||||
mFencesInFlight.Enqueue(FenceInFlight{fence, value},
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "common/RefCounted.h"
|
||||
#include "common/SerialQueue.h"
|
||||
#include "dawn_native/IntegerTypes.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
|
@ -26,14 +27,14 @@ namespace dawn_native {
|
|||
class FenceSignalTracker {
|
||||
struct FenceInFlight {
|
||||
Ref<Fence> fence;
|
||||
uint64_t value;
|
||||
FenceAPISerial value;
|
||||
};
|
||||
|
||||
public:
|
||||
FenceSignalTracker(DeviceBase* device);
|
||||
~FenceSignalTracker();
|
||||
|
||||
void UpdateFenceOnComplete(Fence* fence, uint64_t value);
|
||||
void UpdateFenceOnComplete(Fence* fence, FenceAPISerial value);
|
||||
|
||||
void Tick(Serial finishedSerial);
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ namespace dawn_native {
|
|||
// that was sent.
|
||||
using MapRequestID = TypedInteger<struct MapRequestIDT, uint64_t>;
|
||||
|
||||
// The type for the WebGPU API fence serial values.
|
||||
using FenceAPISerial = TypedInteger<struct FenceAPISerialT, uint64_t>;
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
#endif // DAWNNATIVE_INTEGERTYPES_H_
|
||||
|
|
|
@ -155,7 +155,9 @@ namespace dawn_native {
|
|||
}
|
||||
}
|
||||
|
||||
void QueueBase::Signal(Fence* fence, uint64_t signalValue) {
|
||||
void QueueBase::Signal(Fence* fence, uint64_t apiSignalValue) {
|
||||
FenceAPISerial signalValue(apiSignalValue);
|
||||
|
||||
DeviceBase* device = GetDevice();
|
||||
if (device->ConsumedError(ValidateSignal(fence, signalValue))) {
|
||||
return;
|
||||
|
@ -312,7 +314,7 @@ namespace dawn_native {
|
|||
return {};
|
||||
}
|
||||
|
||||
MaybeError QueueBase::ValidateSignal(const Fence* fence, uint64_t signalValue) const {
|
||||
MaybeError QueueBase::ValidateSignal(const Fence* fence, FenceAPISerial signalValue) const {
|
||||
DAWN_TRY(GetDevice()->ValidateIsAlive());
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
DAWN_TRY(GetDevice()->ValidateObject(fence));
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "dawn_native/Error.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/IntegerTypes.h"
|
||||
#include "dawn_native/ObjectBase.h"
|
||||
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
@ -65,7 +66,7 @@ namespace dawn_native {
|
|||
const Extent3D& writeSize);
|
||||
|
||||
MaybeError ValidateSubmit(uint32_t commandCount, CommandBufferBase* const* commands) const;
|
||||
MaybeError ValidateSignal(const Fence* fence, uint64_t signalValue) const;
|
||||
MaybeError ValidateSignal(const Fence* fence, FenceAPISerial signalValue) const;
|
||||
MaybeError ValidateCreateFence(const FenceDescriptor* descriptor) const;
|
||||
MaybeError ValidateWriteBuffer(const BufferBase* buffer,
|
||||
uint64_t bufferOffset,
|
||||
|
|
Loading…
Reference in New Issue