Move submit Tick from backends to QueueBase
All backends except D3D11 called tick in the same way inside SubmitImpl.
This moves that call to QueueBase so they don't have to.
In the D3D11 backend specifically, note that this *adds* a Tick call
inside Submit. For the others, there should be no behavioral change.
Bug: none, dawn:1863
Change-Id: I0dfad14b9a0fdc167bd8a6bc7fa3ef72922b8fad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/135821
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/Queue.cpp b/src/dawn/native/Queue.cpp
index 5499899..3acde87 100644
--- a/src/dawn/native/Queue.cpp
+++ b/src/dawn/native/Queue.cpp
@@ -198,11 +198,16 @@
}
void QueueBase::APISubmit(uint32_t commandCount, CommandBufferBase* const* commands) {
- SubmitInternal(commandCount, commands);
+ MaybeError result = SubmitInternal(commandCount, commands);
+ // Destroy the command buffers even if SubmitInternal failed. (crbug.com/dawn/1863)
for (uint32_t i = 0; i < commandCount; ++i) {
commands[i]->Destroy();
}
+
+ DAWN_UNUSED(GetDevice()->ConsumedError(
+ std::move(result), "calling %s.Submit(%s)", this,
+ ityp::span<uint32_t, CommandBufferBase* const>(commands, commandCount)));
}
void QueueBase::APIOnSubmittedWorkDone(uint64_t signalValue,
@@ -543,26 +548,24 @@
return {};
}
-void QueueBase::SubmitInternal(uint32_t commandCount, CommandBufferBase* const* commands) {
+MaybeError QueueBase::SubmitInternal(uint32_t commandCount, CommandBufferBase* const* commands) {
DeviceBase* device = GetDevice();
- if (device->ConsumedError(device->ValidateIsAlive())) {
- // If device is lost, don't let any commands be submitted
- return;
- }
+
+ // If device is lost, don't let any commands be submitted
+ DAWN_TRY(device->ValidateIsAlive());
TRACE_EVENT0(device->GetPlatform(), General, "Queue::Submit");
if (device->IsValidationEnabled()) {
- if (device->ConsumedError(
- ValidateSubmit(commandCount, commands), "calling %s.Submit(%s)", this,
- ityp::span<uint32_t, CommandBufferBase* const>(commands, commandCount))) {
- return;
- }
+ DAWN_TRY(ValidateSubmit(commandCount, commands));
}
ASSERT(!IsError());
- if (device->ConsumedError(SubmitImpl(commandCount, commands))) {
- return;
- }
+ DAWN_TRY(SubmitImpl(commandCount, commands));
+
+ // Call Tick() to flush pending work.
+ DAWN_TRY(device->Tick());
+
+ return {};
}
} // namespace dawn::native
diff --git a/src/dawn/native/Queue.h b/src/dawn/native/Queue.h
index b95e508..30192a9 100644
--- a/src/dawn/native/Queue.h
+++ b/src/dawn/native/Queue.h
@@ -120,7 +120,7 @@
const TextureDataLayout& dataLayout,
const Extent3D* writeSize) const;
- void SubmitInternal(uint32_t commandCount, CommandBufferBase* const* commands);
+ MaybeError SubmitInternal(uint32_t commandCount, CommandBufferBase* const* commands);
SerialMap<ExecutionSerial, std::unique_ptr<TrackTaskCallback>> mTasksInFlight;
};
diff --git a/src/dawn/native/d3d12/QueueD3D12.cpp b/src/dawn/native/d3d12/QueueD3D12.cpp
index 22fea57..b489a68 100644
--- a/src/dawn/native/d3d12/QueueD3D12.cpp
+++ b/src/dawn/native/d3d12/QueueD3D12.cpp
@@ -58,9 +58,6 @@
DAWN_TRY(device->NextSerial());
- // Call Tick() to get a chance to resolve callbacks.
- DAWN_TRY(device->Tick());
-
return {};
}
diff --git a/src/dawn/native/metal/QueueMTL.mm b/src/dawn/native/metal/QueueMTL.mm
index 47c854f..8e9bd66 100644
--- a/src/dawn/native/metal/QueueMTL.mm
+++ b/src/dawn/native/metal/QueueMTL.mm
@@ -44,9 +44,6 @@
DAWN_TRY(device->SubmitPendingCommandBuffer());
- // Call Tick() to get a chance to resolve callbacks.
- DAWN_TRY(device->Tick());
-
return {};
}
}
diff --git a/src/dawn/native/null/DeviceNull.cpp b/src/dawn/native/null/DeviceNull.cpp
index c4198f3..1fe813a 100644
--- a/src/dawn/native/null/DeviceNull.cpp
+++ b/src/dawn/native/null/DeviceNull.cpp
@@ -381,11 +381,9 @@
MaybeError Queue::SubmitImpl(uint32_t, CommandBufferBase* const*) {
Device* device = ToBackend(GetDevice());
- // The Vulkan, D3D12 and Metal implementation all tick the device here,
- // for testing purposes we should also tick in the null implementation.
- DAWN_TRY(device->Tick());
+ DAWN_TRY(device->SubmitPendingOperations());
- return device->SubmitPendingOperations();
+ return {};
}
MaybeError Queue::WriteBufferImpl(BufferBase* buffer,
diff --git a/src/dawn/native/opengl/QueueGL.cpp b/src/dawn/native/opengl/QueueGL.cpp
index 5042a8b..544ac33 100644
--- a/src/dawn/native/opengl/QueueGL.cpp
+++ b/src/dawn/native/opengl/QueueGL.cpp
@@ -26,15 +26,12 @@
Queue::Queue(Device* device, const QueueDescriptor* descriptor) : QueueBase(device, descriptor) {}
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
- Device* device = ToBackend(GetDevice());
-
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferGL::Execute");
for (uint32_t i = 0; i < commandCount; ++i) {
DAWN_TRY(ToBackend(commands[i])->Execute());
}
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferGL::Execute");
- device->SubmitFenceSync();
return {};
}
diff --git a/src/dawn/native/vulkan/QueueVk.cpp b/src/dawn/native/vulkan/QueueVk.cpp
index b8ff1ea..3b4cd36 100644
--- a/src/dawn/native/vulkan/QueueVk.cpp
+++ b/src/dawn/native/vulkan/QueueVk.cpp
@@ -55,9 +55,6 @@
DAWN_TRY(device->SubmitPendingCommands());
- // Call Tick() to get a chance to resolve callbacks.
- DAWN_TRY(device->Tick());
-
return {};
}