Browse Source

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

slime 2 years ago
parent
commit
45c3638209
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/modules/graphics/vulkan/Graphics.cpp

+ 9 - 0
src/modules/graphics/vulkan/Graphics.cpp

@@ -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)