Skip to content

vkformat: try UNORM format first and decouple them from colorimetry

From the spec (chapter 34, v1.3.283):

UNORM: the components are unsigned normalized values in the range [0, 1]

SRGB: the R, G and B components are unsigned normalized value that represent
      values using sRGB nonlinear encoding, while the A component (if one
      exists) is a regular unsigned normalized value

The difference is the storage encoding, the first one is aimed for image transfers, while the second is for shaders, mostly in the swapchain stage in the pipeline, and it's done automatically if needed.

As far as I have checked, other frameworks (FFmpeg, GTK+), when import or export images from/to Vulkan, use exclusively UNORM formats, while SRGB formats are ignored.

My conclusion is that Vulkan formats are related on how bits are stored in memory rather their transfer functions (colorimetry).

This patch does two interrelated changes:

  1. It swaps certain color format maps to try first, in both gst_vulkan_format_from_video_info() and gst_vulkan_format_from_video_info_2(), the UNORM formats, when comparing its usage, and later check for SRGB.
  2. It removes the code that check for colorimetry in gst_vulkan_format_from_video_info_2(), since it not storage related.

Cc: @ystreet

Edited by Víctor Manuel Jáquez Leal

Merge request reports