diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2026-03-30 15:54:10 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2026-03-30 15:54:10 +1100 |
| commit | 644bc4ed5edd4e3ffa88750bdacb147c75df9546 (patch) | |
| tree | 5580f05b202493ccb68d5c67ec37e10d53f3cd1d /src/timestamp_pool.hh | |
| parent | 681bd5096ee416b50dd7338de30af7b3db385a36 (diff) | |
Fix AL2 via VK_NV_low_latency2's async implementation, fix race in TimestampPool
Diffstat (limited to 'src/timestamp_pool.hh')
| -rw-r--r-- | src/timestamp_pool.hh | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/timestamp_pool.hh b/src/timestamp_pool.hh index 0d6c52d..d8ee359 100644 --- a/src/timestamp_pool.hh +++ b/src/timestamp_pool.hh @@ -3,7 +3,7 @@ // The purpose of this file is to provide the definition of a 'timestamp pool'. // It manages blocks of timestamp query pools, hands them out when requested, -// and allocates more when (if) we run out. +// and allocates more when (if) we run out. It _should_ be thread safe. // Usage: // 1. Get handle with .acquire(). // 2. Write start/end timestamp operations with the handle's pool and index @@ -15,6 +15,7 @@ #include <vulkan/vulkan.hpp> #include <memory> +#include <mutex> #include <unordered_set> #include <vector> @@ -28,6 +29,7 @@ class DeviceContext; class TimestampPool final { private: QueueContext& queue_context; + std::mutex mutex; // A chunk of data which is useful for making timestamp queries. // Allows association of an index to a query pool and command buffer. @@ -72,10 +74,7 @@ class TimestampPool final { ~CommandBuffersOwner(); public: - VkCommandBuffer operator[](const std::size_t& i) { - assert(i < CHUNK_SIZE); - return this->command_buffers[i]; - } + VkCommandBuffer operator[](const std::size_t& i); }; std::unique_ptr<CommandBuffersOwner> command_buffers; @@ -98,7 +97,7 @@ class TimestampPool final { friend class TimestampPool; private: - const TimestampPool& timestamp_pool; + TimestampPool& timestamp_pool; const std::weak_ptr<QueryChunk> origin_chunk; public: @@ -107,7 +106,7 @@ class TimestampPool final { const VkCommandBuffer command_buffer; public: - Handle(const TimestampPool& timestamp_pool, + Handle(TimestampPool& timestamp_pool, const std::shared_ptr<QueryChunk>& origin_chunk, const std::uint64_t& query_index); Handle(const Handle& handle) = delete; |
