Propagate errors from Tick in backend::Queue::SubmitImpl

Otherwise errors in Tick could cause the device to be lost and further
processing in Queue::SubmitImpl to fail in interesting ways.

Bug: dawn:723
Bug: chromium:1191777
Change-Id: I586c6b0f97c89938b9e7deeb6f31231ec19e826c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/46002
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez 2021-03-30 10:21:36 +00:00 committed by Commit Bot service account
parent d7d98509da
commit 1bc1ed4bc9
5 changed files with 16 additions and 12 deletions

View File

@ -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() {

View File

@ -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<Ref<BindGroupLayoutBase>> CreateEmptyBindGroupLayout();
MaybeError CreateBindGroupInternal(BindGroupBase** result,

View File

@ -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());

View File

@ -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();

View File

@ -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");