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:
authorlumenpearson <139921639+lumenpearson@users.noreply.github.com>2026-11-22 23:25:25 +0300
committerlumenpearson <139921639+lumenpearson@users.noreply.github.com>2026-11-22 23:25:25 +0300
commitf324bfbc71f0eabf9515bcd7c8b7c9e4b89448bf (patch)
tree2db4ae6fd5412abbbc3e1894f8bc7ed88c8ae514 /runtime/src/vulkan_backend.h
parent18380c6d2baf1422109b369860a6e8be5e185b05 (diff)
parentf847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff)
Merge upstream main into SHADER-537
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 140d7234b..1be77a0ca 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);
@@ -1289,11 +1326,13 @@ private:
1289 std::function<void(bool)> bindless_commit_; 1326 std::function<void(bool)> bindless_commit_;
1290 std::unordered_map<QueryHeapId, QueryPool> query_pools_; // element pointers stay valid across inserts 1327 std::unordered_map<QueryHeapId, QueryPool> query_pools_; // element pointers stay valid across inserts
1291 double timestamp_period_ = 0; 1328 double timestamp_period_ = 0;
1329 bool order_timestamp_copies_ = false;
1292 VkPhysicalDeviceMemoryProperties occlusion_resolve_memory_{}; 1330 VkPhysicalDeviceMemoryProperties occlusion_resolve_memory_{};
1293 ReplayFunctions replay_; 1331 ReplayFunctions replay_;
1294 std::unique_ptr<PredicateReducer> predicate_reducer_; 1332 std::unique_ptr<PredicateReducer> predicate_reducer_;
1295 std::unique_ptr<PredicatedBufferCopier> predicated_copier_; 1333 std::unique_ptr<PredicatedBufferCopier> predicated_copier_;
1296 std::uint32_t predicate_family_ = UINT32_MAX; 1334 std::uint32_t predicate_family_ = UINT32_MAX;
1335 std::uint32_t transfer_only_family_ = UINT32_MAX;
1297 DebugLabelFunctions labels_; 1336 DebugLabelFunctions labels_;
1298}; 1337};
1299#ifdef _MSC_VER 1338#ifdef _MSC_VER
@@ -1401,6 +1440,8 @@ public:
1401 } 1440 }
1402 if (pool_) vk.vkDestroyCommandPool(context_.device(), pool_, nullptr); 1441 if (pool_) vk.vkDestroyCommandPool(context_.device(), pool_, nullptr);
1403 if (progress_) vk.vkDestroySemaphore(context_.device(), progress_, nullptr); 1442 if (progress_) vk.vkDestroySemaphore(context_.device(), progress_, nullptr);
1443 for (auto& slot : buffers_) free_events_.insert(free_events_.end(), slot.events.begin(), slot.events.end());
1444 for (VkEvent event : free_events_) vk.vkDestroyEvent(context_.device(), event, nullptr);
1404 } 1445 }
1405 1446
1406 VulkanQueue(const VulkanQueue&) = delete; 1447 VulkanQueue(const VulkanQueue&) = delete;
@@ -1474,6 +1515,12 @@ public:
1474 // the layout tracker as it was. Pending Wait()s are attached to this submission. 1515 // the layout tracker as it was. Pending Wait()s are attached to this submission.
1475 ReplayResult execute(std::span<const CommandList* const> lists) { 1516 ReplayResult execute(std::span<const CommandList* const> lists) {
1476 if (context_.is_device_lost()) return ReplayResult::unsupported; 1517 if (context_.is_device_lost()) return ReplayResult::unsupported;
1518 if (kind_ != QueueKind::direct)
1519 for (const auto* list : lists)
1520 for (const auto& command : list->commands())
1521 if (std::holds_alternative<ClearRenderTarget>(command) ||
1522 std::holds_alternative<ClearDepthStencil>(command))
1523 return ReplayResult::unsupported;
1477 VkCommandBuffer command_buffer = VK_NULL_HANDLE; 1524 VkCommandBuffer command_buffer = VK_NULL_HANDLE;
1478 std::function<void(bool)> bindless_commit; 1525 std::function<void(bool)> bindless_commit;
1479 // Lock hierarchy: resource_mutex_ -> tracker_mutex_ -> submit_mutex_. 1526 // Lock hierarchy: resource_mutex_ -> tracker_mutex_ -> submit_mutex_.
@@ -1500,12 +1547,16 @@ public:
1500 if (active && scratch) scratch->retire(progress, 0); 1547 if (active && scratch) scratch->retire(progress, 0);
1501 } 1548 }
1502 } scratch_guard{context_.scratch_.get(), progress_, false}; 1549 } scratch_guard{context_.scratch_.get(), progress_, false};
1503 bindless_commit = context_.bindless_commit_; 1550 const bool transfer_only = family_ == context_.transfer_only_family_;
1551 if (!transfer_only) bindless_commit = context_.bindless_commit_;
1504 // Kept between executions: prepare refills each list's entries in the storage the last execution left, where 1552 // Kept between executions: prepare refills each list's entries in the storage the last execution left, where
1505 // making them fresh for every command was about half the layer's CPU cost per command (replay_cpu_bench). 1553 // making them fresh for every command was about half the layer's CPU cost per command (replay_cpu_bench).
1506 auto& prepared = prepared_; 1554 auto& prepared = prepared_;
1507 prepared.resize(lists.size()); 1555 prepared.resize(lists.size());
1508 ReplayFunctions replay = context_.replay_; 1556 ReplayFunctions replay = context_.replay_;
1557 replay.queue_stages = kind_ == QueueKind::copy ? detail::queue_stages_copy
1558 : kind_ == QueueKind::compute ? detail::queue_stages_compute
1559 : 0;
1509 std::uint64_t captures = 0; 1560 std::uint64_t captures = 0;
1510 for (const auto* list : lists) 1561 for (const auto* list : lists)
1511 for (const auto& command : list->commands()) 1562 for (const auto& command : list->commands())
@@ -1549,7 +1600,7 @@ public:
1549 return context_.scratch_->get(bytes, buffer, offset); 1600 return context_.scratch_->get(bytes, buffer, offset);
1550 }; 1601 };
1551 } 1602 }
1552 if (context_.depth24_) { 1603 if (context_.depth24_ && !transfer_only) {
1553 replay.depth24_prepare = [this, &tracker_lock, &depth24_guard](Depth24Job& job, 1604 replay.depth24_prepare = [this, &tracker_lock, &depth24_guard](Depth24Job& job,
1554 std::vector<Depth24Job>& parts) { 1605 std::vector<Depth24Job>& parts) {
1555 if (!tracker_lock.owns_lock()) tracker_lock.lock(); 1606 if (!tracker_lock.owns_lock()) tracker_lock.lock();
@@ -1575,6 +1626,10 @@ public:
1575 std::uint32_t count, VkBuffer dst, VkDeviceSize offset) { 1626 std::uint32_t count, VkBuffer dst, VkDeviceSize offset) {
1576 occlusion_resolve_->sum_statistics(cb, pool, first, count, dst, offset); 1627 occlusion_resolve_->sum_statistics(cb, pool, first, count, dst, offset);
1577 }; 1628 };
1629 replay.sum_binary_occlusion = [this](VkCommandBuffer cb, VkQueryPool pool, std::uint32_t first,
1630 std::uint32_t count, VkBuffer dst, VkDeviceSize offset) {
1631 occlusion_resolve_->sum_binary(cb, pool, first, count, dst, offset);
1632 };
1578 } 1633 }
1579 const auto resolve = [this](ResourceId id) { return context_.resolve(id); }; 1634 const auto resolve = [this](ResourceId id) { return context_.resolve(id); };
1580 std::uint32_t segments = 0, statistics_segments = 0; 1635 std::uint32_t segments = 0, statistics_segments = 0;
@@ -1621,19 +1676,38 @@ public:
1621 base += list.segment_count; 1676 base += list.segment_count;
1622 statistics_base += list.statistics_segment_count; 1677 statistics_base += list.statistics_segment_count;
1623 } 1678 }
1624 if (queries.needs_sum || queries.needs_binary || queries.needs_statistics_sum) { 1679 if (queries.needs_sum || queries.needs_binary || queries.needs_statistics_sum || queries.needs_sum_binary) {
1625 if (!occlusion_resolve_) { 1680 if (!occlusion_resolve_) {
1626 auto helper = std::make_unique<OcclusionResolve>(context_.vk, context_.device()); 1681 auto helper = std::make_unique<OcclusionResolve>(context_.vk, context_.device());
1627 if (!helper->initialize(occlusion_memory)) return ReplayResult::unsupported; 1682 if (!helper->initialize(occlusion_memory)) return ReplayResult::unsupported;
1628 occlusion_resolve_ = std::move(helper); 1683 occlusion_resolve_ = std::move(helper);
1629 } 1684 }
1630 if (!occlusion_resolve_->prepare(queries.needs_sum, queries.needs_binary, queries.needs_statistics_sum)) 1685 if (!occlusion_resolve_->prepare(queries.needs_sum, queries.needs_binary, queries.needs_statistics_sum,
1686 queries.needs_sum_binary))
1631 return ReplayResult::unsupported; 1687 return ReplayResult::unsupported;
1632 } 1688 }
1633 1689
1634 CommandSlot* slot = acquire(); 1690 CommandSlot* slot = acquire();
1635 if (!slot) return ReplayResult::unsupported; 1691 if (!slot) return ReplayResult::unsupported;
1636 command_buffer = slot->buffer; 1692 command_buffer = slot->buffer;
1693 // MoltenVK writes a timestamp at the end of a Metal encoder and resolves it with a blit that nothing orders
1694 // after that write, so a copy in the same or the next command buffer reads the old value (docs section 4.6).
1695 // An event set and waited for in this command buffer orders it after this submission's timestamps; a wait for
1696 // this queue's previous submission orders it after earlier ones still running.
1697 bool ordered_timestamps = false;
1698 const auto& events = context_.vk;
1699 if (context_.order_timestamp_copies() && events.vkCreateEvent && events.vkDestroyEvent && events.vkResetEvent &&
1700 events.vkCmdSetEvent && events.vkCmdWaitEvents)
1701 replay.order_timestamp_copy = [this, slot, &ordered_timestamps](VkCommandBuffer cb) {
1702 const VkEvent event = take_event();
1703 if (!event) return;
1704 slot->events.push_back(event);
1705 const auto& vk = context_.vk;
1706 vk.vkCmdSetEvent(cb, event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
1707 vk.vkCmdWaitEvents(cb, 1, &event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
1708 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, nullptr, 0, nullptr);
1709 ordered_timestamps = true;
1710 };
1637 const auto discard = [&] { 1711 const auto discard = [&] {
1638 if (context_.vk.vkResetCommandBuffer(command_buffer, 0) == VK_SUCCESS) slot->ticket = 0; 1712 if (context_.vk.vkResetCommandBuffer(command_buffer, 0) == VK_SUCCESS) slot->ticket = 0;
1639 }; 1713 };
@@ -1644,7 +1718,7 @@ public:
1644 return ReplayResult::unsupported; 1718 return ReplayResult::unsupported;
1645 } 1719 }
1646 if (!tracker_lock.owns_lock()) tracker_lock.lock(); 1720 if (!tracker_lock.owns_lock()) tracker_lock.lock();
1647 if (context_.bindless_prepare_ && !context_.bindless_prepare_(command_buffer)) { 1721 if (!transfer_only && context_.bindless_prepare_ && !context_.bindless_prepare_(command_buffer)) {
1648 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS; 1722 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS;
1649 resource_lock.unlock(); 1723 resource_lock.unlock();
1650 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0); 1724 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0);
@@ -1730,6 +1804,11 @@ public:
1730 } 1804 }
1731 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS; 1805 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS;
1732 resource_lock.unlock(); // release resource_mutex_ before vkQueueSubmit while keeping tracker_lock held 1806 resource_lock.unlock(); // release resource_mutex_ before vkQueueSubmit while keeping tracker_lock held
1807 const bool wait_previous = ordered_timestamps && submitted_;
1808 if (wait_previous) {
1809 waits_.push_back(progress_);
1810 wait_values_.push_back(submitted_);
1811 }
1733 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0); 1812 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0);
1734 if (!submitted && !storage_images.empty()) { // not initialized after all: try again with the next submission 1813 if (!submitted && !storage_images.empty()) { // not initialized after all: try again with the next submission
1735 std::lock_guard lock(context_.storage_mutex_); 1814 std::lock_guard lock(context_.storage_mutex_);
@@ -1742,6 +1821,10 @@ public:
1742 ++context_.storage_init_version_; 1821 ++context_.storage_init_version_;
1743 storage_init_seen_ = context_.storage_init_version_; 1822 storage_init_seen_ = context_.storage_init_version_;
1744 } 1823 }
1824 if (wait_previous && !submitted && !waits_.empty()) { // a failed submit keeps the waits for the next one
1825 waits_.pop_back();
1826 wait_values_.pop_back();
1827 }
1745 if (submitted) { 1828 if (submitted) {
1746 context_.tracker_ = std::move(next_tracker); 1829 context_.tracker_ = std::move(next_tracker);
1747 slot->predicate = std::move(batch); 1830 slot->predicate = std::move(batch);
@@ -1804,6 +1887,7 @@ private:
1804 VkCommandBuffer buffer; 1887 VkCommandBuffer buffer;
1805 std::uint64_t ticket; 1888 std::uint64_t ticket;
1806 std::vector<std::shared_ptr<const OcclusionSegmentPool>> segments; 1889 std::vector<std::shared_ptr<const OcclusionSegmentPool>> segments;
1890 std::vector<VkEvent> events; // order_timestamp_copy's, reset and reused once the slot completes
1807 std::unique_ptr<PredicatedBufferCopier::Batch> predicated_copy; 1891 std::unique_ptr<PredicatedBufferCopier::Batch> predicated_copy;
1808 std::unique_ptr<PredicateReducer::Batch> predicate; // retained until this slot completes 1892 std::unique_ptr<PredicateReducer::Batch> predicate; // retained until this slot completes
1809 }; 1893 };
@@ -1913,6 +1997,10 @@ private:
1913 for (auto& slot : buffers_) { 1997 for (auto& slot : buffers_) {
1914 if (slot.ticket > done) continue; 1998 if (slot.ticket > done) continue;
1915 slot.segments.clear(); 1999 slot.segments.clear();
2000 for (VkEvent event : slot.events)
2001 if (context_.vk.vkResetEvent(context_.device(), event) == VK_SUCCESS) free_events_.push_back(event);
2002 else context_.vk.vkDestroyEvent(context_.device(), event, nullptr);
2003 slot.events.clear();
1916 if (!reuse) reuse = &slot; 2004 if (!reuse) reuse = &slot;
1917 } 2005 }
1918 if (reuse) { 2006 if (reuse) {
@@ -1933,6 +2021,20 @@ private:
1933 return &buffers_.back(); 2021 return &buffers_.back();
1934 } 2022 }
1935 2023
2024 // An unsignaled event for order_timestamp_copy, or null. MoltenVK decides when the command buffer is submitted
2025 // whether a set or wait does anything, from the event's state then, so each use gets an event of its own.
2026 VkEvent take_event() {
2027 if (!free_events_.empty()) {
2028 const VkEvent event = free_events_.back();
2029 free_events_.pop_back();
2030 return event;
2031 }
2032 VkEventCreateInfo info{VK_STRUCTURE_TYPE_EVENT_CREATE_INFO};
2033 VkEvent event = VK_NULL_HANDLE;
2034 if (context_.vk.vkCreateEvent(context_.device(), &info, nullptr, &event) != VK_SUCCESS) return VK_NULL_HANDLE;
2035 return event;
2036 }
2037
1936 bool submit(VkCommandBuffer command_buffer, VkSemaphore fence, std::uint64_t value) { 2038 bool submit(VkCommandBuffer command_buffer, VkSemaphore fence, std::uint64_t value) {
1937 if (context_.is_device_lost()) return false; 2039 if (context_.is_device_lost()) return false;
1938 const std::uint64_t ticket = submitted_ + 1; 2040 const std::uint64_t ticket = submitted_ + 1;
@@ -2002,6 +2104,7 @@ private:
2002 VkSemaphore progress_ = VK_NULL_HANDLE; // our own timeline: which command buffers are done 2104 VkSemaphore progress_ = VK_NULL_HANDLE; // our own timeline: which command buffers are done
2003 std::uint64_t submitted_ = 0; 2105 std::uint64_t submitted_ = 0;
2004 std::vector<CommandSlot> buffers_; 2106 std::vector<CommandSlot> buffers_;
2107 std::vector<VkEvent> free_events_; // unsignaled, for order_timestamp_copy
2005 std::unique_ptr<OcclusionResolve> occlusion_resolve_; 2108 std::unique_ptr<OcclusionResolve> occlusion_resolve_;
2006 std::uint64_t storage_init_seen_ = 0; // the storage_init_version_ this queue has waited for 2109 std::uint64_t storage_init_seen_ = 0; // the storage_init_version_ this queue has waited for
2007 std::uint64_t last_sparse_ = 0; 2110 std::uint64_t last_sparse_ = 0;