vk_resource_manager: Make use of designated initializers where applicable

This commit is contained in:
Lioncash 2020-07-16 19:02:35 -04:00
parent 8ebd6a21c5
commit 772b6e4d28
1 changed files with 14 additions and 15 deletions

View File

@ -18,33 +18,32 @@ namespace {
constexpr std::size_t COMMAND_BUFFER_POOL_SIZE = 0x1000; constexpr std::size_t COMMAND_BUFFER_POOL_SIZE = 0x1000;
constexpr std::size_t FENCES_GROW_STEP = 0x40; constexpr std::size_t FENCES_GROW_STEP = 0x40;
VkFenceCreateInfo BuildFenceCreateInfo() { constexpr VkFenceCreateInfo BuildFenceCreateInfo() {
VkFenceCreateInfo fence_ci; return {
fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
fence_ci.pNext = nullptr; .pNext = nullptr,
fence_ci.flags = 0; .flags = 0,
return fence_ci; };
} }
} // Anonymous namespace } // Anonymous namespace
class CommandBufferPool final : public VKFencedPool { class CommandBufferPool final : public VKFencedPool {
public: public:
CommandBufferPool(const VKDevice& device) explicit CommandBufferPool(const VKDevice& device)
: VKFencedPool(COMMAND_BUFFER_POOL_SIZE), device{device} {} : VKFencedPool(COMMAND_BUFFER_POOL_SIZE), device{device} {}
void Allocate(std::size_t begin, std::size_t end) override { void Allocate(std::size_t begin, std::size_t end) override {
// Command buffers are going to be commited, recorded, executed every single usage cycle. // Command buffers are going to be commited, recorded, executed every single usage cycle.
// They are also going to be reseted when commited. // They are also going to be reseted when commited.
VkCommandPoolCreateInfo command_pool_ci;
command_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
command_pool_ci.pNext = nullptr;
command_pool_ci.flags =
VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
command_pool_ci.queueFamilyIndex = device.GetGraphicsFamily();
Pool& pool = pools.emplace_back(); Pool& pool = pools.emplace_back();
pool.handle = device.GetLogical().CreateCommandPool(command_pool_ci); pool.handle = device.GetLogical().CreateCommandPool({
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.pNext = nullptr,
.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
.queueFamilyIndex = device.GetGraphicsFamily(),
});
pool.cmdbufs = pool.handle.Allocate(COMMAND_BUFFER_POOL_SIZE); pool.cmdbufs = pool.handle.Allocate(COMMAND_BUFFER_POOL_SIZE);
} }