Mesa (master): st/dri: Set the PIPE_BIND_SHARED flag on create_image_with_modifiers.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Mar 8 23:44:34 UTC 2019


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

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Mar  6 11:08:43 2019 -0800

st/dri: Set the PIPE_BIND_SHARED flag on create_image_with_modifiers.

With createImage(), the caller was expected to set a SHARED flag if they
needed the ability to get a GEM handle.  DRI3, wayland, and gbm all set
it, EGL_MESA_drm_image passes it through, and surfaceless doesn't need it
because there's no way to request a handle.

With the new createImageWithModifiers() DRI method to replace it, the
expectation is that you'll always be able to share the buffer, so the flag
is unnecessary in its arguments.  However, we do need to tell gallium
about this expectation.

Without this, kmscube's modifiers path using
gbm_bo_create_with_modifiers(&modifier, 1) instead of
gbm_bo_create(SCANOUT | SHARED) will call the driver's resource_create()
function wtih PIPE_BIND_SHARED unset, so the driver (particularly
renderonly drivers) may allocate in such a way that it can't return an
answer from gbm_bo_get_handle().  I used to have a hack in v3d using
count==1 && modifier==LINEAR to indicate that you wanted SHARED anyway,
but that was dropped recently.

Fixes: 59527a36e975 ("v3d: Restructure RO allocations using
resource_from_handle.")
Reviewed-by: Kristian H. Kristensen <hoegsberg at chromium.org>

---

 src/gallium/state_trackers/dri/dri2.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 668d177c371..01e88d7c50a 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -992,11 +992,6 @@ dri2_create_image_common(__DRIscreen *_screen,
    if (!map)
       return NULL;
 
-   /* createImageWithModifiers doesn't supply usage, and we should not get
-    * here with both modifiers and a usage flag.
-    */
-   assert(!(use && (modifiers != NULL)));
-
    tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
 
    if (use & __DRI_IMAGE_USE_SCANOUT)
@@ -1069,7 +1064,7 @@ dri2_create_image_with_modifiers(__DRIscreen *dri_screen,
                                  void *loaderPrivate)
 {
    return dri2_create_image_common(dri_screen, width, height, format,
-                                   0 /* use */, modifiers, count,
+                                   __DRI_IMAGE_USE_SHARE, modifiers, count,
                                    loaderPrivate);
 }
 




More information about the mesa-commit mailing list