diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index 87ee093d98..6c79232249 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -870,18 +870,22 @@ namespace dawn_native { // Returns true if future ticking is needed. bool DeviceBase::APITick() { - if (ConsumedError(ValidateIsAlive())) { + if (ConsumedError(Tick())) { return false; } + return !IsDeviceIdle(); + } + + MaybeError DeviceBase::Tick() { + DAWN_TRY(ValidateIsAlive()); + // to avoid overly ticking, we only want to tick when: // 1. the last submitted serial has moved beyond the completed serial // 2. or the completed serial has not reached the future serial set by the trackers if (mLastSubmittedSerial > mCompletedSerial || mCompletedSerial < mFutureSerial) { CheckPassedSerials(); - if (ConsumedError(TickImpl())) { - return false; - } + DAWN_TRY(TickImpl()); // There is no GPU work in flight, we need to move the serials forward so that // so that CPU operations waiting on GPU completion can know they don't have to wait. @@ -900,7 +904,7 @@ namespace dawn_native { mCreatePipelineAsyncTracker->Tick(mCompletedSerial); } - return !IsDeviceIdle(); + return {}; } QueueBase* DeviceBase::APIGetQueue() { diff --git a/src/dawn_native/Device.h b/src/dawn_native/Device.h index 225b689883..320849f738 100644 --- a/src/dawn_native/Device.h +++ b/src/dawn_native/Device.h @@ -89,7 +89,6 @@ namespace dawn_native { ExecutionSerial GetLastSubmittedCommandSerial() const; ExecutionSerial GetFutureSerial() const; ExecutionSerial GetPendingCommandSerial() const; - virtual MaybeError TickImpl() = 0; // Many Dawn objects are completely immutable once created which means that if two // creations are given the same arguments, they can return the same object. Reusing @@ -242,6 +241,8 @@ namespace dawn_native { // Check for passed fences and set the new completed serial void CheckPassedSerials(); + MaybeError Tick(); + virtual uint32_t GetOptimalBytesPerRowAlignment() const = 0; virtual uint64_t GetOptimalBufferToTextureCopyOffsetAlignment() const = 0; @@ -290,6 +291,8 @@ namespace dawn_native { TextureBase* texture, const TextureViewDescriptor* descriptor) = 0; + virtual MaybeError TickImpl() = 0; + ResultOrError> CreateEmptyBindGroupLayout(); MaybeError CreateBindGroupInternal(BindGroupBase** result, diff --git a/src/dawn_native/d3d12/QueueD3D12.cpp b/src/dawn_native/d3d12/QueueD3D12.cpp index 663bb4275b..ca6064de51 100644 --- a/src/dawn_native/d3d12/QueueD3D12.cpp +++ b/src/dawn_native/d3d12/QueueD3D12.cpp @@ -32,8 +32,7 @@ namespace dawn_native { namespace d3d12 { MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { Device* device = ToBackend(GetDevice()); - // TODO(dawn:723): propagate any errors from Tick. - device->APITick(); + DAWN_TRY(device->Tick()); CommandRecordingContext* commandContext; DAWN_TRY_ASSIGN(commandContext, device->GetPendingCommandContext()); diff --git a/src/dawn_native/metal/QueueMTL.mm b/src/dawn_native/metal/QueueMTL.mm index 3c90ea2209..bfa33ac2c1 100644 --- a/src/dawn_native/metal/QueueMTL.mm +++ b/src/dawn_native/metal/QueueMTL.mm @@ -32,8 +32,7 @@ namespace dawn_native { namespace metal { MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { Device* device = ToBackend(GetDevice()); - // TODO(dawn:723): propagate any errors from Tick. - device->APITick(); + DAWN_TRY(device->Tick()); CommandRecordingContext* commandContext = device->GetPendingCommandContext(); diff --git a/src/dawn_native/vulkan/QueueVk.cpp b/src/dawn_native/vulkan/QueueVk.cpp index d7b89bee07..2cb1e69db8 100644 --- a/src/dawn_native/vulkan/QueueVk.cpp +++ b/src/dawn_native/vulkan/QueueVk.cpp @@ -41,8 +41,7 @@ namespace dawn_native { namespace vulkan { MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) { Device* device = ToBackend(GetDevice()); - // TODO(dawn:723): propagate any errors from Tick. - device->APITick(); + DAWN_TRY(device->Tick()); TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferVk::RecordCommands");