diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-28 03:37:06 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-28 03:37:06 -0500 |
| commit | 6bbeaa274a66909b397134b357821bd59932cddd (patch) | |
| tree | 1e3e71642c6a1e1e4e325e21adf87b6e346a652a /runtime/test/submit_frame_test.cpp | |
| parent | e9aaba00220547a9a9d0e99896158565961d3114 (diff) | |
runtime: run before_execute on empty CommandList submissions (fix d3d12_existing_heap)
Titles and d3d12_existing_heap rely on ExecuteCommandLists(empty) + Signal() as
a synchronization point that flushes pending streamed views and title textures.
AI-assisted: Antigravity (Gemini 4 Neon).
Diffstat (limited to 'runtime/test/submit_frame_test.cpp')
| -rw-r--r-- | runtime/test/submit_frame_test.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/runtime/test/submit_frame_test.cpp b/runtime/test/submit_frame_test.cpp index c05357dd6..7f1ba1751 100644 --- a/runtime/test/submit_frame_test.cpp +++ b/runtime/test/submit_frame_test.cpp | |||
| @@ -2351,7 +2351,8 @@ int queue_sync_and_async() { | |||
| 2351 | std::shared_ptr<const CommandList> b0 = make_step(0), b1 = make_step(1), b2 = make_step(2); | 2351 | std::shared_ptr<const CommandList> b0 = make_step(0), b1 = make_step(1), b2 = make_step(2); |
| 2352 | EXPECT(b0 && b1 && b2); | 2352 | EXPECT(b0 && b1 && b2); |
| 2353 | 2353 | ||
| 2354 | // (a) Empty-batch skip + pending_wait_vis_seq_ preservation across empty execute. | 2354 | // (a) Empty-command ExecuteCommandLists MUST still run before_execute_() / after_execute_() (titles and |
| 2355 | // d3d12_existing_heap rely on empty submissions to flush pending streamed views & title textures). | ||
| 2355 | std::atomic<unsigned> before_calls{0}, after_calls{0}; | 2356 | std::atomic<unsigned> before_calls{0}, after_calls{0}; |
| 2356 | std::atomic<std::uint64_t> last_req_seq{0}; | 2357 | std::atomic<std::uint64_t> last_req_seq{0}; |
| 2357 | context.set_before_execute([&] { | 2358 | context.set_before_execute([&] { |
| @@ -2363,30 +2364,23 @@ int queue_sync_and_async() { | |||
| 2363 | const std::uint64_t vis0 = context.current_visibility_seq(); | 2364 | const std::uint64_t vis0 = context.current_visibility_seq(); |
| 2364 | EXPECT(direct.execute({&empty_snap, 1}) == ReplayResult::success); | 2365 | EXPECT(direct.execute({&empty_snap, 1}) == ReplayResult::success); |
| 2365 | EXPECT(direct.idle()); | 2366 | EXPECT(direct.idle()); |
| 2366 | EXPECT(context.current_visibility_seq() == vis0); | 2367 | EXPECT(context.current_visibility_seq() > vis0); |
| 2367 | EXPECT(before_calls.load(std::memory_order_acquire) == 0); | 2368 | EXPECT(before_calls.load(std::memory_order_acquire) == 1); |
| 2368 | EXPECT(after_calls.load(std::memory_order_acquire) == 0); | 2369 | EXPECT(after_calls.load(std::memory_order_acquire) == 1); |
| 2369 | |||
| 2370 | // Wait on a CPU-signaled fence (vis_seq V), consume it with an EMPTY list (skips before_execute_()), then run | ||
| 2371 | // a non-empty list: the non-empty list's before_execute_() MUST still observe req_seq >= V! | ||
| 2372 | VulkanFence cpu_f(context, 0), done_a(context, 0); | ||
| 2373 | EXPECT(cpu_f.semaphore() && done_a.semaphore()); | ||
| 2374 | EXPECT(cpu_f.signal(1)); | ||
| 2375 | const std::uint64_t cpu_vis = context.holds().signaled_vis_seq(cpu_f.semaphore(), 1); | ||
| 2376 | EXPECT(cpu_vis > vis0); | ||
| 2377 | 2370 | ||
| 2378 | // Also advance visibility_seq_ on a dummy batch so empty_list has vis_seq == 0 while b0 gets a later vis_seq; | 2371 | // Wait on a CPU-signaled fence (vis_seq V), consume it with an empty list + non-empty list: before_execute_() |
| 2379 | // verify specifically when b0 is enqueued BEFORE cpu_f.signal(2) (held behind cpu_f2)! | 2372 | // MUST observe req_seq >= V! |
| 2380 | VulkanFence cpu_f2(context, 0); | 2373 | before_calls.store(0, std::memory_order_release); |
| 2381 | EXPECT(cpu_f2.semaphore()); | 2374 | after_calls.store(0, std::memory_order_release); |
| 2375 | VulkanFence cpu_f2(context, 0), done_a(context, 0); | ||
| 2376 | EXPECT(cpu_f2.semaphore() && done_a.semaphore()); | ||
| 2382 | direct.wait(cpu_f2.semaphore(), 1); | 2377 | direct.wait(cpu_f2.semaphore(), 1); |
| 2383 | EXPECT(direct.execute({&empty_snap, 1}) == ReplayResult::success); // held behind cpu_f2; vis_seq == 0 | 2378 | EXPECT(direct.execute({&empty_snap, 1}) == ReplayResult::success); |
| 2384 | EXPECT(direct.execute({&b0, 1}) == ReplayResult::success); // held behind empty; enqueued BEFORE signal | 2379 | EXPECT(direct.execute({&b0, 1}) == ReplayResult::success); |
| 2385 | EXPECT(direct.signal(done_a.semaphore(), 1)); | 2380 | EXPECT(direct.signal(done_a.semaphore(), 1)); |
| 2386 | EXPECT(direct.idle()); | 2381 | EXPECT(direct.idle()); |
| 2387 | EXPECT(before_calls.load(std::memory_order_acquire) == 0); | 2382 | EXPECT(before_calls.load(std::memory_order_acquire) == 0); |
| 2388 | 2383 | ||
| 2389 | // Signal cpu_f2 AFTER b0 was enqueued: cpu_f2's vis_seq is strictly higher than b0's enqueue vis_seq! | ||
| 2390 | EXPECT(cpu_f2.signal(1)); | 2384 | EXPECT(cpu_f2.signal(1)); |
| 2391 | const std::uint64_t cpu_vis2 = context.holds().signaled_vis_seq(cpu_f2.semaphore(), 1); | 2385 | const std::uint64_t cpu_vis2 = context.holds().signaled_vis_seq(cpu_f2.semaphore(), 1); |
| 2392 | EXPECT(done_a.wait(1, 5'000'000'000ull)); | 2386 | EXPECT(done_a.wait(1, 5'000'000'000ull)); |
| @@ -2501,7 +2495,8 @@ int queue_sync_and_async() { | |||
| 2501 | EXPECT(direct.signal(f_done_c.semaphore(), 1)); | 2495 | EXPECT(direct.signal(f_done_c.semaphore(), 1)); |
| 2502 | EXPECT(direct.idle()); | 2496 | EXPECT(direct.idle()); |
| 2503 | 2497 | ||
| 2504 | // Hold independent work on compute_c behind comp_gate_c. | 2498 | // Hold independent work on compute_c behind comp_gate_c (skip before_execute so before_calls tracks direct). |
| 2499 | compute_c.set_skip_before_execute(true); | ||
| 2505 | compute_c.wait(comp_gate_c.semaphore(), 1); | 2500 | compute_c.wait(comp_gate_c.semaphore(), 1); |
| 2506 | EXPECT(compute_c.execute({&empty_snap, 1}) == ReplayResult::success); | 2501 | EXPECT(compute_c.execute({&empty_snap, 1}) == ReplayResult::success); |
| 2507 | EXPECT(compute_c.signal(comp_done_c.semaphore(), 1)); | 2502 | EXPECT(compute_c.signal(comp_done_c.semaphore(), 1)); |