diff options
| author | traeb0n <masonbartelme@gmail.com> | 2026-11-21 22:19:11 -0600 |
|---|---|---|
| committer | traeb0n <masonbartelme@gmail.com> | 2026-11-22 09:19:29 -0600 |
| commit | 9df4eda200b6cd7b8b33dd6f8bc84d681d2c7a29 (patch) | |
| tree | b2a7c168e48971b4490cd7d77c8d1079518c3518 /runtime/src | |
| parent | 6a6704df1592e1dc4a3215ddf1423a78adb52045 (diff) | |
Runtime: VulkanQueue keeps its PreparedList storage between executions
execute built a new std::vector<PreparedList> on every call, so every
command's detail::Prepared entry (1288 bytes on main now) was made in
fresh memory and freed again: replay_cpu_bench measures that at 274-292
ns per command on an i7-14700K, against 85 ns refilled in kept storage,
over half of the layer's whole CPU cost per command. The queue now keeps
the vector as a member (per queue, like its command buffers: one execute
at a time on a queue, as acquire() and submit() already assume) and
resizes it to the list count; prepare refills each list's entries in
place, where the per-entry vectors also keep their capacity.
replay_cpu_bench mirrors the change and reports both floors (entries in
kept storage and made fresh). Its frame goes from 425 to 194 ns per
command (a 21,504-command frame from 9.1 ms to 4.2 ms).
d3d12_vulkan_device_test executes {B, A}, then {B} alone, and checks
that only B ran the second time: with storage that only grows, a stale A
is replayed after B and the test fails (checked).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/vulkan_backend.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h index e577e6af0..e2aa0c830 100644 --- a/runtime/src/vulkan_backend.h +++ b/runtime/src/vulkan_backend.h | |||
| @@ -1279,7 +1279,10 @@ public: | |||
| 1279 | } | 1279 | } |
| 1280 | } scratch_guard{context_.scratch_.get(), progress_, false}; | 1280 | } scratch_guard{context_.scratch_.get(), progress_, false}; |
| 1281 | bindless_commit = context_.bindless_commit_; | 1281 | bindless_commit = context_.bindless_commit_; |
| 1282 | std::vector<PreparedList> prepared(lists.size()); | 1282 | // Kept between executions: prepare refills each list's entries in the storage the last execution left, where |
| 1283 | // making them fresh for every command was about half the layer's CPU cost per command (replay_cpu_bench). | ||
| 1284 | auto& prepared = prepared_; | ||
| 1285 | prepared.resize(lists.size()); | ||
| 1283 | ReplayFunctions replay = context_.replay_; | 1286 | ReplayFunctions replay = context_.replay_; |
| 1284 | std::uint64_t captures = 0; | 1287 | std::uint64_t captures = 0; |
| 1285 | for (const auto* list : lists) | 1288 | for (const auto* list : lists) |
| @@ -1632,6 +1635,9 @@ private: | |||
| 1632 | std::unique_ptr<OcclusionResolve> occlusion_resolve_; | 1635 | std::unique_ptr<OcclusionResolve> occlusion_resolve_; |
| 1633 | std::vector<VkSemaphore> waits_; | 1636 | std::vector<VkSemaphore> waits_; |
| 1634 | std::vector<std::uint64_t> wait_values_; | 1637 | std::vector<std::uint64_t> wait_values_; |
| 1638 | // execute's working storage. Per queue like buffers_: one execute at a time on a queue, as acquire() and | ||
| 1639 | // submit() already assume; other queues prepare concurrently with their own. | ||
| 1640 | std::vector<PreparedList> prepared_; | ||
| 1635 | std::uint32_t open_labels_ = 0; // queue labels begun and not ended | 1641 | std::uint32_t open_labels_ = 0; // queue labels begun and not ended |
| 1636 | bool ok_ = false; | 1642 | bool ok_ = false; |
| 1637 | }; | 1643 | }; |