diff options
Diffstat (limited to 'engine/xe_swap_chain.cpp')
-rwxr-xr-x | engine/xe_swap_chain.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/engine/xe_swap_chain.cpp b/engine/xe_swap_chain.cpp index 79da771..7044226 100755 --- a/engine/xe_swap_chain.cpp +++ b/engine/xe_swap_chain.cpp @@ -2,21 +2,21 @@ namespace xe { -bool XeSwapChain::initialSwapChainCreated = false; +bool SwapChain::initialSwapChainCreated = false; -XeSwapChain::XeSwapChain(XeDevice &deviceRef, VkExtent2D extent) +SwapChain::SwapChain(Device &deviceRef, VkExtent2D extent) : device{deviceRef}, windowExtent{extent} { init(); } -XeSwapChain::XeSwapChain(XeDevice &deviceRef, VkExtent2D extent, std::shared_ptr<XeSwapChain> previous) +SwapChain::SwapChain(Device &deviceRef, VkExtent2D extent, std::shared_ptr<SwapChain> previous) : device{deviceRef}, windowExtent{extent}, oldSwapChain{previous} { init(); oldSwapChain = nullptr; } -void XeSwapChain::init() { +void SwapChain::init() { createSwapChain(); createImageViews(); createRenderPass(); @@ -26,7 +26,7 @@ void XeSwapChain::init() { initialSwapChainCreated = true; } -XeSwapChain::~XeSwapChain() { +SwapChain::~SwapChain() { for (auto imageView : swapChainImageViews) { vkDestroyImageView(device.device(), imageView, nullptr); } @@ -56,7 +56,7 @@ XeSwapChain::~XeSwapChain() { } } -VkResult XeSwapChain::acquireNextImage(uint32_t *imageIndex) { +VkResult SwapChain::acquireNextImage(uint32_t *imageIndex) { vkWaitForFences( device.device(), 1, @@ -75,7 +75,7 @@ VkResult XeSwapChain::acquireNextImage(uint32_t *imageIndex) { return result; } -VkResult XeSwapChain::submitCommandBuffers( +VkResult SwapChain::submitCommandBuffers( const VkCommandBuffer *buffers, uint32_t *imageIndex) { if (imagesInFlight[*imageIndex] != VK_NULL_HANDLE) { vkWaitForFences(device.device(), 1, &imagesInFlight[*imageIndex], VK_TRUE, UINT64_MAX); @@ -123,7 +123,7 @@ VkResult XeSwapChain::submitCommandBuffers( return result; } -void XeSwapChain::createSwapChain() { +void SwapChain::createSwapChain() { SwapChainSupportDetails swapChainSupport = device.getSwapChainSupport(); VkSurfaceFormatKHR surfaceFormat = chooseSwapSurfaceFormat(swapChainSupport.formats); @@ -180,7 +180,7 @@ void XeSwapChain::createSwapChain() { swapChainExtent = extent; } -void XeSwapChain::createImageViews() { +void SwapChain::createImageViews() { swapChainImageViews.resize(swapChainImages.size()); for (size_t i = 0; i < swapChainImages.size(); i++) { VkImageViewCreateInfo viewInfo{}; @@ -201,7 +201,7 @@ void XeSwapChain::createImageViews() { } } -void XeSwapChain::createRenderPass() { +void SwapChain::createRenderPass() { VkAttachmentDescription depthAttachment{}; depthAttachment.format = findDepthFormat(); depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT; @@ -262,7 +262,7 @@ void XeSwapChain::createRenderPass() { } } -void XeSwapChain::createFramebuffers() { +void SwapChain::createFramebuffers() { swapChainFramebuffers.resize(imageCount()); for (size_t i = 0; i < imageCount(); i++) { std::array<VkImageView, 2> attachments = {swapChainImageViews[i], depthImageViews[i]}; @@ -287,7 +287,7 @@ void XeSwapChain::createFramebuffers() { } } -void XeSwapChain::createDepthResources() { +void SwapChain::createDepthResources() { VkFormat depthFormat = findDepthFormat(); swapChainDepthFormat = depthFormat; VkExtent2D swapChainExtent = getSwapChainExtent(); @@ -336,7 +336,7 @@ void XeSwapChain::createDepthResources() { } } -void XeSwapChain::createSyncObjects() { +void SwapChain::createSyncObjects() { imageAvailableSemaphores.resize(MAX_FRAMES_IN_FLIGHT); renderFinishedSemaphores.resize(MAX_FRAMES_IN_FLIGHT); inFlightFences.resize(MAX_FRAMES_IN_FLIGHT); @@ -360,7 +360,7 @@ void XeSwapChain::createSyncObjects() { } } -VkSurfaceFormatKHR XeSwapChain::chooseSwapSurfaceFormat( +VkSurfaceFormatKHR SwapChain::chooseSwapSurfaceFormat( const std::vector<VkSurfaceFormatKHR> &availableFormats) { for (const auto &availableFormat : availableFormats) { if (availableFormat.format == VK_FORMAT_B8G8R8A8_UNORM && @@ -372,7 +372,7 @@ VkSurfaceFormatKHR XeSwapChain::chooseSwapSurfaceFormat( return availableFormats[0]; } -VkPresentModeKHR XeSwapChain::chooseSwapPresentMode( +VkPresentModeKHR SwapChain::chooseSwapPresentMode( const std::vector<VkPresentModeKHR> &availablePresentModes) { for (const auto &availablePresentMode : availablePresentModes) { if (availablePresentMode == VK_PRESENT_MODE_MAILBOX_KHR) { @@ -395,7 +395,7 @@ VkPresentModeKHR XeSwapChain::chooseSwapPresentMode( return VK_PRESENT_MODE_FIFO_KHR; } -VkExtent2D XeSwapChain::chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities) { +VkExtent2D SwapChain::chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities) { if (capabilities.currentExtent.width != std::numeric_limits<uint32_t>::max()) { return capabilities.currentExtent; } else { @@ -411,7 +411,7 @@ VkExtent2D XeSwapChain::chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabil } } -VkFormat XeSwapChain::findDepthFormat() { +VkFormat SwapChain::findDepthFormat() { return device.findSupportedFormat( {VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT}, VK_IMAGE_TILING_OPTIMAL, |