summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/trace
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/trace')
-rw-r--r--src/gallium/drivers/trace/tr_buffer.c6
-rw-r--r--src/gallium/drivers/trace/tr_buffer.h2
-rw-r--r--src/gallium/drivers/trace/tr_context.c11
-rw-r--r--src/gallium/drivers/trace/tr_context.h2
-rw-r--r--src/gallium/drivers/trace/tr_screen.c7
-rw-r--r--src/gallium/drivers/trace/tr_screen.h33
-rw-r--r--src/gallium/drivers/trace/tr_texture.c21
-rw-r--r--src/gallium/drivers/trace/tr_texture.h6
8 files changed, 84 insertions, 4 deletions
diff --git a/src/gallium/drivers/trace/tr_buffer.c b/src/gallium/drivers/trace/tr_buffer.c
index 3cdb107dc6b..4f0eff6a5a4 100644
--- a/src/gallium/drivers/trace/tr_buffer.c
+++ b/src/gallium/drivers/trace/tr_buffer.c
@@ -27,10 +27,10 @@
#include "util/u_memory.h"
+#include "util/u_simple_list.h"
#include "tr_buffer.h"
-
struct pipe_buffer *
trace_buffer_create(struct trace_screen *tr_scr,
struct pipe_buffer *buffer)
@@ -52,6 +52,8 @@ trace_buffer_create(struct trace_screen *tr_scr,
tr_buf->base.screen = &tr_scr->base;
tr_buf->buffer = buffer;
+ trace_screen_add_to_list(tr_scr, buffers, tr_buf);
+
return &tr_buf->base;
error:
@@ -66,6 +68,8 @@ trace_buffer_destroy(struct trace_screen *tr_scr,
{
struct trace_buffer *tr_buf = trace_buffer(buffer);
+ trace_screen_remove_from_list(tr_scr, buffers, tr_buf);
+
pipe_buffer_reference(&tr_buf->buffer, NULL);
FREE(tr_buf);
}
diff --git a/src/gallium/drivers/trace/tr_buffer.h b/src/gallium/drivers/trace/tr_buffer.h
index bb8a3b2c3aa..1a2d0b9aeae 100644
--- a/src/gallium/drivers/trace/tr_buffer.h
+++ b/src/gallium/drivers/trace/tr_buffer.h
@@ -41,6 +41,8 @@ struct trace_buffer
struct pipe_buffer *buffer;
+ struct tr_list list;
+
void *map;
boolean range_flushed;
};
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index 696b6a4f59b..38646f8aad3 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -26,6 +26,8 @@
**************************************************************************/
#include "util/u_memory.h"
+#include "util/u_simple_list.h"
+
#include "pipe/p_screen.h"
#include "tr_dump.h"
@@ -1014,16 +1016,17 @@ trace_context_flush(struct pipe_context *_pipe,
static INLINE void
trace_context_destroy(struct pipe_context *_pipe)
{
+ struct trace_screen *tr_scr = trace_screen(_pipe->screen);
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
trace_dump_call_begin("pipe_context", "destroy");
-
trace_dump_arg(ptr, pipe);
+ trace_dump_call_end();
- pipe->destroy(pipe);
+ trace_screen_remove_from_list(tr_scr, contexts, tr_ctx);
- trace_dump_call_end();
+ pipe->destroy(pipe);
FREE(tr_ctx);
}
@@ -1150,6 +1153,8 @@ trace_context_create(struct pipe_screen *_screen,
trace_dump_ret(ptr, pipe);
trace_dump_call_end();
+ trace_screen_add_to_list(tr_scr, contexts, tr_ctx);
+
return &tr_ctx->base;
error1:
diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h
index d02b22a069b..2512a0a2328 100644
--- a/src/gallium/drivers/trace/tr_context.h
+++ b/src/gallium/drivers/trace/tr_context.h
@@ -44,6 +44,8 @@ struct trace_context
struct pipe_context base;
struct pipe_context *pipe;
+
+ struct tr_list list;
};
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 3e676f01559..7205dfd1d99 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -26,6 +26,7 @@
**************************************************************************/
#include "util/u_memory.h"
+#include "util/u_simple_list.h"
#include "tr_buffer.h"
#include "tr_dump.h"
@@ -855,6 +856,12 @@ trace_screen_create(struct pipe_screen *screen)
#else
winsys = screen->winsys;
#endif
+ pipe_mutex_init(tr_scr->list_mutex);
+ make_empty_list(&tr_scr->buffers);
+ make_empty_list(&tr_scr->contexts);
+ make_empty_list(&tr_scr->textures);
+ make_empty_list(&tr_scr->surfaces);
+ make_empty_list(&tr_scr->transfers);
tr_scr->base.winsys = winsys;
tr_scr->base.destroy = trace_screen_destroy;
diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h
index 8c65516b509..59f254166d4 100644
--- a/src/gallium/drivers/trace/tr_screen.h
+++ b/src/gallium/drivers/trace/tr_screen.h
@@ -30,6 +30,7 @@
#include "pipe/p_screen.h"
+#include "pipe/p_thread.h"
#ifdef __cplusplus
@@ -37,6 +38,11 @@ extern "C" {
#endif
+struct tr_list {
+ struct tr_list *next;
+ struct tr_list *prev;
+};
+
/**
* It often happens that new data is written directly to the user buffers
* without mapping/unmapping. This flag marks user buffers, so that their
@@ -50,6 +56,18 @@ struct trace_screen
struct pipe_screen base;
struct pipe_screen *screen;
+
+ pipe_mutex list_mutex;
+ int num_buffers;
+ int num_contexts;
+ int num_textures;
+ int num_surfaces;
+ int num_transfers;
+ struct tr_list buffers;
+ struct tr_list contexts;
+ struct tr_list textures;
+ struct tr_list surfaces;
+ struct tr_list transfers;
};
@@ -65,6 +83,21 @@ void
trace_screen_user_buffer_update(struct pipe_screen *screen,
struct pipe_buffer *buffer);
+#define trace_screen_add_to_list(tr_scr, name, obj) \
+ do { \
+ pipe_mutex_lock(tr_scr->list_mutex); \
+ insert_at_head(&tr_scr->name, &obj->list); \
+ tr_scr->num_##name++; \
+ pipe_mutex_unlock(tr_scr->list_mutex); \
+ } while (0)
+
+#define trace_screen_remove_from_list(tr_scr, name, obj) \
+ do { \
+ pipe_mutex_lock(tr_scr->list_mutex); \
+ remove_from_list(&obj->list); \
+ tr_scr->num_##name--; \
+ pipe_mutex_unlock(tr_scr->list_mutex); \
+ } while (0)
#ifdef __cplusplus
}
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
index f4e433792b1..1f25fe38d4c 100644
--- a/src/gallium/drivers/trace/tr_texture.c
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -27,6 +27,7 @@
#include "util/u_hash_table.h"
#include "util/u_memory.h"
+#include "util/u_simple_list.h"
#include "tr_screen.h"
#include "tr_texture.h"
@@ -53,6 +54,8 @@ trace_texture_create(struct trace_screen *tr_scr,
tr_tex->base.screen = &tr_scr->base;
tr_tex->texture = texture;
+ trace_screen_add_to_list(tr_scr, textures, tr_tex);
+
return &tr_tex->base;
error:
@@ -64,6 +67,10 @@ error:
void
trace_texture_destroy(struct trace_texture *tr_tex)
{
+ struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
+
+ trace_screen_remove_from_list(tr_scr, textures, tr_tex);
+
pipe_texture_reference(&tr_tex->texture, NULL);
FREE(tr_tex);
}
@@ -73,6 +80,7 @@ struct pipe_surface *
trace_surface_create(struct trace_texture *tr_tex,
struct pipe_surface *surface)
{
+ struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
struct trace_surface *tr_surf;
if(!surface)
@@ -91,6 +99,8 @@ trace_surface_create(struct trace_texture *tr_tex,
pipe_texture_reference(&tr_surf->base.texture, &tr_tex->base);
tr_surf->surface = surface;
+ trace_screen_add_to_list(tr_scr, surfaces, tr_surf);
+
return &tr_surf->base;
error:
@@ -102,6 +112,10 @@ error:
void
trace_surface_destroy(struct trace_surface *tr_surf)
{
+ struct trace_screen *tr_scr = trace_screen(tr_surf->base.texture->screen);
+
+ trace_screen_remove_from_list(tr_scr, surfaces, tr_surf);
+
pipe_texture_reference(&tr_surf->base.texture, NULL);
pipe_surface_reference(&tr_surf->surface, NULL);
FREE(tr_surf);
@@ -112,6 +126,7 @@ struct pipe_transfer *
trace_transfer_create(struct trace_texture *tr_tex,
struct pipe_transfer *transfer)
{
+ struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
struct trace_transfer *tr_trans;
if(!transfer)
@@ -130,6 +145,8 @@ trace_transfer_create(struct trace_texture *tr_tex,
tr_trans->transfer = transfer;
assert(tr_trans->base.texture == &tr_tex->base);
+ trace_screen_add_to_list(tr_scr, transfers, tr_trans);
+
return &tr_trans->base;
error:
@@ -141,7 +158,11 @@ error:
void
trace_transfer_destroy(struct trace_transfer *tr_trans)
{
+ struct trace_screen *tr_scr = trace_screen(tr_trans->base.texture->screen);
struct pipe_screen *screen = tr_trans->transfer->texture->screen;
+
+ trace_screen_remove_from_list(tr_scr, transfers, tr_trans);
+
pipe_texture_reference(&tr_trans->base.texture, NULL);
screen->tex_transfer_destroy(tr_trans->transfer);
FREE(tr_trans);
diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h
index 14dafd8b2c3..395e523e73a 100644
--- a/src/gallium/drivers/trace/tr_texture.h
+++ b/src/gallium/drivers/trace/tr_texture.h
@@ -40,6 +40,8 @@ struct trace_texture
struct pipe_texture base;
struct pipe_texture *texture;
+
+ struct tr_list list;
};
@@ -48,6 +50,8 @@ struct trace_surface
struct pipe_surface base;
struct pipe_surface *surface;
+
+ struct tr_list list;
};
@@ -57,6 +61,8 @@ struct trace_transfer
struct pipe_transfer *transfer;
+ struct tr_list list;
+
void *map;
};