Mesa (master): anv/wsi: Advertise UNORM formats as well as sRGB

Jason Ekstrand jekstrand at kemper.freedesktop.org
Thu Oct 6 23:55:45 UTC 2016


Module: Mesa
Branch: master
Commit: a1db0e87ffe8cbb567d0f7eb3a9036288eb1036c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1db0e87ffe8cbb567d0f7eb3a9036288eb1036c

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Oct  5 13:23:22 2016 -0700

anv/wsi: Advertise UNORM formats as well as sRGB

Because WSI images are created with VkImageCreateInfo::flags explicitly set
to 0, they don't ever have the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT set.
This means that you can't create an image view of it with a different
format so applications can't render directly in sRGB (without automatic
encoding) unless we actually advertise UNORM formats.  There are a lot of
applications that want to do their own sRGB conversion, so we should allow
for that.  We do, however, make UNORM come after sRGB in the list so that
the default for dumb apps that just grab the first thing is to render in
linear and let the sRGB conversion happen automatically.

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/intel/vulkan/anv_wsi_wayland.c | 4 ++++
 src/intel/vulkan/anv_wsi_x11.c     | 1 +
 2 files changed, 5 insertions(+)

diff --git a/src/intel/vulkan/anv_wsi_wayland.c b/src/intel/vulkan/anv_wsi_wayland.c
index d210e79..afce96f 100644
--- a/src/intel/vulkan/anv_wsi_wayland.c
+++ b/src/intel/vulkan/anv_wsi_wayland.c
@@ -106,8 +106,10 @@ wl_drm_format_for_vk_format(VkFormat vk_format, bool alpha)
    case VK_FORMAT_B5G5R5A1_UNORM:
       return alpha ? WL_DRM_FORMAT_XRGB1555 : WL_DRM_FORMAT_XRGB1555;
 #endif
+   case VK_FORMAT_B8G8R8_UNORM:
    case VK_FORMAT_B8G8R8_SRGB:
       return WL_DRM_FORMAT_BGRX8888;
+   case VK_FORMAT_B8G8R8A8_UNORM:
    case VK_FORMAT_B8G8R8A8_SRGB:
       return alpha ? WL_DRM_FORMAT_ARGB8888 : WL_DRM_FORMAT_XRGB8888;
 #if 0
@@ -163,9 +165,11 @@ drm_handle_format(void *data, struct wl_drm *drm, uint32_t wl_format)
 #endif
    case WL_DRM_FORMAT_XRGB8888:
       wsi_wl_display_add_vk_format(display, VK_FORMAT_B8G8R8_SRGB);
+      wsi_wl_display_add_vk_format(display, VK_FORMAT_B8G8R8_UNORM);
       /* fallthrough */
    case WL_DRM_FORMAT_ARGB8888:
       wsi_wl_display_add_vk_format(display, VK_FORMAT_B8G8R8A8_SRGB);
+      wsi_wl_display_add_vk_format(display, VK_FORMAT_B8G8R8A8_UNORM);
       break;
 #if 0
    case WL_DRM_FORMAT_ARGB2101010:
diff --git a/src/intel/vulkan/anv_wsi_x11.c b/src/intel/vulkan/anv_wsi_x11.c
index 7c6ef97..25c585f 100644
--- a/src/intel/vulkan/anv_wsi_x11.c
+++ b/src/intel/vulkan/anv_wsi_x11.c
@@ -123,6 +123,7 @@ wsi_x11_get_connection(struct anv_physical_device *device,
 
 static const VkSurfaceFormatKHR formats[] = {
    { .format = VK_FORMAT_B8G8R8A8_SRGB, },
+   { .format = VK_FORMAT_B8G8R8A8_UNORM, },
 };
 
 static const VkPresentModeKHR present_modes[] = {




More information about the mesa-commit mailing list