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 20:26:00 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 20:26:00 -0500
commit154e4ec034902deffa4b89b2cbca9a949f38baec (patch)
tree1b2ef5656de42c172291bc6009efa4c510650815 /runtime/test/queue_proxy_test.cpp
parenteb6a08cd359d98b5777e70d54d0ae8a75879495a (diff)
parent8a242efebf823aeb23c72d17c3d666daf0bbd3e2 (diff)
Merge the #984 result (main + RT-PROTON-STORY-LOAD) into #939
The base is 8a242efeb, the merge of main and #984. 68 files conflicted; they were resolved in seven groups by one rule: the same change in two forms keeps the base's form, everything only #939 has is kept, and where the two solve one problem in two ways the base's is the frame and #939's plugs into it. A, the Xbox proxy (d3d12_xs_device.cpp/.h, d3d12_xs.cpp, d3d12_xs_pso_stream.cpp/.h, d3d12_xs_alloc_size.h, d3d12_xs_desc_clean.h, device_proxy_test.cpp, queue_proxy_test.cpp): the base's files with #939's additions ported in. Device slot 57 asks #939's NativeGraphicsFactory first and falls back to the base's proxy_create_graphics_pipeline_from_native_code on E_NOTIMPL. Kept from #939: the providers (texture lease, raw texture view, resource by address, constant view, descriptor mapping, depth-stencil UAV, texture pages), the title-backed descriptor mirror, slot 13's feature answers, GPU labels on list slots 71/72. Dropped: #939's duplicates of the boot ladder routes, its fallback window, its slot 133 stand-in. A2 (xs_proxy_mock_test.cpp): the base's test with #939's slot 70 raw-buffer case; presentation cases follow #939's rule that a device which ever had a handler has no queue fallback. B1, the Vulkan device (d3d12_vulkan_device.cpp, d3d12_com.cpp/.h, shader_library.h, queue_families.h, pipeline_cache_file.h, startup_trace.h): one lazy-pipeline mechanism, the base's; #939's pending_base_compile and first_use_backend_pipelines dropped, prepare_on_bind and cold_graphics_compile kept. create_texture keeps the base's signature; #939's deferred backing is folded into the base's placed-memory binder. #939's quad lists as triangle indices. B2, the D3D12 tests (d3d12_existing_heap, a8_dimensions, pipeline_cache_seed, title_va, rect_list, shader_library, loader_tls_index0, draw, compute, xmem_placed, shader_library_corpus): the base's tests where both carry the same case, #939's cases added (rebound tables, linear texture map, large vertex batch, executable shaders, default A8 views). C, the backend (vulkan_replay.h, vulkan_backend.h, vulkan_bindless.h, vulkan_scratch.h, vulkan_present.h, rect_list_geometry.h, vk_test_device.h, vk_pipeline_check.cpp, vk_store_test.cpp, bindless_sizing_test.cpp, replay_texture_barrier_test.cpp): the base's prepare_draw and lazy compute, its #1055 release rule and its rectangle generator; #939's rectangle variants, GPU quad index expansion, 1D/3D and depth-stencil UAVs, the label fence on the base's submit. D, memory, services, presentation (xmem.cpp/.h, xg_xs.cpp, xg_xs_test.cpp, title_va_alias.h and its test, main.cpp, frame_pacer.h, xbox_present.cpp/.h; xgameruntime_offline.cpp for one comment): the base's xmem with #939's label hooks, file-backed sections and pin_mapped_data; both texture computers in xg_xs.cpp, the base's answering first; --first-run-ui kept without host speech in its profile. E, build, tools, docs (runtime/CMakeLists.txt, make_game.py, tools/rdna2spirv.py, tools/shader_disasm.py, scripts, tests, docs; docs/README.md and tests/test_exe_shaders_stage.py beyond the conflicts): the base's v_dot4 decode, #281's disassembler form and tests/semantic/test_fspx_dot4_op_sel_disasm.py dropped; the base's executable-shader step with #939's cache fix; 366 registered tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/queue_proxy_test.cpp')
-rw-r--r--runtime/test/queue_proxy_test.cpp86
1 files changed, 65 insertions, 21 deletions
diff --git a/runtime/test/queue_proxy_test.cpp b/runtime/test/queue_proxy_test.cpp
index ece44f117..d1e09d39f 100644
--- a/runtime/test/queue_proxy_test.cpp
+++ b/runtime/test/queue_proxy_test.cpp
@@ -258,7 +258,9 @@ int check_slots(const Backend& b) {
258 } 258 }
259 } 259 }
260 260
261 // 10: ExecuteCommandLists passes the (real, not wrapped) command lists through. 261 // 10 and console slot 35: ExecuteCommandLists passes the (real, not wrapped) command lists through.
262 EXPECT(xs::queue_slot_overridden(35) && xs::queue_slot_overridden(14) && xs::queue_slot_overridden(15));
263 EXPECT(!xs::queue_slot_overridden(10) && !xs::queue_slot_overridden(34));
262 { 264 {
263 Ref<ID3D12CommandAllocator> allocator; 265 Ref<ID3D12CommandAllocator> allocator;
264 EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, 266 EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT,
@@ -273,6 +275,11 @@ int check_slots(const Backend& b) {
273 EXPECT(qhits(10) == before + 1); 275 EXPECT(qhits(10) == before + 1);
274 EXPECT(SUCCEEDED(queue->Signal(fence.p, 6))); 276 EXPECT(SUCCEEDED(queue->Signal(fence.p, 6)));
275 if (wait_for(label, fence.p, 6)) return 1; 277 if (wait_for(label, fence.p, 6)) return 1;
278 const std::uint64_t before35 = qhits(35);
279 EXPECT(raw_call(queue.p, 35, 1, reinterpret_cast<std::uint64_t>(lists)) == 0);
280 EXPECT(qhits(35) == before35 + 1 && xs::queue_slot_first_call_seen(35));
281 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7)));
282 if (wait_for(label, fence.p, 7)) return 1;
276 if (b.vulkan) { 283 if (b.vulkan) {
277 // The layer's own helpers find their queue behind the proxy. 284 // The layer's own helpers find their queue behind the proxy.
278 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success); 285 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
@@ -294,17 +301,17 @@ int check_slots(const Backend& b) {
294 301
295 // 14/15: Signal and Wait take fence proxies; the real queue gets the real fences. 302 // 14/15: Signal and Wait take fence proxies; the real queue gets the real fences.
296 before = qhits(14); 303 before = qhits(14);
297 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7))); 304 EXPECT(SUCCEEDED(queue->Signal(fence.p, 8)));
298 EXPECT(qhits(14) == before + 1); 305 EXPECT(qhits(14) == before + 1);
299 if (wait_for(label, fence.p, 7)) return 1; 306 if (wait_for(label, fence.p, 8)) return 1;
300 before = qhits(15); 307 before = qhits(15);
301 EXPECT(SUCCEEDED(queue->Wait(fence.p, 8))); // the queue waits until the CPU signals 8 308 EXPECT(SUCCEEDED(queue->Wait(fence.p, 9))); // the queue waits until the CPU signals 9
302 EXPECT(qhits(15) == before + 1); 309 EXPECT(qhits(15) == before + 1);
303 EXPECT(SUCCEEDED(queue->Signal(second.p, 1))); 310 EXPECT(SUCCEEDED(queue->Signal(second.p, 1)));
304 Sleep(50); 311 Sleep(50);
305 EXPECT(second->GetCompletedValue() == 0); // still held by the Wait 312 EXPECT(second->GetCompletedValue() == 0); // still held by the Wait
306 before = fhits(10); 313 before = fhits(10);
307 EXPECT(SUCCEEDED(fence->Signal(8))); // fence 10, from the CPU 314 EXPECT(SUCCEEDED(fence->Signal(9))); // fence 10, from the CPU
308 EXPECT(fhits(10) == before + 1); 315 EXPECT(fhits(10) == before + 1);
309 if (wait_for(label, second.p, 1)) return 1; 316 if (wait_for(label, second.p, 1)) return 1;
310 317
@@ -360,12 +367,12 @@ int check_slots(const Backend& b) {
360 EXPECT(fhits(7) == before + 1); 367 EXPECT(fhits(7) == before + 1);
361 } 368 }
362 before = fhits(8); 369 before = fhits(8);
363 EXPECT(fence->GetCompletedValue() == 8); 370 EXPECT(fence->GetCompletedValue() == 9);
364 EXPECT(fhits(8) == before + 1); 371 EXPECT(fhits(8) == before + 1);
365 { 372 {
366 Event done; 373 Event done;
367 before = fhits(9); 374 before = fhits(9);
368 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(8, done.h)) && done.set_within(5000)); 375 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(9, done.h)) && done.set_within(5000));
369 EXPECT(fhits(9) == before + 1); 376 EXPECT(fhits(9) == before + 1);
370 } 377 }
371 if (fence_slots == 12) { 378 if (fence_slots == 12) {
@@ -390,10 +397,6 @@ int check_slots(const Backend& b) {
390 } 397 }
391 } 398 }
392 399
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 400 // 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). 401 // signal without another call (a wait on the real fence refreshes it).
399 { 402 {
@@ -410,9 +413,14 @@ int check_slots(const Backend& b) {
410 EXPECT(raw_call(fence.p, 12, 9, 0, 0) == reinterpret_cast<std::uint64_t>(completed)); 413 EXPECT(raw_call(fence.p, 12, 9, 0, 0) == reinterpret_cast<std::uint64_t>(completed));
411 } 414 }
412 415
413 // The refused tail: every slot from the end of the public chain to the end of the table, but fence slot 12. 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.
414 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) { 422 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) {
415 if (slot == 23 || slot == 30) continue; 423 if (slot == 23 || slot == 30 || xs::queue_slot_overridden(slot)) continue;
416 before = qhits(slot); 424 before = qhits(slot);
417 EXPECT(as_hr(call_slot(queue.p, slot)) == S_OK); 425 EXPECT(as_hr(call_slot(queue.p, slot)) == S_OK);
418 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));
@@ -441,10 +449,8 @@ int check_slots(const Backend& b) {
441 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);
442 } 450 }
443 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
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 " 452 std::printf("%s: every public queue and fence slot forwarded and counted; fence slot 12 follows a queue "
447 "signal; tail refused\n", label); 453 "signal; queue tail S_OK, fence tail refused\n", label);
448 return 0; 454 return 0;
449} 455}
450 456
@@ -1498,18 +1504,56 @@ int check_xbox_client(const Backend& b) {
1498 EXPECT(same); // the GPU really ran the list the queue proxy submitted 1504 EXPECT(same); // the GPU really ran the list the queue proxy submitted
1499 } 1505 }
1500 1506
1501 // Device slot 50: EnqueueMakeResident with the objects and a fence proxy to signal. 1507 // Second copy with fresh bytes, submitted through console ExecuteCommandLists slot 35.
1502 EXPECT(SUCCEEDED(as_hr(raw(device, 50, D3D12_RESIDENCY_FLAG_NONE, 4, word(pageables), word(fence.p), 2)))); 1508 {
1509 std::uint8_t* bytes = nullptr;
1510 EXPECT(SUCCEEDED(upload->Map(0, nullptr, reinterpret_cast<void**>(&bytes))));
1511 for (UINT64 i = 0; i < kBytes; ++i) bytes[i] = static_cast<std::uint8_t>(i * 11 + 5);
1512 upload->Unmap(0, nullptr);
1513 }
1514 EXPECT(SUCCEEDED(allocator->Reset()));
1515 EXPECT(SUCCEEDED(list->Reset(allocator.p, nullptr)));
1516 D3D12_RESOURCE_BARRIER to_dest{};
1517 to_dest.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
1518 to_dest.Transition.pResource = gpu.p;
1519 to_dest.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
1520 to_dest.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE;
1521 to_dest.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST;
1522 list->ResourceBarrier(1, &to_dest);
1523 list->CopyBufferRegion(gpu.p, 0, upload.p, 0, kBytes);
1524 D3D12_RESOURCE_BARRIER to_source = to_dest;
1525 to_source.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST;
1526 to_source.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
1527 list->ResourceBarrier(1, &to_source);
1528 list->CopyBufferRegion(readback.p, 0, gpu.p, 0, kBytes);
1529 EXPECT(SUCCEEDED(list->Close()));
1530 EXPECT(raw(queue.p, 35, 1, word(lists)) == 0);
1531 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(fence.p), 2))));
1503 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 2, word(done.h)))) && done.set_within(5000)); 1532 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 2, word(done.h)))) && done.set_within(5000));
1533 EXPECT(raw(fence.p, 8) >= 2);
1534 {
1535 std::uint8_t* bytes = nullptr;
1536 const D3D12_RANGE read_range{0, kBytes};
1537 EXPECT(SUCCEEDED(readback->Map(0, &read_range, reinterpret_cast<void**>(&bytes))));
1538 bool same = true;
1539 for (UINT64 i = 0; i < kBytes; ++i) same = same && bytes[i] == static_cast<std::uint8_t>(i * 11 + 5);
1540 const D3D12_RANGE nothing{0, 0};
1541 readback->Unmap(0, &nothing);
1542 EXPECT(same); // the GPU really ran the list submitted via queue slot 35
1543 }
1544
1545 // Device slot 50: EnqueueMakeResident with the objects and a fence proxy to signal.
1546 EXPECT(SUCCEEDED(as_hr(raw(device, 50, D3D12_RESIDENCY_FLAG_NONE, 4, word(pageables), word(fence.p), 3))));
1547 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 3, word(done.h)))) && done.set_within(5000));
1504 1548
1505 // Queue slot 15 holds the queue until the CPU (fence slot 10) signals; device slot 45 then sees both fences. 1549 // Queue slot 15 holds the queue until the CPU (fence slot 10) signals; device slot 45 then sees both fences.
1506 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 15, word(fence.p), 3)))); 1550 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 15, word(fence.p), 4))));
1507 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(second.p), 1)))); 1551 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(second.p), 1))));
1508 Sleep(50); 1552 Sleep(50);
1509 EXPECT(raw(second.p, 8) == 0); 1553 EXPECT(raw(second.p, 8) == 0);
1510 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 10, 3)))); 1554 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 10, 4))));
1511 ID3D12Fence* both[] = {fence.p, second.p}; 1555 ID3D12Fence* both[] = {fence.p, second.p};
1512 const UINT64 values[] = {3, 1}; 1556 const UINT64 values[] = {4, 1};
1513 EXPECT(SUCCEEDED(as_hr(raw(device, 45, word(both), word(values), 2, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL, 1557 EXPECT(SUCCEEDED(as_hr(raw(device, 45, word(both), word(values), 2, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL,
1514 word(done.h)))) && 1558 word(done.h)))) &&
1515 done.set_within(5000)); 1559 done.set_within(5000));