#include "macros.h"
#include "mtypes.h"
+#include "bufferobj.h"
+#include "context.h"
#include "externalobjects.h"
#include "teximage.h"
#include "texobj.h"
#include "glformats.h"
#include "texstorage.h"
+#include "util/u_memory.h"
/**
* Allocate and initialize a new memory object. But don't put it into the
return obj ? GL_TRUE : GL_FALSE;
}
+/**
+ * Helper that outputs the correct error status for parameter
+ * calls where no pnames are defined
+ */
+static void
+semaphore_parameter_stub(const char* func, GLenum pname)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.EXT_semaphore) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ /* EXT_semaphore and EXT_semaphore_fd define no parameters */
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
+}
+
void GLAPIENTRY
_mesa_SemaphoreParameterui64vEXT(GLuint semaphore,
GLenum pname,
const GLuint64 *params)
{
+ const char *func = "glSemaphoreParameterui64vEXT";
+ semaphore_parameter_stub(func, pname);
}
void GLAPIENTRY
GLenum pname,
GLuint64 *params)
{
+ const char *func = "glGetSemaphoreParameterui64vEXT";
+ semaphore_parameter_stub(func, pname);
}
void GLAPIENTRY
const GLuint *textures,
const GLenum *srcLayouts)
{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_semaphore_object *semObj = NULL;
+ struct gl_buffer_object **bufObjs = NULL;
+ struct gl_texture_object **texObjs = NULL;
+
+ const char *func = "glWaitSemaphoreEXT";
+
+ if (!ctx->Extensions.EXT_semaphore) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ semObj = _mesa_lookup_semaphore_object(ctx, semaphore);
+ if (!semObj)
+ return;
+
+ FLUSH_VERTICES(ctx, 0);
+
+ bufObjs = malloc(sizeof(struct gl_buffer_object *) * numBufferBarriers);
+ if (!bufObjs) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numBufferBarriers=%u)",
+ func, numBufferBarriers);
+ goto end;
+ }
+ for (unsigned i = 0; i < numBufferBarriers; i++) {
+ bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
+ }
+
+ texObjs = malloc(sizeof(struct gl_texture_object *) * numTextureBarriers);
+ if (!texObjs) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numTextureBarriers=%u)",
+ func, numTextureBarriers);
+ goto end;
+ }
+
+ 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);
+
+end:
+ free(bufObjs);
+ free(texObjs);
}
void GLAPIENTRY
const GLuint *textures,
const GLenum *dstLayouts)
{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_semaphore_object *semObj = NULL;
+ struct gl_buffer_object **bufObjs = NULL;
+ struct gl_texture_object **texObjs = NULL;
+
+ const char *func = "glSignalSemaphoreEXT";
+
+ if (!ctx->Extensions.EXT_semaphore) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ semObj = _mesa_lookup_semaphore_object(ctx, semaphore);
+ if (!semObj)
+ return;
+
+ FLUSH_VERTICES(ctx, 0);
+
+ bufObjs = malloc(sizeof(struct gl_buffer_object *) * numBufferBarriers);
+ if (!bufObjs) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numBufferBarriers=%u)",
+ func, numBufferBarriers);
+ goto end;
+ }
+
+ for (unsigned i = 0; i < numBufferBarriers; i++) {
+ bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
+ }
+
+ texObjs = malloc(sizeof(struct gl_texture_object *) * numTextureBarriers);
+ if (!texObjs) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numTextureBarriers=%u)",
+ func, numTextureBarriers);
+ goto end;
+ }
+
+ 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);
+end:
+ free(bufObjs);
+ free(texObjs);
}
void GLAPIENTRY
}
if (handleType != GL_HANDLE_TYPE_OPAQUE_FD_EXT) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(handleType=%u)", func, handleType);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(handleType=%u)", func, handleType);
return;
}
}
if (handleType != GL_HANDLE_TYPE_OPAQUE_FD_EXT) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(handleType=%u)", func, handleType);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(handleType=%u)", func, handleType);
return;
}