diff options
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
| -rw-r--r-- | runtime/test/device_proxy_test.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp index 96cc6c5de..6b7a78938 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | // It creates the proxy through the registered d3d12_xs!D3D12XboxCreateDevice shim, then calls the measured Xbox | 3 | // It creates the proxy through the registered d3d12_xs!D3D12XboxCreateDevice shim, then calls the measured Xbox |
| 4 | // slots exactly as the guest would (raw function pointers, not the C++ interface): | 4 | // slots exactly as the guest would (raw function pointers, not the C++ interface): |
| 5 | // slot 14 CreateDescriptorHeap (returns a heap proxy) | 5 | // slot 14 CreateDescriptorHeap (returns a heap proxy) |
| 6 | // slot 26 GetCustomHeapProperties with the struct's buffer in RCX and the device in RDX | 6 | // slot 25/26 GetResourceAllocationInfo/GetCustomHeapProperties in the title's C form (return buffer first) |
| 7 | // heap 9/10 GetCPU/GetGPUDescriptorHandleForHeapStart (Xbox: 8-byte handle in RAX; the PC heap uses the | 7 | // heap 9/10 GetCPU/GetGPUDescriptorHandleForHeapStart (Xbox: 8-byte handle in RAX; the PC heap uses the |
| 8 | // hidden return pointer in RDX, so slot 14 wraps it) | 8 | // hidden return pointer in RDX, so slot 14 wraps it) |
| 9 | // slot 62 CreateComputePipelineState | 9 | // slot 62 CreateComputePipelineState |
| @@ -23,6 +23,7 @@ | |||
| 23 | #include <wrl/client.h> | 23 | #include <wrl/client.h> |
| 24 | 24 | ||
| 25 | #include "d3d12_trace.h" | 25 | #include "d3d12_trace.h" |
| 26 | #include "d3d12_xs_desc_clean.h" | ||
| 26 | #include "d3d12_xs_device.h" | 27 | #include "d3d12_xs_device.h" |
| 27 | #include "shims.h" | 28 | #include "shims.h" |
| 28 | 29 | ||
| @@ -200,6 +201,34 @@ int main(int argc, char** argv) { | |||
| 200 | const LUID real_luid = real ? real->GetAdapterLuid() : LUID{}; | 201 | const LUID real_luid = real ? real->GetAdapterLuid() : LUID{}; |
| 201 | check(proxy_luid.LowPart == real_luid.LowPart && proxy_luid.HighPart == real_luid.HighPart, | 202 | check(proxy_luid.LowPart == real_luid.LowPart && proxy_luid.HighPart == real_luid.HighPart, |
| 202 | "slot 43 forwards GetAdapterLuid (struct return)"); | 203 | "slot 43 forwards GetAdapterLuid (struct return)"); |
| 204 | // Slot 25 returns a struct wider than 8 bytes. The console title calls it with the C ABI: the hidden | ||
| 205 | // return pointer first (RCX), then the device (RDX), then the arguments, and the buffer comes back in RAX | ||
| 206 | // (measured for slot 26 on the retail executable). Call slot 25 that way through a raw function pointer and compare | ||
| 207 | // with the PC device's own answer. | ||
| 208 | check(rt::d3d12_xs::device_slot_overridden(25), "device slot 25 is the C-ABI GetResourceAllocationInfo override"); | ||
| 209 | if (real) { | ||
| 210 | using AllocInfoFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)(D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT, | ||
| 211 | const D3D12_RESOURCE_DESC*); | ||
| 212 | auto get_alloc_info = reinterpret_cast<AllocInfoFn>(proxy_vtbl[25]); | ||
| 213 | const D3D12_RESOURCE_DESC desc = buffer_desc(); | ||
| 214 | D3D12_RESOURCE_ALLOCATION_INFO got{~0ull, ~0ull}; | ||
| 215 | D3D12_RESOURCE_ALLOCATION_INFO* returned = get_alloc_info(&got, device.Get(), 0, 1, &desc); | ||
| 216 | // The proxy cleans the console layout word and flag bits before the PC call (stop 16), so the expected answer is | ||
| 217 | // the PC device's for the cleaned description (the raw 0x101 layout makes WARP answer UINT64_MAX). | ||
| 218 | const D3D12_RESOURCE_DESC clean = rt::d3d12_xs::pc_resource_desc(desc); | ||
| 219 | const D3D12_RESOURCE_ALLOCATION_INFO want = real->GetResourceAllocationInfo(0, 1, &clean); | ||
| 220 | check(want.SizeInBytes != UINT64_MAX, "WARP accepts the normalized slot-25 buffer description"); | ||
| 221 | check(returned == &got, "slot 25 returns the caller's buffer in RAX"); | ||
| 222 | check(got.SizeInBytes == want.SizeInBytes && got.Alignment == want.Alignment, | ||
| 223 | "slot 25 (C ABI) writes the PC device's GetResourceAllocationInfo into the caller's buffer"); | ||
| 224 | |||
| 225 | // The runtime's own code calls the proxy through d3d12.h (PC form: this, then the return buffer). Slot 25 | ||
| 226 | // still answers that form. | ||
| 227 | const D3D12_RESOURCE_ALLOCATION_INFO pc_info = device->GetResourceAllocationInfo(0, 1, &desc); | ||
| 228 | check(pc_info.SizeInBytes == want.SizeInBytes && pc_info.Alignment == want.Alignment, | ||
| 229 | "slot 25 still answers the PC (C++) form"); | ||
| 230 | } | ||
| 231 | |||
| 203 | D3D12_RESOURCE_DESC reserved_desc = buffer_desc(); | 232 | D3D12_RESOURCE_DESC reserved_desc = buffer_desc(); |
| 204 | reserved_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; | 233 | reserved_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; |
| 205 | ComPtr<ID3D12Resource> reserved; | 234 | ComPtr<ID3D12Resource> reserved; |