[Mesa-dev] [PATCH 2/4] st/dri2: Add shared flag to missing locations

Axel Davy axel.davy at ens.fr
Wed Oct 21 03:28:01 PDT 2015


The PIPE_BIND_SHARED flag should be added whenever
the resource may be shared with another process.

In particular if the resource is imported, or may
be exported, the flag should be used.

Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/dri/dri2.c         | 9 +++++++--
 src/gallium/state_trackers/dri/dri_drawable.c | 3 ++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 019414b..5f5bc86 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -554,7 +554,8 @@ dri2_allocate_textures(struct dri_context *ctx,
 
          if (drawable->textures[statt]) {
             templ.format = drawable->textures[statt]->format;
-            templ.bind = drawable->textures[statt]->bind & ~PIPE_BIND_SCANOUT;
+            templ.bind = drawable->textures[statt]->bind &
+               ~(PIPE_BIND_SCANOUT | PIPE_BIND_SHARED);
             templ.nr_samples = drawable->stvis.samples;
 
             /* Try to reuse the resource.
@@ -717,7 +718,8 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
    unsigned tex_usage;
    enum pipe_format pf;
 
-   tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+   tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW |
+      PIPE_BIND_SHARED;
 
    switch (format) {
    case __DRI_IMAGE_FORMAT_RGB565:
@@ -1089,6 +1091,9 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
       return NULL;
    }
 
+   /* TODO: The initial texture was not created with the PIPE_BIND_SHARED flag.
+    * There should be a way to add this flag after creation. This flag is
+    * needed for EGLImages. */
    pipe_resource_reference(&img->texture, tex);
 
    *error = __DRI_IMAGE_ERROR_SUCCESS;
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index f0cc4a2..04041d6 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -285,7 +285,8 @@ dri_drawable_get_format(struct dri_drawable *drawable,
        * to use an sRGB format here.
        */
       *format = util_format_linear(drawable->stvis.color_format);
-      *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
+      *bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW |
+         PIPE_BIND_SHARED;
       break;
    case ST_ATTACHMENT_DEPTH_STENCIL:
       *format = drawable->stvis.depth_stencil_format;
-- 
2.6.1



More information about the mesa-dev mailing list