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:
Diffstat (limited to 'runtime/test/queue_proxy_test.cpp')
-rw-r--r--runtime/test/queue_proxy_test.cpp78
1 files changed, 65 insertions, 13 deletions
diff --git a/runtime/test/queue_proxy_test.cpp b/runtime/test/queue_proxy_test.cpp
index 3f46567f8..674a8cf2e 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,17 @@ 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 // 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;
275 if (b.vulkan) { 288 if (b.vulkan) {
276 // The layer's own helpers find their queue behind the proxy. 289 // The layer's own helpers find their queue behind the proxy.
277 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success); 290 EXPECT(rt::d3d12::last_execute_result(queue.p) == leonida::ReplayResult::success);
@@ -293,17 +306,17 @@ int check_slots(const Backend& b) {
293 306
294 // 14/15: Signal and Wait take fence proxies; the real queue gets the real fences. 307 // 14/15: Signal and Wait take fence proxies; the real queue gets the real fences.
295 before = qhits(14); 308 before = qhits(14);
296 EXPECT(SUCCEEDED(queue->Signal(fence.p, 7))); 309 EXPECT(SUCCEEDED(queue->Signal(fence.p, 8)));
297 EXPECT(qhits(14) == before + 1); 310 EXPECT(qhits(14) == before + 1);
298 if (wait_for(label, fence.p, 7)) return 1; 311 if (wait_for(label, fence.p, 8)) return 1;
299 before = qhits(15); 312 before = qhits(15);
300 EXPECT(SUCCEEDED(queue->Wait(fence.p, 8))); // the queue waits until the CPU signals 8 313 EXPECT(SUCCEEDED(queue->Wait(fence.p, 9))); // the queue waits until the CPU signals 9
301 EXPECT(qhits(15) == before + 1); 314 EXPECT(qhits(15) == before + 1);
302 EXPECT(SUCCEEDED(queue->Signal(second.p, 1))); 315 EXPECT(SUCCEEDED(queue->Signal(second.p, 1)));
303 Sleep(50); 316 Sleep(50);
304 EXPECT(second->GetCompletedValue() == 0); // still held by the Wait 317 EXPECT(second->GetCompletedValue() == 0); // still held by the Wait
305 before = fhits(10); 318 before = fhits(10);
306 EXPECT(SUCCEEDED(fence->Signal(8))); // fence 10, from the CPU 319 EXPECT(SUCCEEDED(fence->Signal(9))); // fence 10, from the CPU
307 EXPECT(fhits(10) == before + 1); 320 EXPECT(fhits(10) == before + 1);
308 if (wait_for(label, second.p, 1)) return 1; 321 if (wait_for(label, second.p, 1)) return 1;
309 322
@@ -359,12 +372,12 @@ int check_slots(const Backend& b) {
359 EXPECT(fhits(7) == before + 1); 372 EXPECT(fhits(7) == before + 1);
360 } 373 }
361 before = fhits(8); 374 before = fhits(8);
362 EXPECT(fence->GetCompletedValue() == 8); 375 EXPECT(fence->GetCompletedValue() == 9);
363 EXPECT(fhits(8) == before + 1); 376 EXPECT(fhits(8) == before + 1);
364 { 377 {
365 Event done; 378 Event done;
366 before = fhits(9); 379 before = fhits(9);
367 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(8, done.h)) && done.set_within(5000)); 380 EXPECT(SUCCEEDED(fence->SetEventOnCompletion(9, done.h)) && done.set_within(5000));
368 EXPECT(fhits(9) == before + 1); 381 EXPECT(fhits(9) == before + 1);
369 } 382 }
370 if (fence_slots == 12) { 383 if (fence_slots == 12) {
@@ -389,8 +402,9 @@ int check_slots(const Backend& b) {
389 } 402 }
390 } 403 }
391 404
392 // The refused tail: every slot from the end of the public chain to the end of the table. 405 // 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) { 406 for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) {
407 if (xs::queue_slot_overridden(slot)) continue;
394 before = qhits(slot); 408 before = qhits(slot);
395 EXPECT(as_hr(call_slot(queue.p, slot)) == E_NOTIMPL); 409 EXPECT(as_hr(call_slot(queue.p, slot)) == E_NOTIMPL);
396 EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot)); 410 EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot));
@@ -1460,18 +1474,56 @@ int check_xbox_client(const Backend& b) {
1460 EXPECT(same); // the GPU really ran the list the queue proxy submitted 1474 EXPECT(same); // the GPU really ran the list the queue proxy submitted
1461 } 1475 }
1462 1476
1463 // Device slot 50: EnqueueMakeResident with the objects and a fence proxy to signal. 1477 // 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)))); 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))));
1465 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 2, word(done.h)))) && done.set_within(5000)); 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.
1516 EXPECT(SUCCEEDED(as_hr(raw(device, 50, D3D12_RESIDENCY_FLAG_NONE, 4, word(pageables), word(fence.p), 3))));
1517 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 9, 3, word(done.h)))) && done.set_within(5000));
1466 1518
1467 // Queue slot 15 holds the queue until the CPU (fence slot 10) signals; device slot 45 then sees both fences. 1519 // 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)))); 1520 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)))); 1521 EXPECT(SUCCEEDED(as_hr(raw(queue.p, 14, word(second.p), 1))));
1470 Sleep(50); 1522 Sleep(50);
1471 EXPECT(raw(second.p, 8) == 0); 1523 EXPECT(raw(second.p, 8) == 0);
1472 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 10, 3)))); 1524 EXPECT(SUCCEEDED(as_hr(raw(fence.p, 10, 4))));
1473 ID3D12Fence* both[] = {fence.p, second.p}; 1525 ID3D12Fence* both[] = {fence.p, second.p};
1474 const UINT64 values[] = {3, 1}; 1526 const UINT64 values[] = {4, 1};
1475 EXPECT(SUCCEEDED(as_hr(raw(device, 45, word(both), word(values), 2, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL, 1527 EXPECT(SUCCEEDED(as_hr(raw(device, 45, word(both), word(values), 2, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL,
1476 word(done.h)))) && 1528 word(done.h)))) &&
1477 done.set_within(5000)); 1529 done.set_within(5000));