[Mesa-dev] [PATCH 05/10] st/dri: implement __DRI_IMAGE_TRANSFER_MAP_USER_STRIDE

Marek Olšák maraeo at gmail.com
Wed Apr 25 21:16:26 UTC 2018


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/gallium/state_trackers/dri/dri2.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 58a6757f037..b9c09fbabd0 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1627,32 +1627,38 @@ dri2_blit_image(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
 
 static void *
 dri2_map_image(__DRIcontext *context, __DRIimage *image,
                 int x0, int y0, int width, int height,
                 unsigned int flags, int *stride, void **data)
 {
    struct dri_context *ctx = dri_context(context);
    struct pipe_context *pipe = ctx->st->pipe;
    enum pipe_transfer_usage pipe_access = 0;
    struct pipe_transfer *trans;
+   struct pipe_box box;
+   unsigned user_stride = 0;
    void *map;
 
    if (!image || !data || *data)
       return NULL;
 
    if (flags & __DRI_IMAGE_TRANSFER_READ)
-         pipe_access |= PIPE_TRANSFER_READ;
+      pipe_access |= PIPE_TRANSFER_READ;
    if (flags & __DRI_IMAGE_TRANSFER_WRITE)
-         pipe_access |= PIPE_TRANSFER_WRITE;
+      pipe_access |= PIPE_TRANSFER_WRITE;
+   if (flags & __DRI_IMAGE_TRANSFER_USER_STRIDE)
+      user_stride = *stride;
 
-   map = pipe_transfer_map(pipe, image->texture,
-                           0, 0, pipe_access, x0, y0, width, height,
+   u_box_2d(x0, y0, width, height, &box);
+
+   map = pipe->transfer_map(pipe, image->texture,
+                           0, pipe_access, &box, user_stride,
                            &trans);
    if (map) {
       *data = trans;
       *stride = trans->stride;
    }
 
    return map;
 }
 
 static void
@@ -1661,27 +1667,26 @@ dri2_unmap_image(__DRIcontext *context, __DRIimage *image, void *data)
    struct dri_context *ctx = dri_context(context);
    struct pipe_context *pipe = ctx->st->pipe;
 
    pipe_transfer_unmap(pipe, (struct pipe_transfer *)data);
 }
 
 static int
 dri2_get_capabilities(__DRIscreen *_screen)
 {
    struct dri_screen *screen = dri_screen(_screen);
-
    return (screen->can_share_buffer ? __DRI_IMAGE_CAP_GLOBAL_NAMES : 0);
 }
 
 /* The extension is modified during runtime if DRI_PRIME is detected */
 static __DRIimageExtension dri2ImageExtension = {
-    .base = { __DRI_IMAGE, 17 },
+    .base = { __DRI_IMAGE, 18 },
 
     .createImageFromName          = dri2_create_image_from_name,
     .createImageFromRenderbuffer  = dri2_create_image_from_renderbuffer,
     .destroyImage                 = dri2_destroy_image,
     .createImage                  = dri2_create_image,
     .queryImage                   = dri2_query_image,
     .dupImage                     = dri2_dup_image,
     .validateUsage                = dri2_validate_usage,
     .createImageFromNames         = dri2_from_names,
     .fromPlanar                   = dri2_from_planar,
-- 
2.17.0



More information about the mesa-dev mailing list