diff options
| author | justr4mzi <243612488+justr4mzi@users.noreply.github.com> | 2026-11-23 23:22:45 +0000 |
|---|---|---|
| committer | DesertGamer <DesertGamer@users.noreply.github.com> | 2026-11-24 18:43:05 +0400 |
| commit | e9a13181f4b5e84a860dada2fc18055c519e5627 (patch) | |
| tree | f7d323b5bd20fe9369750285a44c39e9710dddf5 /runtime/test/device_proxy_test.cpp | |
| parent | f3e26be7c661e97eb4c70464e675a3b32dc149e3 (diff) | |
d3d12_xs: route device slots 86, 101, and 108 to PC Device2/Device5/Device8
Reopened from #7201 (closed in the PR reset), rebased on current main.
Slot 86 (CreatePipelineState stream) -> PC slot 47, slot 101
(CreateStateObject) -> PC slot 62, slot 108 (GetResourceAllocationInfo2)
-> PC slot 68. Slot 108 accepts the console C-ABI order (return buffer
first) and the PC order, reads the title's 56-byte D3D12_RESOURCE_DESC
entries, expands each into a zeroed D3D12_RESOURCE_DESC1, normalizes
Xbox layout words and flag bits, and refuses a count with a null array.
Rebase: kept main's slot 133 (CreatePlacedResourceX) next to the new
slots, and slot 108 now masks flags with slot 133's PC set (0x5FF, which
keeps USE_TIGHT_ALIGNMENT and drops 0x200) instead of 0x1FF.
(cherry picked from commit 1b07215c84443b87ad152ffdc8d23b0356125456)
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
| -rw-r--r-- | runtime/test/device_proxy_test.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp index b3b3f0fc3..1c68dc5da 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp | |||
| @@ -160,6 +160,9 @@ int main(int argc, char** argv) { | |||
| 160 | check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); | 160 | check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); |
| 161 | check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); | 161 | check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); |
| 162 | check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); | 162 | check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); |
| 163 | check(rt::d3d12_xs::device_slot_overridden(86), "device slot 86 is the CreatePipelineState override"); | ||
| 164 | check(rt::d3d12_xs::device_slot_overridden(101), "device slot 101 is the CreateStateObject override"); | ||
| 165 | check(rt::d3d12_xs::device_slot_overridden(108), "device slot 108 is the GetResourceAllocationInfo2 override"); | ||
| 163 | check(rt::d3d12_xs::device_slot_overridden(67), | 166 | check(rt::d3d12_xs::device_slot_overridden(67), |
| 164 | "device slot 67 is the DeserializeComputePipelineStateX override (console native-code compute pipeline, not PC CreateProtectedResourceSession1)"); | 167 | "device slot 67 is the DeserializeComputePipelineStateX override (console native-code compute pipeline, not PC CreateProtectedResourceSession1)"); |
| 165 | 168 | ||
| @@ -516,6 +519,101 @@ int main(int argc, char** argv) { | |||
| 516 | check(SUCCEEDED(hr) && pso67 != nullptr, "slot 67 creates a compute PSO via CreateComputePipelineState"); | 519 | check(SUCCEEDED(hr) && pso67 != nullptr, "slot 67 creates a compute PSO via CreateComputePipelineState"); |
| 517 | check(rt::d3d12_xs::device_slot_hits(67) == 1, "slot 67 hit counter is 1"); | 520 | check(rt::d3d12_xs::device_slot_hits(67) == 1, "slot 67 hit counter is 1"); |
| 518 | check(rt::d3d12_xs::device_slot_first_call_seen(67), "slot 67 first-call flag is set"); | 521 | check(rt::d3d12_xs::device_slot_first_call_seen(67), "slot 67 first-call flag is set"); |
| 522 | |||
| 523 | // Slot 86: CreatePipelineState(const D3D12_PIPELINE_STATE_STREAM_DESC*, REFIID, void**), forwarded to PC | ||
| 524 | // ID3D12Device2::CreatePipelineState (PC slot 47). | ||
| 525 | if (slots > 47) { | ||
| 526 | struct alignas(void*) ComputeStream { | ||
| 527 | alignas(void*) D3D12_PIPELINE_STATE_SUBOBJECT_TYPE root_type = | ||
| 528 | D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE; | ||
| 529 | ID3D12RootSignature* root_sig = nullptr; | ||
| 530 | alignas(void*) D3D12_PIPELINE_STATE_SUBOBJECT_TYPE cs_type = D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS; | ||
| 531 | D3D12_SHADER_BYTECODE cs{}; | ||
| 532 | } stream; | ||
| 533 | stream.root_sig = root_signature.Get(); | ||
| 534 | stream.cs.pShaderBytecode = bytecode->GetBufferPointer(); | ||
| 535 | stream.cs.BytecodeLength = bytecode->GetBufferSize(); | ||
| 536 | D3D12_PIPELINE_STATE_STREAM_DESC stream_desc{sizeof(stream), &stream}; | ||
| 537 | using XboxCreatePipelineStateFn = | ||
| 538 | HRESULT(WINAPI*)(void*, const D3D12_PIPELINE_STATE_STREAM_DESC*, const IID*, void**); | ||
| 539 | auto create_stream_pso = reinterpret_cast<XboxCreatePipelineStateFn>(proxy_vtbl[86]); | ||
| 540 | ComPtr<ID3D12PipelineState> pso86; | ||
| 541 | hr = create_stream_pso(device.Get(), &stream_desc, &iid_pso, | ||
| 542 | reinterpret_cast<void**>(pso86.GetAddressOf())); | ||
| 543 | check(SUCCEEDED(hr) && pso86 != nullptr, | ||
| 544 | "slot 86 creates a PSO via PC ID3D12Device2::CreatePipelineState (slot 47)"); | ||
| 545 | check(rt::d3d12_xs::device_slot_hits(86) == 1, "slot 86 hit counter is 1"); | ||
| 546 | check(rt::d3d12_xs::device_slot_first_call_seen(86), "slot 86 first-call flag is set"); | ||
| 547 | } | ||
| 548 | } | ||
| 549 | |||
| 550 | // Slot 101: CreateStateObject(const D3D12_STATE_OBJECT_DESC*, REFIID, void**), forwarded to PC | ||
| 551 | // ID3D12Device5::CreateStateObject (PC slot 62). | ||
| 552 | if (slots > 62) { | ||
| 553 | using XboxCreateStateObjectFn = HRESULT(WINAPI*)(void*, const D3D12_STATE_OBJECT_DESC*, const IID*, void**); | ||
| 554 | auto create_state_object = reinterpret_cast<XboxCreateStateObjectFn>(proxy_vtbl[101]); | ||
| 555 | D3D12_STATE_OBJECT_DESC empty_so{}; | ||
| 556 | empty_so.Type = D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE; | ||
| 557 | void* so_out = reinterpret_cast<void*>(0x1111); | ||
| 558 | hr = create_state_object(device.Get(), &empty_so, nullptr, &so_out); | ||
| 559 | check(hr == E_POINTER && so_out == nullptr, "slot 101 nulls its output for a null IID"); | ||
| 560 | check(rt::d3d12_xs::device_slot_hits(101) == 1, "slot 101 hit counter is 1"); | ||
| 561 | } | ||
| 562 | |||
| 563 | // Slot 108: GetResourceAllocationInfo2(ret, this, visible_mask, count, descs, info1) with C-ABI struct return, | ||
| 564 | // 56-byte D3D12_RESOURCE_DESC entries, and Xbox layout/flag words, compared against direct PC | ||
| 565 | // ID3D12Device8::GetResourceAllocationInfo2 (PC slot 68). | ||
| 566 | if (slots > 68) { | ||
| 567 | ComPtr<ID3D12Device8> real_device8; | ||
| 568 | if (real && SUCCEEDED(real->QueryInterface(IID_PPV_ARGS(real_device8.GetAddressOf()))) && real_device8) { | ||
| 569 | D3D12_RESOURCE_DESC xbox_descs[2]{}; | ||
| 570 | xbox_descs[0].Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; | ||
| 571 | xbox_descs[0].Width = 64; | ||
| 572 | xbox_descs[0].Height = 64; | ||
| 573 | xbox_descs[0].DepthOrArraySize = 1; | ||
| 574 | xbox_descs[0].MipLevels = 1; | ||
| 575 | xbox_descs[0].Format = DXGI_FORMAT_R8G8B8A8_UNORM; | ||
| 576 | xbox_descs[0].SampleDesc.Count = 1; | ||
| 577 | xbox_descs[0].Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x105); | ||
| 578 | xbox_descs[0].Flags = static_cast<D3D12_RESOURCE_FLAGS>( | ||
| 579 | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | 0x300000u); | ||
| 580 | xbox_descs[1].Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; | ||
| 581 | xbox_descs[1].Width = 4096; | ||
| 582 | xbox_descs[1].Height = 1; | ||
| 583 | xbox_descs[1].DepthOrArraySize = 1; | ||
| 584 | xbox_descs[1].MipLevels = 1; | ||
| 585 | xbox_descs[1].SampleDesc.Count = 1; | ||
| 586 | xbox_descs[1].Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x101); | ||
| 587 | xbox_descs[1].Flags = static_cast<D3D12_RESOURCE_FLAGS>(0x200000u); | ||
| 588 | |||
| 589 | D3D12_RESOURCE_DESC1 pc_descs[2]{}; | ||
| 590 | std::memcpy(&pc_descs[0], &xbox_descs[0], sizeof(D3D12_RESOURCE_DESC)); | ||
| 591 | pc_descs[0].SamplerFeedbackMipRegion = {}; | ||
| 592 | pc_descs[0].Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; | ||
| 593 | pc_descs[0].Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; | ||
| 594 | std::memcpy(&pc_descs[1], &xbox_descs[1], sizeof(D3D12_RESOURCE_DESC)); | ||
| 595 | pc_descs[1].SamplerFeedbackMipRegion = {}; | ||
| 596 | pc_descs[1].Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; | ||
| 597 | pc_descs[1].Flags = D3D12_RESOURCE_FLAG_NONE; | ||
| 598 | |||
| 599 | D3D12_RESOURCE_ALLOCATION_INFO1 pc_info1[2]{}; | ||
| 600 | const D3D12_RESOURCE_ALLOCATION_INFO pc_info = | ||
| 601 | real_device8->GetResourceAllocationInfo2(1, 2, pc_descs, pc_info1); | ||
| 602 | |||
| 603 | using XboxGetAllocInfo2CAbiFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)( | ||
| 604 | D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT, const D3D12_RESOURCE_DESC*, | ||
| 605 | D3D12_RESOURCE_ALLOCATION_INFO1*); | ||
| 606 | auto get_alloc_info2 = reinterpret_cast<XboxGetAllocInfo2CAbiFn>(proxy_vtbl[108]); | ||
| 607 | D3D12_RESOURCE_ALLOCATION_INFO xbox_info{}; | ||
| 608 | D3D12_RESOURCE_ALLOCATION_INFO1 xbox_info1[2]{}; | ||
| 609 | D3D12_RESOURCE_ALLOCATION_INFO* ret_ptr = | ||
| 610 | get_alloc_info2(&xbox_info, device.Get(), 1, 2, xbox_descs, xbox_info1); | ||
| 611 | check(ret_ptr == &xbox_info && xbox_info.SizeInBytes == pc_info.SizeInBytes && | ||
| 612 | xbox_info.Alignment == pc_info.Alignment && xbox_info1[0].SizeInBytes == pc_info1[0].SizeInBytes && | ||
| 613 | xbox_info1[1].SizeInBytes == pc_info1[1].SizeInBytes, | ||
| 614 | "slot 108 C-ABI GetResourceAllocationInfo2 with 56-byte Xbox descs matches PC Device8"); | ||
| 615 | check(rt::d3d12_xs::device_slot_hits(108) == 1, "slot 108 hit counter is 1"); | ||
| 616 | } | ||
| 519 | } | 617 | } |
| 520 | 618 | ||
| 521 | // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, | 619 | // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, |