#include "macros.h"
#include "mtypes.h"
#include "externalobjects.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "glformats.h"
+#include "texstorage.h"
/**
* Allocate and initialize a new memory object. But don't put it into the
{
memset(obj, 0, sizeof(struct gl_memory_object));
obj->Name = name;
+ obj->Dedicated = GL_FALSE;
}
void GLAPIENTRY
memoryObjects);
}
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDeleteMemoryObjectsEXT(unsupported)");
+ return;
+ }
+
if (n < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glDeleteMemoryObjectsEXT(n < 0)");
return;
_mesa_IsMemoryObjectEXT(GLuint memoryObject)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glIsMemoryObjectEXT(unsupported)");
+ return GL_FALSE;
+ }
+
struct gl_memory_object *obj =
_mesa_lookup_memory_object(ctx, memoryObject);
if (MESA_VERBOSE & (VERBOSE_API))
_mesa_debug(ctx, "%s(%d, %p)", func, n, memoryObjects);
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
if (n < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
return;
GLenum pname,
const GLint *params)
{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_memory_object *memObj;
+
+ const char *func = "glMemoryObjectParameterivEXT";
+
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ memObj = _mesa_lookup_memory_object(ctx, memoryObject);
+ if (!memObj)
+ return;
+
+ if (memObj->Immutable) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(memoryObject is immutable", func);
+ return;
+ }
+
+ switch (pname) {
+ case GL_DEDICATED_MEMORY_OBJECT_EXT:
+ memObj->Dedicated = (GLboolean) params[0];
+ break;
+ case GL_PROTECTED_MEMORY_OBJECT_EXT:
+ /* EXT_protected_textures not supported */
+ goto invalid_pname;
+ default:
+ goto invalid_pname;
+ }
+ return;
+invalid_pname:
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
}
void GLAPIENTRY
GLenum pname,
GLint *params)
{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_memory_object *memObj;
+
+ const char *func = "glMemoryObjectParameterivEXT";
+
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ memObj = _mesa_lookup_memory_object(ctx, memoryObject);
+ if (!memObj)
+ return;
+
+ switch (pname) {
+ case GL_DEDICATED_MEMORY_OBJECT_EXT:
+ *params = (GLint) memObj->Dedicated;
+ break;
+ case GL_PROTECTED_MEMORY_OBJECT_EXT:
+ /* EXT_protected_textures not supported */
+ goto invalid_pname;
+ default:
+ goto invalid_pname;
+ }
+ return;
+
+invalid_pname:
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
+}
+
+static struct gl_memory_object *
+lookup_memory_object_err(struct gl_context *ctx, unsigned memory,
+ const char* func)
+{
+ if (memory == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(memory=0)", func);
+ return NULL;
+ }
+
+ struct gl_memory_object *memObj = _mesa_lookup_memory_object(ctx, memory);
+ if (!memObj)
+ return NULL;
+
+ if (!memObj->Immutable) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no associated memory)",
+ func);
+ return NULL;
+ }
+
+ return memObj;
+}
+
+/**
+ * Helper used by _mesa_TexStorageMem1/2/3DEXT().
+ */
+static void
+texstorage_memory(GLuint dims, GLenum target, GLsizei levels,
+ GLenum internalFormat, GLsizei width, GLsizei height,
+ GLsizei depth, GLuint memory, GLuint64 offset,
+ const char *func)
+{
+ struct gl_texture_object *texObj;
+ struct gl_memory_object *memObj;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
+ return;
+
+ memObj = lookup_memory_object_err(ctx, memory, func);
+ if (!memObj)
+ return;
+
+ _mesa_texture_storage_memory(ctx, dims, texObj, memObj, target,
+ levels, internalFormat,
+ width, height, depth, offset, false);
+}
+
+static void
+texstorage_memory_ms(GLuint dims, GLenum target, GLsizei samples,
+ GLenum internalFormat, GLsizei width, GLsizei height,
+ GLsizei depth, GLboolean fixedSampleLocations,
+ GLuint memory, GLuint64 offset, const char* func)
+{
+ struct gl_texture_object *texObj;
+ struct gl_memory_object *memObj;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
+ return;
+
+ memObj = lookup_memory_object_err(ctx, memory, func);
+ if (!memObj)
+ return;
+
+ _mesa_texture_storage_ms_memory(ctx, dims, texObj, memObj, target, samples,
+ internalFormat, width, height, depth,
+ fixedSampleLocations, offset, func);
+}
+
+/**
+ * Helper used by _mesa_TextureStorageMem1/2/3DEXT().
+ */
+static void
+texturestorage_memory(GLuint dims, GLuint texture, GLsizei levels,
+ GLenum internalFormat, GLsizei width, GLsizei height,
+ GLsizei depth, GLuint memory, GLuint64 offset,
+ const char *func)
+{
+ struct gl_texture_object *texObj;
+ struct gl_memory_object *memObj;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ texObj = _mesa_lookup_texture(ctx, texture);
+ if (!texObj)
+ return;
+
+ memObj = lookup_memory_object_err(ctx, memory, func);
+ if (!memObj)
+ return;
+
+ _mesa_texture_storage_memory(ctx, dims, texObj, memObj, texObj->Target,
+ levels, internalFormat,
+ width, height, depth, offset, true);
+}
+
+static void
+texturestorage_memory_ms(GLuint dims, GLuint texture, GLsizei samples,
+ GLenum internalFormat, GLsizei width, GLsizei height,
+ GLsizei depth, GLboolean fixedSampleLocations,
+ GLuint memory, GLuint64 offset, const char* func)
+{
+ struct gl_texture_object *texObj;
+ struct gl_memory_object *memObj;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.EXT_memory_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
+ texObj = _mesa_lookup_texture(ctx, texture);
+ if (!texObj)
+ return;
+
+ memObj = lookup_memory_object_err(ctx, memory, func);
+ if (!memObj)
+ return;
+ _mesa_texture_storage_ms_memory(ctx, dims, texObj, memObj, texObj->Target,
+ samples, internalFormat, width, height,
+ depth, fixedSampleLocations, offset, func);
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texstorage_memory(2, target, levels, internalFormat, width, height, 1,
+ memory, offset, "glTexStorageMem2DEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texstorage_memory_ms(2, target, samples, internalFormat, width, height, 1,
+ fixedSampleLocations, memory, offset,
+ "glTexStorageMem2DMultisampleEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texstorage_memory(3, target, levels, internalFormat, width, height, depth,
+ memory, offset, "glTexStorageMem3DEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texstorage_memory_ms(3, target, samples, internalFormat, width, height,
+ depth, fixedSampleLocations, memory, offset,
+ "glTexStorageMem3DMultisampleEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texturestorage_memory(2, texture, levels, internalFormat, width, height, 1,
+ memory, offset, "glTexureStorageMem2DEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texturestorage_memory_ms(2, texture, samples, internalFormat, width, height,
+ 1, fixedSampleLocations, memory, offset,
+ "glTextureStorageMem2DMultisampleEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texturestorage_memory(3, texture, levels, internalFormat, width, height,
+ depth, memory, offset, "glTextureStorageMem3DEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texturestorage_memory_ms(3, texture, samples, internalFormat, width, height,
+ depth, fixedSampleLocations, memory, offset,
+ "glTextureStorageMem3DMultisampleEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texstorage_memory(1, target, levels, internalFormat, width, 1, 1, memory,
+ offset, "glTexStorageMem1DEXT");
}
void GLAPIENTRY
GLuint memory,
GLuint64 offset)
{
-
+ texturestorage_memory(1, texture, levels, internalFormat, width, 1, 1,
+ memory, offset, "glTextureStorageMem1DEXT");
}
void GLAPIENTRY
{
GET_CURRENT_CONTEXT(ctx);
+ const char *func = "glImportMemoryFdEXT";
+
+ if (!ctx->Extensions.EXT_memory_object_fd) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
+ return;
+ }
+
if (handleType != GL_HANDLE_TYPE_OPAQUE_FD_EXT) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glImportMemoryFdEXT(handleType=%u)",
- handleType);
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(handleType=%u)", func, handleType);
return;
}
return;
ctx->Driver.ImportMemoryObjectFd(ctx, memObj, size, fd);
+ memObj->Immutable = GL_TRUE;
}
void GLAPIENTRY