upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorVadson159 <vad.sofr@gmail.com>2026-11-23 17:24:09 +0100
committerVadson159 <vad.sofr@gmail.com>2026-11-23 17:24:09 +0100
commite925b634551ed96d1ed097dfe17d7dfca0cdbe4d (patch)
tree655ce84a1720a782c8261c32a05efd38d240ff98 /runtime
parent8575d36edc479218972497a7bded8651a42856c0 (diff)
d3d12_xs: route command queue slot 35 to ExecuteCommandLists
Diffstat (limited to 'runtime')
-rw-r--r--runtime/shims/d3d12_xs_device.cpp26
-rw-r--r--runtime/shims/d3d12_xs_device.h14
-rw-r--r--runtime/test/queue_proxy_test.cpp72
-rw-r--r--runtime/test/xs_proxy_mock_test.cpp37
4 files changed, 129 insertions, 20 deletions
diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp
index e17a80353..daa2af795 100644
--- a/runtime/shims/d3d12_xs_device.cpp
+++ b/runtime/shims/d3d12_xs_device.cpp
@@ -674,7 +674,11 @@ static_assert(kQueueSlots * sizeof(void*) <= 4096 && kFenceSlots * sizeof(void*)
674 kAllocatorSlots * sizeof(void*) <= 4096, 674 kAllocatorSlots * sizeof(void*) <= 4096,
675 "a table must fit in the first page of its reservation"); 675 "a table must fit in the first page of its reservation");
676 676
677constexpr unsigned kQueueExecuteCommandLists = 10; // (UINT, ID3D12CommandList* const*)
677constexpr unsigned kQueueSignal = 14, kQueueWait = 15; // (ID3D12Fence*, UINT64) 678constexpr unsigned kQueueSignal = 14, kQueueWait = 15; // (ID3D12Fence*, UINT64)
679constexpr unsigned kQueueExecuteCommandListsX = 35; // console ExecuteCommandLists(count, lists) variant
680static_assert(kQueueExecuteCommandLists < kQueuePublicSlots && kQueueExecuteCommandListsX < kQueueSlots,
681 "queue execution slots must stay within their respective tables");
678 682
679struct ChildProxy { 683struct ChildProxy {
680 void** vtable; // offset 0: the caller's ID3D12CommandQueue* / ID3D12Fence* points here 684 void** vtable; // offset 0: the caller's ID3D12CommandQueue* / ID3D12Fence* points here
@@ -715,6 +719,7 @@ const char* child_public_name(unsigned slot) {
715 if (slot < 8) return object[slot]; 719 if (slot < 8) return object[slot];
716 if constexpr (K == ChildKind::queue) { 720 if constexpr (K == ChildKind::queue) {
717 if (slot < kQueuePublicSlots) return queue[slot - 8]; 721 if (slot < kQueuePublicSlots) return queue[slot - 8];
722 if (slot == kQueueExecuteCommandListsX) return "ExecuteCommandListsX";
718 } else if constexpr (K == ChildKind::fence) { 723 } else if constexpr (K == ChildKind::fence) {
719 if (slot < kFence1PublicSlots) return fence[slot - 8]; 724 if (slot < kFence1PublicSlots) return fence[slot - 8];
720 } else { 725 } else {
@@ -970,6 +975,15 @@ LONG CALLBACK table_overrun_handler(EXCEPTION_POINTERS* info) {
970 return EXCEPTION_CONTINUE_SEARCH; // diagnostics only: the fault goes on to the title's handlers or the crash 975 return EXCEPTION_CONTINUE_SEARCH; // diagnostics only: the fault goes on to the title's handlers or the crash
971} 976}
972 977
978std::uint64_t queue_execute_command_lists(ChildProxy* self, std::uint64_t count_word, std::uint64_t lists_word) {
979 // Pass zero-extended UINT in 64-bit RDX so both 32-bit PC implementations and 64-bit mock thunks see clean count.
980 using ExecuteFn = void(WINAPI*)(void*, std::uint64_t, ID3D12CommandList* const*);
981 reinterpret_cast<ExecuteFn>(self->real_vtable[kQueueExecuteCommandLists])(
982 self->real, static_cast<std::uint64_t>(static_cast<UINT>(count_word)),
983 reinterpret_cast<ID3D12CommandList* const*>(lists_word));
984 return 0;
985}
986
973template <ChildKind K, unsigned Slot> 987template <ChildKind K, unsigned Slot>
974std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3, 988std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_t a2, std::uint64_t a3,
975 std::uint64_t a4, std::uint64_t a5, std::uint64_t a6, std::uint64_t a7, 989 std::uint64_t a4, std::uint64_t a5, std::uint64_t a6, std::uint64_t a7,
@@ -989,6 +1003,10 @@ std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_
989 reinterpret_cast<void**>(a2))); 1003 reinterpret_cast<void**>(a2)));
990 } else { 1004 } else {
991 note_child_slot<K>(Slot); 1005 note_child_slot<K>(Slot);
1006 if constexpr (K == ChildKind::queue && Slot == kQueueExecuteCommandListsX) {
1007 d3d12_trace::record(child_trace_name<K>(Slot));
1008 return queue_execute_command_lists(self, a1, a2);
1009 }
992 if (Slot >= self->slot_count) { 1010 if (Slot >= self->slot_count) {
993 bool expected = false; 1011 bool expected = false;
994 if (ChildStats<K>::beyond_warned[Slot].compare_exchange_strong(expected, true, 1012 if (ChildStats<K>::beyond_warned[Slot].compare_exchange_strong(expected, true,
@@ -1004,6 +1022,9 @@ std::uint64_t WINAPI child_slot(ChildProxy* self, std::uint64_t a1, std::uint64_
1004 return hr_to_u64(E_NOTIMPL); 1022 return hr_to_u64(E_NOTIMPL);
1005 } 1023 }
1006 d3d12_trace::record(child_trace_name<K>(Slot)); // "called": the real object's result is not inspected 1024 d3d12_trace::record(child_trace_name<K>(Slot)); // "called": the real object's result is not inspected
1025 if constexpr (K == ChildKind::queue && Slot == kQueueExecuteCommandLists) {
1026 return queue_execute_command_lists(self, a1, a2);
1027 }
1007 if constexpr (K == ChildKind::queue && (Slot == kQueueSignal || Slot == kQueueWait)) a1 = unwrap_object(a1); 1028 if constexpr (K == ChildKind::queue && (Slot == kQueueSignal || Slot == kQueueWait)) a1 = unwrap_object(a1);
1008 1029
1009 // The PC vtable entry with the real object as `this`; integer/pointer arguments, the hidden struct-return 1030 // The PC vtable entry with the real object as `this`; integer/pointer arguments, the hidden struct-return
@@ -1742,6 +1763,11 @@ unsigned fence_proxy_slot_count(const void* fence) {
1742 1763
1743unsigned queue_proxy_table_size() { return kQueueSlots; } 1764unsigned queue_proxy_table_size() { return kQueueSlots; }
1744unsigned fence_proxy_table_size() { return kFenceSlots; } 1765unsigned fence_proxy_table_size() { return kFenceSlots; }
1766
1767bool queue_slot_overridden(unsigned slot) {
1768 return slot <= 2 || slot == 7 || slot == kQueueSignal || slot == kQueueWait ||
1769 slot == kQueueExecuteCommandListsX;
1770}
1745unsigned allocator_proxy_table_size() { return kAllocatorSlots; } 1771unsigned allocator_proxy_table_size() { return kAllocatorSlots; }
1746unsigned allocator_proxy_slot_count(const void* allocator) { 1772unsigned allocator_proxy_slot_count(const void* allocator) {
1747 return is_allocator_proxy(allocator) ? static_cast<const ChildProxy*>(allocator)->slot_count : 0; 1773 return is_allocator_proxy(allocator) ? static_cast<const ChildProxy*>(allocator)->slot_count : 0;
diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h
index 0019ec506..2bf25000a 100644
--- a/runtime/shims/d3d12_xs_device.h
+++ b/runtime/shims/d3d12_xs_device.h
@@ -35,11 +35,12 @@
35// 35//
36// Command queues and fences (device slots 8, 75, 36, and 32 for a shared fence) come back wrapped in queue and fence 36// Command queues and fences (device slots 8, 75, 36, and 32 for a shared fence) come back wrapped in queue and fence
37// proxies of the same kind: the public chain (19 queue slots, 11 or 12 fence slots in SDK 10.0.26100) is forwarded 37// proxies of the same kind: the public chain (19 queue slots, 11 or 12 fence slots in SDK 10.0.26100) is forwarded
38// in PC order, and a slot past it, up to the end of the proxy's table (128 queue, 64 fence slots), is logged with its 38// in PC order. Queue slot 35 is the console ExecuteCommandLists(count, lists) variant and forwards to PC slot 10;
39// first four argument words and refused with E_NOTIMPL. A slot past the table faults on the vtable read inside a 39// every other slot past the public chain, up to the end of the proxy's table (128 queue, 64 fence slots), is logged
40// reserved, never-committed region, and the fault is logged with the slot. That is where the console's queue methods 40// with its first four argument words and refused with E_NOTIMPL. A slot past the table faults on the vtable read inside a
41// (PresentX, SuspendX, ResumeX) will show up; their slots are not known and are not guessed, and that the console 41// reserved, never-committed region, and the fault is logged with the slot. PresentX, SuspendX and ResumeX slots past
42// keeps the public slots is an assumption (docs/d3d12_command_objects.md §5.2). Heap, queue and fence proxies are 42// the public chain remain refused until measured and implemented, and that the console keeps the public slots is an
43// assumption (docs/d3d12_command_objects.md §5.2). Heap, queue and fence proxies are
43// unwrapped wherever a device or queue method hands them to the real runtime: queue Signal/Wait (14/15), device 44// unwrapped wherever a device or queue method hands them to the real runtime: queue Signal/Wait (14/15), device
44// CreateSharedHandle (31), MakeResident/Evict (34/35), SetEventOnMultipleFenceCompletion (45), SetResidencyPriority 45// CreateSharedHandle (31), MakeResident/Evict (34/35), SetEventOnMultipleFenceCompletion (45), SetResidencyPriority
45// (46) and EnqueueMakeResident (50). Command lists are not wrapped, so ExecuteCommandLists passes them through and a 46// (46) and EnqueueMakeResident (50). Command lists are not wrapped, so ExecuteCommandLists passes them through and a
@@ -107,6 +108,9 @@ unsigned queue_proxy_slot_count(const void* queue);
107unsigned fence_proxy_slot_count(const void* fence); 108unsigned fence_proxy_slot_count(const void* fence);
108unsigned queue_proxy_table_size(); 109unsigned queue_proxy_table_size();
109unsigned fence_proxy_table_size(); 110unsigned fence_proxy_table_size();
111// True for queue slots handled by the proxy instead of forwarded verbatim past IUnknown: 0-2 (IUnknown),
112// 7 (GetDevice), 14/15 (Signal/Wait unwrap fences), and 35 (Xbox ExecuteCommandLists variant -> PC slot 10).
113bool queue_slot_overridden(unsigned slot);
110// Live references on a queue, fence or allocator proxy (0 for anything else). Test helper. 114// Live references on a queue, fence or allocator proxy (0 for anything else). Test helper.
111unsigned long command_object_proxy_ref_count(const void* object); 115unsigned long command_object_proxy_ref_count(const void* object);
112// Per-slot call counters and first-call flags, shared by all queue proxies and all fence proxies. 116// Per-slot call counters and first-call flags, shared by all queue proxies and all fence proxies.
diff --git a/runtime/test/queue_proxy_test.cpp b/runtime/test/queue_proxy_test.cpp
index 3f46567f8..967313d53 100644
--- a/runtime/test/queue_proxy_test.cpp
+++ b/runtime/test/queue_proxy_test.cpp
@@ -257,7 +257,9 @@ int check_slots(const Backend& b) {
257 } 257 }
258 } 258 }
259 259
260 // 10: ExecuteCommandLists passes the (real, not wrapped) command lists through. 260 // 10 and console slot 35: 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));
261 { 263 {
262 Ref<ID3D12CommandAllocator> allocator; 264 Ref<ID3D12CommandAllocator> allocator;
263 EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, 265 EXPECT(SUCCEEDED(device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT,
@@ -272,6 +274,11 @@ int check_slots(const Backend& b) {
272 EXPECT(qhits(10) == before + 1); 274 EXPECT(qhits(10) == before + 1);
273 EXPECT(SUCCEEDED(queue->Signal(fence.p, 6))); 275 EXPECT(SUCCEEDED(queue->Signal(fence.p, 6)));
274 if (wait_for(label, fence.p, 6)) return 1; 276 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 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7)));
281 if (wait_for(label, fence.p, 7)) return 1;
275 if (b.vulkan) { 282 if (b.vulkan) {
276 // The layer's own helpers find their queue behind the proxy. 283 // The layer's own helpers find their queue behind the proxy.
277 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success); 284 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
@@ -293,17 +300,17 @@ int check_slots(const Backend& b) {
293 300
294 // 14/15: Signal and Wait take fence proxies; the real queue gets the real fences. 301 // 14/15: Signal and Wait take fence proxies; the real queue gets the real fences.
295 before = qhits(14); 302 before = qhits(14);
296 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7))); 303 EXPECT(SUCCEEDED(queue->Signal(fence.p, 8)));
297 EXPECT(qhits(14) == before + 1); 304 EXPECT(qhits(14) == before + 1);
298 if (wait_for(label, fence.p, 7)) return 1; 305 if (wait_for(label, fence.p, 8)) return 1;
299 before = qhits(15); 306 before = qhits(15);
300 EXPECT(SUCCEEDED(queue->Wait(fence.p, 8))); // the queue waits until the CPU signals 8 307 EXPECT(SUCCEEDED(queue->Wait(fence.p, 9))); // the queue waits until the CPU signals 9
301 EXPECT(qhits(15) == before + 1); 308 EXPECT(qhits(15) == before + 1);
302 EXPECT(SUCCEEDED(queue->Signal(second.p, 1))); 309 EXPECT(SUCCEEDED(queue->Signal(second.p, 1)));
303 Sleep(50); 310 Sleep(50);
304 EXPECT(second->GetCompletedValue() == 0); // still held by the Wait 311 EXPECT(second->GetCompletedValue() == 0); // still held by the Wait
305 before = fhits(10); 312 before = fhits(10);
306 EXPECT(SUCCEEDED(fence->Signal(8))); // fence 10, from the CPU 313 EXPECT(SUCCEEDED(fence->Signal(9))); // fence 10, from the CPU
307 EXPECT(fhits(10) == before + 1); 314 EXPECT(fhits(10) == before + 1);
308 if (wait_for(label, second.p, 1)) return 1; 315 if (wait_for(label, second.p, 1)) return 1;
309 316
@@ -359,12 +366,12 @@ int check_slots(const Backend& b) {
359 EXPECT(fhits(7) == before + 1); 366 EXPECT(fhits(7) == before + 1);
360 } 367 }
361 before = fhits(8); 368 before = fhits(8);
362 EXPECT(fence->GetCompletedValue() == 8); 369 EXPECT(fence->GetCompletedValue() == 9);
363 EXPECT(fhits(8) == before + 1); 370 EXPECT(fhits(8) == before + 1);
364 { 371 {
365 Event done; 372 Event done;
366 before = fhits(9); 373 before = fhits(9);
367 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(8, done.h)) && done.set_within(5000)); 374 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(9, done.h)) && done.set_within(5000));
368 EXPECT(fhits(9) == before + 1); 375 EXPECT(fhits(9) == before + 1);
369 } 376 }
370 if (fence_slots == 12) { 377 if (fence_slots == 12) {
@@ -389,8 +396,9 @@ int check_slots(const Backend& b) {
389 } 396 }
390 } 397 }
391 398
392 // The refused tail: every slot from the end of the public chain to the end of the table. 399 // The refused tail: every unmodelled slot from the end of the public chain to the end of the table.
393 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) { 400 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) {
401 if (xs::queue_slot_overridden(slot)) continue;
394 before = qhits(slot); 402 before = qhits(slot);
395 EXPECT(as_hr(call_slot(queue.p, slot)) == E_NOTIMPL); 403 EXPECT(as_hr(call_slot(queue.p, slot)) == E_NOTIMPL);
396 EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot)); 404 EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot));
@@ -1460,18 +1468,56 @@ int check_xbox_client(const Backend& b) {
1460 EXPECT(same); // the GPU really ran the list the queue proxy submitted 1468 EXPECT(same); // the GPU really ran the list the queue proxy submitted
1461 } 1469 }
1462 1470
1463 // Device slot 50: EnqueueMakeResident with the objects and a fence proxy to signal. 1471 // Second copy with fresh bytes, submitted through console ExecuteCommandLists slot 35.
1464 EXPECT(SUCCEEDED(as_hr(raw(device, 50, D3D12_RESIDENCY_FLAG_NONE, 4, word(pageables), word(fence.p), 2)))); 1472 {
1473 std::uint8_t* bytes = nullptr;
1474 EXPECT(SUCCEEDED(upload->Map(0, nullptr, reinterpret_cast<void**>(&bytes))));
1475 for (UINT64 i = 0; i < kBytes; ++i) bytes[i] = static_cast<std::uint8_t>(i * 11 + 5);
1476 upload->Unmap(0, nullptr);
1477 }
1478 EXPECT(SUCCEEDED(allocator->Reset()));
1479 EXPECT(SUCCEEDED(list->Reset(allocator.p, nullptr)));
1480 D3D12_RESOURCE_BARRIER to_dest{};
1481 to_dest.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
1482 to_dest.Transition.pResource = gpu.p;
1483 to_dest.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
1484 to_dest.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE;
1485 to_dest.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST;
1486 list->ResourceBarrier(1, &to_dest);
1487 list->CopyBufferRegion(gpu.p, 0, upload.p, 0, kBytes);
1488 D3D12_RESOURCE_BARRIER to_source = to_dest;
1489 to_source.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST;
1490 to_source.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
1491 list->ResourceBarrier(1, &to_source);
1492 list->CopyBufferRegion(readback.p, 0, gpu.p, 0, kBytes);
1493 EXPECT(SUCCEEDED(list->Close()));
1494 EXPECT(raw(queue.p, 35, 1, word(lists)) == 0);
1495 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(fence.p), 2))));
1465 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 2, word(done.h)))) && done.set_within(5000)); 1496 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 2, word(done.h)))) && done.set_within(5000));
1497 EXPECT(raw(fence.p, 8) >= 2);
1498 {
1499 std::uint8_t* bytes = nullptr;
1500 const D3D12_RANGE read_range{0, kBytes};
1501 EXPECT(SUCCEEDED(readback->Map(0, &read_range, reinterpret_cast<void**>(&bytes))));
1502 bool same = true;
1503 for (UINT64 i = 0; i < kBytes; ++i) same = same && bytes[i] == static_cast<std::uint8_t>(i * 11 + 5);
1504 const D3D12_RANGE nothing{0, 0};
1505 readback->Unmap(0, &nothing);
1506 EXPECT(same); // the GPU really ran the list submitted via queue slot 35
1507 }
1508
1509 // Device slot 50: EnqueueMakeResident with the objects and a fence proxy to signal.
1510 EXPECT(SUCCEEDED(as_hr(raw(device, 50, D3D12_RESIDENCY_FLAG_NONE, 4, word(pageables), word(fence.p), 3))));
1511 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 3, word(done.h)))) && done.set_within(5000));
1466 1512
1467 // Queue slot 15 holds the queue until the CPU (fence slot 10) signals; device slot 45 then sees both fences. 1513 // Queue slot 15 holds the queue until the CPU (fence slot 10) signals; device slot 45 then sees both fences.
1468 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 15, word(fence.p), 3)))); 1514 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 15, word(fence.p), 4))));
1469 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(second.p), 1)))); 1515 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(second.p), 1))));
1470 Sleep(50); 1516 Sleep(50);
1471 EXPECT(raw(second.p, 8) == 0); 1517 EXPECT(raw(second.p, 8) == 0);
1472 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 10, 3)))); 1518 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 10, 4))));
1473 ID3D12Fence* both[] = {fence.p, second.p}; 1519 ID3D12Fence* both[] = {fence.p, second.p};
1474 const UINT64 values[] = {3, 1}; 1520 const UINT64 values[] = {4, 1};
1475 EXPECT(SUCCEEDED(as_hr(raw(device, 45, word(both), word(values), 2, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL, 1521 EXPECT(SUCCEEDED(as_hr(raw(device, 45, word(both), word(values), 2, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL,
1476 word(done.h)))) && 1522 word(done.h)))) &&
1477 done.set_within(5000)); 1523 done.set_within(5000));
diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp
index f0030116b..c916402e4 100644
--- a/runtime/test/xs_proxy_mock_test.cpp
+++ b/runtime/test/xs_proxy_mock_test.cpp
@@ -767,6 +767,37 @@ int check_xbox_slots() {
767#endif 767#endif
768} 768}
769 769
770// ---- 7b. Xbox queue ExecuteCommandLists variant (queue slot 35 -> PC slot 10) ----
771
772int check_xbox_queue_slots() {
773 Mock* mock = nullptr;
774 void* device = make_device(mock, 9, true);
775 EXPECT(device);
776 void* queue = make_queue(device);
777 EXPECT(queue);
778 Mock* const queue_mock = reinterpret_cast<Mock*>(xs::queue_proxy_real_queue(queue));
779 xs::reset_device_proxy_stats();
780
781 EXPECT(xs::queue_slot_overridden(35) && xs::queue_slot_overridden(14) && xs::queue_slot_overridden(15));
782 EXPECT(!xs::queue_slot_overridden(10) && !xs::queue_slot_overridden(34) && !xs::queue_slot_overridden(36));
783
784 void* fake_lists[2] = {reinterpret_cast<void*>(0x12340000), reinterpret_cast<void*>(0x56780000)};
785 EXPECT(raw(queue, 35, (0xdeadbeefull << 32) | 2ull, word(fake_lists)) == 0);
786 EXPECT(xs::queue_slot_hits(35) == 1 && xs::queue_slot_first_call_seen(35));
787 EXPECT(xs::queue_slot_hits(10) == 0);
788 EXPECT(queue_mock->calls[35] == 0 && queue_mock->calls[10] == 1);
789 EXPECT(queue_mock->args[10][0] == 2 && queue_mock->args[10][1] == word(fake_lists));
790
791 EXPECT(raw(queue, 35, 0, 0) == 0);
792 EXPECT(xs::queue_slot_hits(35) == 2 && queue_mock->calls[35] == 0 && queue_mock->calls[10] == 2);
793 EXPECT(queue_mock->args[10][0] == 0 && queue_mock->args[10][1] == 0);
794
795 EXPECT(release(queue) == 0 && release(device) == 0 && mock->refs == 0);
796 std::printf("%s: queue slot 35 routes ExecuteCommandLists(count, lists) to PC slot 10 with UINT count masking\n",
797 g_label);
798 return 0;
799}
800
770// ---- 8. Environment overrides for the Xbox device slots (one process each, read once) ---- 801// ---- 8. Environment overrides for the Xbox device slots (one process each, read once) ----
771 802
772int run_env_slots(bool valid) { 803int run_env_slots(bool valid) {
@@ -835,8 +866,10 @@ int check_tail(bool want_guarded) {
835 // Signal (14) still reaches the real queue, with the real fence. 866 // Signal (14) still reaches the real queue, with the real fence.
836 EXPECT(hr_of(raw(queue, 14, word(fence), 5)) == S_OK && queue_mock->calls[14] == 1 && 867 EXPECT(hr_of(raw(queue, 14, word(fence), 5)) == S_OK && queue_mock->calls[14] == 1 &&
837 queue_mock->args[14][0] == word(xs::fence_proxy_real_fence(fence)) && queue_mock->args[14][1] == 5); 868 queue_mock->args[14][0] == word(xs::fence_proxy_real_fence(fence)) && queue_mock->args[14][1] == 5);
838 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) 869 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) {
870 if (xs::queue_slot_overridden(slot)) continue;
839 EXPECT(hr_of(raw(queue, slot)) == E_NOTIMPL && queue_mock->calls[slot] == 0); 871 EXPECT(hr_of(raw(queue, slot)) == E_NOTIMPL && queue_mock->calls[slot] == 0);
872 }
840 for (unsigned slot = 12; slot < xs::fence_proxy_table_size(); ++slot) EXPECT(hr_of(raw(fence, slot)) == E_NOTIMPL); 873 for (unsigned slot = 12; slot < xs::fence_proxy_table_size(); ++slot) EXPECT(hr_of(raw(fence, slot)) == E_NOTIMPL);
841 EXPECT(xs::queue_table_overruns() == 0 && xs::fence_table_overruns() == 0); 874 EXPECT(xs::queue_table_overruns() == 0 && xs::fence_table_overruns() == 0);
842 EXPECT(release(queue) == 0 && release(fence) == 0 && release(device) == 0 && mock->refs == 0); 875 EXPECT(release(queue) == 0 && release(fence) == 0 && release(device) == 0 && mock->refs == 0);
@@ -948,7 +981,7 @@ int main(int argc, char** argv) {
948 } 981 }
949 if (argc != 1) return 2; 982 if (argc != 1) return 2;
950 if (check_tail(true) || check_levels() || check_fence1() || check_create_failures() || check_open_shared() || 983 if (check_tail(true) || check_levels() || check_fence1() || check_create_failures() || check_open_shared() ||
951 check_alloc_failures() || check_allocators() || check_xbox_slots()) 984 check_alloc_failures() || check_allocators() || check_xbox_slots() || check_xbox_queue_slots())
952 return 1; 985 return 1;
953 std::printf("xs_proxy_mock_test: PASS (%d allocations refused on purpose)\n", g_failed_news); 986 std::printf("xs_proxy_mock_test: PASS (%d allocations refused on purpose)\n", g_failed_news);
954 return 0; 987 return 0;