diff options
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
| -rw-r--r-- | runtime/test/device_proxy_test.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp index 36afc3c34..142ebfbc2 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp | |||
| @@ -3,6 +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 25/26 GetResourceAllocationInfo/GetCustomHeapProperties in the title's C form (return buffer first) | ||
| 6 | // 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 |
| 7 | // hidden return pointer in RDX, so slot 14 wraps it) | 8 | // hidden return pointer in RDX, so slot 14 wraps it) |
| 8 | // slot 62 CreateComputePipelineState | 9 | // slot 62 CreateComputePipelineState |
| @@ -199,6 +200,46 @@ int main(int argc, char** argv) { | |||
| 199 | const LUID real_luid = real ? real->GetAdapterLuid() : LUID{}; | 200 | const LUID real_luid = real ? real->GetAdapterLuid() : LUID{}; |
| 200 | check(proxy_luid.LowPart == real_luid.LowPart && proxy_luid.HighPart == real_luid.HighPart, | 201 | check(proxy_luid.LowPart == real_luid.LowPart && proxy_luid.HighPart == real_luid.HighPart, |
| 201 | "slot 43 forwards GetAdapterLuid (struct return)"); | 202 | "slot 43 forwards GetAdapterLuid (struct return)"); |
| 203 | // Slots 25 and 26 return a struct wider than 8 bytes. The console title calls them with the C ABI: the hidden | ||
| 204 | // return pointer first (RCX), then the device (RDX), then the arguments, and the buffer comes back in RAX | ||
| 205 | // (measured for slot 26 on the retail executable). Call them that way through raw function pointers and compare | ||
| 206 | // with the PC device's own answers. | ||
| 207 | check(rt::d3d12_xs::device_slot_overridden(25), "device slot 25 is the C-ABI GetResourceAllocationInfo override"); | ||
| 208 | check(rt::d3d12_xs::device_slot_overridden(26), "device slot 26 is the C-ABI GetCustomHeapProperties override"); | ||
| 209 | if (real) { | ||
| 210 | using HeapPropsFn = D3D12_HEAP_PROPERTIES*(WINAPI*)(D3D12_HEAP_PROPERTIES*, void*, UINT, D3D12_HEAP_TYPE); | ||
| 211 | auto get_heap_props = reinterpret_cast<HeapPropsFn>(proxy_vtbl[26]); | ||
| 212 | for (D3D12_HEAP_TYPE type : {D3D12_HEAP_TYPE_DEFAULT, D3D12_HEAP_TYPE_UPLOAD, D3D12_HEAP_TYPE_READBACK}) { | ||
| 213 | D3D12_HEAP_PROPERTIES got; | ||
| 214 | std::memset(&got, 0xcd, sizeof(got)); | ||
| 215 | D3D12_HEAP_PROPERTIES* returned = get_heap_props(&got, device.Get(), 1, type); | ||
| 216 | const D3D12_HEAP_PROPERTIES want = real->GetCustomHeapProperties(1, type); | ||
| 217 | check(returned == &got, "slot 26 returns the caller's buffer in RAX"); | ||
| 218 | check(std::memcmp(&got, &want, sizeof(got)) == 0, | ||
| 219 | "slot 26 (C ABI) writes the PC device's GetCustomHeapProperties into the caller's buffer"); | ||
| 220 | } | ||
| 221 | |||
| 222 | using AllocInfoFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)(D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT, | ||
| 223 | const D3D12_RESOURCE_DESC*); | ||
| 224 | auto get_alloc_info = reinterpret_cast<AllocInfoFn>(proxy_vtbl[25]); | ||
| 225 | const D3D12_RESOURCE_DESC desc = buffer_desc(); | ||
| 226 | D3D12_RESOURCE_ALLOCATION_INFO got{~0ull, ~0ull}; | ||
| 227 | D3D12_RESOURCE_ALLOCATION_INFO* returned = get_alloc_info(&got, device.Get(), 0, 1, &desc); | ||
| 228 | const D3D12_RESOURCE_ALLOCATION_INFO want = real->GetResourceAllocationInfo(0, 1, &desc); | ||
| 229 | check(returned == &got, "slot 25 returns the caller's buffer in RAX"); | ||
| 230 | check(got.SizeInBytes == want.SizeInBytes && got.Alignment == want.Alignment, | ||
| 231 | "slot 25 (C ABI) writes the PC device's GetResourceAllocationInfo into the caller's buffer"); | ||
| 232 | |||
| 233 | // The runtime's own code calls the proxy through d3d12.h (PC form: this, then the return buffer). Both | ||
| 234 | // slots still answer that form. | ||
| 235 | const D3D12_HEAP_PROPERTIES pc_props = device->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD); | ||
| 236 | const D3D12_HEAP_PROPERTIES pc_want = real->GetCustomHeapProperties(1, D3D12_HEAP_TYPE_UPLOAD); | ||
| 237 | check(std::memcmp(&pc_props, &pc_want, sizeof(pc_props)) == 0, "slot 26 still answers the PC (C++) form"); | ||
| 238 | const D3D12_RESOURCE_ALLOCATION_INFO pc_info = device->GetResourceAllocationInfo(0, 1, &desc); | ||
| 239 | check(pc_info.SizeInBytes == want.SizeInBytes && pc_info.Alignment == want.Alignment, | ||
| 240 | "slot 25 still answers the PC (C++) form"); | ||
| 241 | } | ||
| 242 | |||
| 202 | D3D12_RESOURCE_DESC reserved_desc = buffer_desc(); | 243 | D3D12_RESOURCE_DESC reserved_desc = buffer_desc(); |
| 203 | reserved_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; | 244 | reserved_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; |
| 204 | ComPtr<ID3D12Resource> reserved; | 245 | ComPtr<ID3D12Resource> reserved; |