summaryrefslogtreecommitdiff
path: root/src/blucat/swapchain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/blucat/swapchain.cpp')
-rw-r--r--src/blucat/swapchain.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/blucat/swapchain.cpp b/src/blucat/swapchain.cpp
index 1e521e4..613cf9b 100644
--- a/src/blucat/swapchain.cpp
+++ b/src/blucat/swapchain.cpp
@@ -16,7 +16,7 @@
#include "swapchain.hpp"
-#include "../core.hpp"
+#include "core.hpp"
#include <vector>
@@ -32,18 +32,19 @@ load_swapchain(void *obj)
uint32_t vk_surface_format_count;
std::vector<VkSurfaceFormatKHR> vk_surface_formats;
vkGetPhysicalDeviceSurfaceFormatsKHR(
- cg_core.vk_device_with_swapchain->physical_device, cg_core.window_surface,
- &vk_surface_format_count, nullptr);
+ BluCat::core.vk_device_with_swapchain->physical_device,
+ BluCat::core.window_surface, &vk_surface_format_count, nullptr);
vk_surface_formats.resize(vk_surface_format_count);
vkGetPhysicalDeviceSurfaceFormatsKHR(
- cg_core.vk_device_with_swapchain->physical_device, cg_core.window_surface,
- &vk_surface_format_count, vk_surface_formats.data());
+ BluCat::core.vk_device_with_swapchain->physical_device,
+ BluCat::core.window_surface, &vk_surface_format_count,
+ vk_surface_formats.data());
VkSwapchainCreateInfoKHR swapchain_create_info = {};
swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
swapchain_create_info.pNext = nullptr;
swapchain_create_info.flags = 0;
- swapchain_create_info.surface = cg_core.window_surface;
+ swapchain_create_info.surface = BluCat::core.window_surface;
swapchain_create_info.minImageCount = 3; // triple buffering.
self->image_format = vk_surface_formats[0].format;
@@ -51,7 +52,7 @@ load_swapchain(void *obj)
swapchain_create_info.imageColorSpace = vk_surface_formats[0].colorSpace;
swapchain_create_info.imageExtent = {
- cg_core.display_width, cg_core.display_height};
+ BluCat::core.display_width, BluCat::core.display_height};
swapchain_create_info.imageArrayLayers = 1;
swapchain_create_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
@@ -64,16 +65,16 @@ load_swapchain(void *obj)
swapchain_create_info.oldSwapchain = VK_NULL_HANDLE;
if(vkCreateSwapchainKHR(
- cg_core.vk_device_with_swapchain->device, &swapchain_create_info,
+ BluCat::core.vk_device_with_swapchain->device, &swapchain_create_info,
nullptr, &self->swapchain) != VK_SUCCESS)
throw CommandError{"Vulkan failed to create swapchain."};
vkGetSwapchainImagesKHR(
- cg_core.vk_device_with_swapchain->device, self->swapchain,
+ BluCat::core.vk_device_with_swapchain->device, self->swapchain,
&self->images_count, nullptr);
self->images = new VkImage[self->images_count];
vkGetSwapchainImagesKHR(
- cg_core.vk_device_with_swapchain->device, self->swapchain,
+ BluCat::core.vk_device_with_swapchain->device, self->swapchain,
&self->images_count, self->images);
}
@@ -84,7 +85,7 @@ unload_swapchain(void *obj)
delete[] self->images;
vkDestroySwapchainKHR(
- cg_core.vk_device_with_swapchain->device, self->swapchain, nullptr);
+ BluCat::core.vk_device_with_swapchain->device, self->swapchain, nullptr);
}
void
@@ -111,7 +112,7 @@ load_image_view(void *obj)
create_info.subresourceRange.layerCount = 1;
if(vkCreateImageView(
- cg_core.vk_device_with_swapchain->device, &create_info, nullptr,
+ BluCat::core.vk_device_with_swapchain->device, &create_info, nullptr,
&self->image_views[i]))
throw CommandError{"Could no create Image View for swapchain."};
}
@@ -124,7 +125,8 @@ unload_image_view(void *obj)
for(auto i{0}; i < self->images_count; i++)
vkDestroyImageView(
- cg_core.vk_device_with_swapchain->device, self->image_views[i], nullptr);
+ BluCat::core.vk_device_with_swapchain->device, self->image_views[i],
+ nullptr);
}
void
@@ -150,13 +152,14 @@ load_frame_sync(void *obj)
for(auto i{0}; i < self->max_frames_in_flight; i++)
{
if(vkCreateSemaphore(
- cg_core.vk_device_with_swapchain->device, &semaphore_info,
+ BluCat::core.vk_device_with_swapchain->device, &semaphore_info,
nullptr, &self->image_available_semaphores[i]) != VK_SUCCESS ||
vkCreateSemaphore(
- cg_core.vk_device_with_swapchain->device, &semaphore_info,
+ BluCat::core.vk_device_with_swapchain->device, &semaphore_info,
nullptr, &self->render_finished_semaphores[i]) != VK_SUCCESS ||
- vkCreateFence(cg_core.vk_device_with_swapchain->device, &fence_info,
- nullptr, &self->in_flight_fences[i]) != VK_SUCCESS)
+ vkCreateFence(
+ BluCat::core.vk_device_with_swapchain->device, &fence_info,
+ nullptr, &self->in_flight_fences[i]) != VK_SUCCESS)
throw CommandError{"Failed to create semaphores."};
}
}
@@ -166,16 +169,16 @@ unload_frame_sync(void *obj)
{
auto self = static_cast<BluCat::Swapchain*>(obj);
- vkDeviceWaitIdle(cg_core.vk_device_with_swapchain->device);
+ vkDeviceWaitIdle(BluCat::core.vk_device_with_swapchain->device);
for(auto i{0}; i < self->max_frames_in_flight; i++)
{
- vkDestroySemaphore(cg_core.vk_device_with_swapchain->device,
+ vkDestroySemaphore(BluCat::core.vk_device_with_swapchain->device,
self->render_finished_semaphores[i], nullptr);
- vkDestroySemaphore(cg_core.vk_device_with_swapchain->device,
+ vkDestroySemaphore(BluCat::core.vk_device_with_swapchain->device,
self->image_available_semaphores[i], nullptr);
- vkDestroyFence(cg_core.vk_device_with_swapchain->device,
- self->in_flight_fences[i], nullptr);
+ vkDestroyFence(BluCat::core.vk_device_with_swapchain->device,
+ self->in_flight_fences[i], nullptr);
}
}