upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 08:38:23 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 08:38:23 -0500
commit1352cffcdab442dbd1ba4ccad4cf2c2ed5c94682 (patch)
tree2e39031ebc8ce569f34a49ae08562ebb0c0a2332 /runtime/src
parent73c88c6ee222b904b2bdb19056c143d644d1b247 (diff)
parent07b5dabec378ee54de2c4489b29790d6798c812c (diff)
Merge pull request #1684 from Emirhan Karaca
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/vulkan_backend.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h
index 476f22e2f..73232109e 100644
--- a/runtime/src/vulkan_backend.h
+++ b/runtime/src/vulkan_backend.h
@@ -845,7 +845,10 @@ public:
845 query_pools_[id] = pool; 845 query_pools_[id] = pool;
846 } 846 }
847 void remove_query_pool(QueryHeapId id) { 847 void remove_query_pool(QueryHeapId id) {
848 // Lock hierarchy: resource_mutex_ -> tracker_mutex_. Holding tracker_mutex_ before erasing keeps the
849 // QueryPool node alive until any in-flight execute() that unlocked resource_mutex_ finishes QueryReplay::commit().
848 std::unique_lock lock(resource_mutex_); 850 std::unique_lock lock(resource_mutex_);
851 std::lock_guard tlock(tracker_mutex_);
849 query_pools_.erase(id); 852 query_pools_.erase(id);
850 } 853 }
851 // The heap's d3d12_query_heap type, or ~0u for a heap that is not registered. 854 // The heap's d3d12_query_heap type, or ~0u for a heap that is not registered.
@@ -1347,6 +1350,7 @@ public:
1347 } 1350 }
1348 const auto resolve = [this](ResourceId id) { return context_.resolve(id); }; 1351 const auto resolve = [this](ResourceId id) { return context_.resolve(id); };
1349 std::uint32_t segments = 0, statistics_segments = 0; 1352 std::uint32_t segments = 0, statistics_segments = 0;
1353 bool has_queries = false;
1350 for (std::size_t i = 0; i < lists.size(); ++i) { 1354 for (std::size_t i = 0; i < lists.size(); ++i) {
1351 const auto result = prepare(*lists[i], resolve, replay, prepared[i]); 1355 const auto result = prepare(*lists[i], resolve, replay, prepared[i]);
1352 if (result != ReplayResult::success) return result; 1356 if (result != ReplayResult::success) return result;
@@ -1355,6 +1359,7 @@ public:
1355 return ReplayResult::unsupported; 1359 return ReplayResult::unsupported;
1356 segments += prepared[i].segment_count; 1360 segments += prepared[i].segment_count;
1357 statistics_segments += prepared[i].statistics_segment_count; 1361 statistics_segments += prepared[i].statistics_segment_count;
1362 has_queries = has_queries || !prepared[i].queries.empty();
1358 } 1363 }
1359 const auto segment_pool = [this](VkQueryType type, std::uint32_t count, 1364 const auto segment_pool = [this](VkQueryType type, std::uint32_t count,
1360 std::shared_ptr<OcclusionSegmentPool>& out) { 1365 std::shared_ptr<OcclusionSegmentPool>& out) {
@@ -1376,6 +1381,10 @@ public:
1376 if (statistics_segments && can_resolve_occlusion && 1381 if (statistics_segments && can_resolve_occlusion &&
1377 !segment_pool(VK_QUERY_TYPE_PIPELINE_STATISTICS, statistics_segments, statistics)) 1382 !segment_pool(VK_QUERY_TYPE_PIPELINE_STATISTICS, statistics_segments, statistics))
1378 return ReplayResult::unsupported; 1383 return ReplayResult::unsupported;
1384 // QueryReplay::plan() reads QueryPool::ended / occlusion and QueryReplay::commit() writes them after
1385 // resource_lock is unlocked. Hold tracker_mutex_ across plan -> emit -> submit -> commit so concurrent queues
1386 // see submission-order query state and remove_query_pool() waits until commit finishes.
1387 if (has_queries && !tracker_lock.owns_lock()) tracker_lock.lock();
1379 QueryReplay queries; 1388 QueryReplay queries;
1380 std::uint32_t base = 0, statistics_base = 0; 1389 std::uint32_t base = 0, statistics_base = 0;
1381 for (auto& list : prepared) { 1390 for (auto& list : prepared) {
@@ -1600,10 +1609,12 @@ private:
1600 return false; 1609 return false;
1601 } 1610 }
1602 const bool ok = (res == VK_SUCCESS); 1611 const bool ok = (res == VK_SUCCESS);
1603 waits_.clear(); 1612 if (ok) {
1604 wait_values_.clear(); 1613 waits_.clear();
1605 for (auto& slot : buffers_) 1614 wait_values_.clear();
1606 if (slot.buffer == command_buffer) slot.ticket = ticket; 1615 for (auto& slot : buffers_)
1616 if (slot.buffer == command_buffer) slot.ticket = ticket;
1617 }
1607 return ok; 1618 return ok;
1608 } 1619 }
1609 1620