diff options
| author | justr4mzi <243612488+justr4mzi@users.noreply.github.com> | 2026-11-23 17:26:35 +0100 |
|---|---|---|
| committer | justr4mzi <243612488+justr4mzi@users.noreply.github.com> | 2026-11-23 17:26:35 +0100 |
| commit | a2efc80b9335a039332f5f357b5d77654c6f8c21 (patch) | |
| tree | d25ccf9e846c5bbe39ff025eedb18d9aa5c55875 /runtime/test/device_proxy_test.cpp | |
| parent | dc29ee3471cebae19bac20226d2b798f319c95c3 (diff) | |
d3d12_xs: use 56-byte D3D12_RESOURCE_DESC stride for slot 108 descriptor array
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
| -rw-r--r-- | runtime/test/device_proxy_test.cpp | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp index 65f6d6110..31918dd82 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp | |||
| @@ -480,43 +480,58 @@ int main(int argc, char** argv) { | |||
| 480 | check(rt::d3d12_xs::device_slot_hits(101) == 1, "slot 101 hit counter is 1"); | 480 | check(rt::d3d12_xs::device_slot_hits(101) == 1, "slot 101 hit counter is 1"); |
| 481 | } | 481 | } |
| 482 | 482 | ||
| 483 | // Slot 108: GetResourceAllocationInfo2(ret, this, visible_mask, count, descs, info1) with C-ABI struct return | 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). | 484 | // 56-byte D3D12_RESOURCE_DESC entries, and Xbox layout/flag words, compared against direct PC |
| 485 | // ID3D12Device8::GetResourceAllocationInfo2 (PC slot 68). | ||
| 485 | if (slots > 68) { | 486 | if (slots > 68) { |
| 486 | ComPtr<ID3D12Device8> real_device8; | 487 | ComPtr<ID3D12Device8> real_device8; |
| 487 | if (real && SUCCEEDED(real->QueryInterface(IID_PPV_ARGS(real_device8.GetAddressOf()))) && real_device8) { | 488 | if (real && SUCCEEDED(real->QueryInterface(IID_PPV_ARGS(real_device8.GetAddressOf()))) && real_device8) { |
| 488 | D3D12_RESOURCE_DESC1 xbox_rt{}; | 489 | D3D12_RESOURCE_DESC xbox_descs[2]{}; |
| 489 | xbox_rt.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; | 490 | xbox_descs[0].Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; |
| 490 | xbox_rt.Width = 64; | 491 | xbox_descs[0].Width = 64; |
| 491 | xbox_rt.Height = 64; | 492 | xbox_descs[0].Height = 64; |
| 492 | xbox_rt.DepthOrArraySize = 1; | 493 | xbox_descs[0].DepthOrArraySize = 1; |
| 493 | xbox_rt.MipLevels = 1; | 494 | xbox_descs[0].MipLevels = 1; |
| 494 | xbox_rt.Format = DXGI_FORMAT_R8G8B8A8_UNORM; | 495 | xbox_descs[0].Format = DXGI_FORMAT_R8G8B8A8_UNORM; |
| 495 | xbox_rt.SampleDesc.Count = 1; | 496 | xbox_descs[0].SampleDesc.Count = 1; |
| 496 | xbox_rt.Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x105); | 497 | xbox_descs[0].Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x105); |
| 497 | xbox_rt.Flags = static_cast<D3D12_RESOURCE_FLAGS>( | 498 | xbox_descs[0].Flags = static_cast<D3D12_RESOURCE_FLAGS>( |
| 498 | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | 0x300000u); | 499 | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS | 0x300000u); |
| 499 | 500 | xbox_descs[1].Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; | |
| 500 | D3D12_RESOURCE_DESC1 pc_rt = xbox_rt; | 501 | xbox_descs[1].Width = 4096; |
| 501 | pc_rt.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; | 502 | xbox_descs[1].Height = 1; |
| 502 | pc_rt.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; | 503 | xbox_descs[1].DepthOrArraySize = 1; |
| 503 | 504 | xbox_descs[1].MipLevels = 1; | |
| 504 | D3D12_RESOURCE_ALLOCATION_INFO1 pc_info1{}; | 505 | xbox_descs[1].SampleDesc.Count = 1; |
| 506 | xbox_descs[1].Layout = static_cast<D3D12_TEXTURE_LAYOUT>(0x101); | ||
| 507 | xbox_descs[1].Flags = static_cast<D3D12_RESOURCE_FLAGS>(0x200000u); | ||
| 508 | |||
| 509 | D3D12_RESOURCE_DESC1 pc_descs[2]{}; | ||
| 510 | std::memcpy(&pc_descs[0], &xbox_descs[0], sizeof(D3D12_RESOURCE_DESC)); | ||
| 511 | pc_descs[0].SamplerFeedbackMipRegion = {}; | ||
| 512 | pc_descs[0].Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; | ||
| 513 | pc_descs[0].Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; | ||
| 514 | std::memcpy(&pc_descs[1], &xbox_descs[1], sizeof(D3D12_RESOURCE_DESC)); | ||
| 515 | pc_descs[1].SamplerFeedbackMipRegion = {}; | ||
| 516 | pc_descs[1].Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; | ||
| 517 | pc_descs[1].Flags = D3D12_RESOURCE_FLAG_NONE; | ||
| 518 | |||
| 519 | D3D12_RESOURCE_ALLOCATION_INFO1 pc_info1[2]{}; | ||
| 505 | const D3D12_RESOURCE_ALLOCATION_INFO pc_info = | 520 | const D3D12_RESOURCE_ALLOCATION_INFO pc_info = |
| 506 | real_device8->GetResourceAllocationInfo2(1, 1, &pc_rt, &pc_info1); | 521 | real_device8->GetResourceAllocationInfo2(1, 2, pc_descs, pc_info1); |
| 507 | 522 | ||
| 508 | using XboxGetAllocInfo2CAbiFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)( | 523 | using XboxGetAllocInfo2CAbiFn = D3D12_RESOURCE_ALLOCATION_INFO*(WINAPI*)( |
| 509 | D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT, const D3D12_RESOURCE_DESC1*, | 524 | D3D12_RESOURCE_ALLOCATION_INFO*, void*, UINT, UINT, const D3D12_RESOURCE_DESC*, |
| 510 | D3D12_RESOURCE_ALLOCATION_INFO1*); | 525 | D3D12_RESOURCE_ALLOCATION_INFO1*); |
| 511 | auto get_alloc_info2 = reinterpret_cast<XboxGetAllocInfo2CAbiFn>(proxy_vtbl[108]); | 526 | auto get_alloc_info2 = reinterpret_cast<XboxGetAllocInfo2CAbiFn>(proxy_vtbl[108]); |
| 512 | D3D12_RESOURCE_ALLOCATION_INFO xbox_info{}; | 527 | D3D12_RESOURCE_ALLOCATION_INFO xbox_info{}; |
| 513 | D3D12_RESOURCE_ALLOCATION_INFO1 xbox_info1{}; | 528 | D3D12_RESOURCE_ALLOCATION_INFO1 xbox_info1[2]{}; |
| 514 | D3D12_RESOURCE_ALLOCATION_INFO* ret_ptr = | 529 | D3D12_RESOURCE_ALLOCATION_INFO* ret_ptr = |
| 515 | get_alloc_info2(&xbox_info, device.Get(), 1, 1, &xbox_rt, &xbox_info1); | 530 | get_alloc_info2(&xbox_info, device.Get(), 1, 2, xbox_descs, xbox_info1); |
| 516 | check(ret_ptr == &xbox_info && xbox_info.SizeInBytes == pc_info.SizeInBytes && | 531 | check(ret_ptr == &xbox_info && xbox_info.SizeInBytes == pc_info.SizeInBytes && |
| 517 | xbox_info.Alignment == pc_info.Alignment && xbox_info1.SizeInBytes == pc_info1.SizeInBytes && | 532 | xbox_info.Alignment == pc_info.Alignment && xbox_info1[0].SizeInBytes == pc_info1[0].SizeInBytes && |
| 518 | xbox_info1.Alignment == pc_info1.Alignment, | 533 | xbox_info1[1].SizeInBytes == pc_info1[1].SizeInBytes, |
| 519 | "slot 108 C-ABI GetResourceAllocationInfo2 with Xbox layout/flags matches PC Device8"); | 534 | "slot 108 C-ABI GetResourceAllocationInfo2 with 56-byte Xbox descs matches PC Device8"); |
| 520 | check(rt::d3d12_xs::device_slot_hits(108) == 1, "slot 108 hit counter is 1"); | 535 | check(rt::d3d12_xs::device_slot_hits(108) == 1, "slot 108 hit counter is 1"); |
| 521 | } | 536 | } |
| 522 | } | 537 | } |