upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/test/device_proxy_test.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 19:38:04 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 19:38:04 -0500
commit39879ce0fdcaea23ce3919c1e845dd360b17b0f8 (patch)
tree894ddf50be120cdfbd80b28e895876c518cc2199 /runtime/test/device_proxy_test.cpp
parent273b3bdf9d6e736442ad584ad464df6e86ee928b (diff)
parent1154976d49acca28ad436b90861e9f9aea28eba9 (diff)
Merge main into RT-PROTON-STORY-LOAD (#984)
Merges main at 1154976d4 into the integration branch at 273b3bdf9 (merge base ece4ba5b3). 42 files conflicted; this commit is the resolution only. Build and test repairs follow in their own commits. Rule of resolution: where both sides added different things, both stay; where both made the same change in two forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two changed the same code for different purposes, both purposes are kept. Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h, d3d12_xs_desc_clean.h, registry.cpp): - d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and list slot 139 (#396). - Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider pc_resource_desc, S_OK for queue slots past the PC table. - Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base list proxy, its null-view slot 70 and its refusing slot 133. Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp): - Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra cases added; main's --env-slots-74 and #984's --env-slots-70. - Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy, the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases. D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h, frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp, d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp, vk_pipeline_check.cpp, vk_test_device.h): - Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's origin, so both pools run on disjoint sets of textures. - frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter. - main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4 stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980). - shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it. - Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it. Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp, runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp): - ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file. - gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries. - Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped. Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1, make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py, runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md, runtime/README.md): - Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake. - rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped. - shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags. - shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants. One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
-rw-r--r--runtime/test/device_proxy_test.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp
index 5ff4b4da3..ebcdab2b2 100644
--- a/runtime/test/device_proxy_test.cpp
+++ b/runtime/test/device_proxy_test.cpp
@@ -395,12 +395,25 @@ int main(int argc, char** argv) {
395 const LUID real_luid = real ? real->GetAdapterLuid() : LUID{}; 395 const LUID real_luid = real ? real->GetAdapterLuid() : LUID{};
396 check(proxy_luid.LowPart == real_luid.LowPart && proxy_luid.HighPart == real_luid.HighPart, 396 check(proxy_luid.LowPart == real_luid.LowPart && proxy_luid.HighPart == real_luid.HighPart,
397 "slot 43 forwards GetAdapterLuid (struct return)"); 397 "slot 43 forwards GetAdapterLuid (struct return)");
398 // Slot 25 returns a struct wider than 8 bytes. The console title calls it with the C ABI: the hidden 398 // Slots 25 and 26 return a struct wider than 8 bytes. The console title calls them with the C ABI: the hidden
399 // return pointer first (RCX), then the device (RDX), then the arguments, and the buffer comes back in RAX 399 // return pointer first (RCX), then the device (RDX), then the arguments, and the buffer comes back in RAX
400 // (measured for slot 26 on the retail executable). Call slot 25 that way through a raw function pointer and compare 400 // (measured for slot 26 on the retail executable). Call them that way through raw function pointers and compare
401 // with the PC device's own answer. 401 // with the PC device's own answers.
402 check(rt::d3d12_xs::device_slot_overridden(25), "device slot 25 is the C-ABI GetResourceAllocationInfo override"); 402 check(rt::d3d12_xs::device_slot_overridden(25), "device slot 25 is the C-ABI GetResourceAllocationInfo override");
403 check(rt::d3d12_xs::device_slot_overridden(26), "device slot 26 is the C-ABI GetCustomHeapProperties override");
403 if (real) { 404 if (real) {
405 using HeapPropsFn = D3D12_HEAP_PROPERTIES*(WINAPI*)(D3D12_HEAP_PROPERTIES*, void*, UINT, D3D12_HEAP_TYPE);
406 auto get_heap_props = reinterpret_cast<HeapPropsFn>(proxy_vtbl[26]);
407 for (D3D12_HEAP_TYPE type : {D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_TYPE_UPLOAD, D3D12_HEAP_TYPE_READBACK}) {
408 D3D12_HEAP_PROPERTIES got;
409 std::memset(&got, 0xcd, sizeof(got));
410 D3D12_HEAP_PROPERTIES* returned = get_heap_props(&got, device.Get(), 1, type);
411 const D3D12_HEAP_PROPERTIES want = real->GetCustomHeapProperties(1, type);
412 check(returned == &got, "slot 26 returns the caller's buffer in RAX");
413 check(std::memcmp(&got, &want, sizeof(got)) == 0,
414 "slot 26 (C ABI) writes the PC device's GetCustomHeapProperties into the caller's buffer");
415 }
416
404 using AllocInfoFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)(D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT, 417 using AllocInfoFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)(D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT,
405 const D3D12_RESOURCE_DESC*); 418 const D3D12_RESOURCE_DESC*);
406 auto get_alloc_info = reinterpret_cast<AllocInfoFn>(proxy_vtbl[25]); 419 auto get_alloc_info = reinterpret_cast<AllocInfoFn>(proxy_vtbl[25]);
@@ -416,8 +429,11 @@ int main(int argc, char** argv) {
416 check(got.SizeInBytes == want.SizeInBytes && got.Alignment == want.Alignment, 429 check(got.SizeInBytes == want.SizeInBytes && got.Alignment == want.Alignment,
417 "slot 25 (C ABI) writes the PC device's GetResourceAllocationInfo into the caller's buffer"); 430 "slot 25 (C ABI) writes the PC device's GetResourceAllocationInfo into the caller's buffer");
418 431
419 // The runtime's own code calls the proxy through d3d12.h (PC form: this, then the return buffer). Slot 25 432 // The runtime's own code calls the proxy through d3d12.h (PC form: this, then the return buffer). Both
420 // still answers that form. 433 // slots still answer that form.
434 const D3D12_HEAP_PROPERTIES pc_props = device->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD);
435 const D3D12_HEAP_PROPERTIES pc_want = real->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD);
436 check(std::memcmp(&pc_props, &pc_want, sizeof(pc_props)) == 0, "slot 26 still answers the PC (C++) form");
421 const D3D12_RESOURCE_ALLOCATION_INFO pc_info = device->GetResourceAllocationInfo(0, 1, &desc); 437 const D3D12_RESOURCE_ALLOCATION_INFO pc_info = device->GetResourceAllocationInfo(0, 1, &desc);
422 check(pc_info.SizeInBytes == want.SizeInBytes && pc_info.Alignment == want.Alignment, 438 check(pc_info.SizeInBytes == want.SizeInBytes && pc_info.Alignment == want.Alignment,
423 "slot 25 still answers the PC (C++) form"); 439 "slot 25 still answers the PC (C++) form");
@@ -502,6 +518,7 @@ int main(int argc, char** argv) {
502 D3D12_HEAP_PROPERTIES*(WINAPI*)(D3D12_HEAP_PROPERTIES*, void*, UINT, D3D12_HEAP_TYPE); 518 D3D12_HEAP_PROPERTIES*(WINAPI*)(D3D12_HEAP_PROPERTIES*, void*, UINT, D3D12_HEAP_TYPE);
503 auto get_custom_heap = reinterpret_cast<XboxGetCustomHeapPropertiesFn>(proxy_vtbl[26]); 519 auto get_custom_heap = reinterpret_cast<XboxGetCustomHeapPropertiesFn>(proxy_vtbl[26]);
504 const D3D12_HEAP_TYPE heap_types[] = {D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_TYPE_UPLOAD, D3D12_HEAP_TYPE_READBACK}; 520 const D3D12_HEAP_TYPE heap_types[] = {D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_TYPE_UPLOAD, D3D12_HEAP_TYPE_READBACK};
521 const auto slot26_hits_before = rt::d3d12_xs::device_slot_hits(26);
505 bool console_returns_buffer = true, console_matches_pc = real != nullptr, console_writes_only_struct = true; 522 bool console_returns_buffer = true, console_matches_pc = real != nullptr, console_writes_only_struct = true;
506 for (const D3D12_HEAP_TYPE type : heap_types) { 523 for (const D3D12_HEAP_TYPE type : heap_types) {
507 struct Padded { 524 struct Padded {
@@ -519,15 +536,18 @@ int main(int argc, char** argv) {
519 check(console_returns_buffer, "slot 26 console form returns the buffer's address"); 536 check(console_returns_buffer, "slot 26 console form returns the buffer's address");
520 check(console_matches_pc, "slot 26 console form writes the PC device's DEFAULT, UPLOAD and READBACK properties"); 537 check(console_matches_pc, "slot 26 console form writes the PC device's DEFAULT, UPLOAD and READBACK properties");
521 check(console_writes_only_struct, "slot 26 console form writes nothing past the struct"); 538 check(console_writes_only_struct, "slot 26 console form writes nothing past the struct");
522 check(rt::d3d12_xs::device_slot_hits(26) == 3, "slot 26 hit counter is 3"); 539 check(rt::d3d12_xs::device_slot_hits(26) == slot26_hits_before + 3,
540 "slot 26 hit counter increases by three for the console calls");
523 check(rt::d3d12_xs::is_device_proxy(device.Get()) && rt::d3d12_xs::device_proxy_real_device(device.Get()) == real, 541 check(rt::d3d12_xs::is_device_proxy(device.Get()) && rt::d3d12_xs::device_proxy_real_device(device.Get()) == real,
524 "the proxy is intact after the console-form calls"); 542 "the proxy is intact after the console-form calls");
525 // A PC C++ call through the proxy (the proxy in RCX, the buffer in RDX) is still forwarded. 543 // A PC C++ call through the proxy (the proxy in RCX, the buffer in RDX) is still forwarded.
526 const D3D12_HEAP_PROPERTIES pc_form = device->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD); 544 const D3D12_HEAP_PROPERTIES pc_form = device->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD);
527 const D3D12_HEAP_PROPERTIES pc_want = real ? real->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD) 545 const D3D12_HEAP_PROPERTIES pc_want = real ? real->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD)
528 : D3D12_HEAP_PROPERTIES{}; 546 : D3D12_HEAP_PROPERTIES{};
529 check(real && std::memcmp(&pc_form, &pc_want, sizeof(pc_want)) == 0 && rt::d3d12_xs::device_slot_hits(26) == 4, 547 check(real && std::memcmp(&pc_form, &pc_want, sizeof(pc_want)) == 0,
530 "slot 26 PC form still forwards GetCustomHeapProperties"); 548 "slot 26 PC form still forwards GetCustomHeapProperties");
549 check(rt::d3d12_xs::device_slot_hits(26) == slot26_hits_before + 4,
550 "slot 26 hit counter also includes the PC call");
531 551
532 // Slot 14: descriptor heap through the proxy. The proxy wraps the real PC heap for the handle ABI. 552 // Slot 14: descriptor heap through the proxy. The proxy wraps the real PC heap for the handle ABI.
533 D3D12_DESCRIPTOR_HEAP_DESC heap_desc{}; 553 D3D12_DESCRIPTOR_HEAP_DESC heap_desc{};