Vulkan: Add support for CommandPool and CommandBuffer
Former-commit-id: 0ed1e8d09300577be3d4c52b94d6a8f594178a8b
This commit is contained in:
53
src/Nazara/Vulkan/VkCommandPool.cpp
Normal file
53
src/Nazara/Vulkan/VkCommandPool.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright (C) 2016 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Vulkan"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Vulkan/VkCommandPool.hpp>
|
||||
#include <Nazara/Vulkan/VkCommandBuffer.hpp>
|
||||
#include <Nazara/Vulkan/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
CommandBuffer CommandPool::AllocateCommandBuffer(VkCommandBufferLevel level)
|
||||
{
|
||||
VkCommandBufferAllocateInfo createInfo =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
|
||||
nullptr,
|
||||
m_handle,
|
||||
level,
|
||||
1U
|
||||
};
|
||||
|
||||
VkCommandBuffer handle = VK_NULL_HANDLE;
|
||||
m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, &handle);
|
||||
|
||||
return CommandBuffer(*this, handle);
|
||||
}
|
||||
|
||||
std::vector<CommandBuffer> CommandPool::AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level)
|
||||
{
|
||||
VkCommandBufferAllocateInfo createInfo =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
|
||||
nullptr,
|
||||
m_handle,
|
||||
level,
|
||||
1U
|
||||
};
|
||||
|
||||
std::vector<VkCommandBuffer> handles(commandBufferCount, VK_NULL_HANDLE);
|
||||
m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, handles.data());
|
||||
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
return std::vector<CommandBuffer>();
|
||||
|
||||
std::vector<CommandBuffer> commandBuffers;
|
||||
for (UInt32 i = 0; i < commandBufferCount; ++i)
|
||||
commandBuffers.emplace_back(CommandBuffer(*this, handles[i]));
|
||||
|
||||
return commandBuffers;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user