diff options
| author | justr4mzi <243612488+justr4mzi@users.noreply.github.com> | 2026-11-23 17:10:24 +0100 |
|---|---|---|
| committer | justr4mzi <243612488+justr4mzi@users.noreply.github.com> | 2026-11-23 17:10:24 +0100 |
| commit | dc29ee3471cebae19bac20226d2b798f319c95c3 (patch) | |
| tree | 52872cb4c65e756a5ef69a8c47c766d9d9f10b91 /runtime/test/device_proxy_test.cpp | |
| parent | d239fd8556ba3289a2e1ddbd33db1702305ffc62 (diff) | |
d3d12_xs: route device slots 86, 101, and 108 to PC Device2/Device5/Device8
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
| -rw-r--r-- | runtime/test/device_proxy_test.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp index 46a853e7c..65f6d6110 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp | |||
| @@ -159,6 +159,9 @@ int main(int argc, char** argv) { | |||
| 159 | check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); | 159 | check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); |
| 160 | check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); | 160 | check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); |
| 161 | check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); | 161 | check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); |
| 162 | check(rt::d3d12_xs::device_slot_overridden(86), "device slot 86 is the CreatePipelineState override"); | ||
| 163 | check(rt::d3d12_xs::device_slot_overridden(101), "device slot 101 is the CreateStateObject override"); | ||
| 164 | check(rt::d3d12_xs::device_slot_overridden(108), "device slot 108 is the GetResourceAllocationInfo2 override"); | ||
| 162 | check(rt::d3d12_xs::device_slot_overridden(67), | 165 | check(rt::d3d12_xs::device_slot_overridden(67), |
| 163 | "device slot 67 is the DeserializeComputePipelineStateX override (console native-code compute pipeline, not PC CreateProtectedResourceSession1)"); | 166 | "device slot 67 is the DeserializeComputePipelineStateX override (console native-code compute pipeline, not PC CreateProtectedResourceSession1)"); |
| 164 | 167 | ||
| @@ -436,6 +439,86 @@ int main(int argc, char** argv) { | |||
| 436 | check(SUCCEEDED(hr) && pso67 != nullptr, "slot 67 creates a compute PSO via CreateComputePipelineState"); | 439 | check(SUCCEEDED(hr) && pso67 != nullptr, "slot 67 creates a compute PSO via CreateComputePipelineState"); |
| 437 | check(rt::d3d12_xs::device_slot_hits(67) == 1, "slot 67 hit counter is 1"); | 440 | check(rt::d3d12_xs::device_slot_hits(67) == 1, "slot 67 hit counter is 1"); |
| 438 | check(rt::d3d12_xs::device_slot_first_call_seen(67), "slot 67 first-call flag is set"); | 441 | check(rt::d3d12_xs::device_slot_first_call_seen(67), "slot 67 first-call flag is set"); |
| 442 | |||
| 443 | // Slot 86: CreatePipelineState(const D3D12_PIPELINE_STATE_STREAM_DESC*, REFIID, void**), forwarded to PC | ||
| 444 | // ID3D12Device2::CreatePipelineState (PC slot 47). | ||
| 445 | if (slots > 47) { | ||
| 446 | struct alignas(void*) ComputeStream { | ||
| 447 | alignas(void*) D3D12_PIPELINE_STATE_SUBOBJECT_TYPE root_type = | ||
| 448 | D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE; | ||
| 449 | ID3D12RootSignature* root_sig = nullptr; | ||
| 450 | alignas(void*) D3D12_PIPELINE_STATE_SUBOBJECT_TYPE cs_type = D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS; | ||
| 451 | D3D12_SHADER_BYTECODE cs{}; | ||
| 452 | } stream; | ||
| 453 | stream.root_sig = root_signature.Get(); | ||
| 454 | stream.cs.pShaderBytecode = bytecode->GetBufferPointer(); | ||
| 455 | stream.cs.BytecodeLength = bytecode->GetBufferSize(); | ||
| 456 | D3D12_PIPELINE_STATE_STREAM_DESC stream_desc{sizeof(stream), &stream}; | ||
| 457 | using XboxCreatePipelineStateFn = | ||
| 458 | HRESULT(WINAPI*)(void*, const D3D12_PIPELINE_STATE_STREAM_DESC*, const IID*, void**); | ||
| 459 | auto create_stream_pso = reinterpret_cast<XboxCreatePipelineStateFn>(proxy_vtbl[86]); | ||
| 460 | ComPtr<ID3D12PipelineState> pso86; | ||
| 461 | hr = create_stream_pso(device.Get(), &stream_desc, &iid_pso, | ||
| 462 | reinterpret_cast<void**>(pso86.GetAddressOf())); | ||
| 463 | check(SUCCEEDED(hr) && pso86 != nullptr, | ||
| 464 | "slot 86 creates a PSO via PC ID3D12Device2::CreatePipelineState (slot 47)"); | ||
| 465 | check(rt::d3d12_xs::device_slot_hits(86) == 1, "slot 86 hit counter is 1"); | ||
| 466 | check(rt::d3d12_xs::device_slot_first_call_seen(86), "slot 86 first-call flag is set"); | ||
| 467 | } | ||
| 468 | } | ||
| 469 | |||
| 470 | // Slot 101: CreateStateObject(const D3D12_STATE_OBJECT_DESC*, REFIID, void**), forwarded to PC | ||
| 471 | // ID3D12Device5::CreateStateObject (PC slot 62). | ||
| 472 | if (slots > 62) { | ||
| 473 | using XboxCreateStateObjectFn = HRESULT(WINAPI*)(void*, const D3D12_STATE_OBJECT_DESC*, const IID*, void**); | ||
| 474 | auto create_state_object = reinterpret_cast<XboxCreateStateObjectFn>(proxy_vtbl[101]); | ||
| 475 | D3D12_STATE_OBJECT_DESC empty_so{}; | ||
| 476 | empty_so.Type = D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE; | ||
| 477 | void* so_out = reinterpret_cast<void*>(0x1111); | ||
| 478 | hr = create_state_object(device.Get(), &empty_so, nullptr, &so_out); | ||
| 479 | check(hr == E_POINTER && so_out == nullptr, "slot 101 nulls its output for a null IID"); | ||
| 480 | check(rt::d3d12_xs::device_slot_hits(101) == 1, "slot 101 hit counter is 1"); | ||
| 481 | } | ||
| 482 | |||
| 483 | // Slot 108: GetResourceAllocationInfo2(ret, this, visible_mask, count, descs, info1) with C-ABI struct return | ||
| 484 | // and Xbox layout/flag words, compared against direct PC ID3D12Device8::GetResourceAllocationInfo2 (PC slot 68). | ||
| 485 | if (slots > 68) { | ||
| 486 | ComPtr<ID3D12Device8> real_device8; | ||
| 487 | if (real && SUCCEEDED(real->QueryInterface(IID_PPV_ARGS(real_device8.GetAddressOf()))) && real_device8) { | ||
| 488 | D3D12_RESOURCE_DESC1 xbox_rt{}; | ||
| 489 | xbox_rt.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; | ||
| 490 | xbox_rt.Width = 64; | ||
| 491 | xbox_rt.Height = 64; | ||
| 492 | xbox_rt.DepthOrArraySize = 1; | ||
| 493 | xbox_rt.MipLevels = 1; | ||
| 494 | xbox_rt.Format = DXGI_FORMAT_R8G8B8A8_UNORM; | ||
| 495 | xbox_rt.SampleDesc.Count = 1; | ||
| 496 | xbox_rt.Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x105); | ||
| 497 | xbox_rt.Flags = static_cast<D3D12_RESOURCE_FLAGS>( | ||
| 498 | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | 0x300000u); | ||
| 499 | |||
| 500 | D3D12_RESOURCE_DESC1 pc_rt = xbox_rt; | ||
| 501 | pc_rt.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; | ||
| 502 | pc_rt.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; | ||
| 503 | |||
| 504 | D3D12_RESOURCE_ALLOCATION_INFO1 pc_info1{}; | ||
| 505 | const D3D12_RESOURCE_ALLOCATION_INFO pc_info = | ||
| 506 | real_device8->GetResourceAllocationInfo2(1, 1, &pc_rt, &pc_info1); | ||
| 507 | |||
| 508 | using XboxGetAllocInfo2CAbiFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)( | ||
| 509 | D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT, const D3D12_RESOURCE_DESC1*, | ||
| 510 | D3D12_RESOURCE_ALLOCATION_INFO1*); | ||
| 511 | auto get_alloc_info2 = reinterpret_cast<XboxGetAllocInfo2CAbiFn>(proxy_vtbl[108]); | ||
| 512 | D3D12_RESOURCE_ALLOCATION_INFO xbox_info{}; | ||
| 513 | D3D12_RESOURCE_ALLOCATION_INFO1 xbox_info1{}; | ||
| 514 | D3D12_RESOURCE_ALLOCATION_INFO* ret_ptr = | ||
| 515 | get_alloc_info2(&xbox_info, device.Get(), 1, 1, &xbox_rt, &xbox_info1); | ||
| 516 | check(ret_ptr == &xbox_info && xbox_info.SizeInBytes == pc_info.SizeInBytes && | ||
| 517 | xbox_info.Alignment == pc_info.Alignment && xbox_info1.SizeInBytes == pc_info1.SizeInBytes && | ||
| 518 | xbox_info1.Alignment == pc_info1.Alignment, | ||
| 519 | "slot 108 C-ABI GetResourceAllocationInfo2 with Xbox layout/flags matches PC Device8"); | ||
| 520 | check(rt::d3d12_xs::device_slot_hits(108) == 1, "slot 108 hit counter is 1"); | ||
| 521 | } | ||
| 439 | } | 522 | } |
| 440 | 523 | ||
| 441 | // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, | 524 | // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, |