Добавил namespace VkObjectsдля обёрток. Вынес управление VkSurface в отдельный класс
This commit is contained in:
@@ -29,17 +29,17 @@ UwURenderEngine::SwapchainSupportDetails UwURenderEngine::query_swapchain_detail
|
||||
{
|
||||
SwapchainSupportDetails details;
|
||||
|
||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device_, surface_, &details.capabilities);
|
||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device_, surface_.get_native(), &details.capabilities);
|
||||
|
||||
uint32_t surface_format_cnt = 0;
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device_, surface_, &surface_format_cnt, nullptr))
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device_, surface_.get_native(), &surface_format_cnt, nullptr))
|
||||
details.formats.resize(surface_format_cnt);
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device_, surface_, &surface_format_cnt, details.formats.data()))
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device_, surface_.get_native(), &surface_format_cnt, details.formats.data()))
|
||||
|
||||
uint32_t present_modes_cnt = 0;
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device_, surface_, &present_modes_cnt, nullptr))
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device_, surface_.get_native(), &present_modes_cnt, nullptr))
|
||||
details.present_modes.resize(surface_format_cnt);
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device_, surface_, &present_modes_cnt, details.present_modes.data()))
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device_, surface_.get_native(), &present_modes_cnt, details.present_modes.data()))
|
||||
|
||||
return details;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ void UwURenderEngine::pick_physical_device()
|
||||
|
||||
for (const auto& device : devices)
|
||||
{
|
||||
if (is_device_suitable(device, surface_))
|
||||
if (is_device_suitable(device, surface_.get_native()))
|
||||
{
|
||||
physical_device_ = device;
|
||||
VkPhysicalDeviceProperties device_properties;
|
||||
@@ -215,7 +215,7 @@ void UwURenderEngine::pick_physical_device()
|
||||
|
||||
void UwURenderEngine::create_logical_device()
|
||||
{
|
||||
QueueFamilyIndices indices = find_queue_family_indices(physical_device_, surface_);
|
||||
QueueFamilyIndices indices = find_queue_family_indices(physical_device_, surface_.get_native());
|
||||
|
||||
VkPhysicalDeviceFeatures device_features{};
|
||||
|
||||
@@ -273,7 +273,7 @@ void UwURenderEngine::create_swapchain()
|
||||
|
||||
VkSwapchainCreateInfoKHR swapchain_create_info{};
|
||||
swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||
swapchain_create_info.surface = surface_;
|
||||
swapchain_create_info.surface = surface_.get_native();
|
||||
swapchain_create_info.minImageCount = image_count;
|
||||
swapchain_create_info.imageFormat = surface_format.format;
|
||||
swapchain_create_info.imageColorSpace = surface_format.colorSpace;
|
||||
@@ -286,7 +286,7 @@ void UwURenderEngine::create_swapchain()
|
||||
swapchain_create_info.clipped = VK_TRUE;
|
||||
swapchain_create_info.oldSwapchain = VK_NULL_HANDLE;
|
||||
|
||||
QueueFamilyIndices family_indices = find_queue_family_indices(physical_device_, surface_);
|
||||
QueueFamilyIndices family_indices = find_queue_family_indices(physical_device_, surface_.get_native());
|
||||
const std::set<uint32_t> queue_family_indices = { family_indices.graphics_family,
|
||||
family_indices.present_family,
|
||||
family_indices.transfer_family };
|
||||
@@ -407,7 +407,7 @@ void UwURenderEngine::create_uniform_buffers()
|
||||
uniform_buffers_memory_.resize(swapchain_images_.size());
|
||||
uniform_buffers_mapped_.resize(swapchain_images_.size());
|
||||
|
||||
std::vector<uint32_t> arr_indices = get_unique_family_indices(find_queue_family_indices(physical_device_, surface_));
|
||||
std::vector<uint32_t> arr_indices = get_unique_family_indices(find_queue_family_indices(physical_device_, surface_.get_native()));
|
||||
for (size_t i = 0; i < swapchain_images_.size(); ++i)
|
||||
{
|
||||
const VkDeviceSize size = sizeof(UniformBufferObject);
|
||||
@@ -631,7 +631,7 @@ void UwURenderEngine::create_framebuffers()
|
||||
|
||||
void UwURenderEngine::create_command_pool()
|
||||
{
|
||||
QueueFamilyIndices queue_family_indices = find_queue_family_indices(physical_device_, surface_);
|
||||
QueueFamilyIndices queue_family_indices = find_queue_family_indices(physical_device_, surface_.get_native());
|
||||
|
||||
VkCommandPoolCreateInfo command_pool_info{};
|
||||
command_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
@@ -656,7 +656,7 @@ std::vector<uint32_t> UwURenderEngine::get_unique_family_indices(const QueueFami
|
||||
|
||||
void UwURenderEngine::allocate_vertex_buffer()
|
||||
{
|
||||
QueueFamilyIndices indices = find_queue_family_indices(physical_device_, surface_);
|
||||
QueueFamilyIndices indices = find_queue_family_indices(physical_device_, surface_.get_native());
|
||||
|
||||
|
||||
std::vector<uint32_t> arr_indices = get_unique_family_indices(indices);
|
||||
@@ -688,7 +688,7 @@ void UwURenderEngine::allocate_vertex_buffer()
|
||||
|
||||
void UwURenderEngine::allocate_index_buffer()
|
||||
{
|
||||
QueueFamilyIndices indices = find_queue_family_indices(physical_device_, surface_);
|
||||
QueueFamilyIndices indices = find_queue_family_indices(physical_device_, surface_.get_native());
|
||||
std::set<uint32_t> set_indices = {indices.graphics_family,
|
||||
indices.present_family,
|
||||
indices.transfer_family};
|
||||
@@ -872,16 +872,11 @@ void UwURenderEngine::draw_frame()
|
||||
current_frame_ = (current_frame_ + 1) % static_cast<unsigned int>(swapchain_images_.size());
|
||||
}
|
||||
|
||||
void UwURenderEngine::create_surface()
|
||||
{
|
||||
VK_CHECK(glfwCreateWindowSurface(instance_.get_native(), get_window(), nullptr, &surface_))
|
||||
}
|
||||
|
||||
UwURenderEngine::UwURenderEngine(CoreInstance& core):RenderEngineBase(core),
|
||||
instance_(core),
|
||||
surface_(instance_, get_window()),
|
||||
core_(core)
|
||||
{
|
||||
create_surface();
|
||||
pick_physical_device();
|
||||
create_logical_device();
|
||||
create_swapchain();
|
||||
@@ -970,9 +965,6 @@ UwURenderEngine::~UwURenderEngine()
|
||||
|
||||
if (device_ != VK_NULL_HANDLE)
|
||||
vkDestroyDevice(device_, nullptr);
|
||||
|
||||
if (surface_ != VK_NULL_HANDLE)
|
||||
vkDestroySurfaceKHR(instance_.get_native(), surface_, nullptr);
|
||||
}
|
||||
|
||||
void UwURenderEngine::start()
|
||||
|
||||
Reference in New Issue
Block a user