Add createSyncObjects for GEVulkanDriver
This commit is contained in:
parent
9e321d804e
commit
2f4093516a
@ -311,6 +311,9 @@ namespace GE
|
|||||||
VkSwapchainKHR swap_chain;
|
VkSwapchainKHR swap_chain;
|
||||||
std::vector<VkImage> swap_chain_images;
|
std::vector<VkImage> swap_chain_images;
|
||||||
std::vector<VkImageView> swap_chain_image_views;
|
std::vector<VkImageView> swap_chain_image_views;
|
||||||
|
std::vector<VkSemaphore> image_available_semaphores;
|
||||||
|
std::vector<VkSemaphore> render_finished_semaphores;
|
||||||
|
std::vector<VkFence> in_flight_fences;
|
||||||
VK()
|
VK()
|
||||||
{
|
{
|
||||||
instance = VK_NULL_HANDLE;
|
instance = VK_NULL_HANDLE;
|
||||||
@ -320,6 +323,12 @@ namespace GE
|
|||||||
}
|
}
|
||||||
~VK()
|
~VK()
|
||||||
{
|
{
|
||||||
|
for (VkSemaphore& semaphore : image_available_semaphores)
|
||||||
|
vkDestroySemaphore(device, semaphore, NULL);
|
||||||
|
for (VkSemaphore& semaphore : render_finished_semaphores)
|
||||||
|
vkDestroySemaphore(device, semaphore, NULL);
|
||||||
|
for (VkFence& fence : in_flight_fences)
|
||||||
|
vkDestroyFence(device, fence, NULL);
|
||||||
for (VkImageView& image_view : swap_chain_image_views)
|
for (VkImageView& image_view : swap_chain_image_views)
|
||||||
vkDestroyImageView(device, image_view, NULL);
|
vkDestroyImageView(device, image_view, NULL);
|
||||||
if (swap_chain != VK_NULL_HANDLE)
|
if (swap_chain != VK_NULL_HANDLE)
|
||||||
@ -360,6 +369,7 @@ namespace GE
|
|||||||
std::vector<VkPresentModeKHR>* present_modes);
|
std::vector<VkPresentModeKHR>* present_modes);
|
||||||
void createDevice();
|
void createDevice();
|
||||||
void createSwapChain();
|
void createSwapChain();
|
||||||
|
void createSyncObjects();
|
||||||
std::string getVulkanVersionString() const;
|
std::string getVulkanVersionString() const;
|
||||||
std::string getDriverVersionString() const;
|
std::string getDriverVersionString() const;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "ge_vulkan_driver.hpp"
|
#include "ge_vulkan_driver.hpp"
|
||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_VULKAN_
|
#ifdef _IRR_COMPILE_WITH_VULKAN_
|
||||||
|
const unsigned int MAX_FRAMES_IN_FLIGHT = 2;
|
||||||
#include "SDL_vulkan.h"
|
#include "SDL_vulkan.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -484,6 +485,7 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params,
|
|||||||
|
|
||||||
vkGetPhysicalDeviceProperties(m_physical_device, &m_properties);
|
vkGetPhysicalDeviceProperties(m_physical_device, &m_properties);
|
||||||
createSwapChain();
|
createSwapChain();
|
||||||
|
createSyncObjects();
|
||||||
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);
|
||||||
@ -895,6 +897,51 @@ void GEVulkanDriver::createSwapChain()
|
|||||||
}
|
}
|
||||||
} // createSwapChain
|
} // createSwapChain
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void GEVulkanDriver::createSyncObjects()
|
||||||
|
{
|
||||||
|
VkSemaphoreCreateInfo semaphore_info = {};
|
||||||
|
semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
||||||
|
|
||||||
|
VkFenceCreateInfo fence_info = {};
|
||||||
|
fence_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||||
|
fence_info.flags = VK_FENCE_CREATE_SIGNALED_BIT;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
|
||||||
|
{
|
||||||
|
VkSemaphore image_available_semaphore;
|
||||||
|
VkResult result = vkCreateSemaphore(m_vk.device, &semaphore_info, NULL,
|
||||||
|
&image_available_semaphore);
|
||||||
|
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
throw std::runtime_error(
|
||||||
|
"vkCreateSemaphore on image_available_semaphore failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
VkSemaphore render_finished_semaphore;
|
||||||
|
result = vkCreateSemaphore(m_vk.device, &semaphore_info, NULL,
|
||||||
|
&render_finished_semaphore);
|
||||||
|
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
throw std::runtime_error(
|
||||||
|
"vkCreateSemaphore on render_finished_semaphore failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
VkFence in_flight_fence;
|
||||||
|
result = vkCreateFence(m_vk.device, &fence_info, NULL,
|
||||||
|
&in_flight_fence);
|
||||||
|
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
throw std::runtime_error("vkCreateFence failed");
|
||||||
|
|
||||||
|
m_vk.image_available_semaphores.push_back(image_available_semaphore);
|
||||||
|
m_vk.render_finished_semaphores.push_back(render_finished_semaphore);
|
||||||
|
m_vk.in_flight_fences.push_back(in_flight_fence);
|
||||||
|
}
|
||||||
|
} // createSyncObjects
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
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