Skip to content

Commit 021e474

Browse files
committed
[Perf] GfxRuntime device_to_host: drop redundant wait_idle before readback_data; the readback's own submit_synced already drains
1 parent 3eaef5e commit 021e474

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

quadrants/runtime/gfx/runtime.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,14 @@ class HostDeviceContextBlitter {
210210

211211
if (require_sync) {
212212
if (readback_sizes.size()) {
213+
// `readback_data` internally allocates a staging buffer, records a `buffer_copy` cmdlist, and submits it via
214+
// `submit_synced` (which on every backend drains the compute stream's pending cmdbufs). Both Metal's
215+
// `command_sync` and Vulkan's `vkQueueWaitIdle` drain everything queued, so the kernel cmdlist submitted just
216+
// above completes as part of the same wait the readback already pays. A separate `wait_idle()` here would
217+
// double the host-GPU round-trip per readback launch with no extra correctness; the `command_complete_sema`
218+
// dependency edge is what the readback's submit honors on Vulkan, and Metal ignores `wait_semaphores` but
219+
// drains in submission order so the kernel still completes before the staging buffer's `buffer_copy` runs.
213220
StreamSemaphore command_complete_sema = device_->get_compute_stream()->submit(cmdlist);
214-
215-
device_->wait_idle();
216-
217-
// In this case `readback_data` syncs
218221
QD_ASSERT(device_->readback_data(readback_dev_ptrs.data(), readback_host_ptrs.data(), readback_sizes.data(),
219222
int(readback_sizes.size()), {command_complete_sema}) == RhiResult::success);
220223
} else {

0 commit comments

Comments
 (0)