[Mesa-dev] [PATCH] i965: implement (un)mapImage

Julien Isorce julien.isorce at gmail.com
Mon Nov 6 10:26:46 UTC 2017


Already implemented for Gallium drivers.

Useful for gbm_bo_(un)map.

Tested by porting wayland/weston/clients/simple-dmabuf-drm.c to GBM.

Signed-off-by: Julien Isorce <jisorce at oblong.com>
---
 src/mesa/drivers/dri/i965/intel_screen.c | 47 ++++++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index cdc36ad..0408a14 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -755,6 +755,49 @@ intel_create_image(__DRIscreen *dri_screen,
                                loaderPrivate);
 }
 
+static void *
+intel_map_image(__DRIcontext *context, __DRIimage *image,
+                int x0, int y0, int width, int height,
+                unsigned int flags, int *stride, void **map_info)
+{
+  struct brw_context *brw = NULL;
+  struct brw_bo *bo = NULL;
+  void *raw_data = NULL;
+
+  if (!context || !image || !stride || !map_info || *map_info)
+      return NULL;
+
+  brw = context->driverPrivate;
+  bo = image->bo;
+
+  assert(brw);
+  assert(bo);
+
+  raw_data = brw_bo_map(brw, bo, flags);
+
+  if (raw_data) {
+    *map_info = raw_data;
+    *stride = image->pitch;
+  }
+
+  return raw_data;
+}
+
+static void
+intel_unmap_image(__DRIcontext *context, __DRIimage *image, void *map_info)
+{
+   struct brw_bo *bo = NULL;
+
+   if (!context || !image || !map_info)
+      return;
+
+   bo = image->bo;
+
+   assert(bo);
+
+   brw_bo_unmap(bo);
+}
+
 static __DRIimage *
 intel_create_image_with_modifiers(__DRIscreen *dri_screen,
                                   int width, int height, int format,
@@ -1305,8 +1348,8 @@ static const __DRIimageExtension intelImageExtension = {
     .createImageFromDmaBufs             = intel_create_image_from_dma_bufs,
     .blitImage                          = NULL,
     .getCapabilities                    = NULL,
-    .mapImage                           = NULL,
-    .unmapImage                         = NULL,
+    .mapImage                           = intel_map_image,
+    .unmapImage                         = intel_unmap_image,
     .createImageWithModifiers           = intel_create_image_with_modifiers,
     .createImageFromDmaBufs2            = intel_create_image_from_dma_bufs2,
     .queryDmaBufFormats                 = intel_query_dma_buf_formats,
-- 
2.7.4



More information about the mesa-dev mailing list