From 2404308fd34d41868b9e80e2ec8c1399d252e084 Mon Sep 17 00:00:00 2001 From: Jakob Schaal Date: Sat, 16 Sep 2017 03:30:24 +0200 Subject: [PATCH] Added "Image View creation" readme section in texturemipmapgen --- texturemipmapgen/README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/texturemipmapgen/README.md b/texturemipmapgen/README.md index 2f6f6667..7bd8ee0d 100644 --- a/texturemipmapgen/README.md +++ b/texturemipmapgen/README.md @@ -178,4 +178,20 @@ Once the loop is done we need to transition all mip levels of the image to their VK_PIPELINE_STAGE_HOST_BIT); ``` -Submitting that command buffer will result in an image with a complete mip-chain and all mip levels being transitioned to the proper image layout for shader reads. \ No newline at end of file +Submitting that command buffer will result in an image with a complete mip-chain and all mip levels being transitioned to the proper image layout for shader reads. + +### Image View creation +The Image View also requires information about how many Mip Levels are used. This is specified in the ```VkImageViewCreateInfo.subresourceRange.levelCount``` field. + +```cpp + VkImageViewCreateInfo view = vks::initializers::imageViewCreateInfo(); + view.image = texture.image; + view.viewType = VK_IMAGE_VIEW_TYPE_2D; + view.format = format; + view.components = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }; + view.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + view.subresourceRange.baseMipLevel = 0; + view.subresourceRange.baseArrayLayer = 0; + view.subresourceRange.layerCount = 1; + view.subresourceRange.levelCount = texture.mipLevels; +``` \ No newline at end of file