27 ferr <<
"Cannot create depth stencil view: no image set" << std::endl;
33 ferr <<
"Cannot create depth stencil view: image is not a VK_Image" << std::endl;
37 vk::ImageViewType viewType = vk::ImageViewType::e2D;
38 vk::ImageAspectFlags aspectMask = vk::ImageAspectFlagBits::eDepth;
43 if (vkFormat == vk::Format::eD24UnormS8Uint ||
44 vkFormat == vk::Format::eD32SfloatS8Uint ||
45 vkFormat == vk::Format::eD16UnormS8Uint) {
46 aspectMask |= vk::ImageAspectFlagBits::eStencil;
49 vk::ImageViewCreateInfo viewInfo;
51 if (viewInfo.image ==
nullptr)
56 viewInfo.setViewType(viewType);
57 viewInfo.setFormat(vkFormat);
59 viewInfo.components.r = vk::ComponentSwizzle::eIdentity;
60 viewInfo.components.g = vk::ComponentSwizzle::eIdentity;
61 viewInfo.components.b = vk::ComponentSwizzle::eIdentity;
62 viewInfo.components.a = vk::ComponentSwizzle::eIdentity;
64 viewInfo.subresourceRange.aspectMask = aspectMask;
65 viewInfo.subresourceRange.baseMipLevel = 0;
66 viewInfo.subresourceRange.levelCount = 1;
67 viewInfo.subresourceRange.baseArrayLayer = 0;
68 viewInfo.subresourceRange.layerCount = 1;
71 m_view =
m_ctx->getDevice().createImageView(viewInfo);
73 catch (
const std::exception& e) {
74 ferr <<
"Failed to create depth stencil view: " << e.what() << std::endl;