Skip to content

Commit

Permalink
Work on command pool
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Jun 4, 2023
1 parent da31ac7 commit 637ca5a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion compute/vulkan/command_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,25 @@ CommandPool::CommandPool(Device& dev, uint32_t family /* compute family*/)
}
}

CommandPool::~CommandPool()
{
vkDestroyCommandPool(dev_.dev(), pool_, NULL);
}

VkCommandBuffer CommandPool::acquire()
{
return {};
VkCommandBuffer buffer;
VkCommandBufferAllocateInfo info = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.commandPool = pool_,
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
.commandBufferCount = 1
};

if (vkAllocateCommandBuffers(dev_.dev(), &info, &buffer) != VK_SUCCESS) {
throw std::runtime_error("Failed to allocate command buffers");
}
return buffer;
}

void CommandPool::reset()
Expand Down
1 change: 1 addition & 0 deletions compute/vulkan/command_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace NVulkan {
class CommandPool {
public:
CommandPool(Device& dev, uint32_t family);
~CommandPool();

VkCommandBuffer acquire();
void reset();
Expand Down
2 changes: 2 additions & 0 deletions compute/vulkan/compute.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "device.h"
#include "command_pool.h"

namespace NVulkan {

Expand All @@ -9,6 +10,7 @@ class Compute {
Compute();

private:
CommandPool commandPool_;
VkCommandBuffer commandBuffer_;
VkSemaphore semaphore_;
};
Expand Down

0 comments on commit 637ca5a

Please sign in to comment.