[08/17] mesa: add support for semaphore object signal/wait

Submitted by Andres Rodriguez on Nov. 2, 2017, 3:57 a.m.

Details

Message ID 20171102035720.6839-9-andresx7@gmail.com
State New
Headers show
Series "Add support for GL_EXT_semaphore" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Andres Rodriguez Nov. 2, 2017, 3:57 a.m.
Memory synchronization is left for a future patch.

Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
---
 src/mesa/main/dd.h              | 14 ++++++++++++++
 src/mesa/main/externalobjects.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index b089219..ec9ed8e 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1143,6 +1143,20 @@  struct dd_function_table {
     */
    void (*DeleteSemaphoreObject)(struct gl_context *ctx,
                                  struct gl_semaphore_object *semObj);
+
+   /**
+    * Introduce an operation to wait for the semaphore object in the GL
+    * server's command stream
+    */
+   void (*ServerWaitSemaphoreObject)(struct gl_context *ctx,
+                                     struct gl_semaphore_object *semObj);
+
+   /**
+    * Introduce an operation to signal the semaphore object in the GL
+    * server's command stream
+    */
+   void (*ServerSignalSemaphoreObject)(struct gl_context *ctx,
+                                       struct gl_semaphore_object *semObj);
    /*@}*/
 
    /**
diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c
index 93a92e9..b82d425 100644
--- a/src/mesa/main/externalobjects.c
+++ b/src/mesa/main/externalobjects.c
@@ -23,6 +23,7 @@ 
 
 #include "macros.h"
 #include "mtypes.h"
+#include "context.h"
 #include "externalobjects.h"
 #include "teximage.h"
 #include "texobj.h"
@@ -743,7 +744,23 @@  _mesa_WaitSemaphoreEXT(GLuint semaphore,
                        const GLuint *textures,
                        const GLenum *srcLayouts)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_semaphore_object *semObj;
+
+
+   if (!ctx->Extensions.EXT_semaphore) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glWaitSemaphoreEXT(unsupported)");
+      return;
+   }
+
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   semObj = _mesa_lookup_semaphore_object(ctx, semaphore);
+   if (!semObj)
+      return;
 
+   /* TODO: memory barriers and layout transitions */
+   ctx->Driver.ServerWaitSemaphoreObject(ctx, semObj);
 }
 
 void GLAPIENTRY
@@ -754,7 +771,22 @@  _mesa_SignalSemaphoreEXT(GLuint semaphore,
                          const GLuint *textures,
                          const GLenum *dstLayouts)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_semaphore_object *semObj;
+
+   if (!ctx->Extensions.EXT_semaphore) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glSignalSemaphoreEXT(unsupported)");
+      return;
+   }
+
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   semObj = _mesa_lookup_semaphore_object(ctx, semaphore);
+   if (!semObj)
+      return;
 
+   /* TODO: memory barriers and layout transitions */
+   ctx->Driver.ServerSignalSemaphoreObject(ctx, semObj);
 }
 
 void GLAPIENTRY