vulkan: use sRGB backbuffer format when gamma-correct rendering is on

This commit is contained in:
slime
2022-09-20 19:12:40 -03:00
parent 2b074fe90e
commit 45c3638209
+9
View File
@@ -1858,6 +1858,15 @@ void Graphics::createSwapChain()
VkSurfaceFormatKHR Graphics::chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR> &availableFormats)
{
// TODO: turn off GammaCorrect if a sRGB format can't be found?
if (isGammaCorrect())
{
for (const auto& availableFormat : availableFormats)
// fixme: what if this format and colorspace is not available?
if (availableFormat.format == VK_FORMAT_B8G8R8A8_SRGB && availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
return availableFormat;
}
for (const auto &availableFormat : availableFormats)
// fixme: what if this format and colorspace is not available?
if (availableFormat.format == VK_FORMAT_B8G8R8A8_UNORM && availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)