Clearing sRGB swapchain images

Hi,

I’ve created swapchain with VK_FORMAT_R8G8B8A8_SRGB imageFormat. Later I clear it with

VkClearColorValue clear_color = { { 0.5f, 0.5f, 0.5f, 1.f } }

Here is what spec says (https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html#clears-values):
“Floating point values are automatically converted to the format of the image, with the clear value being treated as linear if the image is sRGB.”

So I’m expecting it to produce rgb(187,187,187) pixels. But with 365.19 drivers I get rgb(127,127,127) just like with VK_FORMAT_R8G8B8A8_UNORM.

  1. Does the image view used to clear have SRGB format set?

  2. Could you share a code snippet and/or get a repro app?

Regards,

Mathias Schott

It was my fault.

vkGetPhysicalDeviceSurfaceFormatsKHR returns only BGRA formats, and there was an mistake in my format-choosing code. My code selected VK_FORMAT_B8G8R8A8_UNORM then I was trying to get something as close as possible to VK_FORMAT_R8G8B8A8_SRGB. And created swapchain was actually in UNORM format.

With VK_FORMAT_B8G8R8A8_SRGB clear work as expected.

Glad to hear that you got it to work :)

Mathias