mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 16:29:16 +01:00
[dxvk] Enable automatic fallbacks for HDR color spaces
The swap chain blitter can deal with the conversion.
This commit is contained in:
parent
d85d07c0ec
commit
d5744e5a81
@ -7,6 +7,13 @@
|
|||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
|
const std::array<std::pair<VkColorSpaceKHR, VkColorSpaceKHR>, 2> Presenter::s_colorSpaceFallbacks = {{
|
||||||
|
{ VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT, VK_COLOR_SPACE_HDR10_ST2084_EXT },
|
||||||
|
|
||||||
|
{ VK_COLOR_SPACE_HDR10_ST2084_EXT, VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT },
|
||||||
|
}};
|
||||||
|
|
||||||
|
|
||||||
Presenter::Presenter(
|
Presenter::Presenter(
|
||||||
const Rc<DxvkDevice>& device,
|
const Rc<DxvkDevice>& device,
|
||||||
const Rc<sync::Signal>& signal,
|
const Rc<sync::Signal>& signal,
|
||||||
@ -215,6 +222,11 @@ namespace dxvk {
|
|||||||
for (const auto& surfaceFormat : surfaceFormats) {
|
for (const auto& surfaceFormat : surfaceFormats) {
|
||||||
if (surfaceFormat.colorSpace == colorspace)
|
if (surfaceFormat.colorSpace == colorspace)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
for (const auto& fallback : s_colorSpaceFallbacks) {
|
||||||
|
if (fallback.first == colorspace && fallback.second == surfaceFormat.colorSpace)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -658,7 +670,8 @@ namespace dxvk {
|
|||||||
const VkSurfaceFormatKHR& desired) {
|
const VkSurfaceFormatKHR& desired) {
|
||||||
VkSurfaceFormatKHR result = { };
|
VkSurfaceFormatKHR result = { };
|
||||||
result.colorSpace = pickColorSpace(numSupported, pSupported, desired.colorSpace);
|
result.colorSpace = pickColorSpace(numSupported, pSupported, desired.colorSpace);
|
||||||
result.format = pickFormat(numSupported, pSupported, result.colorSpace, desired.format);
|
result.format = pickFormat(numSupported, pSupported, result.colorSpace,
|
||||||
|
result.colorSpace == desired.colorSpace ? desired.format : VK_FORMAT_UNDEFINED);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,18 +680,17 @@ namespace dxvk {
|
|||||||
uint32_t numSupported,
|
uint32_t numSupported,
|
||||||
const VkSurfaceFormatKHR* pSupported,
|
const VkSurfaceFormatKHR* pSupported,
|
||||||
VkColorSpaceKHR desired) {
|
VkColorSpaceKHR desired) {
|
||||||
static const std::array<std::pair<VkColorSpaceKHR, VkColorSpaceKHR>, 2> fallbacks = {{
|
VkColorSpaceKHR fallback = pSupported[0].colorSpace;
|
||||||
{ VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT, VK_COLOR_SPACE_HDR10_ST2084_EXT },
|
|
||||||
|
|
||||||
{ VK_COLOR_SPACE_HDR10_ST2084_EXT, VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT },
|
|
||||||
}};
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < numSupported; i++) {
|
for (uint32_t i = 0; i < numSupported; i++) {
|
||||||
if (pSupported[i].colorSpace == desired)
|
if (pSupported[i].colorSpace == desired)
|
||||||
return desired;
|
return desired;
|
||||||
|
|
||||||
|
if (pSupported[i].colorSpace == VK_COLORSPACE_SRGB_NONLINEAR_KHR)
|
||||||
|
fallback = pSupported[i].colorSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& f : fallbacks) {
|
for (const auto& f : s_colorSpaceFallbacks) {
|
||||||
if (f.first != desired)
|
if (f.first != desired)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -688,8 +700,8 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::warn(str::format("No fallback color space found for ", desired, ", using ", pSupported[0].colorSpace));
|
Logger::warn(str::format("No fallback color space found for ", desired, ", using ", fallback));
|
||||||
return pSupported[0].colorSpace;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -790,7 +802,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!desiredFound)
|
if (!desiredFound && format)
|
||||||
Logger::warn(str::format("Desired format ", format, " not in compatibility list for ", colorSpace, ", using ", fallback));
|
Logger::warn(str::format("Desired format ", format, " not in compatibility list for ", colorSpace, ", using ", fallback));
|
||||||
|
|
||||||
return fallback;
|
return fallback;
|
||||||
|
@ -249,6 +249,8 @@ namespace dxvk {
|
|||||||
alignas(CACHE_LINE_SIZE)
|
alignas(CACHE_LINE_SIZE)
|
||||||
FpsLimiter m_fpsLimiter;
|
FpsLimiter m_fpsLimiter;
|
||||||
|
|
||||||
|
static const std::array<std::pair<VkColorSpaceKHR, VkColorSpaceKHR>, 2> s_colorSpaceFallbacks;
|
||||||
|
|
||||||
void updateSwapChain();
|
void updateSwapChain();
|
||||||
|
|
||||||
VkResult recreateSwapChain();
|
VkResult recreateSwapChain();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user