diff --git a/include/vkcv/SwapChain.hpp b/include/vkcv/SwapChain.hpp index 5dad2d95cd9e853af0382ec8c1e5af8be484e5a6..147fc6dccece2f89bedcefb6201ef85f03393e20 100644 --- a/include/vkcv/SwapChain.hpp +++ b/include/vkcv/SwapChain.hpp @@ -4,24 +4,17 @@ #include "vkcv/Window.hpp" #include <iostream> - -// glfw is not initialized in this class because ist must be sure that there exists a context first -// glfw is already initialized by the context or the window class - namespace vkcv { class SwapChain final { private: vk::SurfaceKHR m_surface; - const vkcv::Context& m_context; vk::SwapchainKHR m_swapchain; vk::SurfaceFormatKHR m_format; - SwapChain(vk::SurfaceKHR surface, const vkcv::Context &context, vk::SwapchainKHR swapchain, vk::SurfaceFormatKHR format); + SwapChain(vk::SurfaceKHR surface, vk::SwapchainKHR swapchain, vk::SurfaceFormatKHR format); public: - // bin mir grade unsicher wegen der Mehrfachinstanziierung der Klasse - // es muessen ja oefter mal neue erstellt werden, aber diese existieren ja nicht gleichzeitig, oder? SwapChain(const SwapChain &other) = default; SwapChain(SwapChain &&other) = default; diff --git a/src/vkcv/Context.cpp b/src/vkcv/Context.cpp index 816fded86405cc36d997c2f48a57be18b36f6cab..761add2c9c0792bbf098c1f7f6122e84978a6735 100644 --- a/src/vkcv/Context.cpp +++ b/src/vkcv/Context.cpp @@ -36,7 +36,6 @@ namespace vkcv Context::~Context() noexcept { - std::cout<< " Context " << std::endl; m_Device.destroy(); m_Instance.destroy(); } diff --git a/src/vkcv/Core.cpp b/src/vkcv/Core.cpp index c60b933733908b219481fe8aa1b11c0d100804c5..67307f9cdf8aec6af8c77112382c7b1480ec4631 100644 --- a/src/vkcv/Core.cpp +++ b/src/vkcv/Core.cpp @@ -301,20 +301,18 @@ namespace vkcv if(transferQueueFamilyIndex == -1){ throw std::runtime_error("It is not possible to access another queue as a transfer queue."); } - vk::Queue graphicsQueue = device.getQueue( graphicsQueueFamilyIndex, 0 ); - vk::Queue computeQueue = device.getQueue(computeQueueFamilyIndex,1); - vk::Queue transferQueue = device.getQueue(transferQueueFamilyIndex,2); + vk::Queue graphicsQueue = device.getQueue(graphicsQueueFamilyIndex, 0); + vk::Queue computeQueue = device.getQueue(computeQueueFamilyIndex, 1); + vk::Queue transferQueue = device.getQueue(transferQueueFamilyIndex, 2); Context context(instance, physicalDevice, device); SwapChain swapChain = SwapChain::create(window, context); - std::vector<vk::Image> swapChainImages = device.getSwapchainImagesKHR(swapChain.getSwapchain()); std::vector<vk::ImageView> imageViews; imageViews.reserve( swapChainImages.size() ); //here can be swizzled with vk::ComponentSwizzle if needed - // ToDo: we need the format from the surface object vk::ComponentMapping componentMapping( vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, @@ -353,8 +351,6 @@ namespace vkcv {} Core::~Core() { - std::cout<< " Core " << std::endl; - for( auto image: m_swapchainImageViews ){ m_Context.getDevice().destroyImageView(image); } diff --git a/src/vkcv/SwapChain.cpp b/src/vkcv/SwapChain.cpp index 3a3209e79efa842f453cae255400718728e5f3d4..e9c29482fcce2f94817b29b47b8846633656ebdd 100644 --- a/src/vkcv/SwapChain.cpp +++ b/src/vkcv/SwapChain.cpp @@ -3,8 +3,8 @@ namespace vkcv { - SwapChain::SwapChain(vk::SurfaceKHR surface, const vkcv::Context &context, vk::SwapchainKHR swapchain, vk::SurfaceFormatKHR format ) - : m_surface(surface), m_context(context), m_swapchain(swapchain), m_format( format) + SwapChain::SwapChain(vk::SurfaceKHR surface, vk::SwapchainKHR swapchain, vk::SurfaceFormatKHR format ) + : m_surface(surface), m_swapchain(swapchain), m_format( format) {} vk::SwapchainKHR SwapChain::getSwapchain() { @@ -22,14 +22,10 @@ namespace vkcv { vk::SurfaceKHR createSurface(GLFWwindow *window, const vk::Instance &instance, const vk::PhysicalDevice& physicalDevice) { //create surface VkSurfaceKHR surface; - // 0 means VK_SUCCESS - //std::cout << "FAIL: " << glfwCreateWindowSurface(VkInstance(instance), window, nullptr, &newSurface) << std::endl; if (glfwCreateWindowSurface(VkInstance(instance), window, nullptr, &surface) != VK_SUCCESS) { throw std::runtime_error("failed to create a window surface!"); } vk::Bool32 surfaceSupport = false; - // ToDo: hierfuer brauchen wir jetzt den queuefamiliy Index -> siehe ToDo in Context.cpp - // frage: nimmt die Swapchain automatisch den 0'ten Index (Graphics Queue Family)? if (physicalDevice.getSurfaceSupportKHR(0, vk::SurfaceKHR(surface), &surfaceSupport) != vk::Result::eSuccess && surfaceSupport != true) { throw std::runtime_error("surface is not supported by the device!"); } @@ -37,7 +33,6 @@ namespace vkcv { return vk::SurfaceKHR(surface); } - vk::Extent2D chooseSwapExtent(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface, const Window &window){ vk::SurfaceCapabilitiesKHR surfaceCapabilities; if(physicalDevice.getSurfaceCapabilitiesKHR(surface,&surfaceCapabilities) != vk::Result::eSuccess){ @@ -89,6 +84,7 @@ namespace vkcv { return availablePresentMode; } } + // The FIFO present mode is guaranteed by the spec to be supported return vk::PresentModeKHR::eFifo; } @@ -140,14 +136,12 @@ namespace vkcv { vk::SwapchainKHR swapchain = device.createSwapchainKHR(swapchainCreateInfo); - return SwapChain(surface, context, swapchain, surfaceFormat); + return SwapChain(surface, swapchain, surfaceFormat); } SwapChain::~SwapChain() { - std::cout<< " Swap " << std::endl; -// m_context.getDevice().destroySwapchainKHR( m_swapchain ); -// m_context.getInstance().destroySurfaceKHR( m_surface ); + // needs to be destroyed by creator } }