upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_backend.h
diff options
context:
space:
mode:
authorAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-22 21:11:25 +0100
committerAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-22 21:11:25 +0100
commit92da70ad6b56d3eccbd04a8bebb9fc5745c9f704 (patch)
treef9b52b3f22cf00c569df8cef1e650936c5229441 /runtime/src/vulkan_backend.h
parent342d5672cc61327eb713a407b6a08748e1f06d38 (diff)
parentf847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff)
Merge remote-tracking branch 'origin/main' into bindless-per-queue-retire
# Conflicts: # runtime/src/vulkan_backend.h
Diffstat (limited to 'runtime/src/vulkan_backend.h')
-rw-r--r--runtime/src/vulkan_backend.h117
1 files changed, 110 insertions, 7 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h
index b8258f931..3705d9b18 100644
--- a/runtime/src/vulkan_backend.h
+++ b/runtime/src/vulkan_backend.h
@@ -17,6 +17,7 @@
17#include "vulkan_depth24.h" 17#include "vulkan_depth24.h"
18#include "vulkan_scratch.h" 18#include "vulkan_scratch.h"
19#include "vulkan_replay.h" 19#include "vulkan_replay.h"
20#include "queue_families.h"
20#include "resource_tiling.h" 21#include "resource_tiling.h"
21#include "xdxr_build.h" 22#include "xdxr_build.h"
22 23
@@ -80,7 +81,8 @@ struct VulkanDeviceFunctions {
80 X(vkCmdBindVertexBuffers2) X(vkCmdBindIndexBuffer) X(vkCmdSetViewport) X(vkCmdSetScissor) \ 81 X(vkCmdBindVertexBuffers2) X(vkCmdBindIndexBuffer) X(vkCmdSetViewport) X(vkCmdSetScissor) \
81 X(vkCmdSetPrimitiveTopology) X(vkCmdSetPrimitiveRestartEnable) X(vkCmdSetStencilReference) \ 82 X(vkCmdSetPrimitiveTopology) X(vkCmdSetPrimitiveRestartEnable) X(vkCmdSetStencilReference) \
82 X(vkCmdSetBlendConstants) X(vkCmdDraw) \ 83 X(vkCmdSetBlendConstants) X(vkCmdDraw) \
83 X(vkCmdDrawIndexed) X(vkCreateGraphicsPipelines) X(vkQueueBindSparse) 84 X(vkCmdDrawIndexed) X(vkCreateGraphicsPipelines) X(vkQueueBindSparse) \
85 X(vkCreateEvent) X(vkDestroyEvent) X(vkResetEvent) X(vkCmdSetEvent) X(vkCmdWaitEvents)
84#define LEONIDA_VK_MEMBER(name) PFN_##name name = nullptr; 86#define LEONIDA_VK_MEMBER(name) PFN_##name name = nullptr;
85 LEONIDA_VK_DEVICE_FUNCTIONS(LEONIDA_VK_MEMBER) 87 LEONIDA_VK_DEVICE_FUNCTIONS(LEONIDA_VK_MEMBER)
86#undef LEONIDA_VK_MEMBER 88#undef LEONIDA_VK_MEMBER
@@ -202,7 +204,11 @@ public:
202 return vk_.vkCreatePipelineLayout(device_, &layout, nullptr, &layout_) == VK_SUCCESS; 204 return vk_.vkCreatePipelineLayout(device_, &layout, nullptr, &layout_) == VK_SUCCESS;
203 } 205 }
204 206
205 bool prepare(bool needs_sum, bool needs_binary, bool needs_statistics_sum = false) { 207 bool prepare(bool needs_sum, bool needs_binary, bool needs_statistics_sum = false,
208 bool needs_sum_binary = false) {
209 // The composite (sum then normalize, D3D-252) uses both pipelines.
210 needs_sum = needs_sum || needs_sum_binary;
211 needs_binary = needs_binary || needs_sum_binary;
206 return (!needs_sum || sum_pipeline_ || create_pipeline(occlusion_sum_spirv, sum_pipeline_)) && 212 return (!needs_sum || sum_pipeline_ || create_pipeline(occlusion_sum_spirv, sum_pipeline_)) &&
207 (!needs_binary || binary_pipeline_ || create_pipeline(binary_occlusion_spirv, binary_pipeline_)) && 213 (!needs_binary || binary_pipeline_ || create_pipeline(binary_occlusion_spirv, binary_pipeline_)) &&
208 (!needs_statistics_sum || statistics_pipeline_ || 214 (!needs_statistics_sum || statistics_pipeline_ ||
@@ -250,6 +256,31 @@ public:
250 copy_result(cb, dst, offset, word_size); 256 copy_result(cb, dst, offset, word_size);
251 } 257 }
252 258
259 // Sums `count` binary-occlusion segments into one value and normalizes that total in place to 0 or 1: the
260 // result of a binary query whose interval spans more than one physical segment (overlapping queries, D3D-252).
261 void sum_binary(VkCommandBuffer cb, VkQueryPool queries, std::uint32_t first, std::uint32_t count,
262 VkBuffer dst, VkDeviceSize offset) const {
263 begin_scratch_write(cb);
264 vk_.vkCmdFillBuffer(cb, scratch_, 0, word_size, 0);
265 bind(cb, sum_pipeline_);
266 auto tail = first, left = count;
267 while (left) {
268 const auto chunk = std::min(left, sum_capacity);
269 vk_.vkCmdCopyQueryPoolResults(cb, queries, tail, chunk, scratch_, word_size, word_size,
270 VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT);
271 barrier(cb, transfer | compute, compute, VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT,
272 shader_access);
273 dispatch(cb, chunk, 1);
274 tail += chunk;
275 left -= chunk;
276 if (left) barrier(cb, compute, transfer, shader_access, VK_ACCESS_TRANSFER_WRITE_BIT);
277 }
278 barrier(cb, compute, compute, VK_ACCESS_SHADER_WRITE_BIT, shader_access);
279 bind(cb, binary_pipeline_);
280 dispatch(cb, 1, 1);
281 copy_result(cb, dst, offset, word_size);
282 }
283
253 void normalize(VkCommandBuffer cb, VkQueryPool queries, std::uint32_t first, std::uint32_t count, 284 void normalize(VkCommandBuffer cb, VkQueryPool queries, std::uint32_t first, std::uint32_t count,
254 VkBuffer dst, VkDeviceSize offset) const { 285 VkBuffer dst, VkDeviceSize offset) const {
255 bind(cb, binary_pipeline_); 286 bind(cb, binary_pipeline_);
@@ -1002,6 +1033,10 @@ public:
1002 // (timestampValidBits 0). Set by the device before any queue uses it. 1033 // (timestampValidBits 0). Set by the device before any queue uses it.
1003 double timestamp_period() const { return timestamp_period_; } 1034 double timestamp_period() const { return timestamp_period_; }
1004 void set_timestamp_period(double period) { timestamp_period_ = period; } 1035 void set_timestamp_period(double period) { timestamp_period_ = period; }
1036 // True where a timestamp resolve must be ordered explicitly after the timestamps it copies (MoltenVK on Apple
1037 // GPUs, docs/d3d12_vulkan.md section 4.6). Set by the device before any queue uses it.
1038 bool order_timestamp_copies() const { return order_timestamp_copies_; }
1039 void set_order_timestamp_copies(bool order) { order_timestamp_copies_ = order; }
1005 1040
1006 // The device address of the GPU address arena: console VAs are offsets from it (docs section 3.3). 1041 // The device address of the GPU address arena: console VAs are offsets from it (docs section 3.3).
1007 // execute() copies replay_ under a shared resource_mutex_, so writers hold it uniquely. 1042 // execute() copies replay_ under a shared resource_mutex_, so writers hold it uniquely.
@@ -1115,6 +1150,8 @@ public:
1115 // `prepare` is called at the start of the command buffer of every ExecuteCommandLists, before the lists are 1150 // `prepare` is called at the start of the command buffer of every ExecuteCommandLists, before the lists are
1116 // written: the device brings the bindless set 0 of the translated shaders up to date there (vulkan_bindless.h) 1151 // written: the device brings the bindless set 0 of the translated shaders up to date there (vulkan_bindless.h)
1117 // and records what the set needs first. When it fails, nothing of that call is executed. 1152 // and records what the set needs first. When it fails, nothing of that call is executed.
1153 void set_transfer_only_family(std::uint32_t family) { transfer_only_family_ = family; }
1154
1118 void set_bindless_prepare(std::function<bool(VkCommandBuffer)> prepare) { 1155 void set_bindless_prepare(std::function<bool(VkCommandBuffer)> prepare) {
1119 std::unique_lock lock(resource_mutex_); 1156 std::unique_lock lock(resource_mutex_);
1120 bindless_prepare_ = std::move(prepare); 1157 bindless_prepare_ = std::move(prepare);
@@ -1339,11 +1376,13 @@ private:
1339 std::function<void(bool)> bindless_commit_; 1376 std::function<void(bool)> bindless_commit_;
1340 std::unordered_map<QueryHeapId, QueryPool> query_pools_; // element pointers stay valid across inserts 1377 std::unordered_map<QueryHeapId, QueryPool> query_pools_; // element pointers stay valid across inserts
1341 double timestamp_period_ = 0; 1378 double timestamp_period_ = 0;
1379 bool order_timestamp_copies_ = false;
1342 VkPhysicalDeviceMemoryProperties occlusion_resolve_memory_{}; 1380 VkPhysicalDeviceMemoryProperties occlusion_resolve_memory_{};
1343 ReplayFunctions replay_; 1381 ReplayFunctions replay_;
1344 std::unique_ptr<PredicateReducer> predicate_reducer_; 1382 std::unique_ptr<PredicateReducer> predicate_reducer_;
1345 std::unique_ptr<PredicatedBufferCopier> predicated_copier_; 1383 std::unique_ptr<PredicatedBufferCopier> predicated_copier_;
1346 std::uint32_t predicate_family_ = UINT32_MAX; 1384 std::uint32_t predicate_family_ = UINT32_MAX;
1385 std::uint32_t transfer_only_family_ = UINT32_MAX;
1347 DebugLabelFunctions labels_; 1386 DebugLabelFunctions labels_;
1348}; 1387};
1349#ifdef _MSC_VER 1388#ifdef _MSC_VER
@@ -1451,6 +1490,8 @@ public:
1451 } 1490 }
1452 if (pool_) vk.vkDestroyCommandPool(context_.device(), pool_, nullptr); 1491 if (pool_) vk.vkDestroyCommandPool(context_.device(), pool_, nullptr);
1453 if (progress_) vk.vkDestroySemaphore(context_.device(), progress_, nullptr); 1492 if (progress_) vk.vkDestroySemaphore(context_.device(), progress_, nullptr);
1493 for (auto& slot : buffers_) free_events_.insert(free_events_.end(), slot.events.begin(), slot.events.end());
1494 for (VkEvent event : free_events_) vk.vkDestroyEvent(context_.device(), event, nullptr);
1454 } 1495 }
1455 1496
1456 VulkanQueue(const VulkanQueue&) = delete; 1497 VulkanQueue(const VulkanQueue&) = delete;
@@ -1524,6 +1565,12 @@ public:
1524 // the layout tracker as it was. Pending Wait()s are attached to this submission. 1565 // the layout tracker as it was. Pending Wait()s are attached to this submission.
1525 ReplayResult execute(std::span<const CommandList* const> lists) { 1566 ReplayResult execute(std::span<const CommandList* const> lists) {
1526 if (context_.is_device_lost()) return ReplayResult::unsupported; 1567 if (context_.is_device_lost()) return ReplayResult::unsupported;
1568 if (kind_ != QueueKind::direct)
1569 for (const auto* list : lists)
1570 for (const auto& command : list->commands())
1571 if (std::holds_alternative<ClearRenderTarget>(command) ||
1572 std::holds_alternative<ClearDepthStencil>(command))
1573 return ReplayResult::unsupported;
1527 VkCommandBuffer command_buffer = VK_NULL_HANDLE; 1574 VkCommandBuffer command_buffer = VK_NULL_HANDLE;
1528 std::function<void(bool)> bindless_commit; 1575 std::function<void(bool)> bindless_commit;
1529 // Lock hierarchy: resource_mutex_ -> tracker_mutex_ -> submit_mutex_. 1576 // Lock hierarchy: resource_mutex_ -> tracker_mutex_ -> submit_mutex_.
@@ -1550,12 +1597,16 @@ public:
1550 if (active && scratch) scratch->retire(progress, 0); 1597 if (active && scratch) scratch->retire(progress, 0);
1551 } 1598 }
1552 } scratch_guard{context_.scratch_.get(), progress_, false}; 1599 } scratch_guard{context_.scratch_.get(), progress_, false};
1553 bindless_commit = context_.bindless_commit_; 1600 const bool transfer_only = family_ == context_.transfer_only_family_;
1601 if (!transfer_only) bindless_commit = context_.bindless_commit_;
1554 // Kept between executions: prepare refills each list's entries in the storage the last execution left, where 1602 // Kept between executions: prepare refills each list's entries in the storage the last execution left, where
1555 // making them fresh for every command was about half the layer's CPU cost per command (replay_cpu_bench). 1603 // making them fresh for every command was about half the layer's CPU cost per command (replay_cpu_bench).
1556 auto& prepared = prepared_; 1604 auto& prepared = prepared_;
1557 prepared.resize(lists.size()); 1605 prepared.resize(lists.size());
1558 ReplayFunctions replay = context_.replay_; 1606 ReplayFunctions replay = context_.replay_;
1607 replay.queue_stages = kind_ == QueueKind::copy ? detail::queue_stages_copy
1608 : kind_ == QueueKind::compute ? detail::queue_stages_compute
1609 : 0;
1559 std::uint64_t captures = 0; 1610 std::uint64_t captures = 0;
1560 for (const auto* list : lists) 1611 for (const auto* list : lists)
1561 for (const auto& command : list->commands()) 1612 for (const auto& command : list->commands())
@@ -1599,7 +1650,7 @@ public:
1599 return context_.scratch_->get(bytes, buffer, offset); 1650 return context_.scratch_->get(bytes, buffer, offset);
1600 }; 1651 };
1601 } 1652 }
1602 if (context_.depth24_) { 1653 if (context_.depth24_ && !transfer_only) {
1603 replay.depth24_prepare = [this, &tracker_lock, &depth24_guard](Depth24Job& job, 1654 replay.depth24_prepare = [this, &tracker_lock, &depth24_guard](Depth24Job& job,
1604 std::vector<Depth24Job>& parts) { 1655 std::vector<Depth24Job>& parts) {
1605 if (!tracker_lock.owns_lock()) tracker_lock.lock(); 1656 if (!tracker_lock.owns_lock()) tracker_lock.lock();
@@ -1625,6 +1676,10 @@ public:
1625 std::uint32_t count, VkBuffer dst, VkDeviceSize offset) { 1676 std::uint32_t count, VkBuffer dst, VkDeviceSize offset) {
1626 occlusion_resolve_->sum_statistics(cb, pool, first, count, dst, offset); 1677 occlusion_resolve_->sum_statistics(cb, pool, first, count, dst, offset);
1627 }; 1678 };
1679 replay.sum_binary_occlusion = [this](VkCommandBuffer cb, VkQueryPool pool, std::uint32_t first,
1680 std::uint32_t count, VkBuffer dst, VkDeviceSize offset) {
1681 occlusion_resolve_->sum_binary(cb, pool, first, count, dst, offset);
1682 };
1628 } 1683 }
1629 const auto resolve = [this](ResourceId id) { return context_.resolve(id); }; 1684 const auto resolve = [this](ResourceId id) { return context_.resolve(id); };
1630 std::uint32_t segments = 0, statistics_segments = 0; 1685 std::uint32_t segments = 0, statistics_segments = 0;
@@ -1671,19 +1726,38 @@ public:
1671 base += list.segment_count; 1726 base += list.segment_count;
1672 statistics_base += list.statistics_segment_count; 1727 statistics_base += list.statistics_segment_count;
1673 } 1728 }
1674 if (queries.needs_sum || queries.needs_binary || queries.needs_statistics_sum) { 1729 if (queries.needs_sum || queries.needs_binary || queries.needs_statistics_sum || queries.needs_sum_binary) {
1675 if (!occlusion_resolve_) { 1730 if (!occlusion_resolve_) {
1676 auto helper = std::make_unique<OcclusionResolve>(context_.vk, context_.device()); 1731 auto helper = std::make_unique<OcclusionResolve>(context_.vk, context_.device());
1677 if (!helper->initialize(occlusion_memory)) return ReplayResult::unsupported; 1732 if (!helper->initialize(occlusion_memory)) return ReplayResult::unsupported;
1678 occlusion_resolve_ = std::move(helper); 1733 occlusion_resolve_ = std::move(helper);
1679 } 1734 }
1680 if (!occlusion_resolve_->prepare(queries.needs_sum, queries.needs_binary, queries.needs_statistics_sum)) 1735 if (!occlusion_resolve_->prepare(queries.needs_sum, queries.needs_binary, queries.needs_statistics_sum,
1736 queries.needs_sum_binary))
1681 return ReplayResult::unsupported; 1737 return ReplayResult::unsupported;
1682 } 1738 }
1683 1739
1684 CommandSlot* slot = acquire(); 1740 CommandSlot* slot = acquire();
1685 if (!slot) return ReplayResult::unsupported; 1741 if (!slot) return ReplayResult::unsupported;
1686 command_buffer = slot->buffer; 1742 command_buffer = slot->buffer;
1743 // MoltenVK writes a timestamp at the end of a Metal encoder and resolves it with a blit that nothing orders
1744 // after that write, so a copy in the same or the next command buffer reads the old value (docs section 4.6).
1745 // An event set and waited for in this command buffer orders it after this submission's timestamps; a wait for
1746 // this queue's previous submission orders it after earlier ones still running.
1747 bool ordered_timestamps = false;
1748 const auto& events = context_.vk;
1749 if (context_.order_timestamp_copies() && events.vkCreateEvent && events.vkDestroyEvent && events.vkResetEvent &&
1750 events.vkCmdSetEvent && events.vkCmdWaitEvents)
1751 replay.order_timestamp_copy = [this, slot, &ordered_timestamps](VkCommandBuffer cb) {
1752 const VkEvent event = take_event();
1753 if (!event) return;
1754 slot->events.push_back(event);
1755 const auto& vk = context_.vk;
1756 vk.vkCmdSetEvent(cb, event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
1757 vk.vkCmdWaitEvents(cb, 1, &event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
1758 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, nullptr, 0, nullptr);
1759 ordered_timestamps = true;
1760 };
1687 const auto discard = [&] { 1761 const auto discard = [&] {
1688 if (context_.vk.vkResetCommandBuffer(command_buffer, 0) == VK_SUCCESS) slot->ticket = 0; 1762 if (context_.vk.vkResetCommandBuffer(command_buffer, 0) == VK_SUCCESS) slot->ticket = 0;
1689 }; 1763 };
@@ -1694,7 +1768,7 @@ public:
1694 return ReplayResult::unsupported; 1768 return ReplayResult::unsupported;
1695 } 1769 }
1696 if (!tracker_lock.owns_lock()) tracker_lock.lock(); 1770 if (!tracker_lock.owns_lock()) tracker_lock.lock();
1697 if (context_.bindless_prepare_ && !context_.bindless_prepare_(command_buffer)) { 1771 if (!transfer_only && context_.bindless_prepare_ && !context_.bindless_prepare_(command_buffer)) {
1698 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS; 1772 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS;
1699 resource_lock.unlock(); 1773 resource_lock.unlock();
1700 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0); 1774 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0);
@@ -1791,6 +1865,11 @@ public:
1791 } 1865 }
1792 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS; 1866 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS;
1793 resource_lock.unlock(); // release resource_mutex_ before vkQueueSubmit while keeping tracker_lock held 1867 resource_lock.unlock(); // release resource_mutex_ before vkQueueSubmit while keeping tracker_lock held
1868 const bool wait_previous = ordered_timestamps && submitted_;
1869 if (wait_previous) {
1870 waits_.push_back(progress_);
1871 wait_values_.push_back(submitted_);
1872 }
1794 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0); 1873 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0);
1795 if (!submitted && !storage_images.empty()) { // not initialized after all: try again with the next submission 1874 if (!submitted && !storage_images.empty()) { // not initialized after all: try again with the next submission
1796 std::lock_guard lock(context_.storage_mutex_); 1875 std::lock_guard lock(context_.storage_mutex_);
@@ -1810,6 +1889,10 @@ public:
1810 ++context_.bindless_upload_version_; 1889 ++context_.bindless_upload_version_;
1811 bindless_upload_seen_ = context_.bindless_upload_version_; 1890 bindless_upload_seen_ = context_.bindless_upload_version_;
1812 } 1891 }
1892 if (wait_previous && !submitted && !waits_.empty()) { // a failed submit keeps the waits for the next one
1893 waits_.pop_back();
1894 wait_values_.pop_back();
1895 }
1813 if (submitted) { 1896 if (submitted) {
1814 context_.tracker_ = std::move(next_tracker); 1897 context_.tracker_ = std::move(next_tracker);
1815 slot->predicate = std::move(batch); 1898 slot->predicate = std::move(batch);
@@ -1874,6 +1957,7 @@ private:
1874 VkCommandBuffer buffer; 1957 VkCommandBuffer buffer;
1875 std::uint64_t ticket; 1958 std::uint64_t ticket;
1876 std::vector<std::shared_ptr<const OcclusionSegmentPool>> segments; 1959 std::vector<std::shared_ptr<const OcclusionSegmentPool>> segments;
1960 std::vector<VkEvent> events; // order_timestamp_copy's, reset and reused once the slot completes
1877 std::unique_ptr<PredicatedBufferCopier::Batch> predicated_copy; 1961 std::unique_ptr<PredicatedBufferCopier::Batch> predicated_copy;
1878 std::unique_ptr<PredicateReducer::Batch> predicate; // retained until this slot completes 1962 std::unique_ptr<PredicateReducer::Batch> predicate; // retained until this slot completes
1879 }; 1963 };
@@ -1983,6 +2067,10 @@ private:
1983 for (auto& slot : buffers_) { 2067 for (auto& slot : buffers_) {
1984 if (slot.ticket > done) continue; 2068 if (slot.ticket > done) continue;
1985 slot.segments.clear(); 2069 slot.segments.clear();
2070 for (VkEvent event : slot.events)
2071 if (context_.vk.vkResetEvent(context_.device(), event) == VK_SUCCESS) free_events_.push_back(event);
2072 else context_.vk.vkDestroyEvent(context_.device(), event, nullptr);
2073 slot.events.clear();
1986 if (!reuse) reuse = &slot; 2074 if (!reuse) reuse = &slot;
1987 } 2075 }
1988 if (reuse) { 2076 if (reuse) {
@@ -2003,6 +2091,20 @@ private:
2003 return &buffers_.back(); 2091 return &buffers_.back();
2004 } 2092 }
2005 2093
2094 // An unsignaled event for order_timestamp_copy, or null. MoltenVK decides when the command buffer is submitted
2095 // whether a set or wait does anything, from the event's state then, so each use gets an event of its own.
2096 VkEvent take_event() {
2097 if (!free_events_.empty()) {
2098 const VkEvent event = free_events_.back();
2099 free_events_.pop_back();
2100 return event;
2101 }
2102 VkEventCreateInfo info{VK_STRUCTURE_TYPE_EVENT_CREATE_INFO};
2103 VkEvent event = VK_NULL_HANDLE;
2104 if (context_.vk.vkCreateEvent(context_.device(), &info, nullptr, &event) != VK_SUCCESS) return VK_NULL_HANDLE;
2105 return event;
2106 }
2107
2006 bool submit(VkCommandBuffer command_buffer, VkSemaphore fence, std::uint64_t value) { 2108 bool submit(VkCommandBuffer command_buffer, VkSemaphore fence, std::uint64_t value) {
2007 if (context_.is_device_lost()) return false; 2109 if (context_.is_device_lost()) return false;
2008 const std::uint64_t ticket = submitted_ + 1; 2110 const std::uint64_t ticket = submitted_ + 1;
@@ -2072,6 +2174,7 @@ private:
2072 VkSemaphore progress_ = VK_NULL_HANDLE; // our own timeline: which command buffers are done 2174 VkSemaphore progress_ = VK_NULL_HANDLE; // our own timeline: which command buffers are done
2073 std::uint64_t submitted_ = 0; 2175 std::uint64_t submitted_ = 0;
2074 std::vector<CommandSlot> buffers_; 2176 std::vector<CommandSlot> buffers_;
2177 std::vector<VkEvent> free_events_; // unsignaled, for order_timestamp_copy
2075 std::unique_ptr<OcclusionResolve> occlusion_resolve_; 2178 std::unique_ptr<OcclusionResolve> occlusion_resolve_;
2076 std::uint64_t storage_init_seen_ = 0; // the storage_init_version_ this queue has waited for 2179 std::uint64_t storage_init_seen_ = 0; // the storage_init_version_ this queue has waited for
2077 std::uint64_t bindless_upload_seen_ = 0; // the bindless_upload_version_ this queue has waited for 2180 std::uint64_t bindless_upload_seen_ = 0; // the bindless_upload_version_ this queue has waited for