[Mesa-dev] [PATCH v2 3/4] DRI: implement helper functions for dri resource sharing extension.

Zhigang Gong zhigang.gong at linux.intel.com
Tue Jul 16 01:04:19 PDT 2013


Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/mesa/drivers/dri/common/dri_util.c |   48 ++++++++++++++++++++++++++++++++
 src/mesa/drivers/dri/common/dri_util.h |   10 +++++++
 2 files changed, 58 insertions(+)

diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index 9ed9df4..b7b9ed9 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -520,6 +520,43 @@ dri2ReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
     driDriverAPI.ReleaseBuffer(screen, buffer);
 }
 
+static GLboolean
+driAcquireTexture(__DRIcontext *context, GLenum target,
+                  GLint level, GLuint texture, void *user_data)
+{
+    return driDriverAPI.AcquireTexture(context, target, level, texture, user_data);
+}
+
+static GLboolean
+driReleaseTexture(__DRIcontext *context, GLenum target,
+                  GLint level, GLuint texture)
+{
+    return driDriverAPI.ReleaseTexture(context, target, level, texture);
+}
+
+static GLboolean
+driAcquireBufferObj(__DRIcontext *context, GLuint bufobj, void *user_data)
+{
+    return driDriverAPI.AcquireBufferObj(context, bufobj, user_data);
+}
+
+static GLboolean
+driReleaseBufferObj(__DRIcontext *context, GLuint bufobj)
+{
+    return driDriverAPI.ReleaseBufferObj(context, bufobj);
+}
+
+static GLboolean
+driAcquireRenderBuffer(__DRIcontext *context, GLuint rb, void *user_data)
+{
+    return driDriverAPI.AcquireBufferObj(context, rb, user_data);
+}
+
+static GLboolean
+driReleaseRenderBuffer(__DRIcontext *context, GLuint rb)
+{
+    return driDriverAPI.ReleaseBufferObj(context, rb);
+}
 
 static int
 dri2ConfigQueryb(__DRIscreen *screen, const char *var, GLboolean *val)
@@ -603,6 +640,17 @@ const __DRI2configQueryExtension dri2ConfigQueryExtension = {
    .configQueryf        = dri2ConfigQueryf,
 };
 
+const __DRIResourceShareExtension driResourceShareExtension = {
+   .base = { __DRI_RESOURCE_SHARING, __DRI_RESOURCE_SHARING_VERSION },
+
+   .acquireTexture        = driAcquireTexture,
+   .releaseTexture        = driReleaseTexture,
+   .acquireBufferObj      = driAcquireBufferObj,
+   .releaseBufferObj      = driReleaseBufferObj,
+   .acquireRenderBuffer   = driAcquireRenderBuffer,
+   .releaseRenderBuffer   = driReleaseRenderBuffer
+};
+
 void
 dri2InvalidateDrawable(__DRIdrawable *drawable)
 {
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index 900f048..393d00a 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -65,6 +65,7 @@ extern const __DRIcoreExtension driCoreExtension;
 extern const __DRIswrastExtension driSWRastExtension;
 extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
+extern const __DRIResourceShareExtension driResourceShareExtension;
 
 /**
  * Driver callback functions.
@@ -113,6 +114,15 @@ struct __DriverAPIRec {
                                     int width, int height);
 
     void (*ReleaseBuffer) (__DRIscreen *screenPrivate, __DRIbuffer *buffer);
+
+    GLboolean (*AcquireTexture) (__DRIcontext *driContextPriv, GLenum target, GLint level, GLuint tex, void *user_data);
+    GLboolean (*ReleaseTexture) (__DRIcontext *driContextPriv, GLenum target, GLint level, GLuint tex);
+
+    GLboolean (*AcquireBufferObj) (__DRIcontext *driContextPriv, GLuint bufobj, void *user_data);
+    GLboolean (*ReleaseBufferObj) (__DRIcontext *driContextPriv, GLuint bufobj);
+
+    GLboolean (*AcquireRenderBuffer) (__DRIcontext *driContextPriv, GLuint rb, void *user_data);
+    GLboolean (*ReleaseRenderBuffer) (__DRIcontext *driContextPriv, GLuint rb);
 };
 
 extern const struct __DriverAPIRec driDriverAPI;
-- 
1.7.9.5



More information about the mesa-dev mailing list