[dxvk] Improve swap chain format fallback logic

When requesting an unsupported non-SRGB format, we shouldn't
fall back to an SRGB format since that will cause Gamma issues.
This commit is contained in:
Philip Rebohle 2018-06-06 23:10:38 +02:00
parent 79d3b203ef
commit b8468fda43
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 13 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include "dxvk_surface.h"
#include "dxvk_format.h"
#include "../util/util_math.h"
@ -50,6 +51,18 @@ namespace dxvk {
return fmt;
}
}
// If that didn't work, we'll fall back to a format
// which has similar properties to the preferred one
DxvkFormatFlags prefFlags = imageFormatInfo(preferred[0].format)->flags;
for (auto fmt : m_surfaceFormats) {
auto currFlags = imageFormatInfo(fmt.format)->flags;
if ((currFlags & DxvkFormatFlag::ColorSpaceSrgb)
== (prefFlags & DxvkFormatFlag::ColorSpaceSrgb))
return fmt;
}
}
// Otherwise, fall back to the first format