explicitely choose VK_FORMAT_B8G8R8A8_UNORM

if it's not available, select the first available color format
This commit is contained in:
Christoph Haag 2017-01-31 15:51:33 +01:00
parent 44f26b364b
commit df6bb48766

View file

@ -225,17 +225,34 @@ public:
if ((formatCount == 1) && (surfaceFormats[0].format == VK_FORMAT_UNDEFINED))
{
colorFormat = VK_FORMAT_B8G8R8A8_UNORM;
colorSpace = surfaceFormats[0].colorSpace;
}
else
{
// Always select the first available color format
// If you need a specific format (e.g. SRGB) you'd need to
// iterate over the list of available surface format and
// check for it's presence
colorFormat = surfaceFormats[0].format;
// check for the presence of VK_FORMAT_B8G8R8A8_UNORM
bool found_B8G8R8A8_UNORM = false;
for (auto&& surfaceFormat : surfaceFormats)
{
if (surfaceFormat.format == VK_FORMAT_B8G8R8A8_UNORM)
{
colorFormat = surfaceFormat.format;
colorSpace = surfaceFormat.colorSpace;
found_B8G8R8A8_UNORM = true;
break;
}
}
// in case VK_FORMAT_B8G8R8A8_UNORM is not available
// select the first available color format
if (!found_B8G8R8A8_UNORM)
{
colorFormat = surfaceFormats[0].format;
colorSpace = surfaceFormats[0].colorSpace;
}
}
}
/**
* Set instance, physical and logical device to use for the swapchain and get all required function pointers