aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-04-13 11:34:03 +0200
committermarha <marha@users.sourceforge.net>2012-04-13 11:34:03 +0200
commitfffd436e9c2ec6f5aa501ee57d0e4ade7293ee60 (patch)
tree6fbefab2db2acc7f2d5b066b06649ea88e0d6ab3 /mesalib/src/mesa/main
parent5f8448ef6b85a9ff72c5af4cec99183c8bb60dc6 (diff)
downloadvcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.tar.gz
vcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.tar.bz2
vcxsrv-fffd436e9c2ec6f5aa501ee57d0e4ade7293ee60.zip
fontconfig xserver xkeyboard-config mesa git update 13 Apr 2012
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/bufferobj.c30
-rw-r--r--mesalib/src/mesa/main/bufferobj.h2
-rw-r--r--mesalib/src/mesa/main/texobj.c59
-rw-r--r--mesalib/src/mesa/main/texobj.h3
4 files changed, 94 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index eef10c422..ae7bac14d 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -347,6 +347,36 @@ _mesa_initialize_buffer_object( struct gl_context *ctx,
}
+
+/**
+ * Callback called from _mesa_HashWalk()
+ */
+static void
+count_buffer_size(GLuint key, void *data, void *userData)
+{
+ const struct gl_buffer_object *bufObj =
+ (const struct gl_buffer_object *) data;
+ GLuint *total = (GLuint *) userData;
+
+ *total = *total + bufObj->Size;
+}
+
+
+/**
+ * Compute total size (in bytes) of all buffer objects for the given context.
+ * For debugging purposes.
+ */
+GLuint
+_mesa_total_buffer_object_memory(struct gl_context *ctx)
+{
+ GLuint total = 0;
+
+ _mesa_HashWalk(ctx->Shared->BufferObjects, count_buffer_size, &total);
+
+ return total;
+}
+
+
/**
* Allocate space for and store data in a buffer object. Any data that was
* previously stored in the buffer object is lost. If \c data is \c NULL,
diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h
index a7ce37928..66343c3cd 100644
--- a/mesalib/src/mesa/main/bufferobj.h
+++ b/mesalib/src/mesa/main/bufferobj.h
@@ -89,6 +89,8 @@ _mesa_reference_buffer_object(struct gl_context *ctx,
_mesa_reference_buffer_object_(ctx, ptr, bufObj);
}
+extern GLuint
+_mesa_total_buffer_object_memory(struct gl_context *ctx);
extern void
_mesa_init_buffer_object_functions(struct dd_function_table *driver);
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 4c3eed2b6..155b255a7 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -841,6 +841,65 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
}
+/**
+ * Compute the size of the given texture object, in bytes.
+ */
+static GLuint
+texture_size(const struct gl_texture_object *texObj)
+{
+ const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ GLuint face, level, size = 0;
+
+ for (face = 0; face < numFaces; face++) {
+ for (level = 0; level < MAX_TEXTURE_LEVELS; level++) {
+ const struct gl_texture_image *img = texObj->Image[face][level];
+ if (img) {
+ GLuint sz = _mesa_format_image_size(img->TexFormat, img->Width,
+ img->Height, img->Depth);
+ size += sz;
+ }
+ }
+ }
+
+ return size;
+}
+
+
+/**
+ * Callback called from _mesa_HashWalk()
+ */
+static void
+count_tex_size(GLuint key, void *data, void *userData)
+{
+ const struct gl_texture_object *texObj =
+ (const struct gl_texture_object *) data;
+ GLuint *total = (GLuint *) userData;
+
+ *total = *total + texture_size(texObj);
+}
+
+
+/**
+ * Compute total size (in bytes) of all textures for the given context.
+ * For debugging purposes.
+ */
+GLuint
+_mesa_total_texture_memory(struct gl_context *ctx)
+{
+ GLuint tgt, total = 0;
+
+ _mesa_HashWalk(ctx->Shared->TexObjects, count_tex_size, &total);
+
+ /* plus, the default texture objects */
+ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
+ total += texture_size(ctx->Shared->DefaultTex[tgt]);
+ }
+
+ return total;
+}
+
+
+
/*@}*/
diff --git a/mesalib/src/mesa/main/texobj.h b/mesalib/src/mesa/main/texobj.h
index c020b9013..23e1ade09 100644
--- a/mesalib/src/mesa/main/texobj.h
+++ b/mesalib/src/mesa/main/texobj.h
@@ -112,6 +112,9 @@ _mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj,
extern struct gl_texture_object *
_mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex);
+extern GLuint
+_mesa_total_texture_memory(struct gl_context *ctx);
+
extern void
_mesa_unlock_context_textures( struct gl_context *ctx );