diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2026-03-31 00:05:03 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2026-03-31 00:05:03 +1100 |
| commit | 89f4c0f59a90b1a4447d171bd09235126561af91 (patch) | |
| tree | 4a7cfe1949ce71ee9ddaf7881efc12533287a554 /src | |
| parent | 18b77323841ba3853e6663757fd47ac3bb007eac (diff) | |
Small Handle refactor
Diffstat (limited to 'src')
| -rw-r--r-- | src/layer.cc | 7 | ||||
| -rw-r--r-- | src/timestamp_pool.cc | 18 | ||||
| -rw-r--r-- | src/timestamp_pool.hh | 4 |
3 files changed, 10 insertions, 19 deletions
diff --git a/src/layer.cc b/src/layer.cc index 186178a..bc988f0 100644 --- a/src/layer.cc +++ b/src/layer.cc @@ -396,8 +396,10 @@ vkQueueSubmit(VkQueue queue, std::uint32_t submit_count, std::span{submit_infos, submit_count}, std::back_inserter(next_submits), [&](const auto& submit) { const auto head_handle = context->timestamp_pool->acquire(); + head_handle->write_command(VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT); + const auto tail_handle = context->timestamp_pool->acquire(); - head_handle->setup_command_buffers(*tail_handle, *context); + tail_handle->write_command(VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT); context->notify_submit(extract_present_id(submit), head_handle, tail_handle, now); @@ -449,8 +451,9 @@ vkQueueSubmit2(VkQueue queue, std::uint32_t submit_count, std::span{submit_infos, submit_count}, std::back_inserter(next_submits), [&](const auto& submit) { const auto head_handle = context->timestamp_pool->acquire(); + head_handle->write_command(VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT); const auto tail_handle = context->timestamp_pool->acquire(); - head_handle->setup_command_buffers(*tail_handle, *context); + tail_handle->write_command(VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT); context->notify_submit(extract_present_id(submit), head_handle, tail_handle, now); diff --git a/src/timestamp_pool.cc b/src/timestamp_pool.cc index 19a9560..a618cfb 100644 --- a/src/timestamp_pool.cc +++ b/src/timestamp_pool.cc @@ -154,14 +154,14 @@ void TimestampPool::do_reaper(const std::stop_token stoken) { } } -void TimestampPool::Handle::setup_command_buffers( - const Handle& tail, const QueueContext& queue_context) const { +void TimestampPool::Handle::write_command( + const VkPipelineStageFlagBits2& bit) const { const auto cbbi = VkCommandBufferBeginInfo{ .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, }; - const auto& device_context = queue_context.device; + const auto& device_context = this->timestamp_pool.queue_context.device; const auto& vtable = device_context.vtable; vtable.ResetQueryPoolEXT(device_context.device, this->query_pool, @@ -175,18 +175,6 @@ void TimestampPool::Handle::setup_command_buffers( this->query_pool, static_cast<std::uint32_t>(this->query_index)); THROW_NOT_VKSUCCESS(vtable.EndCommandBuffer(this->command_buffer)); - - vtable.ResetQueryPoolEXT(device_context.device, tail.query_pool, - static_cast<std::uint32_t>(tail.query_index), 1); - - THROW_NOT_VKSUCCESS(vtable.ResetCommandBuffer(tail.command_buffer, 0)); - THROW_NOT_VKSUCCESS(vtable.BeginCommandBuffer(tail.command_buffer, &cbbi)); - - vtable.CmdWriteTimestamp2KHR( - tail.command_buffer, VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT, - tail.query_pool, static_cast<std::uint32_t>(tail.query_index)); - - THROW_NOT_VKSUCCESS(vtable.EndCommandBuffer(tail.command_buffer)); } struct QueryResult { diff --git a/src/timestamp_pool.hh b/src/timestamp_pool.hh index bf3335d..aad2e3e 100644 --- a/src/timestamp_pool.hh +++ b/src/timestamp_pool.hh @@ -123,8 +123,8 @@ class TimestampPool final { ~Handle(); public: - void setup_command_buffers(const Handle& tail, - const QueueContext& queue_context) const; + // Performs the Vulkan that sets up this command buffer for submission. + void write_command(const VkPipelineStageFlagBits2& bit) const; public: // Attempts to get the time - optional if it's not available yet. |
