[Mesa-dev] [PATCH 13/17] mesa: implement buffer/texture barriers for semaphore wait/signal
Andres Rodriguez
andresx7 at gmail.com
Thu Nov 2 03:57:16 UTC 2017
Make sure memory is accessible to the external client, for the specified
memory object, before the signal/after the wait.
Signed-off-by: Andres Rodriguez <andresx7 at gmail.com>
---
src/mesa/main/dd.h | 14 ++++++-
src/mesa/main/externalobjects.c | 38 ++++++++++++++---
src/mesa/state_tracker/st_cb_semaphoreobjects.c | 55 ++++++++++++++++++++++++-
3 files changed, 98 insertions(+), 9 deletions(-)
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index ec9ed8e..5089c86 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1149,14 +1149,24 @@ struct dd_function_table {
* server's command stream
*/
void (*ServerWaitSemaphoreObject)(struct gl_context *ctx,
- struct gl_semaphore_object *semObj);
+ struct gl_semaphore_object *semObj,
+ GLuint numBufferBarriers,
+ struct gl_buffer_object **bufObjs,
+ GLuint numTextureBarriers,
+ struct gl_texture_object **texObjs,
+ const GLenum *srcLayouts);
/**
* 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);
+ struct gl_semaphore_object *semObj,
+ GLuint numBufferBarriers,
+ struct gl_buffer_object **bufObjs,
+ GLuint numTextureBarriers,
+ struct gl_texture_object **texObjs,
+ const GLenum *dstLayouts);
/*@}*/
/**
diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c
index 67912dd..a7e42a9 100644
--- a/src/mesa/main/externalobjects.c
+++ b/src/mesa/main/externalobjects.c
@@ -23,6 +23,7 @@
#include "macros.h"
#include "mtypes.h"
+#include "bufferobj.h"
#include "context.h"
#include "externalobjects.h"
#include "teximage.h"
@@ -744,7 +745,8 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
{
GET_CURRENT_CONTEXT(ctx);
struct gl_semaphore_object *semObj;
-
+ struct gl_buffer_object **bufObjs;
+ struct gl_texture_object **texObjs;
if (!ctx->Extensions.EXT_semaphore) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glWaitSemaphoreEXT(unsupported)");
@@ -757,8 +759,20 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
if (!semObj)
return;
- /* TODO: memory barriers and layout transitions */
- ctx->Driver.ServerWaitSemaphoreObject(ctx, semObj);
+ bufObjs = alloca(sizeof(struct gl_buffer_object **) * numBufferBarriers);
+ for (unsigned i = 0; i < numBufferBarriers; i++) {
+ bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
+ }
+
+ texObjs = alloca(sizeof(struct gl_texture_object **) * numTextureBarriers);
+ for (unsigned i = 0; i < numTextureBarriers; i++) {
+ texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
+ }
+
+ ctx->Driver.ServerWaitSemaphoreObject(ctx, semObj,
+ numBufferBarriers, bufObjs,
+ numTextureBarriers, texObjs,
+ srcLayouts);
}
void GLAPIENTRY
@@ -771,6 +785,8 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
{
GET_CURRENT_CONTEXT(ctx);
struct gl_semaphore_object *semObj;
+ struct gl_buffer_object **bufObjs;
+ struct gl_texture_object **texObjs;
if (!ctx->Extensions.EXT_semaphore) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glSignalSemaphoreEXT(unsupported)");
@@ -783,8 +799,20 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
if (!semObj)
return;
- /* TODO: memory barriers and layout transitions */
- ctx->Driver.ServerSignalSemaphoreObject(ctx, semObj);
+ bufObjs = alloca(sizeof(struct gl_buffer_object **) * numBufferBarriers);
+ for (unsigned i = 0; i < numBufferBarriers; i++) {
+ bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
+ }
+
+ texObjs = alloca(sizeof(struct gl_texture_object **) * numTextureBarriers);
+ for (unsigned i = 0; i < numTextureBarriers; i++) {
+ texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
+ }
+
+ ctx->Driver.ServerSignalSemaphoreObject(ctx, semObj,
+ numBufferBarriers, bufObjs,
+ numTextureBarriers, texObjs,
+ dstLayouts);
}
void GLAPIENTRY
diff --git a/src/mesa/state_tracker/st_cb_semaphoreobjects.c b/src/mesa/state_tracker/st_cb_semaphoreobjects.c
index 4cff3fd..f6242c7 100644
--- a/src/mesa/state_tracker/st_cb_semaphoreobjects.c
+++ b/src/mesa/state_tracker/st_cb_semaphoreobjects.c
@@ -6,6 +6,8 @@
#include "main/externalobjects.h"
#include "st_context.h"
+#include "st_texture.h"
+#include "st_cb_bufferobjects.h"
#include "st_cb_semaphoreobjects.h"
#include "state_tracker/drm_driver.h"
@@ -51,25 +53,74 @@ st_import_semaphoreobj_fd(struct gl_context *ctx,
static void
st_server_wait_semaphore(struct gl_context *ctx,
- struct gl_semaphore_object *semObj)
+ struct gl_semaphore_object *semObj,
+ GLuint numBufferBarriers,
+ struct gl_buffer_object **bufObjs,
+ GLuint numTextureBarriers,
+ struct gl_texture_object **texObjs,
+ const GLenum *srcLayouts)
{
struct st_semaphore_object *st_obj = st_semaphore_object(semObj);
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
+ struct st_buffer_object *bufObj;
+ struct st_texture_object *texObj;
+ for (unsigned i = 0; i < numBufferBarriers; i++) {
+ if (!bufObjs[i])
+ continue;
+
+ bufObj = st_buffer_object(bufObjs[i]);
+ pipe->flush_resource(pipe, bufObj->buffer);
+ }
+
+ for (unsigned i = 0; i < numTextureBarriers; i++) {
+ if (!texObjs[i])
+ continue;
+
+ texObj = st_texture_object(texObjs[i]);
+ pipe->flush_resource(pipe, texObj->pt);
+ }
+
+ /* TODO: layout transition */
_mesa_flush(ctx);
pipe->semobj_wait(pipe, st_obj->semaphore);
}
static void
st_server_signal_semaphore(struct gl_context *ctx,
- struct gl_semaphore_object *semObj)
+ struct gl_semaphore_object *semObj,
+ GLuint numBufferBarriers,
+ struct gl_buffer_object **bufObjs,
+ GLuint numTextureBarriers,
+ struct gl_texture_object **texObjs,
+ const GLenum *dstLayouts)
{
struct st_semaphore_object *st_obj = st_semaphore_object(semObj);
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
+ struct st_buffer_object *bufObj;
+ struct st_texture_object *texObj;
pipe->semobj_signal(pipe, st_obj->semaphore);
+
+ for (unsigned i = 0; i < numBufferBarriers; i++) {
+ if (!bufObjs[i])
+ continue;
+
+ bufObj = st_buffer_object(bufObjs[i]);
+ pipe->flush_resource(pipe, bufObj->buffer);
+ }
+
+ for (unsigned i = 0; i < numTextureBarriers; i++) {
+ if (!texObjs[i])
+ continue;
+
+ texObj = st_texture_object(texObjs[i]);
+ pipe->flush_resource(pipe, texObj->pt);
+ }
+
+ /* TODO: layout transition */
_mesa_flush(ctx);
}
--
2.9.3
More information about the mesa-dev
mailing list