diff options
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 6242d1b52..1c1707243 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp | |||
| @@ -161,6 +161,9 @@ int main(int argc, char** argv) { | |||
| 161 | check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); | 161 | check(rt::d3d12_xs::device_slot_overridden(14), "device slot 14 is the descriptor-heap override"); |
| 162 | check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); | 162 | check(rt::d3d12_xs::device_slot_overridden(62), "device slot 62 is the compute-PSO override"); |
| 163 | check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); | 163 | check(rt::d3d12_xs::device_slot_overridden(76), "device slot 76 is the resource override"); |
| 164 | check(rt::d3d12_xs::device_slot_overridden(86), "device slot 86 is the CreatePipelineState override"); | ||
| 165 | check(rt::d3d12_xs::device_slot_overridden(101), "device slot 101 is the CreateStateObject override"); | ||
| 166 | check(rt::d3d12_xs::device_slot_overridden(108), "device slot 108 is the GetResourceAllocationInfo2 override"); | ||
| 164 | check(rt::d3d12_xs::device_slot_overridden(67), | 167 | check(rt::d3d12_xs::device_slot_overridden(67), |
| 165 | "device slot 67 is the DeserializeComputePipelineStateX override (console native-code compute pipeline, not PC CreateProtectedResourceSession1)"); | 168 | "device slot 67 is the DeserializeComputePipelineStateX override (console native-code compute pipeline, not PC CreateProtectedResourceSession1)"); |
| 166 | 169 | ||
| @@ -521,6 +524,101 @@ int main(int argc, char** argv) { | |||
| 521 | check(SUCCEEDED(hr) && pso67 != nullptr, "slot 67 creates a compute PSO via CreateComputePipelineState"); | 524 | check(SUCCEEDED(hr) && pso67 != nullptr, "slot 67 creates a compute PSO via CreateComputePipelineState"); |
| 522 | check(rt::d3d12_xs::device_slot_hits(67) == 1, "slot 67 hit counter is 1"); | 525 | check(rt::d3d12_xs::device_slot_hits(67) == 1, "slot 67 hit counter is 1"); |
| 523 | check(rt::d3d12_xs::device_slot_first_call_seen(67), "slot 67 first-call flag is set"); | 526 | check(rt::d3d12_xs::device_slot_first_call_seen(67), "slot 67 first-call flag is set"); |
| 527 | |||
| 528 | // Slot 86: CreatePipelineState(const D3D12_PIPELINE_STATE_STREAM_DESC*, REFIID, void**), forwarded to PC | ||
| 529 | // ID3D12Device2::CreatePipelineState (PC slot 47). | ||
| 530 | if (slots > 47) { | ||
| 531 | struct alignas(void*) ComputeStream { | ||
| 532 | alignas(void*) D3D12_PIPELINE_STATE_SUBOBJECT_TYPE root_type = | ||
| 533 | D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE; | ||
| 534 | ID3D12RootSignature* root_sig = nullptr; | ||
| 535 | alignas(void*) D3D12_PIPELINE_STATE_SUBOBJECT_TYPE cs_type = D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS; | ||
| 536 | D3D12_SHADER_BYTECODE cs{}; | ||
| 537 | } stream; | ||
| 538 | stream.root_sig = root_signature.Get(); | ||
| 539 | stream.cs.pShaderBytecode = bytecode->GetBufferPointer(); | ||
| 540 | stream.cs.BytecodeLength = bytecode->GetBufferSize(); | ||
| 541 | D3D12_PIPELINE_STATE_STREAM_DESC stream_desc{sizeof(stream), &stream}; | ||
| 542 | using XboxCreatePipelineStateFn = | ||
| 543 | HRESULT(WINAPI*)(void*, const D3D12_PIPELINE_STATE_STREAM_DESC*, const IID*, void**); | ||
| 544 | auto create_stream_pso = reinterpret_cast<XboxCreatePipelineStateFn>(proxy_vtbl[86]); | ||
| 545 | ComPtr<ID3D12PipelineState> pso86; | ||
| 546 | hr = create_stream_pso(device.Get(), &stream_desc, &iid_pso, | ||
| 547 | reinterpret_cast<void**>(pso86.GetAddressOf())); | ||
| 548 | check(SUCCEEDED(hr) && pso86 != nullptr, | ||
| 549 | "slot 86 creates a PSO via PC ID3D12Device2::CreatePipelineState (slot 47)"); | ||
| 550 | check(rt::d3d12_xs::device_slot_hits(86) == 1, "slot 86 hit counter is 1"); | ||
| 551 | check(rt::d3d12_xs::device_slot_first_call_seen(86), "slot 86 first-call flag is set"); | ||
| 552 | } | ||
| 553 | } | ||
| 554 | |||
| 555 | // Slot 101: CreateStateObject(const D3D12_STATE_OBJECT_DESC*, REFIID, void**), forwarded to PC | ||
| 556 | // ID3D12Device5::CreateStateObject (PC slot 62). | ||
| 557 | if (slots > 62) { | ||
| 558 | using XboxCreateStateObjectFn = HRESULT(WINAPI*)(void*, const D3D12_STATE_OBJECT_DESC*, const IID*, void**); | ||
| 559 | auto create_state_object = reinterpret_cast<XboxCreateStateObjectFn>(proxy_vtbl[101]); | ||
| 560 | D3D12_STATE_OBJECT_DESC empty_so{}; | ||
| 561 | empty_so.Type = D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE; | ||
| 562 | void* so_out = reinterpret_cast<void*>(0x1111); | ||
| 563 | hr = create_state_object(device.Get(), &empty_so, nullptr, &so_out); | ||
| 564 | check(hr == E_POINTER && so_out == nullptr, "slot 101 nulls its output for a null IID"); | ||
| 565 | check(rt::d3d12_xs::device_slot_hits(101) == 1, "slot 101 hit counter is 1"); | ||
| 566 | } | ||
| 567 | |||
| 568 | // Slot 108: GetResourceAllocationInfo2(ret, this, visible_mask, count, descs, info1) with C-ABI struct return, | ||
| 569 | // 56-byte D3D12_RESOURCE_DESC entries, and Xbox layout/flag words, compared against direct PC | ||
| 570 | // ID3D12Device8::GetResourceAllocationInfo2 (PC slot 68). | ||
| 571 | if (slots > 68) { | ||
| 572 | ComPtr<ID3D12Device8> real_device8; | ||
| 573 | if (real && SUCCEEDED(real->QueryInterface(IID_PPV_ARGS(real_device8.GetAddressOf()))) && real_device8) { | ||
| 574 | D3D12_RESOURCE_DESC xbox_descs[2]{}; | ||
| 575 | xbox_descs[0].Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; | ||
| 576 | xbox_descs[0].Width = 64; | ||
| 577 | xbox_descs[0].Height = 64; | ||
| 578 | xbox_descs[0].DepthOrArraySize = 1; | ||
| 579 | xbox_descs[0].MipLevels = 1; | ||
| 580 | xbox_descs[0].Format = DXGI_FORMAT_R8G8B8A8_UNORM; | ||
| 581 | xbox_descs[0].SampleDesc.Count = 1; | ||
| 582 | xbox_descs[0].Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x105); | ||
| 583 | xbox_descs[0].Flags = static_cast<D3D12_RESOURCE_FLAGS>( | ||
| 584 | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | 0x300000u); | ||
| 585 | xbox_descs[1].Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; | ||
| 586 | xbox_descs[1].Width = 4096; | ||
| 587 | xbox_descs[1].Height = 1; | ||
| 588 | xbox_descs[1].DepthOrArraySize = 1; | ||
| 589 | xbox_descs[1].MipLevels = 1; | ||
| 590 | xbox_descs[1].SampleDesc.Count = 1; | ||
| 591 | xbox_descs[1].Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x101); | ||
| 592 | xbox_descs[1].Flags = static_cast<D3D12_RESOURCE_FLAGS>(0x200000u); | ||
| 593 | |||
| 594 | D3D12_RESOURCE_DESC1 pc_descs[2]{}; | ||
| 595 | std::memcpy(&pc_descs[0], &xbox_descs[0], sizeof(D3D12_RESOURCE_DESC)); | ||
| 596 | pc_descs[0].SamplerFeedbackMipRegion = {}; | ||
| 597 | pc_descs[0].Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; | ||
| 598 | pc_descs[0].Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; | ||
| 599 | std::memcpy(&pc_descs[1], &xbox_descs[1], sizeof(D3D12_RESOURCE_DESC)); | ||
| 600 | pc_descs[1].SamplerFeedbackMipRegion = {}; | ||
| 601 | pc_descs[1].Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; | ||
| 602 | pc_descs[1].Flags = D3D12_RESOURCE_FLAG_NONE; | ||
| 603 | |||
| 604 | D3D12_RESOURCE_ALLOCATION_INFO1 pc_info1[2]{}; | ||
| 605 | const D3D12_RESOURCE_ALLOCATION_INFO pc_info = | ||
| 606 | real_device8->GetResourceAllocationInfo2(1, 2, pc_descs, pc_info1); | ||
| 607 | |||
| 608 | using XboxGetAllocInfo2CAbiFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)( | ||
| 609 | D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT, const D3D12_RESOURCE_DESC*, | ||
| 610 | D3D12_RESOURCE_ALLOCATION_INFO1*); | ||
| 611 | auto get_alloc_info2 = reinterpret_cast<XboxGetAllocInfo2CAbiFn>(proxy_vtbl[108]); | ||
| 612 | D3D12_RESOURCE_ALLOCATION_INFO xbox_info{}; | ||
| 613 | D3D12_RESOURCE_ALLOCATION_INFO1 xbox_info1[2]{}; | ||
| 614 | D3D12_RESOURCE_ALLOCATION_INFO* ret_ptr = | ||
| 615 | get_alloc_info2(&xbox_info, device.Get(), 1, 2, xbox_descs, xbox_info1); | ||
| 616 | check(ret_ptr == &xbox_info && xbox_info.SizeInBytes == pc_info.SizeInBytes && | ||
| 617 | xbox_info.Alignment == pc_info.Alignment && xbox_info1[0].SizeInBytes == pc_info1[0].SizeInBytes && | ||
| 618 | xbox_info1[1].SizeInBytes == pc_info1[1].SizeInBytes, | ||
| 619 | "slot 108 C-ABI GetResourceAllocationInfo2 with 56-byte Xbox descs matches PC Device8"); | ||
| 620 | check(rt::d3d12_xs::device_slot_hits(108) == 1, "slot 108 hit counter is 1"); | ||
| 621 | } | ||
| 524 | } | 622 | } |
| 525 | 623 | ||
| 526 | // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, | 624 | // _COM_Outptr_ (d3d12.h): a failed create leaves NULL in the output. WARP accepts invalid heap descriptions, |