Signed-off-by: Chris Wilson <[email protected]>
---
src/mesa/main/api_exec.c | 6 ++
src/mesa/main/bufferobj.c | 161 ++++++++++++++++++++++++++++++++++++++++++++
src/mesa/main/bufferobj.h | 11 +++
src/mesa/main/dd.h | 10 +++
src/mesa/main/extensions.c | 4 +
src/mesa/main/mfeatures.h | 1 +
src/mesa/main/mtypes.h | 2 +
7 files changed, 195 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c
index 1559984..953dcd9 100644
--- a/src/mesa/main/api_exec.c
+++ b/src/mesa/main/api_exec.c
@@ -746,4 +746,10 @@ _mesa_init_exec_table(struct _glapi_table *exec)
/* GL_ARB_vertex_array_object */
SET_BindVertexArray(exec, _mesa_BindVertexArray);
SET_GenVertexArrays(exec, _mesa_GenVertexArrays);
+
+#if FEATURE_APPLE_object_purgeable
+ SET_ObjectPurgeableAPPLE(exec, _mesa_ObjectPurgeableAPPLE);
+ SET_ObjectUnpurgeableAPPLE(exec, _mesa_ObjectUnpurgeableAPPLE);
+ SET_GetObjectParameterivAPPLE(exec, _mesa_GetObjectParameterivAPPLE);
+#endif
}
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 52c4995..56df150 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1655,3 +1655,164 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr
offset, GLsizeiptr length)
if (ctx->Driver.FlushMappedBufferRange)
ctx->Driver.FlushMappedBufferRange(ctx, target, offset, length, bufObj);
}
+
+#if FEATURE_APPLE_object_purgeable
+GLenum GLAPIENTRY
+_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+ GLenum retval;
+
+ switch (objectType) {
+ case GL_TEXTURE:
+ case GL_BUFFER_OBJECT_APPLE:
+ case GL_RENDERBUFFER_EXT:
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glObjectPurgeable(name = 0x%x) invalid type: %d", name,
objectType);
+ return 0;
+ }
+
+ if (name == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glObjectPurgeable(name = 0x%x)", name);
+ return 0;
+ }
+
+ switch (option) {
+ case GL_VOLATILE_APPLE:
+ case GL_RELEASED_APPLE:
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glObjectPurgeable(name = 0x%x) invalid option: %d", name,
option);
+ return 0;
+ }
+
+ bufObj = get_buffer(ctx, name);
+ if (!bufObj) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glObjectPurgeable(name = 0x%x)", name);
+ return 0;
+ }
+
+ if (bufObj->Purgeable) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glObjectPurgeable(name = 0x%x) is already purgeable", name);
+ return GL_VOLATILE_APPLE;
+ }
+
+ bufObj->Purgeable = GL_TRUE;
+
+ retval = GL_VOLATILE_APPLE;
+ if (ctx->Driver.ObjectPurgeable)
+ retval = ctx->Driver.ObjectPurgeable(ctx, bufObj, option);
+
+ return retval;
+}
+
+GLenum GLAPIENTRY
+_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+ GLenum retval;
+
+ switch (objectType) {
+ case GL_TEXTURE:
+ case GL_BUFFER_OBJECT_APPLE:
+ case GL_RENDERBUFFER_EXT:
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glObjectUnpurgeable(name = 0x%x) invalid type: %d", name,
objectType);
+ return 0;
+ }
+
+ if (name == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glObjectUnpurgeable(name = 0x%x)", name);
+ return 0;
+ }
+
+ switch (option) {
+ case GL_RETAINED_APPLE:
+ case GL_UNDEFINED_APPLE:
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glObjectUnpurgeable(name = 0x%x) invalid option: %d", name,
option);
+ return 0;
+ }
+
+ bufObj = get_buffer(ctx, name);
+ if (!bufObj) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glObjectUnpurgeable(name = 0x%x)", name);
+ return 0;
+ }
+
+ if (! bufObj->Purgeable) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glObjectUnpurgeable(name = 0x%x) object is already
\"unpurged\"", name);
+ return 0;
+ }
+
+ bufObj->Purgeable = GL_FALSE;
+
+ retval = GL_RETAINED_APPLE;
+ if (ctx->Driver.ObjectUnpurgeable)
+ retval = ctx->Driver.ObjectUnpurgeable(ctx, bufObj, option);
+
+ return retval;
+}
+
+void GLAPIENTRY
+_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname,
GLint* params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+
+ switch (objectType) {
+ case GL_TEXTURE:
+ case GL_BUFFER_OBJECT_APPLE:
+ case GL_RENDERBUFFER_EXT:
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetObjectParameteriv(name = 0x%x) invalid type: %d",
name, objectType);
+ return;
+ }
+
+ if (name == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetObjectParameteriv(name = 0x%x)", name);
+ return;
+ }
+
+ bufObj = get_buffer(ctx, name);
+ if (!bufObj) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetObjectParameteriv(name = 0x%x) invalid object", name);
+ return;
+ }
+
+ switch (pname) {
+ case GL_PURGEABLE_APPLE:
+ *params = !! bufObj->Purgeable;
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetObjectParameteriv(name = 0x%x) invalid enum: %d",
name, pname);
+ break;
+ }
+}
+#endif
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 9f732ec..8080695 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -169,4 +169,15 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset,
GLsizeiptr length,
extern void GLAPIENTRY
_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr
length);
+#if FEATURE_APPLE_object_purgeable
+extern GLenum GLAPIENTRY
+_mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
+
+extern GLenum GLAPIENTRY
+_mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
+
+extern void GLAPIENTRY
+_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname,
GLint* params);
+#endif
+
#endif
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 99f2cad..412b857 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -808,6 +808,16 @@ struct dd_function_table {
#endif
/**
+ * \name Functions for GL_APPLE_object_purgeable
+ */
+#if FEATURE_APPLE_object_purgeable
+ /*...@{*/
+ GLenum (*ObjectPurgeable)( GLcontext *ctx, struct gl_buffer_object *obj,
GLenum option );
+ GLenum (*ObjectUnpurgeable)( GLcontext *ctx, struct gl_buffer_object *obj,
GLenum option );
+ /*...@}*/
+#endif
+
+ /**
* \name Functions for GL_EXT_framebuffer_object
*/
#if FEATURE_EXT_framebuffer_object
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 54cf37c..878f3f7 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -147,6 +147,7 @@ static const struct {
{ OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
{ ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) },
{ OFF, "GL_APPLE_vertex_array_object", F(APPLE_vertex_array_object) },
+ { OFF, "GL_APPLE_object_purgeable", F(APPLE_object_purgeable) },
{ OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate)
},
{ OFF, "GL_ATI_envmap_bumpmap", F(ATI_envmap_bumpmap) },
{ OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
@@ -252,6 +253,9 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
ctx->Extensions.ARB_sync = GL_TRUE;
#endif
ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
+#if FEATURE_APPLE_object_purgeable
+ ctx->Extensions.APPLE_object_purgeable = GL_TRUE;
+#endif
ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE;
#if FEATURE_ATI_fragment_shader
ctx->Extensions.ATI_fragment_shader = GL_TRUE;
diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h
index 4e68bc1..196f6c5 100644
--- a/src/mesa/main/mfeatures.h
+++ b/src/mesa/main/mfeatures.h
@@ -116,6 +116,7 @@
#define FEATURE_EXT_framebuffer_blit _HAVE_FULL_GL
#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL
#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL
+#define FEATURE_APPLE_object_purgeable _HAVE_FULL_GL
#define FEATURE_EXT_texture_sRGB _HAVE_FULL_GL
#define FEATURE_ATI_fragment_shader _HAVE_FULL_GL
#define FEATURE_NV_fence _HAVE_FULL_GL
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 94d29a7..4f3b94b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1410,6 +1410,7 @@ struct gl_buffer_object
GLsizeiptr Length; /**< Mapped length */
/*...@}*/
GLboolean Written; /**< Ever written to? (for debugging) */
+ GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
};
@@ -2453,6 +2454,7 @@ struct gl_extensions
GLboolean APPLE_client_storage;
GLboolean APPLE_packed_pixels;
GLboolean APPLE_vertex_array_object;
+ GLboolean APPLE_object_purgeable;
GLboolean ATI_envmap_bumpmap;
GLboolean ATI_texture_mirror_once;
GLboolean ATI_texture_env_combine3;
--
1.6.5.2
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel