diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-21 23:15:36 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-21 23:15:36 -0500 |
| commit | 6b8b2e5f6efe8a0be506b2a4a1bec0c2a3c229b3 (patch) | |
| tree | 2237ce28f0fc2fc6147cce7d617d363be8692d9f /runtime | |
| parent | f54d1f3f89f034b544b52ba5da5003532dd972b0 (diff) | |
| parent | a03f0c5e13bc2e3336388656b59abfe3e2eddb0c (diff) | |
Merge pull request #865 from Felix Croasdale
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/src/vulkan_replay.h | 4 | ||||
| -rw-r--r-- | runtime/test/d3d12_state_map_test.cpp | 35 |
2 files changed, 36 insertions, 3 deletions
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h index 8d3385600..40e163e46 100644 --- a/runtime/src/vulkan_replay.h +++ b/runtime/src/vulkan_replay.h | |||
| @@ -1418,8 +1418,8 @@ ReplayResult prepare(const CommandList& list, Resolve&& resolve, const ReplayFun | |||
| 1418 | if (!image_range(p.binding, all_subresources, range)) return ReplayResult::invalid_subresource; | 1418 | if (!image_range(p.binding, all_subresources, range)) return ReplayResult::invalid_subresource; |
| 1419 | if (!discard->partial) p.discards.push_back(range); | 1419 | if (!discard->partial) p.discards.push_back(range); |
| 1420 | } else { | 1420 | } else { |
| 1421 | for (std::uint64_t i = discard->first_subresource; i < end; ++i) { | 1421 | for (std::uint64_t sub = discard->first_subresource; sub < end; ++sub) { |
| 1422 | const auto s = static_cast<std::uint32_t>(i); | 1422 | const auto s = static_cast<std::uint32_t>(sub); |
| 1423 | VkImageSubresourceRange range{}; | 1423 | VkImageSubresourceRange range{}; |
| 1424 | if (!image_range(p.binding, s, range)) return ReplayResult::invalid_subresource; | 1424 | if (!image_range(p.binding, s, range)) return ReplayResult::invalid_subresource; |
| 1425 | if (!discard->partial) p.discards.push_back(range); | 1425 | if (!discard->partial) p.discards.push_back(range); |
diff --git a/runtime/test/d3d12_state_map_test.cpp b/runtime/test/d3d12_state_map_test.cpp index 9daeb5ce9..a25ff6a6d 100644 --- a/runtime/test/d3d12_state_map_test.cpp +++ b/runtime/test/d3d12_state_map_test.cpp | |||
| @@ -404,6 +404,38 @@ int main() { | |||
| 404 | merged.forget(1); | 404 | merged.forget(1); |
| 405 | CHECK(!merged.tracked(1)); | 405 | CHECK(!merged.tracked(1)); |
| 406 | 406 | ||
| 407 | // DiscardResource by subresource range (D3D-26), through prepare(): each listed subresource becomes one range, | ||
| 408 | // and the command loop goes on to the next command after a discard's own loop. | ||
| 409 | { | ||
| 410 | ResourceBinding target{}; | ||
| 411 | target.image = reinterpret_cast<VkImage>(std::uintptr_t{3}); | ||
| 412 | target.mip_levels = 3; | ||
| 413 | target.array_layers = 2; | ||
| 414 | const auto resolve = [&](ResourceId id) -> const ResourceBinding* { return id == 3 ? &target : nullptr; }; | ||
| 415 | CommandList list; | ||
| 416 | CHECK(list.discard({3, 1, 3, false})); // mips 1 and 2 of layer 0, mip 0 of layer 1 | ||
| 417 | CHECK(list.discard({3, 5, 1, false})); // mip 2 of layer 1, the last subresource | ||
| 418 | CHECK(list.discard({3, 0, 2, true})); // a partial discard keeps the contents: nothing to record | ||
| 419 | CHECK(list.close()); | ||
| 420 | PreparedList prepared; | ||
| 421 | CHECK(prepare(list, resolve, ReplayFunctions{}, prepared) == ReplayResult::success); | ||
| 422 | CHECK(prepared.commands.size() == 3); | ||
| 423 | const auto& first = prepared.commands[0].discards; | ||
| 424 | CHECK(first.size() == 3); | ||
| 425 | CHECK(first[0].baseMipLevel == 1 && first[0].baseArrayLayer == 0 && first[0].levelCount == 1); | ||
| 426 | CHECK(first[1].baseMipLevel == 2 && first[1].baseArrayLayer == 0); | ||
| 427 | CHECK(first[2].baseMipLevel == 0 && first[2].baseArrayLayer == 1 && first[2].layerCount == 1); | ||
| 428 | const auto& second = prepared.commands[1].discards; | ||
| 429 | CHECK(second.size() == 1 && second[0].baseMipLevel == 2 && second[0].baseArrayLayer == 1); | ||
| 430 | CHECK(prepared.commands[2].discards.empty()); | ||
| 431 | |||
| 432 | // One subresource past the end is refused. | ||
| 433 | CommandList past; | ||
| 434 | CHECK(past.discard({3, 4, 3, false})); | ||
| 435 | CHECK(past.close()); | ||
| 436 | CHECK(prepare(past, resolve, ReplayFunctions{}, prepared) == ReplayResult::invalid_subresource); | ||
| 437 | } | ||
| 438 | |||
| 407 | // Resizable BAR detection (D3D-96) on the heap layouts real cards report. | 439 | // Resizable BAR detection (D3D-96) on the heap layouts real cards report. |
| 408 | { | 440 | { |
| 409 | constexpr VkDeviceSize mib = VkDeviceSize(1) << 20; | 441 | constexpr VkDeviceSize mib = VkDeviceSize(1) << 20; |
| @@ -442,6 +474,7 @@ int main() { | |||
| 442 | CHECK(!resizable_bar(VkPhysicalDeviceMemoryProperties{})); | 474 | CHECK(!resizable_bar(VkPhysicalDeviceMemoryProperties{})); |
| 443 | } | 475 | } |
| 444 | 476 | ||
| 445 | std::printf("state map, enhanced barriers, subresource decoding, layout tracking and BAR detection OK\n"); | 477 | std::printf("state map, enhanced barriers, subresource decoding, layout tracking, discard ranges and BAR " |
| 478 | "detection OK\n"); | ||
| 446 | return 0; | 479 | return 0; |
| 447 | } | 480 | } |