Skip to content

Commit

Permalink
color_space_helper: Allow 8- and 10-bit fmts for the sRGB color space
Browse files Browse the repository at this point in the history
Most texture formats should be presentable on the default sRGB color
space, in particular 10-bit formats for higher bit depth and detail than
the typical 8-bit.

A couple notes:
- This currently only affects `VK_KHR_display` as there is a
  `needsWorkaround` case in `PhysicalDevice::GetSurfaceFormats()` that
  returns exclusively RGBA8 and BGRA8 in the windowed/compositor case;
- Before this patch, `A2B10G10R10` wasn't in the list returned by
  `vkGetPhysicalDeviceSurfaceFormatsKHR()` but worked anyway on
  `VK_KHR_display` _without_ validation errors;
- Using the `A2B10G10R10` format inside a 10-bit compositor works
  anyway, albeit with validation layer errors;
- RADV also allows 10-bit sRGB swapchains, but only in a compositor, not
  in `VK_KHR_display`;
- Windows also does not report support for this 10-bit sRGB format
  combination, but it works anyway (also with validation layer errors);
- This was previously `Fmt_All` already before commit 02e867e ("Update
  xgl from commit 2aeb0b25") but it is assumed that sub-commit "Fix
  ColorspaceHelper's lookup table so it only reports formats that are
  legal" changed this behaviour. At least 10-bit sRGB should be retained?

(When saying "it works", I mean that it works as intended, i.e.
any 8-bit banding previously observable is gone when using a 10-bit
swapchain)
  • Loading branch information
MarijnS95 committed Jan 17, 2024
1 parent 53656ff commit df3a754
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion icd/api/color_space_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct LookupDefines

const LookupDefines colorspaceLookup[] =
{
{ Pal::ScreenColorSpace::CsSrgb, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, FmtSupport::Fmt_8bpc },
{ Pal::ScreenColorSpace::CsSrgb, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, FmtSupport::Fmt_KnownSRGB },
{ Pal::ScreenColorSpace::CsBt709, VK_COLOR_SPACE_BT709_NONLINEAR_EXT, FmtSupport::Fmt_All },
{ Pal::ScreenColorSpace::TfHlg, VK_COLOR_SPACE_HDR10_HLG_EXT, FmtSupport::Fmt_KnownHDR },
{ Pal::ScreenColorSpace::TfPq2084, VK_COLOR_SPACE_HDR10_ST2084_EXT, FmtSupport::Fmt_10bpc },
Expand Down
9 changes: 5 additions & 4 deletions icd/api/include/color_space_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ class ColorSpaceHelper
Fmt_16bpc_sfloat = 0x0400,
Fmt_32bpc = 0x0800,

Fmt_8bpc = Fmt_8bpc_srgb | Fmt_8bpc_unorm,
Fmt_16bpc = Fmt_16bpc_unorm | Fmt_16bpc_sfloat,
Fmt_KnownHDR = Fmt_10bpc | Fmt_11bpc | Fmt_12bpc | Fmt_16bpc,
Fmt_All = Fmt_4bpc | Fmt_5bpc | Fmt_6bpc | Fmt_8bpc | Fmt_KnownHDR | Fmt_32bpc,
Fmt_8bpc = Fmt_8bpc_srgb | Fmt_8bpc_unorm,
Fmt_16bpc = Fmt_16bpc_unorm | Fmt_16bpc_sfloat,
Fmt_KnownHDR = Fmt_10bpc | Fmt_11bpc | Fmt_12bpc | Fmt_16bpc,
Fmt_KnownSRGB = Fmt_8bpc | Fmt_10bpc,
Fmt_All = Fmt_4bpc | Fmt_5bpc | Fmt_6bpc | Fmt_8bpc | Fmt_KnownHDR | Fmt_32bpc,

Fmt_FreeSync2 = Fmt_10bpc | Fmt_16bpc,
};
Expand Down

0 comments on commit df3a754

Please sign in to comment.