diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 23:11:09 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 23:11:09 -0500 |
| commit | 433f4e12e13892a447ba0742f2b0a693aabb07dc (patch) | |
| tree | 70cbfc4f317666ffee5512652a5fc8477c3034dc /runtime/test | |
| parent | ae846b5b9790df26d0c4d40cab417ab97dca8f3e (diff) | |
| parent | e01d37d65683531efa6cc1c3ac1e90c67be4a53c (diff) | |
Merge pull request #4088 from Exopus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test')
| -rw-r--r-- | runtime/test/d3d12_vulkan_device_test.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/runtime/test/d3d12_vulkan_device_test.cpp b/runtime/test/d3d12_vulkan_device_test.cpp index bcdb650d2..c6622e8d1 100644 --- a/runtime/test/d3d12_vulkan_device_test.cpp +++ b/runtime/test/d3d12_vulkan_device_test.cpp | |||
| @@ -4321,6 +4321,67 @@ int compare_heap_neighbours(ID3D12Device* ours) { | |||
| 4321 | return mismatches; | 4321 | return mismatches; |
| 4322 | } | 4322 | } |
| 4323 | 4323 | ||
| 4324 | // ID3D12Heap::GetDesc reads back as the host's for heaps of each type with each node-mask pair, on a device with the | ||
| 4325 | // GPU address arena: a node mask of 0 reads back as the one node (1), as the layer's resources, descriptor heaps and | ||
| 4326 | // queues already answer (d3d12_node_mask_test). Returns the number of mismatches, or -1 without a host. | ||
| 4327 | int compare_heap_descs(ID3D12Device* ours) { | ||
| 4328 | Ref<ID3D12Device> host; | ||
| 4329 | if (!create_host_device(host)) return -1; | ||
| 4330 | struct HeapCase { | ||
| 4331 | D3D12_HEAP_PROPERTIES properties; | ||
| 4332 | UINT64 alignment; // 0: the default | ||
| 4333 | }; | ||
| 4334 | const HeapCase heaps[] = { | ||
| 4335 | {{D3D12_HEAP_TYPE_DEFAULT}, 0}, | ||
| 4336 | {{D3D12_HEAP_TYPE_DEFAULT}, D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT}, | ||
| 4337 | {{D3D12_HEAP_TYPE_UPLOAD}, 0}, | ||
| 4338 | {{D3D12_HEAP_TYPE_READBACK}, 0}, | ||
| 4339 | {{D3D12_HEAP_TYPE_CUSTOM, D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE, D3D12_MEMORY_POOL_L0}, 0}, | ||
| 4340 | }; | ||
| 4341 | const UINT masks[][2] = {{0, 0}, {0, 1}, {1, 0}, {1, 1}}; | ||
| 4342 | int mismatches = 0; | ||
| 4343 | for (const HeapCase& heap : heaps) { | ||
| 4344 | for (const auto& mask : masks) { | ||
| 4345 | D3D12_HEAP_PROPERTIES props = heap.properties; | ||
| 4346 | props.CreationNodeMask = mask[0]; | ||
| 4347 | props.VisibleNodeMask = mask[1]; | ||
| 4348 | const D3D12_HEAP_DESC desc = heap_desc_of(heap.alignment, props, D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS, | ||
| 4349 | heap.alignment ? heap.alignment : 64 * 1024); | ||
| 4350 | Ref<ID3D12Heap> a, e; | ||
| 4351 | const HRESULT ha = ours->CreateHeap(&desc, IID_PPV_ARGS(&a.p)); | ||
| 4352 | const HRESULT he = host->CreateHeap(&desc, IID_PPV_ARGS(&e.p)); | ||
| 4353 | if (FAILED(he) || !e.p) continue; // nothing to compare | ||
| 4354 | if (FAILED(ha) || !a.p) { | ||
| 4355 | ++mismatches; | ||
| 4356 | std::fprintf(stderr, "heap GetDesc type %d align %llu masks %u/%u: the layer refused it (0x%08lx)\n", | ||
| 4357 | int(props.Type), heap.alignment, mask[0], mask[1], ha); | ||
| 4358 | continue; | ||
| 4359 | } | ||
| 4360 | const D3D12_HEAP_DESC x = a->GetDesc(), y = e->GetDesc(); | ||
| 4361 | if (x.SizeInBytes == y.SizeInBytes && x.Alignment == y.Alignment && x.Flags == y.Flags && | ||
| 4362 | x.Properties.Type == y.Properties.Type && | ||
| 4363 | x.Properties.CPUPageProperty == y.Properties.CPUPageProperty && | ||
| 4364 | x.Properties.MemoryPoolPreference == y.Properties.MemoryPoolPreference && | ||
| 4365 | x.Properties.CreationNodeMask == y.Properties.CreationNodeMask && | ||
| 4366 | x.Properties.VisibleNodeMask == y.Properties.VisibleNodeMask) | ||
| 4367 | continue; | ||
| 4368 | ++mismatches; | ||
| 4369 | std::fprintf(stderr, | ||
| 4370 | "heap GetDesc type %d align %llu masks %u/%u: ours size %llu align %llu flags 0x%x cpu %d " | ||
| 4371 | "pool %d masks %u/%u, host size %llu align %llu flags 0x%x cpu %d pool %d masks %u/%u\n", | ||
| 4372 | int(props.Type), heap.alignment, mask[0], mask[1], x.SizeInBytes, x.Alignment, | ||
| 4373 | unsigned(x.Flags), int(x.Properties.CPUPageProperty), | ||
| 4374 | int(x.Properties.MemoryPoolPreference), x.Properties.CreationNodeMask, | ||
| 4375 | x.Properties.VisibleNodeMask, y.SizeInBytes, y.Alignment, unsigned(y.Flags), | ||
| 4376 | int(y.Properties.CPUPageProperty), int(y.Properties.MemoryPoolPreference), | ||
| 4377 | y.Properties.CreationNodeMask, y.Properties.VisibleNodeMask); | ||
| 4378 | } | ||
| 4379 | } | ||
| 4380 | std::printf("ID3D12Heap::GetDesc against the host: %zu heaps, %d differ\n", std::size(heaps) * std::size(masks), | ||
| 4381 | mismatches); | ||
| 4382 | return mismatches; | ||
| 4383 | } | ||
| 4384 | |||
| 4324 | // CreatePlacedResource and CreateReservedResource answer their arguments as the host runtime does: the placement | 4385 | // CreatePlacedResource and CreateReservedResource answer their arguments as the host runtime does: the placement |
| 4325 | // (offset, alignment, room in the heap), the heap's type and DENY flags against the resource, the description and | 4386 | // (offset, alignment, room in the heap), the heap's type and DENY flags against the resource, the description and |
| 4326 | // initial state rules CreateCommittedResource shares, and the output and interface. Run on a device with the GPU | 4387 | // initial state rules CreateCommittedResource shares, and the output and interface. Run on a device with the GPU |
| @@ -7116,6 +7177,10 @@ int main() { | |||
| 7116 | if (heap_mismatches < 0) | 7177 | if (heap_mismatches < 0) |
| 7117 | std::printf("CreateHeap valid neighbours: no host D3D12 device to compare with, skipped\n"); | 7178 | std::printf("CreateHeap valid neighbours: no host D3D12 device to compare with, skipped\n"); |
| 7118 | EXPECT(heap_mismatches <= 0); | 7179 | EXPECT(heap_mismatches <= 0); |
| 7180 | const int heap_desc_mismatches = compare_heap_descs(standalone.p); | ||
| 7181 | if (heap_desc_mismatches < 0) | ||
| 7182 | std::printf("ID3D12Heap::GetDesc: no host D3D12 device to compare with, skipped\n"); | ||
| 7183 | EXPECT(heap_desc_mismatches <= 0); | ||
| 7119 | const int placed_mismatches = compare_placed_reserved(standalone.p); | 7184 | const int placed_mismatches = compare_placed_reserved(standalone.p); |
| 7120 | if (placed_mismatches < 0) | 7185 | if (placed_mismatches < 0) |
| 7121 | std::printf("CreatePlacedResource/CreateReservedResource arguments: no host D3D12 device to compare " | 7186 | std::printf("CreatePlacedResource/CreateReservedResource arguments: no host D3D12 device to compare " |