Fixed depth format selection. Fixes #13, Fixes #19

This commit is contained in:
saschawillems 2016-02-18 22:09:47 +01:00
parent f5919fc988
commit 97485ab357
6 changed files with 17 additions and 90 deletions

View file

@ -388,25 +388,11 @@ public:
&offScreenFrameBuf.albedo);
// Depth attachment
// Find supported depth format
// We prefer 24 bits of depth and 8 bits of stencil, but that may not be supported by all implementations
VkFormat attDepthFormat;
std::vector<VkFormat> depthFormats = { VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D16_UNORM };
bool depthFormatFound = false;
for (auto& format : depthFormats)
{
VkFormatProperties formatProps;
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProps);
// Format must support depth stencil attachment for optimal tiling
if (formatProps.optimalTilingFeatures && VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
{
attDepthFormat = format;
depthFormatFound = true;
break;
}
}
assert(depthFormatFound);
// Find a suitable depth format
VkFormat attDepthFormat;
VkBool32 validDepthFormat = vkTools::getSupportedDepthFormat(physicalDevice, &attDepthFormat);
assert(validDepthFormat);
createAttachment(
attDepthFormat,