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:
authorRain156 <77776581+Rain156@users.noreply.github.com>2026-11-24 21:26:25 +0800
committerRain156 <77776581+Rain156@users.noreply.github.com>2026-11-24 21:26:25 +0800
commitaa8be9aef20291e6faf6ed986d2b6691aad96abf (patch)
tree80e0224b761256cd2375d069089f1eb6413dcd7a /runtime/test/queue_proxy_test.cpp
parentbe767b6889cb373cc695b67367644ea4370f8e9c (diff)
parentdb19bbd3455a757c3fe986c6e6db36998f275150 (diff)
Integrate the offline first-run UI runtime with current main and the published renderer fixes
Use the tagged pipeline variants and indexed quad expansion from #722 and #682 with the shared shader cache. Retain title-backed index uploads, cross-queue scratch sharing, amd64 console return conventions and the PC/console caller discriminator. The local shader build indexes native containers and includes the executable's embedded stages.
Diffstat (limited to 'runtime/test/queue_proxy_test.cpp')
-rw-r--r--runtime/test/queue_proxy_test.cpp126
1 files changed, 56 insertions, 70 deletions
diff --git a/runtime/test/queue_proxy_test.cpp b/runtime/test/queue_proxy_test.cpp
index 674a8cf2e..ece44f117 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
@@ -257,9 +258,7 @@ int check_slots(const Backend& b) {
257 } 258 }
258 } 259 }
259 260
260 // 10 and console slot 35: ExecuteCommandLists passes the (real, not wrapped) command lists through. 261 // 10: ExecuteCommandLists passes the (real, not wrapped) command lists through.
261 EXPECT(xs::queue_slot_overridden(35) && xs::queue_slot_overridden(14) && xs::queue_slot_overridden(15));
262 EXPECT(!xs::queue_slot_overridden(10) && !xs::queue_slot_overridden(34));
263 { 262 {
264 Ref<ID3D12CommandAllocator> allocator; 263 Ref<ID3D12CommandAllocator> allocator;
265 EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, 264 EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT,
@@ -274,17 +273,6 @@ int check_slots(const Backend& b) {
274 EXPECT(qhits(10) == before + 1); 273 EXPECT(qhits(10) == before + 1);
275 EXPECT(SUCCEEDED(queue->Signal(fence.p, 6))); 274 EXPECT(SUCCEEDED(queue->Signal(fence.p, 6)));
276 if (wait_for(label, fence.p, 6)) return 1; 275 if (wait_for(label, fence.p, 6)) return 1;
277 const std::uint64_t before35 = qhits(35);
278 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 // 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)));
287 if (wait_for(label, fence.p, 7)) return 1;
288 if (b.vulkan) { 276 if (b.vulkan) {
289 // The layer's own helpers find their queue behind the proxy. 277 // The layer's own helpers find their queue behind the proxy.
290 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success); 278 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
@@ -306,17 +294,17 @@ int check_slots(const Backend& b) {
306 294
307 // 14/15: Signal and Wait take fence proxies; the real queue gets the real fences. 295 // 14/15: Signal and Wait take fence proxies; the real queue gets the real fences.
308 before = qhits(14); 296 before = qhits(14);
309 EXPECT(SUCCEEDED(queue->Signal(fence.p, 8))); 297 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7)));
310 EXPECT(qhits(14) == before + 1); 298 EXPECT(qhits(14) == before + 1);
311 if (wait_for(label, fence.p, 8)) return 1; 299 if (wait_for(label, fence.p, 7)) return 1;
312 before = qhits(15); 300 before = qhits(15);
313 EXPECT(SUCCEEDED(queue->Wait(fence.p, 9))); // the queue waits until the CPU signals 9 301 EXPECT(SUCCEEDED(queue->Wait(fence.p, 8))); // the queue waits until the CPU signals 8
314 EXPECT(qhits(15) == before + 1); 302 EXPECT(qhits(15) == before + 1);
315 EXPECT(SUCCEEDED(queue->Signal(second.p, 1))); 303 EXPECT(SUCCEEDED(queue->Signal(second.p, 1)));
316 Sleep(50); 304 Sleep(50);
317 EXPECT(second->GetCompletedValue() == 0); // still held by the Wait 305 EXPECT(second->GetCompletedValue() == 0); // still held by the Wait
318 before = fhits(10); 306 before = fhits(10);
319 EXPECT(SUCCEEDED(fence->Signal(9))); // fence 10, from the CPU 307 EXPECT(SUCCEEDED(fence->Signal(8))); // fence 10, from the CPU
320 EXPECT(fhits(10) == before + 1); 308 EXPECT(fhits(10) == before + 1);
321 if (wait_for(label, second.p, 1)) return 1; 309 if (wait_for(label, second.p, 1)) return 1;
322 310
@@ -372,12 +360,12 @@ int check_slots(const Backend& b) {
372 EXPECT(fhits(7) == before + 1); 360 EXPECT(fhits(7) == before + 1);
373 } 361 }
374 before = fhits(8); 362 before = fhits(8);
375 EXPECT(fence->GetCompletedValue() == 9); 363 EXPECT(fence->GetCompletedValue() == 8);
376 EXPECT(fhits(8) == before + 1); 364 EXPECT(fhits(8) == before + 1);
377 { 365 {
378 Event done; 366 Event done;
379 before = fhits(9); 367 before = fhits(9);
380 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(9, done.h)) && done.set_within(5000)); 368 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(8, done.h)) && done.set_within(5000));
381 EXPECT(fhits(9) == before + 1); 369 EXPECT(fhits(9) == before + 1);
382 } 370 }
383 if (fence_slots == 12) { 371 if (fence_slots == 12) {
@@ -402,25 +390,61 @@ int check_slots(const Backend& b) {
402 } 390 }
403 } 391 }
404 392
405 // The refused tail: every unmodelled slot from the end of the public chain to the end of the table. 393 // The console queue tail answers S_OK instead of refusing: frame pacing flows through those
394 // methods, the contract xs_proxy_mock checks too. The two methods the proxy models — SignalX at
395 // 23 and PresentX at 30 on the older layout the 16/17 calls above pinned — are checked below.
396 // The fence tail below is still refused — nothing console-shaped was measured past its public chain.
397 // Fence slot 12 (value, descriptor, flags): the address of the completed value, which follows a queue's
398 // signal without another call (a wait on the real fence refreshes it).
399 {
400 before = fhits(12);
401 const auto* completed = reinterpret_cast<const volatile UINT64*>(raw_call(fence.p, 12, 9, 0, 0));
402 EXPECT(completed && *completed == fence->GetCompletedValue() && fhits(12) == before + 1);
403 EXPECT(SUCCEEDED(queue->Signal(fence.p, 9)));
404 bool seen = false;
405 for (int i = 0; i < 5000 && !seen; ++i) {
406 seen = *completed == 9;
407 if (!seen) Sleep(1);
408 }
409 EXPECT(seen);
410 EXPECT(raw_call(fence.p, 12, 9, 0, 0) == reinterpret_cast<std::uint64_t>(completed));
411 }
412
413 // The refused tail: every slot from the end of the public chain to the end of the table, but fence slot 12.
406 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) { 414 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) {
407 if (xs::queue_slot_overridden(slot)) continue; 415 if (slot == 23 || slot == 30) continue;
408 before = qhits(slot); 416 before = qhits(slot);
409 EXPECT(as_hr(call_slot(queue.p, slot)) == E_NOTIMPL); 417 EXPECT(as_hr(call_slot(queue.p, slot)) == S_OK);
410 EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot)); 418 EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot));
411 } 419 }
420 // SignalX forwards to the real queue's Signal with the extra word dropped: the fence reaching 9
421 // proves the call was forwarded rather than swallowed by the console-tail answer.
422 before = qhits(23);
423 EXPECT(as_hr(raw_call(queue.p, 23, reinterpret_cast<std::uint64_t>(fence.p), 9)) == S_OK);
424 EXPECT(qhits(23) == before + 1 && xs::queue_slot_first_call_seen(23));
425 if (wait_for(label, fence.p, 9)) return 1;
426 // PresentX is handled by the presentation front end, not refused: its status is the swapchain's
427 // (a black frame on the test window, or S_OK where it cannot present), so anything but E_NOTIMPL
428 // shows the modelled path ran.
429 before = qhits(30);
430 EXPECT(as_hr(call_slot(queue.p, 30)) != E_NOTIMPL);
431 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) { 432 for (unsigned slot = fence_slots; slot < xs::fence_proxy_table_size(); ++slot) {
433 if (slot == 12) continue;
413 before = fhits(slot); 434 before = fhits(slot);
414 EXPECT(as_hr(call_slot(fence.p, slot)) == E_NOTIMPL); 435 EXPECT(as_hr(call_slot(fence.p, slot)) == E_NOTIMPL);
415 EXPECT(fhits(slot) == before + 1 && xs::fence_slot_first_call_seen(slot)); 436 EXPECT(fhits(slot) == before + 1 && xs::fence_slot_first_call_seen(slot));
416 } 437 }
417 // The objects still work after refused calls. 438 // The objects still work after the console-only calls.
418 EXPECT(SUCCEEDED(queue->Signal(fence.p, 10))); 439 EXPECT(SUCCEEDED(queue->Signal(fence.p, 10)));
419 if (wait_for(label, fence.p, 10)) return 1; 440 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); 441 EXPECT(xs::command_object_proxy_ref_count(queue.p) == 1 && xs::command_object_proxy_ref_count(fence.p) == 1);
421 } 442 }
422 EXPECT(xs::device_proxy_ref_count(device) == device_refs); // every queue and fence gave its reference back 443 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); 444 std::printf("%s: every public queue and fence slot forwarded and counted; queue tail S_OK, fence tail "
445 "refused\n", label);
446 std::printf("%s: every public queue and fence slot forwarded and counted; fence slot 12 follows a queue "
447 "signal; tail refused\n", label);
424 return 0; 448 return 0;
425} 449}
426 450
@@ -1474,56 +1498,18 @@ int check_xbox_client(const Backend& b) {
1474 EXPECT(same); // the GPU really ran the list the queue proxy submitted 1498 EXPECT(same); // the GPU really ran the list the queue proxy submitted
1475 } 1499 }
1476 1500
1477 // Second copy with fresh bytes, submitted through console ExecuteCommandLists slot 35.
1478 {
1479 std::uint8_t* bytes = nullptr;
1480 EXPECT(SUCCEEDED(upload->Map(0, nullptr, reinterpret_cast<void**>(&bytes))));
1481 for (UINT64 i = 0; i < kBytes; ++i) bytes[i] = static_cast<std::uint8_t>(i * 11 + 5);
1482 upload->Unmap(0, nullptr);
1483 }
1484 EXPECT(SUCCEEDED(allocator->Reset()));
1485 EXPECT(SUCCEEDED(list->Reset(allocator.p, nullptr)));
1486 D3D12_RESOURCE_BARRIER to_dest{};
1487 to_dest.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
1488 to_dest.Transition.pResource = gpu.p;
1489 to_dest.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
1490 to_dest.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE;
1491 to_dest.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST;
1492 list->ResourceBarrier(1, &to_dest);
1493 list->CopyBufferRegion(gpu.p, 0, upload.p, 0, kBytes);
1494 D3D12_RESOURCE_BARRIER to_source = to_dest;
1495 to_source.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST;
1496 to_source.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
1497 list->ResourceBarrier(1, &to_source);
1498 list->CopyBufferRegion(readback.p, 0, gpu.p, 0, kBytes);
1499 EXPECT(SUCCEEDED(list->Close()));
1500 EXPECT(raw(queue.p, 35, 1, word(lists)) == 0);
1501 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(fence.p), 2))));
1502 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 2, word(done.h)))) && done.set_within(5000));
1503 EXPECT(raw(fence.p, 8) >= 2);
1504 {
1505 std::uint8_t* bytes = nullptr;
1506 const D3D12_RANGE read_range{0, kBytes};
1507 EXPECT(SUCCEEDED(readback->Map(0, &read_range, reinterpret_cast<void**>(&bytes))));
1508 bool same = true;
1509 for (UINT64 i = 0; i < kBytes; ++i) same = same && bytes[i] == static_cast<std::uint8_t>(i * 11 + 5);
1510 const D3D12_RANGE nothing{0, 0};
1511 readback->Unmap(0, &nothing);
1512 EXPECT(same); // the GPU really ran the list submitted via queue slot 35
1513 }
1514
1515 // Device slot 50: EnqueueMakeResident with the objects and a fence proxy to signal. 1501 // Device slot 50: EnqueueMakeResident with the objects and a fence proxy to signal.
1516 EXPECT(SUCCEEDED(as_hr(raw(device, 50, D3D12_RESIDENCY_FLAG_NONE, 4, word(pageables), word(fence.p), 3)))); 1502 EXPECT(SUCCEEDED(as_hr(raw(device, 50, D3D12_RESIDENCY_FLAG_NONE, 4, word(pageables), word(fence.p), 2))));
1517 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 3, word(done.h)))) && done.set_within(5000)); 1503 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 2, word(done.h)))) && done.set_within(5000));
1518 1504
1519 // Queue slot 15 holds the queue until the CPU (fence slot 10) signals; device slot 45 then sees both fences. 1505 // Queue slot 15 holds the queue until the CPU (fence slot 10) signals; device slot 45 then sees both fences.
1520 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 15, word(fence.p), 4)))); 1506 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 15, word(fence.p), 3))));
1521 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(second.p), 1)))); 1507 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(second.p), 1))));
1522 Sleep(50); 1508 Sleep(50);
1523 EXPECT(raw(second.p, 8) == 0); 1509 EXPECT(raw(second.p, 8) == 0);
1524 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 10, 4)))); 1510 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 10, 3))));
1525 ID3D12Fence* both[] = {fence.p, second.p}; 1511 ID3D12Fence* both[] = {fence.p, second.p};
1526 const UINT64 values[] = {4, 1}; 1512 const UINT64 values[] = {3, 1};
1527 EXPECT(SUCCEEDED(as_hr(raw(device, 45, word(both), word(values), 2, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL, 1513 EXPECT(SUCCEEDED(as_hr(raw(device, 45, word(both), word(values), 2, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL,
1528 word(done.h)))) && 1514 word(done.h)))) &&
1529 done.set_within(5000)); 1515 done.set_within(5000));