Mesa (master): st/dri: cleanup dri extension handling

Emil Velikov evelikov at kemper.freedesktop.org
Mon Apr 28 18:12:56 UTC 2014


Module: Mesa
Branch: master
Commit: 98e2a8e2f98dd78de682d92f100598191617ac89
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=98e2a8e2f98dd78de682d92f100598191617ac89

Author: Emil Velikov <emil.l.velikov at gmail.com>
Date:   Wed Feb 12 19:19:17 2014 +0000

st/dri: cleanup dri extension handling

Explicitly set the version that is implemented, as that may differ
from the one defined in dri_interface.h. Use designated initialisers
and constify whereever possible.

Note: __DRIimageExtension should not be made const as it's modified
at runtime. This patch should have no side effects on compilers that
do not support designated initialisers, as the existing code in
dri/common already uses them.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

---

 .../state_trackers/dri/common/dri_drawable.c       |   14 ++++---
 src/gallium/state_trackers/dri/drm/dri2.c          |   41 +++++++++++---------
 2 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c
index a399938..b7df053 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -258,10 +258,11 @@ dri_set_tex_buffer(__DRIcontext *pDRICtx, GLint target,
 }
 
 const __DRItexBufferExtension driTexBufferExtension = {
-    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
-   dri_set_tex_buffer,
-   dri_set_tex_buffer2,
-   NULL,
+   .base = { __DRI_TEX_BUFFER, 2 },
+
+   .setTexBuffer       = dri_set_tex_buffer,
+   .setTexBuffer2      = dri_set_tex_buffer2,
+   .releaseTexBuffer   = NULL,
 };
 
 /**
@@ -561,8 +562,9 @@ dri_throttle(__DRIcontext *cPriv, __DRIdrawable *dPriv,
 
 
 const __DRI2throttleExtension dri2ThrottleExtension = {
-    .base = { __DRI2_THROTTLE, __DRI2_THROTTLE_VERSION },
-    .throttle = dri_throttle,
+    .base = { __DRI2_THROTTLE, 1 },
+
+    .throttle          = dri_throttle,
 };
 
 
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 4f2a87e..7dccc5e 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -95,10 +95,11 @@ dri2_invalidate_drawable(__DRIdrawable *dPriv)
 }
 
 static const __DRI2flushExtension dri2FlushExtension = {
-    { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
-    dri2_flush_drawable,
-    dri2_invalidate_drawable,
-    dri_flush,
+    .base = { __DRI2_FLUSH, 4 },
+
+    .flush                = dri2_flush_drawable,
+    .invalidate           = dri2_invalidate_drawable,
+    .flush_with_flags     = dri_flush,
 };
 
 /**
@@ -110,7 +111,7 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
                           unsigned *count)
 {
    __DRIdrawable *dri_drawable = drawable->dPriv;
-   struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader;
+   const __DRIdri2LoaderExtension *loader = drawable->sPriv->dri2.loader;
    boolean with_format;
    __DRIbuffer *buffers;
    int num_buffers;
@@ -522,7 +523,7 @@ dri2_flush_frontbuffer(struct dri_context *ctx,
                        enum st_attachment_type statt)
 {
    __DRIdrawable *dri_drawable = drawable->dPriv;
-   struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader;
+   const __DRIdri2LoaderExtension *loader = drawable->sPriv->dri2.loader;
    struct pipe_context *pipe = ctx->st->pipe;
 
    if (statt != ST_ATTACHMENT_FRONT_LEFT)
@@ -557,7 +558,7 @@ dri2_update_tex_buffer(struct dri_drawable *drawable,
 static __DRIimage *
 dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
 {
-   __DRIimageLookupExtension *loader = screen->sPriv->dri2.image;
+   const __DRIimageLookupExtension *loader = screen->sPriv->dri2.image;
    __DRIimage *img;
 
    if (!loader->lookupEGLImage)
@@ -1035,18 +1036,20 @@ dri2_destroy_image(__DRIimage *img)
    FREE(img);
 }
 
-static struct __DRIimageExtensionRec dri2ImageExtension = {
-    { __DRI_IMAGE, 6 },
-    dri2_create_image_from_name,
-    dri2_create_image_from_renderbuffer,
-    dri2_destroy_image,
-    dri2_create_image,
-    dri2_query_image,
-    dri2_dup_image,
-    dri2_validate_usage,
-    dri2_from_names,
-    dri2_from_planar,
-    dri2_create_from_texture,
+/* The extension is modified during runtime if DRI_PRIME is detected */
+static __DRIimageExtension dri2ImageExtension = {
+    .base = { __DRI_IMAGE, 6 },
+
+    .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,
+    .createImageFromTexture       = dri2_create_from_texture,
 };
 
 /*




More information about the mesa-commit mailing list