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:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 13:12:26 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 13:12:26 -0500
commit60cc47cb79f5362f39e9179e0797c3eb5d8aa643 (patch)
tree36bd1d1c5e942163746fe42338546ff4c962ca9d /runtime/src/vulkan_backend.h
parentec8ec4c9a46c6623f1a9c125afd3566da97f1e0c (diff)
parent1ace3ac642605c16136547377de650fb22699f8d (diff)
Merge pull request #306 from IAmNotSiob
Diffstat (limited to 'runtime/src/vulkan_backend.h')
-rw-r--r--runtime/src/vulkan_backend.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h
index 140d7234b..086b6772a 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
@@ -1115,6 +1116,8 @@ public:
1115 // `prepare` is called at the start of the command buffer of every ExecuteCommandLists, before the lists are 1116 // `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) 1117 // 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. 1118 // and records what the set needs first. When it fails, nothing of that call is executed.
1119 void set_transfer_only_family(std::uint32_t family) { transfer_only_family_ = family; }
1120
1118 void set_bindless_prepare(std::function<bool(VkCommandBuffer)> prepare) { 1121 void set_bindless_prepare(std::function<bool(VkCommandBuffer)> prepare) {
1119 std::unique_lock lock(resource_mutex_); 1122 std::unique_lock lock(resource_mutex_);
1120 bindless_prepare_ = std::move(prepare); 1123 bindless_prepare_ = std::move(prepare);
@@ -1294,6 +1297,7 @@ private:
1294 std::unique_ptr<PredicateReducer> predicate_reducer_; 1297 std::unique_ptr<PredicateReducer> predicate_reducer_;
1295 std::unique_ptr<PredicatedBufferCopier> predicated_copier_; 1298 std::unique_ptr<PredicatedBufferCopier> predicated_copier_;
1296 std::uint32_t predicate_family_ = UINT32_MAX; 1299 std::uint32_t predicate_family_ = UINT32_MAX;
1300 std::uint32_t transfer_only_family_ = UINT32_MAX;
1297 DebugLabelFunctions labels_; 1301 DebugLabelFunctions labels_;
1298}; 1302};
1299#ifdef _MSC_VER 1303#ifdef _MSC_VER
@@ -1474,6 +1478,12 @@ public:
1474 // the layout tracker as it was. Pending Wait()s are attached to this submission. 1478 // the layout tracker as it was. Pending Wait()s are attached to this submission.
1475 ReplayResult execute(std::span<const CommandList* const> lists) { 1479 ReplayResult execute(std::span<const CommandList* const> lists) {
1476 if (context_.is_device_lost()) return ReplayResult::unsupported; 1480 if (context_.is_device_lost()) return ReplayResult::unsupported;
1481 if (kind_ != QueueKind::direct)
1482 for (const auto* list : lists)
1483 for (const auto& command : list->commands())
1484 if (std::holds_alternative<ClearRenderTarget>(command) ||
1485 std::holds_alternative<ClearDepthStencil>(command))
1486 return ReplayResult::unsupported;
1477 VkCommandBuffer command_buffer = VK_NULL_HANDLE; 1487 VkCommandBuffer command_buffer = VK_NULL_HANDLE;
1478 std::function<void(bool)> bindless_commit; 1488 std::function<void(bool)> bindless_commit;
1479 // Lock hierarchy: resource_mutex_ -> tracker_mutex_ -> submit_mutex_. 1489 // Lock hierarchy: resource_mutex_ -> tracker_mutex_ -> submit_mutex_.
@@ -1500,12 +1510,16 @@ public:
1500 if (active && scratch) scratch->retire(progress, 0); 1510 if (active && scratch) scratch->retire(progress, 0);
1501 } 1511 }
1502 } scratch_guard{context_.scratch_.get(), progress_, false}; 1512 } scratch_guard{context_.scratch_.get(), progress_, false};
1503 bindless_commit = context_.bindless_commit_; 1513 const bool transfer_only = family_ == context_.transfer_only_family_;
1514 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 1515 // 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). 1516 // making them fresh for every command was about half the layer's CPU cost per command (replay_cpu_bench).
1506 auto& prepared = prepared_; 1517 auto& prepared = prepared_;
1507 prepared.resize(lists.size()); 1518 prepared.resize(lists.size());
1508 ReplayFunctions replay = context_.replay_; 1519 ReplayFunctions replay = context_.replay_;
1520 replay.queue_stages = kind_ == QueueKind::copy ? detail::queue_stages_copy
1521 : kind_ == QueueKind::compute ? detail::queue_stages_compute
1522 : 0;
1509 std::uint64_t captures = 0; 1523 std::uint64_t captures = 0;
1510 for (const auto* list : lists) 1524 for (const auto* list : lists)
1511 for (const auto& command : list->commands()) 1525 for (const auto& command : list->commands())
@@ -1549,7 +1563,7 @@ public:
1549 return context_.scratch_->get(bytes, buffer, offset); 1563 return context_.scratch_->get(bytes, buffer, offset);
1550 }; 1564 };
1551 } 1565 }
1552 if (context_.depth24_) { 1566 if (context_.depth24_ && !transfer_only) {
1553 replay.depth24_prepare = [this, &tracker_lock, &depth24_guard](Depth24Job& job, 1567 replay.depth24_prepare = [this, &tracker_lock, &depth24_guard](Depth24Job& job,
1554 std::vector<Depth24Job>& parts) { 1568 std::vector<Depth24Job>& parts) {
1555 if (!tracker_lock.owns_lock()) tracker_lock.lock(); 1569 if (!tracker_lock.owns_lock()) tracker_lock.lock();
@@ -1644,7 +1658,7 @@ public:
1644 return ReplayResult::unsupported; 1658 return ReplayResult::unsupported;
1645 } 1659 }
1646 if (!tracker_lock.owns_lock()) tracker_lock.lock(); 1660 if (!tracker_lock.owns_lock()) tracker_lock.lock();
1647 if (context_.bindless_prepare_ && !context_.bindless_prepare_(command_buffer)) { 1661 if (!transfer_only && context_.bindless_prepare_ && !context_.bindless_prepare_(command_buffer)) {
1648 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS; 1662 const bool ended = context_.vk.vkEndCommandBuffer(command_buffer) == VK_SUCCESS;
1649 resource_lock.unlock(); 1663 resource_lock.unlock();
1650 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0); 1664 const bool submitted = ended && submit(command_buffer, VK_NULL_HANDLE, 0);