diff --git a/rendering_api/vulkan/src/presentation_queue/vulkan_presentation_queue.c b/rendering_api/vulkan/src/presentation_queue/vulkan_presentation_queue.c index 0a33c00..648d0e5 100644 --- a/rendering_api/vulkan/src/presentation_queue/vulkan_presentation_queue.c +++ b/rendering_api/vulkan/src/presentation_queue/vulkan_presentation_queue.c @@ -76,8 +76,29 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, NULL); presentationQueue->presentationQueue->swapChainImages = malloc(sizeof(VkImage) * presentationQueue->imageCount); + presentationQueue->presentationQueue->swapChainImageViews = malloc(sizeof(VkImageView) * presentationQueue->imageCount); vkGetSwapchainImagesKHR(device->outputDevice->device, presentationQueue->presentationQueue->swapChain, &presentationQueue->imageCount, presentationQueue->presentationQueue->swapChainImages); + VkImageViewCreateInfo imageViewCreateInfo = {}; + imageViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + imageViewCreateInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; + imageViewCreateInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY; + imageViewCreateInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY; + imageViewCreateInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY; + imageViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + imageViewCreateInfo.subresourceRange.baseMipLevel = 0; + imageViewCreateInfo.subresourceRange.levelCount = 1; + imageViewCreateInfo.subresourceRange.baseArrayLayer = 0; + imageViewCreateInfo.subresourceRange.layerCount = 1; + + for (int i = 0; i < presentationQueue->imageCount; i++) { + imageViewCreateInfo.image = presentationQueue->presentationQueue->swapChainImages[i]; + if (vkCreateImageView(device, &imageViewCreateInfo, NULL, &presentationQueue->presentationQueue->swapChainImageViews[i]) != VK_SUCCESS) { + return GN_FAILED_TO_CREATE_IMAGE_VIEW; + } + + } + return GN_SUCCESS; } diff --git a/rendering_api/vulkan/src/presentation_queue/vulkan_presentation_queue.h b/rendering_api/vulkan/src/presentation_queue/vulkan_presentation_queue.h index 161b9be..218008e 100644 --- a/rendering_api/vulkan/src/presentation_queue/vulkan_presentation_queue.h +++ b/rendering_api/vulkan/src/presentation_queue/vulkan_presentation_queue.h @@ -6,4 +6,5 @@ typedef struct gnPlatformPresentationQueue_t { VkSwapchainKHR swapChain; VkImage* swapChainImages; + VkImageView* swapChainImageViews; } gnPlatformPresentationQueue; diff --git a/src/utils/gryphn_error_code.h b/src/utils/gryphn_error_code.h index 74930a9..85d36da 100644 --- a/src/utils/gryphn_error_code.h +++ b/src/utils/gryphn_error_code.h @@ -15,7 +15,8 @@ typedef enum gnReturnCode_t { GN_NO_SUPPORTED_PRESENT_MODES, GN_UNKNOWN_IMAGE_FORMAT, GN_FAILED_TO_CREATE_PRESENTATION_QUEUE, - GN_UNSUPPORTED_IMAGE_COUNT + GN_UNSUPPORTED_IMAGE_COUNT, + GN_FAILED_TO_CREATE_IMAGE_VIEW // GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT, // GN_UNKNOWN_SHADER_MODULE, @@ -46,5 +47,6 @@ static const char* gnErrorCodeToCString(enum gnReturnCode_t returnCode) { case GN_UNKNOWN_IMAGE_FORMAT: return "GN_UNKNOWN_IMAGE_FORMAT"; case GN_FAILED_TO_CREATE_PRESENTATION_QUEUE: return "GN_FAILED_TO_CREATE_PRESENTATION_QUEUE"; case GN_UNSUPPORTED_IMAGE_COUNT: return "GN_UNSUPPORTED_IMAGE_COUNT"; + case GN_FAILED_TO_CREATE_IMAGE_VIEW: return "GN_FAILED_TO_CREATE_IMAGE_VIEW"; } }