Properly choose swapchain image format
This commit is contained in:
parent
517c4504c6
commit
322309061d
1 changed files with 8 additions and 2 deletions
|
@ -39,6 +39,12 @@ RenderTarget* Renderer::createSurfaceRenderTarget(VkSurfaceKHR surface) {
|
|||
VkSurfaceFormatKHR* surfaceFormats = new VkSurfaceFormatKHR[surfaceFormatCount];
|
||||
vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice_, surface, &surfaceFormatCount, surfaceFormats);
|
||||
|
||||
uint32_t chosenFormat = 0;
|
||||
for(uint32_t i = 0; i < surfaceFormatCount; i++) {
|
||||
if(surfaceFormats[i].colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
|
||||
chosenFormat = i;
|
||||
}
|
||||
|
||||
VkBool32 supported = false;
|
||||
vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice_, queueIndices.presentation, surface, &supported);
|
||||
|
||||
|
@ -46,8 +52,8 @@ RenderTarget* Renderer::createSurfaceRenderTarget(VkSurfaceKHR surface) {
|
|||
swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||
swapchainCreateInfo.surface = surface;
|
||||
swapchainCreateInfo.minImageCount = surfaceCapabilities.minImageCount;
|
||||
swapchainCreateInfo.imageColorSpace = surfaceFormats[0].colorSpace;
|
||||
swapchainCreateInfo.imageFormat = surfaceFormats[0].format;
|
||||
swapchainCreateInfo.imageColorSpace = surfaceFormats[chosenFormat].colorSpace;
|
||||
swapchainCreateInfo.imageFormat = surfaceFormats[chosenFormat].format;
|
||||
swapchainCreateInfo.imageExtent = surfaceCapabilities.currentExtent;
|
||||
swapchainCreateInfo.imageArrayLayers = 1;
|
||||
swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
|
Reference in a new issue