explicitely choose VK_FORMAT_B8G8R8A8_UNORM
if it's not available, select the first available color format
This commit is contained in:
parent
44f26b364b
commit
df6bb48766
1 changed files with 22 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue