diff options
| author | Tomgamer <tomanhorak22@gmail.com> | 2026-11-22 16:32:05 +0100 |
|---|---|---|
| committer | Tomgamer <tomanhorak22@gmail.com> | 2026-11-22 16:32:05 +0100 |
| commit | eb35aed2e7e8ea1d4a11fd4e42ab80d853f05169 (patch) | |
| tree | 22bd0e6fa6363235d1feedc1c9be678ab63bee4b /runtime/test/device_proxy_test.cpp | |
| parent | 759a90c42e58886153f67dcd2d5d41c44face012 (diff) | |
| parent | 4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 (diff) | |
Merge origin/main into shader-309-wave64-lds-limit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
| -rw-r--r-- | runtime/test/device_proxy_test.cpp | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp index e414f155b..70cae9a89 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp | |||
| @@ -151,19 +151,19 @@ int main() { | |||
| 151 | unsigned slots = rt::d3d12_xs::device_proxy_slot_count(device.Get()); | 151 | unsigned slots = rt::d3d12_xs::device_proxy_slot_count(device.Get()); |
| 152 | std::printf("proxy forwards %u PC vtable slots (ID3D12Device..Device14 max is 83)\n", slots); | 152 | std::printf("proxy forwards %u PC vtable slots (ID3D12Device..Device14 max is 83)\n", slots); |
| 153 | check(slots >= 44, "proxy forwards at least the base ID3D12Device vtable"); | 153 | check(slots >= 44, "proxy forwards at least the base ID3D12Device vtable"); |
| 154 | check(!rt::d3d12_xs::device_slot_overridden(9), "device slot 9 is forwarded (PC CreateCommandAllocator)"); | 154 | check(rt::d3d12_xs::device_slot_overridden(9), "device slot 9 is CreateCommandAllocator (allocator proxies)"); |
| 155 | check(!rt::d3d12_xs::device_slot_overridden(10), "device slot 10 is forwarded (PC CreateGraphicsPipelineState)"); | 155 | check(!rt::d3d12_xs::device_slot_overridden(10), "device slot 10 is forwarded (PC CreateGraphicsPipelineState)"); |
| 156 | check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); | 156 | check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); |
| 157 | check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); | 157 | check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); |
| 158 | check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); | 158 | check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); |
| 159 | check(rt::d3d12_xs::device_slot_overridden(67), | 159 | check(rt::d3d12_xs::device_slot_overridden(67), |
| 160 | "device slot 67 is refused (console DeserializeComputePipelineStateX, " | 160 | "device slot 67 is the DeserializeComputePipelineStateX override (console native-code compute pipeline, not PC CreateProtectedResourceSession1)"); |
| 161 | "not PC CreateProtectedResourceSession1)"); | ||
| 162 | 161 | ||
| 163 | void** proxy_vtbl = *reinterpret_cast<void***>(device.Get()); | 162 | void** proxy_vtbl = *reinterpret_cast<void***>(device.Get()); |
| 164 | void** real_vtbl = real ? *reinterpret_cast<void***>(real) : nullptr; | 163 | void** real_vtbl = real ? *reinterpret_cast<void***>(real) : nullptr; |
| 165 | check(proxy_vtbl != nullptr && proxy_vtbl[14] != real_vtbl[14], "slot 14 thunk differs from the PC entry"); | 164 | check(proxy_vtbl != nullptr && proxy_vtbl[14] != real_vtbl[14], "slot 14 thunk differs from the PC entry"); |
| 166 | if (slots > 62) check(proxy_vtbl[62] != real_vtbl[62], "slot 62 thunk differs from PC CreateStateObject"); | 165 | if (slots > 62) check(proxy_vtbl[62] != real_vtbl[62], "slot 62 thunk differs from PC CreateStateObject"); |
| 166 | if (slots > 67) check(proxy_vtbl[67] != real_vtbl[67], "slot 67 thunk differs from PC CreateProtectedResourceSession1"); | ||
| 167 | if (slots > 76) check(proxy_vtbl[76] != real_vtbl[76], "slot 76 thunk differs from PC CreateCommittedResource3"); | 167 | if (slots > 76) check(proxy_vtbl[76] != real_vtbl[76], "slot 76 thunk differs from PC CreateCommittedResource3"); |
| 168 | 168 | ||
| 169 | rt::d3d12_xs::reset_device_proxy_stats(); | 169 | rt::d3d12_xs::reset_device_proxy_stats(); |
| @@ -278,6 +278,8 @@ int main() { | |||
| 278 | ComPtr<ID3D12CommandAllocator> allocator; | 278 | ComPtr<ID3D12CommandAllocator> allocator; |
| 279 | hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(allocator.GetAddressOf())); | 279 | hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(allocator.GetAddressOf())); |
| 280 | check(SUCCEEDED(hr) && allocator != nullptr, "device slot 9 forwards CreateCommandAllocator"); | 280 | check(SUCCEEDED(hr) && allocator != nullptr, "device slot 9 forwards CreateCommandAllocator"); |
| 281 | // A PC runtime allocator is not wrapped: the PC runtime's lists could not resolve an allocator proxy. | ||
| 282 | check(!rt::d3d12_xs::is_allocator_proxy(allocator.Get()), "slot 9 hands out the PC allocator unwrapped"); | ||
| 281 | check(rt::d3d12_xs::device_slot_hits(9) == 1, "slot 9 hit counter is 1"); | 283 | check(rt::d3d12_xs::device_slot_hits(9) == 1, "slot 9 hit counter is 1"); |
| 282 | 284 | ||
| 283 | // Slot 76: buffer resource with the measured Xbox layout word 0x101; PC committed resources take ROW_MAJOR. | 285 | // Slot 76: buffer resource with the measured Xbox layout word 0x101; PC committed resources take ROW_MAJOR. |
| @@ -342,6 +344,31 @@ int main() { | |||
| 342 | check(SUCCEEDED(hr) && pso != nullptr, "slot 62 creates a compute PSO via CreateComputePipelineState"); | 344 | check(SUCCEEDED(hr) && pso != nullptr, "slot 62 creates a compute PSO via CreateComputePipelineState"); |
| 343 | check(rt::d3d12_xs::device_slot_hits(62) == 1, "slot 62 hit counter is 1"); | 345 | check(rt::d3d12_xs::device_slot_hits(62) == 1, "slot 62 hit counter is 1"); |
| 344 | check(rt::d3d12_xs::device_slot_first_call_seen(62), "slot 62 first-call flag is set"); | 346 | check(rt::d3d12_xs::device_slot_first_call_seen(62), "slot 62 first-call flag is set"); |
| 347 | |||
| 348 | // Slot 67: Xbox native compute pipeline creation. Maps the console descriptor (+0x00 root signature, | ||
| 349 | // +0x28 kind 6 code blob, +0x30 code size) to D3D12_COMPUTE_PIPELINE_STATE_DESC and calls CreateComputePipelineState. | ||
| 350 | struct XboxNativeComputeDesc { | ||
| 351 | ID3D12RootSignature* root_signature; | ||
| 352 | const void* kind0; | ||
| 353 | std::uint64_t kind0_size; | ||
| 354 | const void* kind1; | ||
| 355 | std::uint64_t kind1_size; | ||
| 356 | const void* kind6; | ||
| 357 | std::uint64_t kind6_size; | ||
| 358 | const void* kind7; | ||
| 359 | std::uint64_t kind7_size; | ||
| 360 | } xbox_desc{}; | ||
| 361 | xbox_desc.root_signature = root_signature.Get(); | ||
| 362 | xbox_desc.kind6 = bytecode->GetBufferPointer(); | ||
| 363 | xbox_desc.kind6_size = bytecode->GetBufferSize(); | ||
| 364 | |||
| 365 | using XboxCreateNativeComputePsoFn = HRESULT(WINAPI*)(void*, const void*, const IID*, void**); | ||
| 366 | auto create_native_pso = reinterpret_cast<XboxCreateNativeComputePsoFn>(proxy_vtbl[67]); | ||
| 367 | ComPtr<ID3D12PipelineState> pso67; | ||
| 368 | hr = create_native_pso(device.Get(), &xbox_desc, &iid_pso, reinterpret_cast<void**>(pso67.GetAddressOf())); | ||
| 369 | check(SUCCEEDED(hr) && pso67 != nullptr, "slot 67 creates a compute PSO via CreateComputePipelineState"); | ||
| 370 | check(rt::d3d12_xs::device_slot_hits(67) == 1, "slot 67 hit counter is 1"); | ||
| 371 | check(rt::d3d12_xs::device_slot_first_call_seen(67), "slot 67 first-call flag is set"); | ||
| 345 | } | 372 | } |
| 346 | 373 | ||
| 347 | // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, | 374 | // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, |
| @@ -357,6 +384,14 @@ int main() { | |||
| 357 | D3D12_COMPUTE_PIPELINE_STATE_DESC empty_pso{}; | 384 | D3D12_COMPUTE_PIPELINE_STATE_DESC empty_pso{}; |
| 358 | hr = reinterpret_cast<Slot62Fn>(proxy_vtbl[62])(device.Get(), &empty_pso, 0, 0, nullptr, &proxy_out); | 385 | hr = reinterpret_cast<Slot62Fn>(proxy_vtbl[62])(device.Get(), &empty_pso, 0, 0, nullptr, &proxy_out); |
| 359 | check(FAILED(hr) && proxy_out == nullptr, "slot 62 nulls its output for a null IID"); | 386 | check(FAILED(hr) && proxy_out == nullptr, "slot 62 nulls its output for a null IID"); |
| 387 | using Slot67Fn = HRESULT(WINAPI*)(void*, const void*, const IID*, void**); | ||
| 388 | proxy_out = reinterpret_cast<void*>(0x1111); | ||
| 389 | const IID iid_pso = __uuidof(ID3D12PipelineState); | ||
| 390 | hr = reinterpret_cast<Slot67Fn>(proxy_vtbl[67])(device.Get(), nullptr, &iid_pso, &proxy_out); | ||
| 391 | check(FAILED(hr) && proxy_out == nullptr, "slot 67 nulls its output for a null description"); | ||
| 392 | proxy_out = reinterpret_cast<void*>(0x1111); | ||
| 393 | hr = reinterpret_cast<Slot67Fn>(proxy_vtbl[67])(device.Get(), &root_desc, nullptr, &proxy_out); | ||
| 394 | check(FAILED(hr) && proxy_out == nullptr, "slot 67 nulls its output for a null IID"); | ||
| 360 | using Slot76Fn = HRESULT(WINAPI*)(void*, const D3D12_HEAP_PROPERTIES*, D3D12_HEAP_FLAGS, | 395 | using Slot76Fn = HRESULT(WINAPI*)(void*, const D3D12_HEAP_PROPERTIES*, D3D12_HEAP_FLAGS, |
| 361 | const D3D12_RESOURCE_DESC*, D3D12_RESOURCE_STATES, | 396 | const D3D12_RESOURCE_DESC*, D3D12_RESOURCE_STATES, |
| 362 | const D3D12_CLEAR_VALUE*, const IID*, void**); | 397 | const D3D12_CLEAR_VALUE*, const IID*, void**); |