19 bool presentModeFound =
false;
25 presentModeFound =
true;
30 if (!presentModeFound) {
31 LUG_LOG.error(
"Swapchain::build: Missing present mode supported by Lugdunum");
39 LUG_LOG.error(
"Swapchain::build: Missing imageColorSpace parameter. Call Builder::Swapchain::setImageColorSpace()");
43 bool formatFound =
false;
47 return lhs.colorSpace == localColorSpace && imageFormat == lhs.format;
58 LUG_LOG.error(
"Swapchain::build: Missing swapchain format supported by Lugdunum");
65 bool compositeAlphaFound =
false;
71 compositeAlphaFound =
true;
76 if (!compositeAlphaFound) {
77 LUG_LOG.error(
"Swapchain::build: Missing composite alpha supported by Lugdunum");
89 VkSharingMode sharingMode = VK_SHARING_MODE_EXCLUSIVE;
91 if (queueFamilyIndices.size() > 1 && !
_exclusive) {
92 sharingMode = VK_SHARING_MODE_CONCURRENT;
106 const VkSwapchainCreateInfoKHR createInfo{
107 VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
118 static_cast<uint32_t
>(queueFamilyIndices.size()),
119 queueFamilyIndices.data(),
128 VkSwapchainKHR vkSwapchain{VK_NULL_HANDLE};
129 VkResult result = vkCreateSwapchainKHR(static_cast<VkDevice>(
_device), &createInfo,
nullptr, &vkSwapchain);
132 *returnResult = result;
135 if (result != VK_SUCCESS) {
141 return swapchain.
init();
145 std::unique_ptr<API::Swapchain> swapchain = std::make_unique<API::Swapchain>();
146 return build(*swapchain, returnResult) ? std::move(swapchain) :
nullptr;
bool build(API::Swapchain &instance, VkResult *returnResult=nullptr)
struct lug::Graphics::Vulkan::PhysicalDeviceInfo::Swapchain swapchain
VkSurfaceCapabilitiesKHR capabilities
VkColorSpaceKHR _imageColorSpace
VkSwapchainKHR _oldSwapchain
std::vector< VkCompositeAlphaFlagBitsKHR > compositeAlphas
VkSurfaceTransformFlagBitsKHR _preTransform
std::vector< VkPresentModeKHR > presentModes
std::vector< VkFormat > formats
bool setFromPreferences()
const PhysicalDeviceInfo * getPhysicalDeviceInfo() const
std::vector< VkSurfaceFormatKHR > formats
VkPresentModeKHR _presentMode
VkImageUsageFlags _imageUsage
const Renderer::Preferences::Swapchain * _preferences
std::set< uint32_t > _queueFamilyIndices
const API::Device & _device
const char * toStr(VkResult enumVal)
Swapchain(const API::Device &device)
std::vector< VkPresentModeKHR > presentModes
VkCompositeAlphaFlagBitsKHR _compositeAlpha