[Mesa-dev] [PATCH 05/26] glx: Implement __DRI_BACKGROUND_CALLABLE (v2)

Marek Olšák maraeo at gmail.com
Wed Feb 8 18:03:19 UTC 2017


From: Paul Berry <stereotype441 at gmail.com>

v2: Marek: Add DRI3 support.
---
 src/glx/dri2_glx.c | 16 +++++++++++++++-
 src/glx/dri3_glx.c | 13 +++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index d6eb281..8dabcb3 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -67,21 +67,21 @@ struct dri2_display
     ** XFree86-DRI version information
     */
    int driMajor;
    int driMinor;
    int driPatch;
    int swapAvailable;
    int invalidateAvailable;
 
    __glxHashTable *dri2Hash;
 
-   const __DRIextension *loader_extensions[4];
+   const __DRIextension *loader_extensions[5];
 };
 
 struct dri2_drawable
 {
    __GLXDRIdrawable base;
    __DRIdrawable *driDrawable;
    __DRIbuffer buffers[5];
    int bufferCount;
    int width, height;
    int have_back;
@@ -939,40 +939,52 @@ dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
 }
 
 static int
 dri2GetSwapInterval(__GLXDRIdrawable *pdraw)
 {
    struct dri2_drawable *priv =  (struct dri2_drawable *) pdraw;
 
   return priv->swap_interval;
 }
 
+static void
+driSetBackgroundContext(void *loaderPrivate)
+{
+   struct dri2_context *pcp = (struct dri2_context *) loaderPrivate;
+   __glXSetCurrentContext(&pcp->base);
+}
+
 static const __DRIdri2LoaderExtension dri2LoaderExtension = {
    .base = { __DRI_DRI2_LOADER, 3 },
 
    .getBuffers              = dri2GetBuffers,
    .flushFrontBuffer        = dri2FlushFrontBuffer,
    .getBuffersWithFormat    = dri2GetBuffersWithFormat,
 };
 
 static const __DRIdri2LoaderExtension dri2LoaderExtension_old = {
    .base = { __DRI_DRI2_LOADER, 3 },
 
    .getBuffers              = dri2GetBuffers,
    .flushFrontBuffer        = dri2FlushFrontBuffer,
    .getBuffersWithFormat    = NULL,
 };
 
 static const __DRIuseInvalidateExtension dri2UseInvalidate = {
    .base = { __DRI_USE_INVALIDATE, 1 }
 };
 
+static const __DRIbackgroundCallableExtension driBackgroundCallable = {
+   { __DRI_BACKGROUND_CALLABLE, __DRI_BACKGROUND_CALLABLE_VERSION },
+   driSetBackgroundContext,
+};
+
 _X_HIDDEN void
 dri2InvalidateBuffers(Display *dpy, XID drawable)
 {
    __GLXDRIdrawable *pdraw =
       dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
    struct dri2_screen *psc;
    struct dri2_drawable *pdp = (struct dri2_drawable *) pdraw;
 
    if (!pdraw)
       return;
@@ -1390,20 +1402,22 @@ dri2CreateDisplay(Display * dpy)
    i = 0;
    if (pdp->driMinor < 1)
       pdp->loader_extensions[i++] = &dri2LoaderExtension_old.base;
    else
       pdp->loader_extensions[i++] = &dri2LoaderExtension.base;
    
    pdp->loader_extensions[i++] = &systemTimeExtension.base;
 
    pdp->loader_extensions[i++] = &dri2UseInvalidate.base;
 
+   pdp->loader_extensions[i++] = &driBackgroundCallable.base;
+
    pdp->loader_extensions[i++] = NULL;
 
    pdp->dri2Hash = __glxHashCreate();
    if (pdp->dri2Hash == NULL) {
       free(pdp);
       return NULL;
    }
 
    return &pdp->base;
 }
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index 42a94f9..688b457 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -489,37 +489,50 @@ dri3_flush_front_buffer(__DRIdrawable *driDrawable, void *loaderPrivate)
 
    psc = (struct dri3_screen *) pdraw->base.psc;
 
    (void) __glXInitialize(psc->base.dpy);
 
    loader_dri3_flush(draw, __DRI2_FLUSH_DRAWABLE, __DRI2_THROTTLE_FLUSHFRONT);
 
    loader_dri3_wait_gl(draw);
 }
 
+static void
+dri_set_background_context(void *loaderPrivate)
+{
+   struct dri3_context *pcp = (struct dri3_context *)loaderPrivate;
+   __glXSetCurrentContext(&pcp->base);
+}
+
 /* The image loader extension record for DRI3
  */
 static const __DRIimageLoaderExtension imageLoaderExtension = {
    .base = { __DRI_IMAGE_LOADER, 1 },
 
    .getBuffers          = loader_dri3_get_buffers,
    .flushFrontBuffer    = dri3_flush_front_buffer,
 };
 
 const __DRIuseInvalidateExtension dri3UseInvalidate = {
    .base = { __DRI_USE_INVALIDATE, 1 }
 };
 
+static const __DRIbackgroundCallableExtension driBackgroundCallable = {
+   { __DRI_BACKGROUND_CALLABLE, 1 },
+   dri_set_background_context,
+};
+
 static const __DRIextension *loader_extensions[] = {
    &imageLoaderExtension.base,
    &systemTimeExtension.base,
    &dri3UseInvalidate.base,
+   &driBackgroundCallable.base,
    NULL
 };
 
 /** dri3_swap_buffers
  *
  * Make the current back buffer visible using the present extension
  */
 static int64_t
 dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
                   int64_t remainder, Bool flush)
-- 
2.7.4



More information about the mesa-dev mailing list