aboutsummaryrefslogtreecommitdiff
path: root/src/queue_context.cc
diff options
context:
space:
mode:
authorNicolas James <nj3ahxac@gmail.com>2026-02-08 17:49:48 +1100
committerNicolas James <nj3ahxac@gmail.com>2026-02-08 17:49:48 +1100
commit5ab5046b643b04b9c31fd41cdfca39b9d5f6b99e (patch)
treeda5383b41b2fff17362425d2a57cbd129f681498 /src/queue_context.cc
parentc7363b6165a7795d10a8989c241dcdec84d0c7d7 (diff)
track queue submits WIP
Diffstat (limited to 'src/queue_context.cc')
-rw-r--r--src/queue_context.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/queue_context.cc b/src/queue_context.cc
new file mode 100644
index 0000000..dbae4c0
--- /dev/null
+++ b/src/queue_context.cc
@@ -0,0 +1,51 @@
+#include "queue_context.hh"
+
+namespace low_latency {
+
+static VkCommandPool make_command_pool(const VkDevice& device,
+ const std::uint32_t& queue_family_index,
+ const VkuDeviceDispatchTable& vtable) {
+
+ const auto cpci = VkCommandPoolCreateInfo{
+ .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
+ .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
+ VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
+ .queueFamilyIndex = queue_family_index,
+ };
+
+ auto command_pool = VkCommandPool{};
+ vtable.CreateCommandPool(device, &cpci, nullptr, &command_pool);
+ return command_pool;
+}
+
+QueueContext::QueueContext(const VkDevice& device, const VkQueue queue,
+ const std::uint32_t& queue_family_index,
+ const VkuDeviceDispatchTable& vtable)
+ : device(device), queue(queue), queue_family_index(queue_family_index),
+ vtable(vtable),
+ // Important we make the command pool before the timestamp pool, because it's a dependency.
+ command_pool(make_command_pool(device, queue_family_index, vtable)),
+ timestamp_pool(device, vtable, command_pool) {
+
+ this->semaphore = [&]() -> VkSemaphore {
+ const auto stci = VkSemaphoreTypeCreateInfo{
+ .sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO,
+ .semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE,
+ .initialValue = 0,
+ };
+
+ const auto sci = VkSemaphoreCreateInfo{
+ .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
+ .pNext = &stci,
+ };
+
+ auto semaphore = VkSemaphore{};
+ vtable.CreateSemaphore(device, &sci, nullptr, &semaphore);
+ return semaphore;
+ }();
+}
+
+QueueContext::~QueueContext() {
+}
+
+} // namespace low_latency \ No newline at end of file