diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 8fe0ce5d..af78de27 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -183,7 +183,7 @@ void VulkanExampleBase::prepare() vulkanDevice, queue, frameBuffers, - colorformat, + swapChain.colorFormat, depthFormat, &width, &height, @@ -1466,7 +1466,7 @@ void VulkanExampleBase::setupRenderPass() { std::array attachments = {}; // Color attachment - attachments[0].format = colorformat; + attachments[0].format = swapChain.colorFormat; attachments[0].samples = VK_SAMPLE_COUNT_1_BIT; attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE; diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 6f945bbe..674d5804 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -89,10 +89,7 @@ protected: vk::VulkanDevice *vulkanDevice; // Handle to the device graphics queue that command buffers are submitted to VkQueue queue; - // Color buffer format - VkFormat colorformat = VK_FORMAT_B8G8R8A8_UNORM; - // Depth buffer format - // Depth format is selected during Vulkan initialization + // Depth buffer format (selected during Vulkan initialization) VkFormat depthFormat; // Command buffer pool VkCommandPool cmdPool; diff --git a/multisampling/multisampling.cpp b/multisampling/multisampling.cpp index 0f8d925b..1be6eab8 100644 --- a/multisampling/multisampling.cpp +++ b/multisampling/multisampling.cpp @@ -127,7 +127,7 @@ public: // Color target VkImageCreateInfo info = vkTools::initializers::imageCreateInfo(); info.imageType = VK_IMAGE_TYPE_2D; - info.format = colorformat; + info.format = swapChain.colorFormat; info.extent.width = width; info.extent.height = height; info.extent.depth = 1; @@ -162,7 +162,7 @@ public: VkImageViewCreateInfo viewInfo = vkTools::initializers::imageViewCreateInfo(); viewInfo.image = multisampleTarget.color.image; viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; - viewInfo.format = colorformat; + viewInfo.format = swapChain.colorFormat; viewInfo.components.r = VK_COMPONENT_SWIZZLE_R; viewInfo.components.g = VK_COMPONENT_SWIZZLE_G; viewInfo.components.b = VK_COMPONENT_SWIZZLE_B; @@ -228,7 +228,7 @@ public: std::array attachments = {}; // Multisampled attachment that we render to - attachments[0].format = colorformat; + attachments[0].format = swapChain.colorFormat; attachments[0].samples = SAMPLE_COUNT; attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; // No longer required after resolve, this may save some bandwidth on certain GPUs @@ -240,7 +240,7 @@ public: // This is the frame buffer attachment to where the multisampled image // will be resolved to and which will be presented to the swapchain - attachments[1].format = colorformat; + attachments[1].format = swapChain.colorFormat; attachments[1].samples = VK_SAMPLE_COUNT_1_BIT; attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE; diff --git a/subpasses/subpasses.cpp b/subpasses/subpasses.cpp index 2f5d4925..acce07a3 100644 --- a/subpasses/subpasses.cpp +++ b/subpasses/subpasses.cpp @@ -261,7 +261,7 @@ public: std::array attachments{}; // Color attachment - attachments[0].format = colorformat; + attachments[0].format = swapChain.colorFormat; attachments[0].samples = VK_SAMPLE_COUNT_1_BIT; attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE; diff --git a/textoverlay/textoverlay.cpp b/textoverlay/textoverlay.cpp index a5ba0bef..4b7beaf9 100644 --- a/textoverlay/textoverlay.cpp +++ b/textoverlay/textoverlay.cpp @@ -1147,7 +1147,7 @@ public: vulkanDevice, queue, frameBuffers, - colorformat, + swapChain.colorFormat, depthFormat, &width, &height, diff --git a/triangle/triangle.cpp b/triangle/triangle.cpp index dacc509a..6ebd8bb4 100644 --- a/triangle/triangle.cpp +++ b/triangle/triangle.cpp @@ -703,7 +703,7 @@ public: std::array attachments = {}; // Color attachment - attachments[0].format = colorformat; + attachments[0].format = swapChain.colorFormat; // Use the color format selected by the swapchain attachments[0].samples = VK_SAMPLE_COUNT_1_BIT; // We don't use multi sampling in this example attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; // Clear this attachment at the start of the render pass attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE; // Keep it's contents after the render pass is finished (for displaying it) @@ -713,7 +713,7 @@ public: attachments[0].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; // Layout to which the attachment is transitioned when the render pass is finished // As we want to present the color buffer to the swapchain, we transition to PRESENT_KHR // Depth attachment - attachments[1].format = depthFormat; + attachments[1].format = depthFormat; // A proper depth format is selected in the example base attachments[1].samples = VK_SAMPLE_COUNT_1_BIT; attachments[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; // Clear depth at start of first subpass attachments[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; // We don't need depth after render pass has finished (DONT_CARE may result in better performance)