i965/dri: Store the screen associated with the image
authorBen Widawsky <ben@bwidawsk.net>
Thu, 20 Oct 2016 21:51:53 +0000 (14:51 -0700)
committerBen Widawsky <ben@bwidawsk.net>
Tue, 21 Mar 2017 21:48:11 +0000 (14:48 -0700)
I intend to need to get to the devinfo structure, and storing the screen
is an easy way to do that.

It seems to be the consensus that you cannot share an image between
multiple screens.

Scape-goat: Rob Clark <robdclark@gmail.com>
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/mesa/drivers/dri/i965/intel_image.h
src/mesa/drivers/dri/i965/intel_screen.c

index 9b3816efd13a4ca5fe6d134b42e119714c0cb7b8..fd63919b2d275b4c3504097df0073a4823d73443 100644 (file)
@@ -65,6 +65,7 @@ struct intel_image_format {
 };
 
 struct __DRIimageRec {
+   struct intel_screen *screen;
    drm_intel_bo *bo;
    uint32_t pitch; /**< in bytes */
    GLenum internal_format;
index b77933e100eda543060e8ae662ad098dd5cb0918..90223bab2b1ffd20a3dfe07c98980b5cd89f7700 100644 (file)
@@ -323,7 +323,8 @@ static boolean intel_lookup_fourcc(int dri_format, int *fourcc)
 }
 
 static __DRIimage *
-intel_allocate_image(int dri_format, void *loaderPrivate)
+intel_allocate_image(struct intel_screen *screen, int dri_format,
+                     void *loaderPrivate)
 {
     __DRIimage *image;
 
@@ -331,6 +332,7 @@ intel_allocate_image(int dri_format, void *loaderPrivate)
     if (image == NULL)
        return NULL;
 
+    image->screen = screen;
     image->dri_format = dri_format;
     image->offset = 0;
 
@@ -381,7 +383,7 @@ intel_create_image_from_name(__DRIscreen *dri_screen,
     __DRIimage *image;
     int cpp;
 
-    image = intel_allocate_image(format, loaderPrivate);
+    image = intel_allocate_image(screen, format, loaderPrivate);
     if (image == NULL)
        return NULL;
 
@@ -557,7 +559,7 @@ intel_create_image_common(__DRIscreen *dri_screen,
    if (use & __DRI_IMAGE_USE_LINEAR)
       tiling = I915_TILING_NONE;
 
-   image = intel_allocate_image(format, loaderPrivate);
+   image = intel_allocate_image(screen, format, loaderPrivate);
    if (image == NULL)
       return NULL;
 
@@ -740,9 +742,11 @@ intel_create_image_from_fds(__DRIscreen *dri_screen,
       return NULL;
 
    if (f->nplanes == 1)
-      image = intel_allocate_image(f->planes[0].dri_format, loaderPrivate);
+      image = intel_allocate_image(screen, f->planes[0].dri_format,
+                                   loaderPrivate);
    else
-      image = intel_allocate_image(__DRI_IMAGE_FORMAT_NONE, loaderPrivate);
+      image = intel_allocate_image(screen, __DRI_IMAGE_FORMAT_NONE,
+                                   loaderPrivate);
 
    if (image == NULL)
       return NULL;
@@ -845,7 +849,7 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
     offset = parent->offsets[index];
     stride = parent->strides[index];
 
-    image = intel_allocate_image(dri_format, loaderPrivate);
+    image = intel_allocate_image(parent->screen, dri_format, loaderPrivate);
     if (image == NULL)
        return NULL;