summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2013-04-03 16:23:57 (GMT)
committerBrian Paul <brianp@vmware.com>2013-04-03 17:02:47 (GMT)
commitac114c682413065a5b8baa678733555e94e43120 (patch)
tree61764015469959c8917abb4ae2672a61df22b9a0
parenta69efa9482d7d4dee476a50b3788544ba9b14a50 (diff)
svga: add new memory-used HUD query
To track the amount of memory used by all pipe_resources (textures and buffers). Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
-rw-r--r--src/gallium/drivers/svga/svga_context.h1
-rw-r--r--src/gallium/drivers/svga/svga_pipe_query.c11
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer.c6
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer.h2
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.c6
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.h2
-rw-r--r--src/gallium/drivers/svga/svga_screen.c3
-rw-r--r--src/gallium/drivers/svga/svga_screen.h3
8 files changed, 33 insertions, 1 deletions
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index e27778e..517102d 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -45,6 +45,7 @@
/** Non-GPU queries for gallium HUD */
#define SVGA_QUERY_DRAW_CALLS (PIPE_QUERY_DRIVER_SPECIFIC + 0)
#define SVGA_QUERY_FALLBACKS (PIPE_QUERY_DRIVER_SPECIFIC + 1)
+#define SVGA_QUERY_MEMORY_USED (PIPE_QUERY_DRIVER_SPECIFIC + 2)
struct draw_vertex_shader;
diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c
index 11f6a05..de84189 100644
--- a/src/gallium/drivers/svga/svga_pipe_query.c
+++ b/src/gallium/drivers/svga/svga_pipe_query.c
@@ -111,6 +111,7 @@ static struct pipe_query *svga_create_query( struct pipe_context *pipe,
break;
case SVGA_QUERY_DRAW_CALLS:
case SVGA_QUERY_FALLBACKS:
+ case SVGA_QUERY_MEMORY_USED:
break;
default:
assert(!"unexpected query type in svga_create_query()");
@@ -144,6 +145,7 @@ static void svga_destroy_query(struct pipe_context *pipe,
break;
case SVGA_QUERY_DRAW_CALLS:
case SVGA_QUERY_FALLBACKS:
+ case SVGA_QUERY_MEMORY_USED:
/* nothing */
break;
default:
@@ -203,6 +205,9 @@ static void svga_begin_query(struct pipe_context *pipe,
case SVGA_QUERY_FALLBACKS:
sq->begin_count = svga->num_fallbacks;
break;
+ case SVGA_QUERY_MEMORY_USED:
+ /* nothing */
+ break;
default:
assert(!"unexpected query type in svga_begin_query()");
}
@@ -246,6 +251,9 @@ static void svga_end_query(struct pipe_context *pipe,
case SVGA_QUERY_FALLBACKS:
sq->end_count = svga->num_fallbacks;
break;
+ case SVGA_QUERY_MEMORY_USED:
+ /* nothing */
+ break;
default:
assert(!"unexpected query type in svga_end_query()");
}
@@ -304,6 +312,9 @@ static boolean svga_get_query_result(struct pipe_context *pipe,
case SVGA_QUERY_FALLBACKS:
vresult->u64 = sq->end_count - sq->begin_count;
break;
+ case SVGA_QUERY_MEMORY_USED:
+ vresult->u64 = svgascreen->total_resource_bytes;
+ break;
default:
assert(!"unexpected query type in svga_get_query_result");
}
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c
index 3aa6644..8ba2252 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer.c
+++ b/src/gallium/drivers/svga/svga_resource_buffer.c
@@ -31,6 +31,7 @@
#include "os/os_thread.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_resource.h"
#include "svga_context.h"
#include "svga_screen.h"
@@ -297,6 +298,8 @@ svga_buffer_destroy( struct pipe_screen *screen,
if(sbuf->swbuf && !sbuf->user)
align_free(sbuf->swbuf);
+ ss->total_resource_bytes -= sbuf->size;
+
FREE(sbuf);
}
@@ -342,6 +345,9 @@ svga_buffer_create(struct pipe_screen *screen,
debug_reference(&sbuf->b.b.reference,
(debug_reference_descriptor)debug_describe_resource, 0);
+ sbuf->size = util_resource_size(template);
+ ss->total_resource_bytes += sbuf->size;
+
return &sbuf->b.b;
error2:
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.h b/src/gallium/drivers/svga/svga_resource_buffer.h
index ee12acf..b431d7b 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer.h
+++ b/src/gallium/drivers/svga/svga_resource_buffer.h
@@ -177,6 +177,8 @@ struct svga_buffer
* a context. It is only valid if the dma.pending is set above.
*/
struct list_head head;
+
+ unsigned size; /**< Approximate size in bytes */
};
diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
index 7f36da8..3cb7d34 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -32,6 +32,7 @@
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_resource.h"
#include "svga_format.h"
#include "svga_screen.h"
@@ -229,6 +230,8 @@ svga_texture_destroy(struct pipe_screen *screen,
SVGA_DBG(DEBUG_DMA, "unref sid %p (texture)\n", tex->handle);
svga_screen_surface_destroy(ss, &tex->key, &tex->handle);
+ ss->total_resource_bytes -= tex->size;
+
FREE(tex);
}
@@ -470,6 +473,9 @@ svga_texture_create(struct pipe_screen *screen,
debug_reference(&tex->b.b.reference,
(debug_reference_descriptor)debug_describe_resource, 0);
+ tex->size = util_resource_size(template);
+ svgascreen->total_resource_bytes += tex->size;
+
return &tex->b.b;
error2:
diff --git a/src/gallium/drivers/svga/svga_resource_texture.h b/src/gallium/drivers/svga/svga_resource_texture.h
index 57ed0f5..b3a1a6d 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.h
+++ b/src/gallium/drivers/svga/svga_resource_texture.h
@@ -75,6 +75,8 @@ struct svga_texture
* to this texture and never destroy this handle directly.
*/
struct svga_winsys_surface *handle;
+
+ unsigned size; /**< Approximate size in bytes */
};
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
index bd1b03f..6213535 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -499,7 +499,8 @@ svga_get_driver_query_info(struct pipe_screen *screen,
{
static const struct pipe_driver_query_info queries[] = {
{"draw-calls", SVGA_QUERY_DRAW_CALLS, 0, FALSE},
- {"fallbacks", SVGA_QUERY_FALLBACKS, 0, FALSE}
+ {"fallbacks", SVGA_QUERY_FALLBACKS, 0, FALSE},
+ {"memory-used", SVGA_QUERY_MEMORY_USED, 0, TRUE}
};
if (!info)
diff --git a/src/gallium/drivers/svga/svga_screen.h b/src/gallium/drivers/svga/svga_screen.h
index d7d2c75..77b552a 100644
--- a/src/gallium/drivers/svga/svga_screen.h
+++ b/src/gallium/drivers/svga/svga_screen.h
@@ -73,6 +73,9 @@ struct svga_screen
} depth;
struct svga_host_surface_cache cache;
+
+ /** Memory used by all resources (buffers and surfaces) */
+ uint64_t total_resource_bytes;
};
#ifndef DEBUG