st/dri2 Plumb the flush_swapbuffer functionality through to dri3
authorThomas Hellstrom <thellstrom@vmware.com>
Tue, 20 Jun 2017 17:24:34 +0000 (19:24 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 3 Aug 2017 06:01:31 +0000 (08:01 +0200)
Implement the state tracker manager drawable interface flush_swapbuffer
method by plumbing it through to dri3 if available.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
src/gallium/state_trackers/dri/dri2.c
src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/dri/dri_drawable.h

index 0f71adc7689b8a0dffcc70999eece4ea6eb7b206..1171e7386d76ea8711b3675488af5c50b551c407 100644 (file)
@@ -861,6 +861,21 @@ dri2_flush_frontbuffer(struct dri_context *ctx,
    }
 }
 
+/**
+ * The struct dri_drawable flush_swapbuffers callback
+ */
+static void
+dri2_flush_swapbuffers(struct dri_context *ctx,
+                       struct dri_drawable *drawable)
+{
+   __DRIdrawable *dri_drawable = drawable->dPriv;
+   const __DRIimageLoaderExtension *image = drawable->sPriv->image.loader;
+
+   if (image && image->base.version >= 3 && image->flushSwapBuffers) {
+      image->flushSwapBuffers(dri_drawable, dri_drawable->loaderPrivate);
+   }
+}
+
 static void
 dri2_update_tex_buffer(struct dri_drawable *drawable,
                        struct dri_context *ctx,
@@ -2218,6 +2233,7 @@ dri2_create_buffer(__DRIscreen * sPriv,
    drawable->allocate_textures = dri2_allocate_textures;
    drawable->flush_frontbuffer = dri2_flush_frontbuffer;
    drawable->update_tex_buffer = dri2_update_tex_buffer;
+   drawable->flush_swapbuffers = dri2_flush_swapbuffers;
 
    return TRUE;
 }
index 9e0dd6bcfb3b6c828425ec137d49a9029747551a..75a8197d330539a7fbc737c44b1515d894b46c0a 100644 (file)
@@ -122,6 +122,23 @@ dri_st_framebuffer_flush_front(struct st_context_iface *stctx,
    return TRUE;
 }
 
+/**
+ * The state tracker framebuffer interface flush_swapbuffers callback
+ */
+static boolean
+dri_st_framebuffer_flush_swapbuffers(struct st_context_iface *stctx,
+                                     struct st_framebuffer_iface *stfbi)
+{
+   struct dri_context *ctx = (struct dri_context *)stctx->st_manager_private;
+   struct dri_drawable *drawable =
+      (struct dri_drawable *) stfbi->st_manager_private;
+
+   if (drawable->flush_swapbuffers)
+      drawable->flush_swapbuffers(ctx, drawable);
+
+   return TRUE;
+}
+
 /**
  * This is called when we need to set up GL rendering to a new X window.
  */
@@ -146,6 +163,7 @@ dri_create_buffer(__DRIscreen * sPriv,
    drawable->base.visual = &drawable->stvis;
    drawable->base.flush_front = dri_st_framebuffer_flush_front;
    drawable->base.validate = dri_st_framebuffer_validate;
+   drawable->base.flush_swapbuffers = dri_st_framebuffer_flush_swapbuffers;
    drawable->base.st_manager_private = (void *) drawable;
 
    drawable->screen = screen;
index 1f9842ea541b97bc14f0d04cdfb49d466975d70c..7c45004ba64483badefbc3942be0048115887219 100644 (file)
@@ -85,6 +85,8 @@ struct dri_drawable
    void (*update_tex_buffer)(struct dri_drawable *drawable,
                              struct dri_context *ctx,
                              struct pipe_resource *res);
+   void (*flush_swapbuffers)(struct dri_context *ctx,
+                             struct dri_drawable *drawable);
 };
 
 static inline struct dri_drawable *