upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/vk_queue_query_sync_test.cpp
diff options
context:
space:
mode:
authorAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-22 21:02:33 +0100
committerAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-22 21:02:33 +0100
commitf8007dda67f9c45757b63df5c5fd8377647da4ae (patch)
treecdffc5cc7c81dcbbf683af9c0df6077c6587ac0d /runtime/test/vk_queue_query_sync_test.cpp
parent9bebfb107070d84609e303009b0f91b011b9aa2e (diff)
Queue holds: review fixes (Present ordering, pins, timeline monotonicity, fence lifetime, teardown, docs)
- Present is queued behind held work (QueueHolds::after_held) and submitted in order by the releasing thread. - Held batches keep the pipeline states and root signatures of their lists; fences a queue waits on or signals are kept until the submission has completed on the GPU (a D3D12 queue holds them). - A held Signal released below an unheld one on the same fence leaves the Vulkan signal out (claimed under the submit lock). - A queue destroyed with held Signals completes the CPU waits on their fences and reports it. - A failed held batch is reported (take_held_failure, last_execute_result), its waits stay for the next submission, and the Signal behind it still signals. - d3d12_queue_handover_test: pairs, two-thread signalling stress, held Signal of a released fence, shared fence, teardown with a CPU waiter; --two-queues and --shared-queue modes on a caller-owned device. - Tests for each fix in vk_presenter_sync_test, vk_queue_query_sync_test and d3d12_m4_compute_test; docs section 4.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/vk_queue_query_sync_test.cpp')
-rw-r--r--runtime/test/vk_queue_query_sync_test.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/runtime/test/vk_queue_query_sync_test.cpp b/runtime/test/vk_queue_query_sync_test.cpp
index a03e369b9..b7237b911 100644
--- a/runtime/test/vk_queue_query_sync_test.cpp
+++ b/runtime/test/vk_queue_query_sync_test.cpp
@@ -291,6 +291,46 @@ int main() {
291 std::printf("queue/query sync: pending Wait() preserved across failed vkQueueSubmit ok\n"); 291 std::printf("queue/query sync: pending Wait() preserved across failed vkQueueSubmit ok\n");
292 } 292 }
293 293
294 // 3b. The same for a batch held behind a Wait with no submitted Signal (queue_holds.h): its submission
295 // fails when the CPU Signal releases it, the failure is reported through take_held_failure(), and its
296 // waits stay for the next submission, as when the call is not held. A Signal queued behind the failed
297 // batch still runs.
298 {
299 VulkanFence gate(context, 0), after(context, 0);
300 EXPECT(gate.semaphore() != VK_NULL_HANDLE && after.semaphore() != VK_NULL_HANDLE);
301 const std::uint64_t pattern = 0x0badf00dcafe1234ULL;
302 std::memcpy(src_ptr, &pattern, sizeof(pattern));
303 std::memset(dst_ptr, 0, sizeof(pattern));
304 CommandList copy_list;
305 EXPECT(copy_list.copy_buffer({2, 0, 1, 0, sizeof(pattern)}));
306 EXPECT(copy_list.close());
307 const CommandList* ptr = &copy_list;
308
309 queue_a.wait(gate.semaphore(), 1);
310 EXPECT(queue_a.execute({&ptr, 1}) == ReplayResult::success); // held: the Signal is not submitted yet
311 EXPECT(queue_a.signal(after.semaphore(), 1)); // held behind it
312 EXPECT(after.completed() == 0 && queue_a.take_held_failure() == ReplayResult::success);
313 driver::fail_next_submit.store(VK_ERROR_OUT_OF_HOST_MEMORY);
314 EXPECT(gate.signal(1)); // releases the batch on this thread
315 EXPECT(queue_a.take_held_failure() == ReplayResult::unsupported);
316 EXPECT(queue_a.take_held_failure() == ReplayResult::success); // reported once
317 EXPECT(queue_a.idle() && after.completed() == 1); // the Signal behind it still signaled
318
319 driver::captured_wait_count.store(0);
320 driver::captured_wait_sem.store(0);
321 driver::captured_wait_val.store(0);
322 driver::capture_next_waits.store(true);
323 EXPECT(queue_a.execute({&ptr, 1}) == ReplayResult::success);
324 EXPECT(queue_a.idle());
325 EXPECT(driver::captured_wait_count.load() == 1); // the failed batch's wait on (gate, 1) came along
326 EXPECT(driver::captured_wait_sem.load() == reinterpret_cast<std::uintptr_t>(gate.semaphore()));
327 EXPECT(driver::captured_wait_val.load() == 1);
328 std::uint64_t got = 0;
329 std::memcpy(&got, dst_ptr, sizeof(got));
330 EXPECT(got == pattern);
331 std::printf("queue/query sync: failed held batch reported, its wait kept for the retry, Signal behind it ran\n");
332 }
333
294 // 4. Concurrent multi-queue EndQuery + ResolveQueries + temporary query pool add/remove stress. 334 // 4. Concurrent multi-queue EndQuery + ResolveQueries + temporary query pool add/remove stress.
295 // Each iteration uses a distinct query slot so no slot is reset while another submission resolves it. 335 // Each iteration uses a distinct query slot so no slot is reset while another submission resolves it.
296 { 336 {