Add command creation for GEVulkanDriver
This commit is contained in:
parent
2f4093516a
commit
8e64c69c5d
@ -314,15 +314,26 @@ namespace GE
|
|||||||
std::vector<VkSemaphore> image_available_semaphores;
|
std::vector<VkSemaphore> image_available_semaphores;
|
||||||
std::vector<VkSemaphore> render_finished_semaphores;
|
std::vector<VkSemaphore> render_finished_semaphores;
|
||||||
std::vector<VkFence> in_flight_fences;
|
std::vector<VkFence> in_flight_fences;
|
||||||
|
VkCommandPool command_pool;
|
||||||
|
std::vector<VkCommandBuffer> command_buffers;
|
||||||
VK()
|
VK()
|
||||||
{
|
{
|
||||||
instance = VK_NULL_HANDLE;
|
instance = VK_NULL_HANDLE;
|
||||||
surface = VK_NULL_HANDLE;
|
surface = VK_NULL_HANDLE;
|
||||||
device = VK_NULL_HANDLE;
|
device = VK_NULL_HANDLE;
|
||||||
swap_chain = VK_NULL_HANDLE;
|
swap_chain = VK_NULL_HANDLE;
|
||||||
|
command_pool = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
~VK()
|
~VK()
|
||||||
{
|
{
|
||||||
|
if (!command_buffers.empty())
|
||||||
|
{
|
||||||
|
vkFreeCommandBuffers(device, command_pool,
|
||||||
|
(uint32_t)(command_buffers.size()),
|
||||||
|
&command_buffers[0]);
|
||||||
|
}
|
||||||
|
if (command_pool != VK_NULL_HANDLE)
|
||||||
|
vkDestroyCommandPool(device, command_pool, NULL);
|
||||||
for (VkSemaphore& semaphore : image_available_semaphores)
|
for (VkSemaphore& semaphore : image_available_semaphores)
|
||||||
vkDestroySemaphore(device, semaphore, NULL);
|
vkDestroySemaphore(device, semaphore, NULL);
|
||||||
for (VkSemaphore& semaphore : render_finished_semaphores)
|
for (VkSemaphore& semaphore : render_finished_semaphores)
|
||||||
@ -370,6 +381,8 @@ namespace GE
|
|||||||
void createDevice();
|
void createDevice();
|
||||||
void createSwapChain();
|
void createSwapChain();
|
||||||
void createSyncObjects();
|
void createSyncObjects();
|
||||||
|
void createCommandPool();
|
||||||
|
void createCommandBuffers();
|
||||||
std::string getVulkanVersionString() const;
|
std::string getVulkanVersionString() const;
|
||||||
std::string getDriverVersionString() const;
|
std::string getDriverVersionString() const;
|
||||||
};
|
};
|
||||||
|
@ -486,6 +486,8 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params,
|
|||||||
vkGetPhysicalDeviceProperties(m_physical_device, &m_properties);
|
vkGetPhysicalDeviceProperties(m_physical_device, &m_properties);
|
||||||
createSwapChain();
|
createSwapChain();
|
||||||
createSyncObjects();
|
createSyncObjects();
|
||||||
|
createCommandPool();
|
||||||
|
createCommandBuffers();
|
||||||
os::Printer::log("Vulkan version", getVulkanVersionString().c_str());
|
os::Printer::log("Vulkan version", getVulkanVersionString().c_str());
|
||||||
os::Printer::log("Vulkan vendor", getVendorInfo().c_str());
|
os::Printer::log("Vulkan vendor", getVendorInfo().c_str());
|
||||||
os::Printer::log("Vulkan renderer", m_properties.deviceName);
|
os::Printer::log("Vulkan renderer", m_properties.deviceName);
|
||||||
@ -942,6 +944,40 @@ void GEVulkanDriver::createSyncObjects()
|
|||||||
}
|
}
|
||||||
} // createSyncObjects
|
} // createSyncObjects
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void GEVulkanDriver::createCommandPool()
|
||||||
|
{
|
||||||
|
VkCommandPoolCreateInfo pool_info = {};
|
||||||
|
pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
|
pool_info.queueFamilyIndex = m_graphics_family;
|
||||||
|
|
||||||
|
VkResult result = vkCreateCommandPool(m_vk.device, &pool_info, NULL,
|
||||||
|
&m_vk.command_pool);
|
||||||
|
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
throw std::runtime_error("vkCreateCommandPool failed");
|
||||||
|
} // createCommandPool
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void GEVulkanDriver::createCommandBuffers()
|
||||||
|
{
|
||||||
|
std::vector<VkCommandBuffer> buffers(m_vk.swap_chain_images.size());
|
||||||
|
|
||||||
|
VkCommandBufferAllocateInfo alloc_info = {};
|
||||||
|
alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||||
|
alloc_info.commandPool = m_vk.command_pool;
|
||||||
|
alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||||
|
alloc_info.commandBufferCount = (uint32_t)buffers.size();
|
||||||
|
|
||||||
|
VkResult result = vkAllocateCommandBuffers(m_vk.device, &alloc_info,
|
||||||
|
&buffers[0]);
|
||||||
|
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
throw std::runtime_error("vkAllocateCommandBuffers failed");
|
||||||
|
|
||||||
|
m_vk.command_buffers = buffers;
|
||||||
|
} // createCommandBuffers
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void GEVulkanDriver::OnResize(const core::dimension2d<u32>& size)
|
void GEVulkanDriver::OnResize(const core::dimension2d<u32>& size)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user