[Mesa-dev] [PATCH RFC 1/2] i965: Store gen in DRIimages

Daniel Stone daniels at collabora.com
Tue May 3 21:42:32 UTC 2016


This will be used so we can implement a better validateUsage, which
takes neither a screen nor a context.

Signed-off-by: Daniel Stone <daniels at collabora.com>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 src/mesa/drivers/dri/i965/intel_image.h  |  2 ++
 src/mesa/drivers/dri/i965/intel_screen.c | 22 ++++++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_image.h b/src/mesa/drivers/dri/i965/intel_image.h
index 9b3816e..ac3a8bf 100644
--- a/src/mesa/drivers/dri/i965/intel_image.h
+++ b/src/mesa/drivers/dri/i965/intel_image.h
@@ -65,6 +65,8 @@ struct intel_image_format {
 };
 
 struct __DRIimageRec {
+   int gen; /**< device generation number */
+
    drm_intel_bo *bo;
    uint32_t pitch; /**< in bytes */
    GLenum internal_format;
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index db9d94d..e52554c 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -318,7 +318,7 @@ static boolean intel_lookup_fourcc(int dri_format, int *fourcc)
 }
 
 static __DRIimage *
-intel_allocate_image(int dri_format, void *loaderPrivate)
+intel_allocate_image(int dri_format, int gen, void *loaderPrivate)
 {
     __DRIimage *image;
 
@@ -326,6 +326,7 @@ intel_allocate_image(int dri_format, void *loaderPrivate)
     if (image == NULL)
 	return NULL;
 
+    image->gen = gen;
     image->dri_format = dri_format;
     image->offset = 0;
 
@@ -376,7 +377,8 @@ intel_create_image_from_name(__DRIscreen *screen,
     __DRIimage *image;
     int cpp;
 
-    image = intel_allocate_image(format, loaderPrivate);
+    image = intel_allocate_image(format, intelScreen->devinfo->gen,
+                                 loaderPrivate);
     if (image == NULL)
        return NULL;
 
@@ -420,6 +422,7 @@ intel_create_image_from_renderbuffer(__DRIcontext *context,
    if (image == NULL)
       return NULL;
 
+   image->gen = brw->gen;
    image->internal_format = rb->InternalFormat;
    image->format = rb->Format;
    image->offset = 0;
@@ -481,6 +484,7 @@ intel_create_image_from_texture(__DRIcontext *context, int target,
       return NULL;
    }
 
+   image->gen = brw->gen;
    image->internal_format = obj->Image[face][level]->InternalFormat;
    image->format = obj->Image[face][level]->TexFormat;
    image->data = loaderPrivate;
@@ -526,7 +530,8 @@ intel_create_image(__DRIscreen *screen,
    if (use & __DRI_IMAGE_USE_LINEAR)
       tiling = I915_TILING_NONE;
 
-   image = intel_allocate_image(format, loaderPrivate);
+   image = intel_allocate_image(format, intelScreen->devinfo->gen,
+                                loaderPrivate);
    if (image == NULL)
       return NULL;
 
@@ -598,6 +603,7 @@ intel_dup_image(__DRIimage *orig_image, void *loaderPrivate)
       return NULL;
 
    drm_intel_bo_reference(orig_image->bo);
+   image->gen             = orig_image->gen;
    image->bo              = orig_image->bo;
    image->internal_format = orig_image->internal_format;
    image->planar_format   = orig_image->planar_format;
@@ -684,9 +690,13 @@ intel_create_image_from_fds(__DRIscreen *screen,
       return NULL;
 
    if (f->nplanes == 1)
-      image = intel_allocate_image(f->planes[0].dri_format, loaderPrivate);
+      image = intel_allocate_image(f->planes[0].dri_format,
+                                   intelScreen->devinfo->gen,
+                                   loaderPrivate);
    else
-      image = intel_allocate_image(__DRI_IMAGE_FORMAT_NONE, loaderPrivate);
+      image = intel_allocate_image(__DRI_IMAGE_FORMAT_NONE,
+                                   intelScreen->devinfo->gen,
+                                   loaderPrivate);
 
    if (image == NULL)
       return NULL;
@@ -784,7 +794,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(dri_format, parent->gen, loaderPrivate);
     if (image == NULL)
        return NULL;
 
-- 
2.7.4



More information about the mesa-dev mailing list