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:
authorVadson159 <vad.sofr@gmail.com>2026-11-23 17:24:09 +0100
committerMumogg <104529023+Mumogg@users.noreply.github.com>2026-11-24 03:52:41 -0600
commit1bd72a87ada80475d2a51f9eda359906d9962a3f (patch)
tree15df398522ae5a36e0842c1a4d01941733400034 /runtime/test/queue_proxy_test.cpp
parent3ca10dfe1f90824bb52efe653677cd821f3ac138 (diff)
d3d12_xs: route command queue slot 35 to ExecuteCommandLists
(cherry picked from commit e925b634551ed96d1ed097dfe17d7dfca0cdbe4d) Adapted to main by Mumogg: main has command-list proxies, so the shared execute function replaces them by their real lists in a copy of the array (UnwrappedArray), for the console slot 35 as for the PC slot 10, whose test failed otherwise. The slot 35 mock case passes two mock lists instead of two numbers and checks that they arrive and that the caller's array is not written.
Diffstat (limited to 'runtime/test/queue_proxy_test.cpp')
-rw-r--r--runtime/test/queue_proxy_test.cpp72
1 files changed, 59 insertions, 13 deletions
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));