diff options
| author | Rain156 <77776581+Rain156@users.noreply.github.com> | 2026-11-24 21:26:25 +0800 |
|---|---|---|
| committer | Rain156 <77776581+Rain156@users.noreply.github.com> | 2026-11-24 21:26:25 +0800 |
| commit | aa8be9aef20291e6faf6ed986d2b6691aad96abf (patch) | |
| tree | 80e0224b761256cd2375d069089f1eb6413dcd7a /runtime/src/vulkan_backend.h | |
| parent | be767b6889cb373cc695b67367644ea4370f8e9c (diff) | |
| parent | db19bbd3455a757c3fe986c6e6db36998f275150 (diff) | |
Integrate the offline first-run UI runtime with current main and the published renderer fixes
Use the tagged pipeline variants and indexed quad expansion from #722 and #682 with the shared shader cache. Retain title-backed index uploads, cross-queue scratch sharing, amd64 console return conventions and the PC/console caller discriminator. The local shader build indexes native containers and includes the executable's embedded stages.
Diffstat (limited to 'runtime/src/vulkan_backend.h')
| -rw-r--r-- | runtime/src/vulkan_backend.h | 116 |
1 files changed, 108 insertions, 8 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h index a041825c2..568fa5253 100644 --- a/runtime/src/vulkan_backend.h +++ b/runtime/src/vulkan_backend.h | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | #include "vulkan_gpu_labels.h" | ||
| 2 | 3 | ||
| 3 | // The execution side of the D3D12 layer, without COM: the per-device Vulkan context (resources, layout tracker, | 4 | // The execution side of the D3D12 layer, without COM: the per-device Vulkan context (resources, layout tracker, |
| 4 | // image views), queues that execute command lists, and timeline-semaphore fences. The COM objects in | 5 | // image views), queues that execute command lists, and timeline-semaphore fences. The COM objects in |
| @@ -85,7 +86,7 @@ struct VulkanDeviceFunctions { | |||
| 85 | X(vkCmdClearAttachments) X(vkDeviceWaitIdle) X(vkCreateImage) X(vkDestroyImage) \ | 86 | X(vkCmdClearAttachments) X(vkDeviceWaitIdle) X(vkCreateImage) X(vkDestroyImage) \ |
| 86 | X(vkGetImageMemoryRequirements) X(vkBindImageMemory) X(vkCreateBuffer) X(vkDestroyBuffer) \ | 87 | X(vkGetImageMemoryRequirements) X(vkBindImageMemory) X(vkCreateBuffer) X(vkDestroyBuffer) \ |
| 87 | X(vkGetBufferMemoryRequirements) X(vkBindBufferMemory) X(vkAllocateMemory) X(vkFreeMemory) X(vkMapMemory) \ | 88 | X(vkGetBufferMemoryRequirements) X(vkBindBufferMemory) X(vkAllocateMemory) X(vkFreeMemory) X(vkMapMemory) \ |
| 88 | X(vkUnmapMemory) X(vkCmdCopyBuffer) X(vkCmdCopyBufferToImage) X(vkCmdCopyImageToBuffer) X(vkCmdCopyImage) \ | 89 | X(vkUnmapMemory) X(vkCmdCopyBuffer) X(vkCmdCopyBufferToImage) X(vkCmdCopyImageToBuffer) X(vkCmdCopyImage) X(vkCmdBlitImage) \ |
| 89 | X(vkCmdResolveImage) X(vkCmdFillBuffer) X(vkCmdUpdateBuffer) X(vkCreateSampler) X(vkDestroySampler) \ | 90 | X(vkCmdResolveImage) X(vkCmdFillBuffer) X(vkCmdUpdateBuffer) X(vkCreateSampler) X(vkDestroySampler) \ |
| 90 | X(vkCmdBeginConditionalRenderingEXT) X(vkCmdEndConditionalRenderingEXT) X(vkCreateQueryPool) \ | 91 | X(vkCmdBeginConditionalRenderingEXT) X(vkCmdEndConditionalRenderingEXT) X(vkCreateQueryPool) \ |
| 91 | X(vkDestroyQueryPool) X(vkCmdResetQueryPool) X(vkCmdBeginQuery) X(vkCmdEndQuery) X(vkCmdWriteTimestamp) \ | 92 | X(vkDestroyQueryPool) X(vkCmdResetQueryPool) X(vkCmdBeginQuery) X(vkCmdEndQuery) X(vkCmdWriteTimestamp) \ |
| @@ -104,7 +105,7 @@ struct VulkanDeviceFunctions { | |||
| 104 | X(vkCmdSetPrimitiveTopology) X(vkCmdSetPrimitiveRestartEnable) X(vkCmdSetStencilReference) \ | 105 | X(vkCmdSetPrimitiveTopology) X(vkCmdSetPrimitiveRestartEnable) X(vkCmdSetStencilReference) \ |
| 105 | X(vkCmdSetBlendConstants) X(vkCmdDraw) \ | 106 | X(vkCmdSetBlendConstants) X(vkCmdDraw) \ |
| 106 | X(vkCmdDrawIndexed) X(vkCreateGraphicsPipelines) X(vkQueueBindSparse) X(vkGetImageSparseMemoryRequirements) \ | 107 | X(vkCmdDrawIndexed) X(vkCreateGraphicsPipelines) X(vkQueueBindSparse) X(vkGetImageSparseMemoryRequirements) \ |
| 107 | X(vkCreatePipelineCache) X(vkDestroyPipelineCache) \ | 108 | X(vkCreatePipelineCache) X(vkDestroyPipelineCache) X(vkGetPipelineCacheData) X(vkMergePipelineCaches) \ |
| 108 | X(vkCreateEvent) X(vkDestroyEvent) X(vkResetEvent) X(vkCmdSetEvent) X(vkCmdWaitEvents) X(vkCmdDrawMeshTasksEXT) \ | 109 | X(vkCreateEvent) X(vkDestroyEvent) X(vkResetEvent) X(vkCmdSetEvent) X(vkCmdWaitEvents) X(vkCmdDrawMeshTasksEXT) \ |
| 109 | X(vkCreateRenderPass2) X(vkDestroyRenderPass) X(vkCreateFramebuffer) X(vkDestroyFramebuffer) \ | 110 | X(vkCreateRenderPass2) X(vkDestroyRenderPass) X(vkCreateFramebuffer) X(vkDestroyFramebuffer) \ |
| 110 | X(vkCmdBeginRenderPass) X(vkCmdEndRenderPass) | 111 | X(vkCmdBeginRenderPass) X(vkCmdEndRenderPass) |
| @@ -941,6 +942,7 @@ public: | |||
| 941 | replay_.copy_buffer_to_image = vk.vkCmdCopyBufferToImage; | 942 | replay_.copy_buffer_to_image = vk.vkCmdCopyBufferToImage; |
| 942 | replay_.copy_image_to_buffer = vk.vkCmdCopyImageToBuffer; | 943 | replay_.copy_image_to_buffer = vk.vkCmdCopyImageToBuffer; |
| 943 | replay_.copy_image = vk.vkCmdCopyImage; | 944 | replay_.copy_image = vk.vkCmdCopyImage; |
| 945 | replay_.blit_image = vk.vkCmdBlitImage; | ||
| 944 | replay_.resolve_image = vk.vkCmdResolveImage; | 946 | replay_.resolve_image = vk.vkCmdResolveImage; |
| 945 | replay_.fill_buffer = vk.vkCmdFillBuffer; | 947 | replay_.fill_buffer = vk.vkCmdFillBuffer; |
| 946 | replay_.update_buffer = vk.vkCmdUpdateBuffer; | 948 | replay_.update_buffer = vk.vkCmdUpdateBuffer; |
| @@ -1142,6 +1144,12 @@ public: | |||
| 1142 | std::unique_lock lock(resource_mutex_); | 1144 | std::unique_lock lock(resource_mutex_); |
| 1143 | set_resource_locked(id, binding); | 1145 | set_resource_locked(id, binding); |
| 1144 | } | 1146 | } |
| 1147 | // Whether `va` is in a buffer this context knows by VA (the index buffer_at searches). | ||
| 1148 | bool knows_buffer_va(std::uint64_t va) { | ||
| 1149 | std::shared_lock lock(resource_mutex_); | ||
| 1150 | BufferVaIndex<ResourceId>::Hit hit{}; | ||
| 1151 | return buffer_vas_.find(va, hit); | ||
| 1152 | } | ||
| 1145 | void add_resource(ResourceId id, const ResourceBinding& binding, VkImageLayout current_layout) { | 1153 | void add_resource(ResourceId id, const ResourceBinding& binding, VkImageLayout current_layout) { |
| 1146 | std::unique_lock rlock(resource_mutex_); | 1154 | std::unique_lock rlock(resource_mutex_); |
| 1147 | set_resource_locked(id, binding); | 1155 | set_resource_locked(id, binding); |
| @@ -1203,6 +1211,7 @@ public: | |||
| 1203 | } | 1211 | } |
| 1204 | { | 1212 | { |
| 1205 | std::lock_guard lock(storage_mutex_); // a buffer destroyed before any submission is not filled | 1213 | std::lock_guard lock(storage_mutex_); // a buffer destroyed before any submission is not filled |
| 1214 | storage_pending_.erase(id); | ||
| 1206 | std::erase_if(zero_pending_, [id](const PendingZero& zero) { return zero.id == id; }); | 1215 | std::erase_if(zero_pending_, [id](const PendingZero& zero) { return zero.id == id; }); |
| 1207 | } | 1216 | } |
| 1208 | if (img) { | 1217 | if (img) { |
| @@ -1275,6 +1284,24 @@ public: | |||
| 1275 | replay_.zero_size = size; | 1284 | replay_.zero_size = size; |
| 1276 | } | 1285 | } |
| 1277 | 1286 | ||
| 1287 | struct GeometryUpload { | ||
| 1288 | std::uint64_t source{}, size{}; | ||
| 1289 | VkBuffer buffer{}; | ||
| 1290 | VkDeviceSize offset{}; | ||
| 1291 | std::shared_ptr<void> owner; | ||
| 1292 | }; | ||
| 1293 | using GeometryProvider = std::function<bool(std::uint64_t,std::uint64_t,GeometryUpload&)>; | ||
| 1294 | void set_geometry_provider(GeometryProvider provider) { | ||
| 1295 | std::unique_lock lock(resource_mutex_); | ||
| 1296 | geometry_provider_=std::move(provider); | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | // LOCAL: the copy-in fallback for vertex and index views in title memory (ReplayFunctions::title_memory). | ||
| 1300 | void set_title_memory(std::function<bool(std::uint64_t, std::uint64_t, VkBuffer&, VkDeviceSize&)> copy) { | ||
| 1301 | std::unique_lock lock(resource_mutex_); | ||
| 1302 | replay_.title_memory = std::move(copy); | ||
| 1303 | } | ||
| 1304 | |||
| 1278 | // Pre-expanded 32-bit triangle indices for non-indexed quad lists (ReplayFunctions::quad_indices). | 1305 | // Pre-expanded 32-bit triangle indices for non-indexed quad lists (ReplayFunctions::quad_indices). |
| 1279 | void set_quad_indices(VkBuffer buffer, VkDeviceSize offset, std::uint32_t count) { | 1306 | void set_quad_indices(VkBuffer buffer, VkDeviceSize offset, std::uint32_t count) { |
| 1280 | std::unique_lock lock(resource_mutex_); | 1307 | std::unique_lock lock(resource_mutex_); |
| @@ -1323,6 +1350,23 @@ public: | |||
| 1323 | return resources_.find(id) != resources_.end(); | 1350 | return resources_.find(id) != resources_.end(); |
| 1324 | } | 1351 | } |
| 1325 | 1352 | ||
| 1353 | // The registered buffer whose VA range holds `va`, preferring one that holds [va, va + bytes) as buffer_at does: its | ||
| 1354 | // ID, first VA and size in bytes. False when none does, or when `acquire(id)` returns false. `acquire` runs with | ||
| 1355 | // the registry locked, so the resource cannot finish being removed under it: it takes the caller's reference | ||
| 1356 | // (Resource's destructor removes its entry first, which waits for this lock). Used where a console call names a | ||
| 1357 | // buffer by VA only (Xbox device slot 70). | ||
| 1358 | template<class Acquire> | ||
| 1359 | bool buffer_resource_at(std::uint64_t va, std::uint64_t bytes, ResourceId& id, std::uint64_t& start, | ||
| 1360 | std::uint64_t& size, Acquire&& acquire) { | ||
| 1361 | std::shared_lock lock(resource_mutex_); | ||
| 1362 | BufferVaIndex<ResourceId>::Hit hit{}; | ||
| 1363 | if (!buffer_vas_.find(va, hit, bytes) || !acquire(hit.id)) return false; | ||
| 1364 | id = hit.id; | ||
| 1365 | start = hit.start; | ||
| 1366 | size = hit.size; | ||
| 1367 | return true; | ||
| 1368 | } | ||
| 1369 | |||
| 1326 | bool ray_tracing_supported() const { return ray_tracing_ && vk.vkCmdBuildAccelerationStructuresKHR != nullptr; } | 1370 | bool ray_tracing_supported() const { return ray_tracing_ && vk.vkCmdBuildAccelerationStructuresKHR != nullptr; } |
| 1327 | bool xdxr_acceleration_structures() const { return xdxr_ != nullptr; } | 1371 | bool xdxr_acceleration_structures() const { return xdxr_ != nullptr; } |
| 1328 | 1372 | ||
| @@ -1397,6 +1441,28 @@ public: | |||
| 1397 | // written: the device brings the bindless set 0 of the translated shaders up to date there (vulkan_bindless.h) | 1441 | // written: the device brings the bindless set 0 of the translated shaders up to date there (vulkan_bindless.h) |
| 1398 | // and records what the set needs first. When it fails, nothing of that call is executed. | 1442 | // and records what the set needs first. When it fails, nothing of that call is executed. |
| 1399 | void set_transfer_only_family(std::uint32_t family) { transfer_only_family_ = family; } | 1443 | void set_transfer_only_family(std::uint32_t family) { transfer_only_family_ = family; } |
| 1444 | void set_graphics_family(std::uint32_t family) { graphics_family_ = family; } | ||
| 1445 | void set_compute_copy_aspects(std::function<VkImageAspectFlags(VkFormat)> check) { | ||
| 1446 | replay_.compute_copy_aspects = std::move(check); | ||
| 1447 | } | ||
| 1448 | |||
| 1449 | // `before` is called at the start of every submission of command lists (a held batch: when it is released), | ||
| 1450 | // before any lock here is taken: the device re-copies its slot-133 shadow buffers from the title's pages there. | ||
| 1451 | // Set once, before the first queue exists. | ||
| 1452 | void set_before_execute(std::function<void()> before) { before_execute_ = std::move(before); } | ||
| 1453 | |||
| 1454 | // Table VAs are offsets in this device's arena. Install its scanner before creating any queues. | ||
| 1455 | using TableScanner = std::function<void(std::uint64_t, std::uint32_t)>; | ||
| 1456 | void set_table_scanner(TableScanner scan) { table_scanner_ = std::move(scan); } | ||
| 1457 | void set_cpu_texture_publisher(std::function<bool()> f) { cpu_texture_publisher_ = std::move(f); } | ||
| 1458 | bool publish_cpu_textures() const { return !cpu_texture_publisher_ || cpu_texture_publisher_(); } | ||
| 1459 | void set_sample_table_resolver(std::function<bool(std::uint64_t,std::uint32_t)> f) { sample_table_resolver_ = std::move(f); } | ||
| 1460 | bool prepare_sample_table(std::uint64_t address, std::uint32_t count) const { | ||
| 1461 | return !sample_table_resolver_ || sample_table_resolver_(address,count); | ||
| 1462 | } | ||
| 1463 | void scan_table(std::uint64_t va, std::uint32_t descriptors) const { | ||
| 1464 | if (table_scanner_) table_scanner_(va, descriptors); | ||
| 1465 | } | ||
| 1400 | 1466 | ||
| 1401 | void set_bindless_prepare(std::function<bool(VkCommandBuffer)> prepare) { | 1467 | void set_bindless_prepare(std::function<bool(VkCommandBuffer)> prepare) { |
| 1402 | std::unique_lock lock(resource_mutex_); | 1468 | std::unique_lock lock(resource_mutex_); |
| @@ -1423,9 +1489,9 @@ public: | |||
| 1423 | // `allocate`. Without this such a copy is refused as unsupported. `extra_usage` is added to the chunks' transfer | 1489 | // `allocate`. Without this such a copy is refused as unsupported. `extra_usage` is added to the chunks' transfer |
| 1424 | // usage, for configure_quad_indices. | 1490 | // usage, for configure_quad_indices. |
| 1425 | void enable_copy_scratch(PFN_vkGetDeviceProcAddr get, ScratchBuffers::Allocate allocate, | 1491 | void enable_copy_scratch(PFN_vkGetDeviceProcAddr get, ScratchBuffers::Allocate allocate, |
| 1426 | VkBufferUsageFlags extra_usage = 0) { | 1492 | VkBufferUsageFlags extra_usage = 0, std::vector<std::uint32_t> families = {}) { |
| 1427 | std::unique_lock lock(resource_mutex_); | 1493 | std::unique_lock lock(resource_mutex_); |
| 1428 | scratch_ = std::make_unique<ScratchBuffers>(get, device_, std::move(allocate), extra_usage); | 1494 | scratch_ = std::make_unique<ScratchBuffers>(get, device_, std::move(allocate), extra_usage, std::move(families)); |
| 1429 | if (!scratch_->loaded()) scratch_.reset(); | 1495 | if (!scratch_->loaded()) scratch_.reset(); |
| 1430 | } | 1496 | } |
| 1431 | 1497 | ||
| @@ -1586,7 +1652,11 @@ private: | |||
| 1586 | 1652 | ||
| 1587 | const ResourceBinding* resolve(ResourceId id) const { | 1653 | const ResourceBinding* resolve(ResourceId id) const { |
| 1588 | const auto it = resources_.find(id); | 1654 | const auto it = resources_.find(id); |
| 1589 | return it == resources_.end() ? nullptr : &it->second; | 1655 | if (it == resources_.end()) return nullptr; |
| 1656 | const auto& binding = it->second; | ||
| 1657 | // The caller holds resource_mutex_, so the registered owner's lifetime includes this bind. | ||
| 1658 | if (binding.ensure_residency && !binding.ensure_residency(binding.residency_owner)) return nullptr; | ||
| 1659 | return &binding; | ||
| 1590 | } | 1660 | } |
| 1591 | 1661 | ||
| 1592 | // Called from prepare; protected by views_mutex_ so concurrent shared_lock readers are safe. | 1662 | // Called from prepare; protected by views_mutex_ so concurrent shared_lock readers are safe. |
| @@ -1713,6 +1783,11 @@ private: | |||
| 1713 | std::map<std::tuple<VkFormat, std::uint32_t, VkImageLayout, VkImageLayout, VkResolveModeFlagBits>, VkRenderPass> | 1783 | std::map<std::tuple<VkFormat, std::uint32_t, VkImageLayout, VkImageLayout, VkResolveModeFlagBits>, VkRenderPass> |
| 1714 | resolve_passes_; | 1784 | resolve_passes_; |
| 1715 | std::map<std::tuple<VkImage, VkImage, VkImageView, VkImageView, VkRenderPass>, VkFramebuffer> resolve_framebuffers_; | 1785 | std::map<std::tuple<VkImage, VkImage, VkImageView, VkImageView, VkRenderPass>, VkFramebuffer> resolve_framebuffers_; |
| 1786 | std::function<void()> before_execute_; | ||
| 1787 | TableScanner table_scanner_; | ||
| 1788 | GeometryProvider geometry_provider_; | ||
| 1789 | std::function<bool(std::uint64_t,std::uint32_t)> sample_table_resolver_; | ||
| 1790 | std::function<bool()> cpu_texture_publisher_; | ||
| 1716 | std::function<bool(VkCommandBuffer)> bindless_prepare_; | 1791 | std::function<bool(VkCommandBuffer)> bindless_prepare_; |
| 1717 | std::function<VkDescriptorSet()> bindless_current_; | 1792 | std::function<VkDescriptorSet()> bindless_current_; |
| 1718 | bool bindless_upload_pending_ = false; // tracker_mutex_ | 1793 | bool bindless_upload_pending_ = false; // tracker_mutex_ |
| @@ -1735,6 +1810,7 @@ private: | |||
| 1735 | std::unique_ptr<QuadIndexExpander> quad_indices_; | 1810 | std::unique_ptr<QuadIndexExpander> quad_indices_; |
| 1736 | std::uint32_t predicate_family_ = UINT32_MAX; | 1811 | std::uint32_t predicate_family_ = UINT32_MAX; |
| 1737 | std::uint32_t transfer_only_family_ = UINT32_MAX; | 1812 | std::uint32_t transfer_only_family_ = UINT32_MAX; |
| 1813 | std::uint32_t graphics_family_ = UINT32_MAX; | ||
| 1738 | DebugLabelFunctions labels_; | 1814 | DebugLabelFunctions labels_; |
| 1739 | }; | 1815 | }; |
| 1740 | #ifdef _MSC_VER | 1816 | #ifdef _MSC_VER |
| @@ -2268,6 +2344,7 @@ private: | |||
| 2268 | 2344 | ||
| 2269 | ReplayResult execute_now(std::span<const CommandList* const> lists) { | 2345 | ReplayResult execute_now(std::span<const CommandList* const> lists) { |
| 2270 | if (context_.is_device_lost() || !wait_for_room()) return ReplayResult::unsupported; | 2346 | if (context_.is_device_lost() || !wait_for_room()) return ReplayResult::unsupported; |
| 2347 | if (context_.before_execute_) context_.before_execute_(); | ||
| 2271 | if (kind_ != QueueKind::direct) | 2348 | if (kind_ != QueueKind::direct) |
| 2272 | for (const auto* list : lists) | 2349 | for (const auto* list : lists) |
| 2273 | for (const auto& command : list->commands()) | 2350 | for (const auto& command : list->commands()) |
| @@ -2319,6 +2396,23 @@ private: | |||
| 2319 | // use only the first lists.size() entries, so stale entries are never prepared, queried or emitted. | 2396 | // use only the first lists.size() entries, so stale entries are never prepared, queried or emitted. |
| 2320 | if (prepared.size() < lists.size()) prepared.resize(lists.size()); | 2397 | if (prepared.size() < lists.size()) prepared.resize(lists.size()); |
| 2321 | ReplayFunctions replay = context_.replay_; | 2398 | ReplayFunctions replay = context_.replay_; |
| 2399 | std::vector<VulkanContext::GeometryUpload> geometry; | ||
| 2400 | if (context_.geometry_provider_) { | ||
| 2401 | replay.title_memory = [&](std::uint64_t va, std::uint64_t bytes, VkBuffer& buffer, VkDeviceSize& offset) { | ||
| 2402 | if (!va || !bytes || bytes>UINT64_MAX-va) return false; | ||
| 2403 | for (const auto& upload : geometry) { | ||
| 2404 | if (va < upload.source || va-upload.source > upload.size || bytes > upload.size-(va-upload.source)) continue; | ||
| 2405 | buffer=upload.buffer; offset=upload.offset+(va-upload.source); | ||
| 2406 | return true; | ||
| 2407 | } | ||
| 2408 | VulkanContext::GeometryUpload upload; | ||
| 2409 | if (!context_.geometry_provider_(va,bytes,upload)) return false; | ||
| 2410 | buffer=upload.buffer;offset=upload.offset; | ||
| 2411 | geometry.push_back(std::move(upload)); | ||
| 2412 | return true; | ||
| 2413 | }; | ||
| 2414 | } | ||
| 2415 | replay.graphics_family = family_ == context_.graphics_family_; | ||
| 2322 | replay.queue_stages = kind_ == QueueKind::copy ? detail::queue_stages_copy | 2416 | replay.queue_stages = kind_ == QueueKind::copy ? detail::queue_stages_copy |
| 2323 | : kind_ == QueueKind::compute ? detail::queue_stages_compute | 2417 | : kind_ == QueueKind::compute ? detail::queue_stages_compute |
| 2324 | : 0; | 2418 | : 0; |
| @@ -2542,6 +2636,7 @@ private: | |||
| 2542 | }; | 2636 | }; |
| 2543 | VkCommandBufferBeginInfo begin{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; | 2637 | VkCommandBufferBeginInfo begin{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; |
| 2544 | begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | 2638 | begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 2639 | label::completions().begin_record(command_buffer); | ||
| 2545 | if (context_.vk.vkBeginCommandBuffer(command_buffer, &begin) != VK_SUCCESS) { | 2640 | if (context_.vk.vkBeginCommandBuffer(command_buffer, &begin) != VK_SUCCESS) { |
| 2546 | discard(); | 2641 | discard(); |
| 2547 | return ReplayResult::unsupported; | 2642 | return ReplayResult::unsupported; |
| @@ -2585,8 +2680,7 @@ private: | |||
| 2585 | storage_init_seen_ = context_.storage_init_version_; | 2680 | storage_init_seen_ = context_.storage_init_version_; |
| 2586 | } | 2681 | } |
| 2587 | // The set this submission binds may be a new generation whose table another queue's submission uploads: | 2682 | // The set this submission binds may be a new generation whose table another queue's submission uploads: |
| 2588 | // wait for that one, as for the storage images (the table's buffers are used by one queue family only: | 2683 | // wait for that one, as for the storage images. The table and fallback images share the device's families. |
| 2589 | // every D3D12 queue of the device is made in info.queue_family). | ||
| 2590 | if (context_.bindless_upload_semaphore_ && context_.bindless_upload_semaphore_ != progress_ && | 2684 | if (context_.bindless_upload_semaphore_ && context_.bindless_upload_semaphore_ != progress_ && |
| 2591 | context_.bindless_upload_version_ != bindless_upload_seen_) { | 2685 | context_.bindless_upload_version_ != bindless_upload_seen_) { |
| 2592 | waits_.push_back(context_.bindless_upload_semaphore_); | 2686 | waits_.push_back(context_.bindless_upload_semaphore_); |
| @@ -2693,6 +2787,7 @@ private: | |||
| 2693 | slot->counted_dispatch = std::move(counted_batch); | 2787 | slot->counted_dispatch = std::move(counted_batch); |
| 2694 | queries.commit(); | 2788 | queries.commit(); |
| 2695 | slot->segments = std::move(queries.retained); | 2789 | slot->segments = std::move(queries.retained); |
| 2790 | slot->geometry = std::move(geometry); | ||
| 2696 | } else { | 2791 | } else { |
| 2697 | discard(); | 2792 | discard(); |
| 2698 | } | 2793 | } |
| @@ -2927,6 +3022,7 @@ private: | |||
| 2927 | std::unique_ptr<PredicateReducer::Batch> predicate; // retained until this slot completes | 3022 | std::unique_ptr<PredicateReducer::Batch> predicate; // retained until this slot completes |
| 2928 | std::vector<KhrInstanceStage> khr_instances; // KHR ARRAY_OF_POINTERS staging, same lifetime | 3023 | std::vector<KhrInstanceStage> khr_instances; // KHR ARRAY_OF_POINTERS staging, same lifetime |
| 2929 | std::vector<KhrAsQueryPool> khr_as_queries; // KHR postbuild COMPACTED_SIZE query pools, same lifetime | 3024 | std::vector<KhrAsQueryPool> khr_as_queries; // KHR postbuild COMPACTED_SIZE query pools, same lifetime |
| 3025 | std::vector<VulkanContext::GeometryUpload> geometry; | ||
| 2930 | }; | 3026 | }; |
| 2931 | 3027 | ||
| 2932 | struct PendingBindings { | 3028 | struct PendingBindings { |
| @@ -2949,6 +3045,7 @@ private: | |||
| 2949 | auto& vk = context_.vk; | 3045 | auto& vk = context_.vk; |
| 2950 | VkCommandBufferBeginInfo begin{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; | 3046 | VkCommandBufferBeginInfo begin{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO}; |
| 2951 | begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | 3047 | begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 3048 | label::completions().begin_record(command_buffer); | ||
| 2952 | if (vk.vkBeginCommandBuffer(command_buffer, &begin) != VK_SUCCESS) { | 3049 | if (vk.vkBeginCommandBuffer(command_buffer, &begin) != VK_SUCCESS) { |
| 2953 | slot->ticket = 0; | 3050 | slot->ticket = 0; |
| 2954 | return false; | 3051 | return false; |
| @@ -3087,6 +3184,7 @@ private: | |||
| 3087 | for (auto& slot : buffers_) { | 3184 | for (auto& slot : buffers_) { |
| 3088 | if (slot.ticket > done) continue; | 3185 | if (slot.ticket > done) continue; |
| 3089 | slot.segments.clear(); | 3186 | slot.segments.clear(); |
| 3187 | slot.geometry.clear(); | ||
| 3090 | recycle_khr_stages(slot.khr_instances); | 3188 | recycle_khr_stages(slot.khr_instances); |
| 3091 | recycle_khr_as_queries(slot.khr_as_queries); | 3189 | recycle_khr_as_queries(slot.khr_as_queries); |
| 3092 | for (VkEvent event : slot.events) | 3190 | for (VkEvent event : slot.events) |
| @@ -3223,7 +3321,9 @@ private: | |||
| 3223 | submit.pCommandBuffers = &command_buffer; | 3321 | submit.pCommandBuffers = &command_buffer; |
| 3224 | submit.signalSemaphoreCount = signal_count; | 3322 | submit.signalSemaphoreCount = signal_count; |
| 3225 | submit.pSignalSemaphores = signals; | 3323 | submit.pSignalSemaphores = signals; |
| 3226 | res = context_.vk.vkQueueSubmit(queue_, 1, &submit, VK_NULL_HANDLE); | 3324 | const auto label_fence=label::completions().submit_fence(command_buffer); |
| 3325 | res = context_.vk.vkQueueSubmit(queue_, 1, &submit, label_fence); | ||
| 3326 | label::completions().submitted(command_buffer,res==VK_SUCCESS); | ||
| 3227 | if (res == VK_SUCCESS) { | 3327 | if (res == VK_SUCCESS) { |
| 3228 | context_.record_submit_locked(progress_, ticket); | 3328 | context_.record_submit_locked(progress_, ticket); |
| 3229 | if (signals_fence) context_.holds().signaled(fence, value); | 3329 | if (signals_fence) context_.holds().signaled(fence, value); |