upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorFelix Croasdale <x2020evy@stfx.ca>2026-11-21 22:03:26 -0600
committerFelix Croasdale <x2020evy@stfx.ca>2026-11-21 22:03:26 -0600
commita03f0c5e13bc2e3336388656b59abfe3e2eddb0c (patch)
treeeb7b79adf6bd512521b18f3f53fde6939da488fc /runtime
parentc6b684c2688803ff31d710032a506a9e5f6dd821 (diff)
d3d12_state_map_test: DiscardResource subresource ranges through prepare()
A CPU-only check of the loop renamed in the previous commit: two per-subresource discards in one list each give their own ranges (mip and layer decoded), a partial discard records none, and a range one past the last subresource is refused. With the loop stopping one short, the test fails at first.size() == 3. docs/d3d12_vulkan.md now lists this and the Resizable BAR detection the test already had. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/test/d3d12_state_map_test.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/runtime/test/d3d12_state_map_test.cpp b/runtime/test/d3d12_state_map_test.cpp
index 99f9916f1..b55323273 100644
--- a/runtime/test/d3d12_state_map_test.cpp
+++ b/runtime/test/d3d12_state_map_test.cpp
@@ -379,6 +379,38 @@ int main() {
379 merged.forget(1); 379 merged.forget(1);
380 CHECK(!merged.tracked(1)); 380 CHECK(!merged.tracked(1));
381 381
382 // DiscardResource by subresource range (D3D-26), through prepare(): each listed subresource becomes one range,
383 // and the command loop goes on to the next command after a discard's own loop.
384 {
385 ResourceBinding target{};
386 target.image = reinterpret_cast<VkImage>(std::uintptr_t{3});
387 target.mip_levels = 3;
388 target.array_layers = 2;
389 const auto resolve = [&](ResourceId id) -> const ResourceBinding* { return id == 3 ? &target : nullptr; };
390 CommandList list;
391 CHECK(list.discard({3, 1, 3, false})); // mips 1 and 2 of layer 0, mip 0 of layer 1
392 CHECK(list.discard({3, 5, 1, false})); // mip 2 of layer 1, the last subresource
393 CHECK(list.discard({3, 0, 2, true})); // a partial discard keeps the contents: nothing to record
394 CHECK(list.close());
395 PreparedList prepared;
396 CHECK(prepare(list, resolve, ReplayFunctions{}, prepared) == ReplayResult::success);
397 CHECK(prepared.commands.size() == 3);
398 const auto& first = prepared.commands[0].discards;
399 CHECK(first.size() == 3);
400 CHECK(first[0].baseMipLevel == 1 && first[0].baseArrayLayer == 0 && first[0].levelCount == 1);
401 CHECK(first[1].baseMipLevel == 2 && first[1].baseArrayLayer == 0);
402 CHECK(first[2].baseMipLevel == 0 && first[2].baseArrayLayer == 1 && first[2].layerCount == 1);
403 const auto& second = prepared.commands[1].discards;
404 CHECK(second.size() == 1 && second[0].baseMipLevel == 2 && second[0].baseArrayLayer == 1);
405 CHECK(prepared.commands[2].discards.empty());
406
407 // One subresource past the end is refused.
408 CommandList past;
409 CHECK(past.discard({3, 4, 3, false}));
410 CHECK(past.close());
411 CHECK(prepare(past, resolve, ReplayFunctions{}, prepared) == ReplayResult::invalid_subresource);
412 }
413
382 // Resizable BAR detection (D3D-96) on the heap layouts real cards report. 414 // Resizable BAR detection (D3D-96) on the heap layouts real cards report.
383 { 415 {
384 constexpr VkDeviceSize mib = VkDeviceSize(1) << 20; 416 constexpr VkDeviceSize mib = VkDeviceSize(1) << 20;
@@ -417,6 +449,7 @@ int main() {
417 CHECK(!resizable_bar(VkPhysicalDeviceMemoryProperties{})); 449 CHECK(!resizable_bar(VkPhysicalDeviceMemoryProperties{}));
418 } 450 }
419 451
420 std::printf("state map, enhanced barriers, subresource decoding, layout tracking and BAR detection OK\n"); 452 std::printf("state map, enhanced barriers, subresource decoding, layout tracking, discard ranges and BAR "
453 "detection OK\n");
421 return 0; 454 return 0;
422} 455}