upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/test/queue_proxy_test.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 22:35:34 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 22:35:34 -0500
commit6ed716a99a7416f1e8a60c2e38e128876ab752ec (patch)
tree3c35526aa8b96594252c82c278ab19b9aa3a98ba /runtime/test/queue_proxy_test.cpp
parent028a414fade7058a96e5933d1325f374a0026588 (diff)
parentbfef489cb6307fa4e1dc6ed2c40bfc0ce120d066 (diff)
Merge main into RT-QUEUE-SIGNAL (#430)
Everything below this rung (#414, #416, #427) and the rung's own routing are in main already, through #984 and #939, in main's form; what is left of #430 is its test of queue slot 17, ported onto main's layout detection. Conflicts, all resolved to main's form: - runtime/shims/d3d12_xs_device.cpp: main's queue slot 16/17 rule (a fence there is the newer layout's Signal/Wait, for any caller) replaces the rung's caller-gated rule; main's PresentX routing (slot 30, or 32 once the newer layout is detected, LEONIDA_XS_PRESENT_X_SLOT) and lazily built presenter replace the fixed slot 32 of #414; main's list proxy already translates the CPU handles of console list slots 50 to 54 (#416) and drops unordered access from a depth-stencil texture at slot 76 (#427). - runtime/shims/d3d12_xs_device.h, runtime/shims/xbox_present.cpp, runtime/shims/xbox_present.h, runtime/src/frame_pacer.h: main's shared FrameTokenSource (Logan's piece of #414, as #984 carried it). - runtime/shims/d3d12_xs_desc_clean.h, runtime/test/device_proxy_test.cpp: main's without_depth_stencil_uav and its slot 25/76 test (#427). - runtime/test/xs_proxy_mock_test.cpp: main's file, which already has check_list_cpu_handles (#416's cases and more); the rung's slot 16/17 case is ported to main's form at the end of check_xbox_queue_slots: slot 16 and 17 with a fence reach PC Signal and Wait with the real fence, not the PC getters, and the fence proxy's vtable pointer is unchanged. The rung's host-caller and no-fence expectations are dropped: under main's rule a fence at 16 proves the newer layout, after which those calls answer S_OK. Auto-merged, then set to main's content: - runtime/test/queue_proxy_test.cpp: #414's call of queue slot 32 as an overridden slot; on main slot 32 is routed only on the newer layout and the sweep of the console tail already calls it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/queue_proxy_test.cpp')
-rw-r--r--runtime/test/queue_proxy_test.cpp56
1 files changed, 43 insertions, 13 deletions
diff --git a/runtime/test/queue_proxy_test.cpp b/runtime/test/queue_proxy_test.cpp
index 674a8cf2e..d1e09d39f 100644
--- a/runtime/test/queue_proxy_test.cpp
+++ b/runtime/test/queue_proxy_test.cpp
@@ -8,8 +8,9 @@
8// - heap, queue and fence proxies are unwrapped where the real runtime receives them (Signal/Wait, 8// - heap, queue and fence proxies are unwrapped where the real runtime receives them (Signal/Wait,
9// SetEventOnMultipleFenceCompletion, MakeResident/Evict/SetResidencyPriority/EnqueueMakeResident, 9// SetEventOnMultipleFenceCompletion, MakeResident/Evict/SetResidencyPriority/EnqueueMakeResident,
10// CreateSharedHandle), and OpenSharedHandle wraps a shared fence; 10// CreateSharedHandle), and OpenSharedHandle wraps a shared fence;
11// - slots past the public chain are refused (E_NOTIMPL) up to the end of the table, and a slot past the table 11// - slots past the public chain answer the console contract — a queue slot returns S_OK having signalled
12// faults on the vtable read in the guard region and is counted; 12// nothing (frame pacing flows through those methods), a fence slot is refused with E_NOTIMPL — and a
13// slot past either table faults on the vtable read in the guard region and is counted;
13// - calls from eight threads at once, and repeated device, queue and fence creation without leaks; 14// - calls from eight threads at once, and repeated device, queue and fence creation without leaks;
14// - the child-process runner of the differential check itself: large output, hangs, crashes, failed starts. 15// - the child-process runner of the differential check itself: large output, hangs, crashes, failed starts.
15// No shaders, game data or Xbox DLLs. LEONIDA_VK_VALIDATION=1 runs the Vulkan device under 16// No shaders, game data or Xbox DLLs. LEONIDA_VK_VALIDATION=1 runs the Vulkan device under
@@ -277,12 +278,6 @@ int check_slots(const Backend& b) {
277 const std::uint64_t before35 = qhits(35); 278 const std::uint64_t before35 = qhits(35);
278 EXPECT(raw_call(queue.p, 35, 1, reinterpret_cast<std::uint64_t>(lists)) == 0); 279 EXPECT(raw_call(queue.p, 35, 1, reinterpret_cast<std::uint64_t>(lists)) == 0);
279 EXPECT(qhits(35) == before35 + 1 && xs::queue_slot_first_call_seen(35)); 280 EXPECT(qhits(35) == before35 + 1 && xs::queue_slot_first_call_seen(35));
280 // Console slot 32, PresentX. This test's build of the proxy has no presenter (the wiring is in gta6rt's,
281 // LEONIDA_VULKAN_DEVICE), so the slot answers S_OK and reaches no PC slot; it is counted like any other.
282 EXPECT(xs::queue_slot_overridden(32));
283 const std::uint64_t before32 = qhits(32);
284 EXPECT(static_cast<std::uint32_t>(raw_call(queue.p, 32, 0, 0, 0)) == static_cast<std::uint32_t>(S_OK));
285 EXPECT(qhits(32) == before32 + 1);
286 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7))); 281 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7)));
287 if (wait_for(label, fence.p, 7)) return 1; 282 if (wait_for(label, fence.p, 7)) return 1;
288 if (b.vulkan) { 283 if (b.vulkan) {
@@ -402,25 +397,60 @@ int check_slots(const Backend& b) {
402 } 397 }
403 } 398 }
404 399
405 // The refused tail: every unmodelled slot from the end of the public chain to the end of the table. 400 // Fence slot 12 (value, descriptor, flags): the address of the completed value, which follows a queue's
401 // signal without another call (a wait on the real fence refreshes it).
402 {
403 before = fhits(12);
404 const auto* completed = reinterpret_cast<const volatile UINT64*>(raw_call(fence.p, 12, 9, 0, 0));
405 EXPECT(completed && *completed == fence->GetCompletedValue() && fhits(12) == before + 1);
406 EXPECT(SUCCEEDED(queue->Signal(fence.p, 9)));
407 bool seen = false;
408 for (int i = 0; i < 5000 && !seen; ++i) {
409 seen = *completed == 9;
410 if (!seen) Sleep(1);
411 }
412 EXPECT(seen);
413 EXPECT(raw_call(fence.p, 12, 9, 0, 0) == reinterpret_cast<std::uint64_t>(completed));
414 }
415
416 // The console queue tail answers S_OK instead of refusing: frame pacing flows through those
417 // methods, the contract xs_proxy_mock checks too. The two methods the proxy models — SignalX at
418 // 23 and PresentX at 30 on the older layout the 16/17 calls above pinned — are checked below.
419 // The fence tail below is still refused — nothing console-shaped was measured past its public chain.
420 // (Fence slot 12 is not part of that tail: it is served, above.)
421 // Queue slot 35 (the console ExecuteCommandLists variant) is not part of the tail either.
406 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) { 422 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) {
407 if (xs::queue_slot_overridden(slot)) continue; 423 if (slot == 23 || slot == 30 || xs::queue_slot_overridden(slot)) continue;
408 before = qhits(slot); 424 before = qhits(slot);
409 EXPECT(as_hr(call_slot(queue.p, slot)) == E_NOTIMPL); 425 EXPECT(as_hr(call_slot(queue.p, slot)) == S_OK);
410 EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot)); 426 EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot));
411 } 427 }
428 // SignalX forwards to the real queue's Signal with the extra word dropped: the fence reaching 9
429 // proves the call was forwarded rather than swallowed by the console-tail answer.
430 before = qhits(23);
431 EXPECT(as_hr(raw_call(queue.p, 23, reinterpret_cast<std::uint64_t>(fence.p), 9)) == S_OK);
432 EXPECT(qhits(23) == before + 1 && xs::queue_slot_first_call_seen(23));
433 if (wait_for(label, fence.p, 9)) return 1;
434 // PresentX is handled by the presentation front end, not refused: its status is the swapchain's
435 // (a black frame on the test window, or S_OK where it cannot present), so anything but E_NOTIMPL
436 // shows the modelled path ran.
437 before = qhits(30);
438 EXPECT(as_hr(call_slot(queue.p, 30)) != E_NOTIMPL);
439 EXPECT(qhits(30) == before + 1 && xs::queue_slot_first_call_seen(30));
412 for (unsigned slot = fence_slots; slot < xs::fence_proxy_table_size(); ++slot) { 440 for (unsigned slot = fence_slots; slot < xs::fence_proxy_table_size(); ++slot) {
441 if (slot == 12) continue;
413 before = fhits(slot); 442 before = fhits(slot);
414 EXPECT(as_hr(call_slot(fence.p, slot)) == E_NOTIMPL); 443 EXPECT(as_hr(call_slot(fence.p, slot)) == E_NOTIMPL);
415 EXPECT(fhits(slot) == before + 1 && xs::fence_slot_first_call_seen(slot)); 444 EXPECT(fhits(slot) == before + 1 && xs::fence_slot_first_call_seen(slot));
416 } 445 }
417 // The objects still work after refused calls. 446 // The objects still work after the console-only calls.
418 EXPECT(SUCCEEDED(queue->Signal(fence.p, 10))); 447 EXPECT(SUCCEEDED(queue->Signal(fence.p, 10)));
419 if (wait_for(label, fence.p, 10)) return 1; 448 if (wait_for(label, fence.p, 10)) return 1;
420 EXPECT(xs::command_object_proxy_ref_count(queue.p) == 1 && xs::command_object_proxy_ref_count(fence.p) == 1); 449 EXPECT(xs::command_object_proxy_ref_count(queue.p) == 1 && xs::command_object_proxy_ref_count(fence.p) == 1);
421 } 450 }
422 EXPECT(xs::device_proxy_ref_count(device) == device_refs); // every queue and fence gave its reference back 451 EXPECT(xs::device_proxy_ref_count(device) == device_refs); // every queue and fence gave its reference back
423 std::printf("%s: every public queue and fence slot forwarded and counted; tail refused\n", label); 452 std::printf("%s: every public queue and fence slot forwarded and counted; fence slot 12 follows a queue "
453 "signal; queue tail S_OK, fence tail refused\n", label);
424 return 0; 454 return 0;
425} 455}
426 456