[Mesa-dev] [PATCH v3 05/15] st/dri: enable DRIimage modifier queries

Varad Gautam varadgautam at gmail.com
Wed May 10 17:45:32 UTC 2017


From: Varad Gautam <varad.gautam at collabora.com>

introduce modifier field in DRIimage and set it to
DRM_FORMAT_MOD_INVALID for now. support DRIimage modifier
queries.

Suggested-by: Daniel Stone <daniels at collabora.com>
Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
 src/gallium/state_trackers/dri/dri2.c       | 15 +++++++++++++++
 src/gallium/state_trackers/dri/dri_screen.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index d561fe8..42fa155 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -52,6 +52,10 @@
 #include "dri_query_renderer.h"
 #include "dri2_buffer.h"
 
+#ifndef DRM_FORMAT_MOD_INVALID
+#define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1)
+#endif
+
 /* format list taken from intel_screen.c */
 static struct image_format image_formats[] = {
    { __DRI_IMAGE_FOURCC_ARGB8888, __DRI_IMAGE_COMPONENTS_RGBA, 1,
@@ -874,6 +878,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen,
    img->layer = 0;
    img->dri_format = format;
    img->use = 0;
+   img->modifier = DRM_FORMAT_MOD_INVALID;
    img->loader_private = loaderPrivate;
 
    return img;
@@ -1024,6 +1029,7 @@ dri2_create_image(__DRIscreen *_screen,
    img->dri_format = format;
    img->dri_components = 0;
    img->use = use;
+   img->modifier = DRM_FORMAT_MOD_INVALID;
 
    img->loader_private = loaderPrivate;
    return img;
@@ -1103,6 +1109,12 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
    case __DRI_IMAGE_ATTRIB_NUM_PLANES:
       *value = 1;
       return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_MODIFIER_UPPER:
+      *value = ((image->modifier >> 32) & 0xffffffff);
+      return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_MODIFIER_LOWER:
+      *value = image->modifier & 0xffffffff;
+      return GL_TRUE;
    default:
       return GL_FALSE;
    }
@@ -1121,6 +1133,7 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate)
    pipe_resource_reference(&img->texture, image->texture);
    img->level = image->level;
    img->layer = image->layer;
+   img->modifier = image->modifier;
    img->dri_format = image->dri_format;
    /* This should be 0 for sub images, but dup is also used for base images. */
    img->dri_components = image->dri_components;
@@ -1250,6 +1263,8 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
    img->level = level;
    img->layer = depth;
    img->dri_format = driGLFormatToImageFormat(obj->Image[face][level]->TexFormat);
+   /* XXX: no way to retrieve modifier from tex here, we lose the modifier. */
+   img->modifier = DRM_FORMAT_MOD_INVALID;
 
    img->loader_private = loaderPrivate;
 
diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h
index de88cd2..0fae51b 100644
--- a/src/gallium/state_trackers/dri/dri_screen.h
+++ b/src/gallium/state_trackers/dri/dri_screen.h
@@ -123,6 +123,7 @@ struct __DRIimageRec {
    uint32_t dri_format;
    uint32_t dri_components;
    unsigned use;
+   uint64_t modifier;
 
    void *loader_private;
 
-- 
2.10.0



More information about the mesa-dev mailing list