zink: blow up broken xservers more reliably
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 19 Sep 2023 17:00:03 +0000 (13:00 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 25 Oct 2023 18:23:16 +0000 (18:23 +0000)
only certain drivers can successfully run an xserver with implicit modifier
handling, and the rest will have broken rendering

until such time that a vk extension emerges to handle this more widely,
break this interop for drivers where it's already broken

fixes #9819

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25299>

src/gallium/drivers/zink/zink_resource.c
src/gallium/drivers/zink/zink_screen.c
src/gallium/drivers/zink/zink_types.h

index c7f33c8..fd1ed0c 100644 (file)
@@ -1851,8 +1851,13 @@ zink_resource_from_handle(struct pipe_screen *pscreen,
    int modifier_count = 1;
    if (whandle->modifier != DRM_FORMAT_MOD_INVALID)
       modifier = whandle->modifier;
-   else
+   else {
+      if (!zink_screen(pscreen)->driver_workarounds.can_do_invalid_linear_modifier) {
+         mesa_loge("zink: display server doesn't support DRI3 modifiers and driver can't handle INVALID<->LINEAR!");
+         return NULL;
+      }
       whandle->modifier = modifier;
+   }
    templ2.bind |= ZINK_BIND_DMABUF;
    struct pipe_resource *pres = resource_create(pscreen, &templ2, whandle, usage, &modifier, modifier_count, NULL, NULL);
    if (pres) {
index 26397fc..74b575e 100644 (file)
@@ -2872,6 +2872,15 @@ init_driver_workarounds(struct zink_screen *screen)
       break;
    }
 
+   /* these drivers can successfully do INVALID <-> LINEAR dri3 modifier swap */
+   switch (screen->info.driver_props.driverID) {
+   case VK_DRIVER_ID_MESA_TURNIP:
+      screen->driver_workarounds.can_do_invalid_linear_modifier = true;
+      break;
+   default:
+      break;
+   }
+
    /* these drivers have no difference between unoptimized and optimized shader compilation */
    switch (screen->info.driver_props.driverID) {
    case VK_DRIVER_ID_MESA_LLVMPIPE:
index 455be33..05d3633 100644 (file)
@@ -1537,6 +1537,7 @@ struct zink_screen {
       bool no_hw_gl_point;
       bool lower_robustImageAccess2;
       bool needs_zs_shader_swizzle;
+      bool can_do_invalid_linear_modifier;
       unsigned z16_unscaled_bias;
       unsigned z24_unscaled_bias;
    } driver_workarounds;