upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 01:38:14 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 01:38:14 -0500
commit86ef2454a81ecfc64bc74b6fa251042e882c8bd4 (patch)
tree508d3727c31459b97b8880b31f1cba88cad3796b /runtime/test
parent586c6352538407e2ca18b582b305494ab4a00a7b (diff)
parent55bf9d0328f84657486395b6d56862c6faf2e3dc (diff)
Merge pull request #1069 from undeadhuman37
Diffstat (limited to 'runtime/test')
-rw-r--r--runtime/test/d3d12_vulkan_device_test.cpp67
1 files changed, 66 insertions, 1 deletions
diff --git a/runtime/test/d3d12_vulkan_device_test.cpp b/runtime/test/d3d12_vulkan_device_test.cpp
index a97e2fad2..a8d6e32b4 100644
--- a/runtime/test/d3d12_vulkan_device_test.cpp
+++ b/runtime/test/d3d12_vulkan_device_test.cpp
@@ -427,6 +427,58 @@ int compare_format_info(ID3D12Device* ours, const vktest::Device& vk) {
427 return mismatches; 427 return mismatches;
428} 428}
429 429
430// D3D-122: descriptions GetCopyableFootprints must refuse (false) or answer (true), as the PC runtime does. All were
431// measured on WARP. Also on an NVIDIA GPU: texture Width/Height 0, Count 0, Count 4 without a render-target or depth
432// flag, Count 3; buffer Width 0, Height 2, Format, MipLevels 0, Layout, Count 0; and the buffer render-target, extra
433// mip, ROW_MAJOR and Quality 1 controls. compare_footprints checks them against the host, the main test on their own.
434std::vector<std::pair<D3D12_RESOURCE_DESC, bool>> footprint_validity_cases() {
435 const auto rgba = DXGI_FORMAT_R8G8B8A8_UNORM;
436 const auto rt = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
437 std::vector<std::pair<D3D12_RESOURCE_DESC, bool>> cases;
438 const auto add = [&](D3D12_RESOURCE_DESC d, bool valid, auto&& change) {
439 change(d);
440 cases.push_back({d, valid});
441 };
442 const auto buffer = buffer_desc(256);
443 add(buffer, false, [](auto& d) { d.Width = 0; });
444 add(buffer, false, [](auto& d) { d.Height = 2; });
445 add(buffer, false, [](auto& d) { d.DepthOrArraySize = 2; });
446 add(buffer, false, [](auto& d) { d.MipLevels = 0; });
447 add(buffer, false, [](auto& d) { d.MipLevels = 2; });
448 add(buffer, false, [&](auto& d) { d.Format = rgba; });
449 add(buffer, false, [](auto& d) { d.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; });
450 add(buffer, false, [](auto& d) { d.SampleDesc.Count = 0; });
451 add(buffer, false, [](auto& d) { d.SampleDesc.Count = 2; });
452 add(buffer, false, [](auto& d) { d.SampleDesc.Quality = 1; });
453 add(buffer, false, [](auto& d) { d.Alignment = 4096; });
454 add(buffer, true, [&](auto& d) { d.Flags = rt; });
455 add(buffer, true, [](auto& d) { d.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; });
456
457 const auto texture = texture_desc(16, 16, rgba, D3D12_RESOURCE_FLAG_NONE);
458 add(texture, false, [](auto& d) { d.Width = 0; });
459 add(texture, false, [](auto& d) { d.Height = 0; });
460 add(texture, false, [](auto& d) { d.DepthOrArraySize = 0; });
461 add(texture, false, [](auto& d) { d.SampleDesc.Count = 0; });
462 add(texture, false, [](auto& d) { d.SampleDesc.Count = 4; }); // no render-target or depth flag
463 add(texture, false, [](auto& d) { d.SampleDesc.Count = 4, d.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; });
464 add(texture, false, [&](auto& d) { d.SampleDesc.Count = 3, d.Flags = rt; });
465 add(texture, false, [&](auto& d) { d.SampleDesc.Count = 4, d.Flags = rt, d.MipLevels = 2; });
466 add(texture, false, [&](auto& d) { d.SampleDesc.Count = 4, d.Flags = rt, d.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; });
467 add(texture, true, [&](auto& d) { d.SampleDesc.Count = 4, d.Flags = rt; });
468 add(texture, true, [](auto& d) { d.MipLevels = 9; }); // past the full chain
469 add(texture, true, [](auto& d) { d.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; });
470 add(texture, true, [](auto& d) { d.SampleDesc.Quality = 1; });
471 add(texture_desc(16, 16, DXGI_FORMAT_D32_FLOAT, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL), true,
472 [](auto& d) { d.SampleDesc.Count = 4; });
473
474 add(line_desc(16, 1, 1, rgba), false, [](auto& d) { d.Width = 0; });
475 add(line_desc(16, 1, 1, rgba), false, [&](auto& d) { d.SampleDesc.Count = 2, d.Flags = rt; });
476 add(volume_desc(1), false, [](auto& d) { d.DepthOrArraySize = 0; });
477 add(volume_desc(1), false, [](auto& d) { d.Height = 0; });
478 add(volume_desc(1), false, [&](auto& d) { d.SampleDesc.Count = 2, d.Flags = rt; });
479 return cases;
480}
481
430// GetCopyableFootprints must match the PC runtime's exactly, since applications size and fill upload buffers from 482// GetCopyableFootprints must match the PC runtime's exactly, since applications size and fill upload buffers from
431// it. Unaligned block-compressed cases are skipped when the host runtime cannot answer them, so the rest still 483// it. Unaligned block-compressed cases are skipped when the host runtime cannot answer them, so the rest still
432// run. Returns the number of mismatches, or -1 when the host has no D3D12 device to compare with. 484// run. Returns the number of mismatches, or -1 when the host has no D3D12 device to compare with.
@@ -439,7 +491,7 @@ int compare_footprints(ID3D12Device* ours) {
439 D3D12_RESOURCE_DESC desc; 491 D3D12_RESOURCE_DESC desc;
440 UINT subresources; 492 UINT subresources;
441 }; 493 };
442 const Case cases[] = { 494 std::vector<Case> cases = {
443 {volume_desc(5), 5}, 495 {volume_desc(5), 5},
444 {line_desc(13, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM), 4}, 496 {line_desc(13, 4, 1, DXGI_FORMAT_R8G8B8A8_UNORM), 4},
445 {line_desc(5, 3, 2, DXGI_FORMAT_R8G8B8A8_UNORM), 6}, 497 {line_desc(5, 3, 2, DXGI_FORMAT_R8G8B8A8_UNORM), 6},
@@ -472,6 +524,7 @@ int compare_footprints(ID3D12Device* ours) {
472 {texture_desc(16, 16, DXGI_FORMAT_R8G8_UINT, D3D12_RESOURCE_FLAG_NONE, 3), 3}, 524 {texture_desc(16, 16, DXGI_FORMAT_R8G8_UINT, D3D12_RESOURCE_FLAG_NONE, 3), 3},
473 {texture_desc(16, 16, DXGI_FORMAT_R8G8_SINT, D3D12_RESOURCE_FLAG_NONE, 3), 3}, 525 {texture_desc(16, 16, DXGI_FORMAT_R8G8_SINT, D3D12_RESOURCE_FLAG_NONE, 3), 3},
474 }; 526 };
527 for (const auto& c : footprint_validity_cases()) cases.push_back({c.first, 1});
475 int mismatches = 0; 528 int mismatches = 0;
476 for (const Case& c : cases) { 529 for (const Case& c : cases) {
477 if (!unaligned_blocks && uses_unaligned_blocks(c.desc)) { 530 if (!unaligned_blocks && uses_unaligned_blocks(c.desc)) {
@@ -1956,6 +2009,18 @@ int main() {
1956 if (footprint_mismatches < 0) 2009 if (footprint_mismatches < 0)
1957 std::printf("GetCopyableFootprints: no host D3D12 device to compare with, skipped\n"); 2010 std::printf("GetCopyableFootprints: no host D3D12 device to compare with, skipped\n");
1958 EXPECT(footprint_mismatches <= 0); 2011 EXPECT(footprint_mismatches <= 0);
2012 {
2013 // D3D-122: the same refusals without a host device (CI's llvmpipe), so they can't regress unseen.
2014 const auto cases = footprint_validity_cases();
2015 for (size_t i = 0; i < cases.size(); ++i) {
2016 UINT64 total = 0;
2017 device->GetCopyableFootprints(&cases[i].first, 0, 1, 0, nullptr, nullptr, nullptr, &total);
2018 if ((total != UINT64_MAX) != cases[i].second)
2019 std::fprintf(stderr, "footprint validity case %zu: total %llu, expected %s\n", i,
2020 (unsigned long long)total, cases[i].second ? "a footprint" : "the failure answer");
2021 EXPECT((total != UINT64_MAX) == cases[i].second);
2022 }
2023 }
1959 2024
1960 // Shader model and root signature (D3D-86): the answers are only useful if the game can rely on them, so 2025 // Shader model and root signature (D3D-86): the answers are only useful if the game can rely on them, so
1961 // pin both the ceiling and the refusal cases rather than just comparing with the host. 2026 // pin both the ceiling and the refusal cases rather than just comparing with the host.