From: Eric Anholt Date: Wed, 6 Mar 2019 19:08:43 +0000 (-0800) Subject: st/dri: Set the PIPE_BIND_SHARED flag on create_image_with_modifiers. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fafead7b6257d0e3f0674a1f19563ed11d47ca8d;p=mesa.git 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 --- 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); }