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:
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
-rw-r--r--runtime/test/device_proxy_test.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp
index d5a6ec04e..44c5bd516 100644
--- a/runtime/test/device_proxy_test.cpp
+++ b/runtime/test/device_proxy_test.cpp
@@ -324,6 +324,62 @@ int main(int argc, char** argv) {
324 check(rt::d3d12_xs::device_slot_hits(76) == 2, "slot 76 hit counter is 2"); 324 check(rt::d3d12_xs::device_slot_hits(76) == 2, "slot 76 hit counter is 2");
325 check(rt::d3d12_xs::device_slot_first_call_seen(76), "slot 76 first-call flag is set"); 325 check(rt::d3d12_xs::device_slot_first_call_seen(76), "slot 76 first-call flag is set");
326 326
327 // Xbox device slots from the public HLE. On the Vulkan device the PC entries at 78/79 are
328 // CreateReservedResource2/CreateSampler2 and 80 is past the 80-slot table, so success here can only come from
329 // the routes: frame events return S_OK and a fresh token, CreateCommandQueueX returns a queue proxy and
330 // CreateCommandListX (desc, allocator, initialState, riid, out; no node mask) reaches PC CreateCommandList.
331 {
332 using SetFrameIntervalFn = HRESULT(WINAPI*)(void*, void*, UINT, UINT, UINT);
333 using ScheduleFrameEventFn = HRESULT(WINAPI*)(void*, UINT, UINT, void*, UINT);
334 using WaitFrameEventFn = HRESULT(WINAPI*)(void*, UINT, UINT, void*, UINT, UINT64*);
335 using CreateQueueXFn = HRESULT(WINAPI*)(void*, const D3D12_COMMAND_QUEUE_DESC*, const IID*, void**);
336 using CreateListXFn = HRESULT(WINAPI*)(void*, const void*, ID3D12CommandAllocator*, ID3D12PipelineState*,
337 const IID*, void**);
338
339 hr = reinterpret_cast<SetFrameIntervalFn>(proxy_vtbl[78])(device.Get(), nullptr, 16667, 1, 0);
340 check(hr == S_OK, "slot 78 SetFrameIntervalX returns S_OK");
341 hr = reinterpret_cast<ScheduleFrameEventFn>(proxy_vtbl[79])(device.Get(), 0, 0, nullptr, 0);
342 check(hr == S_OK, "slot 79 ScheduleFrameEventX returns S_OK");
343
344 std::uint64_t token = 0, token2 = 0;
345 hr = reinterpret_cast<WaitFrameEventFn>(proxy_vtbl[80])(device.Get(), 0, INFINITE, nullptr, 0, &token);
346 check(hr == S_OK && token != 0, "slot 80 WaitFrameEventX returns a non-zero token");
347 hr = reinterpret_cast<WaitFrameEventFn>(proxy_vtbl[80])(device.Get(), 0, 0, nullptr, 0, &token2);
348 check(hr == S_OK && token2 != 0 && token2 != token, "slot 80 returns a fresh token on the next wait");
349 hr = reinterpret_cast<WaitFrameEventFn>(proxy_vtbl[80])(device.Get(), 0, 0, nullptr, 0, nullptr);
350 check(hr == E_POINTER, "slot 80 refuses a null token with E_POINTER");
351 check(rt::d3d12_xs::device_slot_hits(78) == 1 && rt::d3d12_xs::device_slot_hits(79) == 1 &&
352 rt::d3d12_xs::device_slot_hits(80) == 3,
353 "slots 78/79/80 hit counters are 1/1/3");
354
355 // The console description is 32 bytes: the PC prefix, then four Xbox words (the proxy logs them).
356 struct { D3D12_COMMAND_QUEUE_DESC pc; std::uint32_t extra[4]; } xbox_queue{};
357 xbox_queue.pc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
358 const IID iid_queue = __uuidof(ID3D12CommandQueue);
359 ComPtr<ID3D12CommandQueue> xbox_queue_proxy;
360 hr = reinterpret_cast<CreateQueueXFn>(proxy_vtbl[48])(device.Get(), reinterpret_cast<const D3D12_COMMAND_QUEUE_DESC*>(&xbox_queue), &iid_queue,
361 reinterpret_cast<void**>(xbox_queue_proxy.GetAddressOf()));
362 check(hr == S_OK && rt::d3d12_xs::is_queue_proxy(xbox_queue_proxy.Get()),
363 "slot 48 CreateCommandQueueX returns a queue proxy");
364 check(rt::d3d12_xs::device_slot_hits(48) == 1, "slot 48 hit counter is 1");
365
366 ComPtr<ID3D12CommandAllocator> xbox_allocator;
367 hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT,
368 IID_PPV_ARGS(xbox_allocator.GetAddressOf()));
369 struct XboxCommandListDesc {
370 UINT Type;
371 UINT NodeMask;
372 } list_desc{D3D12_COMMAND_LIST_TYPE_DIRECT, 7}; // the node mask is ignored by the console call
373 const IID iid_list = __uuidof(ID3D12GraphicsCommandList);
374 ComPtr<ID3D12GraphicsCommandList> xbox_list;
375 hr = SUCCEEDED(hr) ? reinterpret_cast<CreateListXFn>(proxy_vtbl[73])(
376 device.Get(), &list_desc, xbox_allocator.Get(), nullptr, &iid_list,
377 reinterpret_cast<void**>(xbox_list.GetAddressOf()))
378 : hr;
379 check(hr == S_OK && xbox_list != nullptr, "slot 73 CreateCommandListX returns a command list");
380 check(rt::d3d12_xs::device_slot_hits(73) == 1, "slot 73 hit counter is 1");
381 }
382
327 // Slot 62: an empty root signature and a trivial compute shader through the Xbox signature. The PC entry at 383 // Slot 62: an empty root signature and a trivial compute shader through the Xbox signature. The PC entry at
328 // slot 62 is CreateStateObject, so success here proves the override reached CreateComputePipelineState. 384 // slot 62 is CreateStateObject, so success here proves the override reached CreateComputePipelineState.
329 D3D12_ROOT_SIGNATURE_DESC root_desc{}; 385 D3D12_ROOT_SIGNATURE_DESC root_desc{};