summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300/r300_context.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-07-19 14:31:25 +0200
committerMarek Olšák <[email protected]>2010-07-19 17:12:11 +0200
commit7b31b235d069ab4154bfc4b1eacde6368852aaee (patch)
treefce58f29a6ab87184c2518349568a8eacb171e74 /src/gallium/drivers/r300/r300_context.c
parentad44b775e30b2740d25bb8330c9e8879f1ec5533 (diff)
r300g: use memory pools for buffer_create and get_transfer
The improvement in Tremulous: 68.9 fps -> 71.1 fps.
Diffstat (limited to 'src/gallium/drivers/r300/r300_context.c')
-rw-r--r--src/gallium/drivers/r300/r300_context.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 0f7deca2826..0c06d41f4a4 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -36,6 +36,24 @@
#include <inttypes.h>
+static void r300_update_num_contexts(struct r300_screen *r300screen,
+ int diff)
+{
+ if (diff > 0) {
+ p_atomic_dec(&r300screen->num_contexts);
+
+ if (r300screen->num_contexts > 1)
+ util_mempool_set_thread_safety(&r300screen->pool_buffers,
+ UTIL_MEMPOOL_MULTITHREADED);
+ } else {
+ p_atomic_dec(&r300screen->num_contexts);
+
+ if (r300screen->num_contexts <= 1)
+ util_mempool_set_thread_safety(&r300screen->pool_buffers,
+ UTIL_MEMPOOL_SINGLETHREADED);
+ }
+}
+
static void r300_release_referenced_objects(struct r300_context *r300)
{
struct pipe_framebuffer_state *fb =
@@ -102,6 +120,8 @@ static void r300_destroy_context(struct pipe_context* context)
r300->rws->cs_destroy(r300->cs);
+ util_mempool_destroy(&r300->pool_transfers);
+
FREE(r300->aa_state.state);
FREE(r300->blend_color_state.state);
FREE(r300->clip_state.state);
@@ -121,6 +141,8 @@ static void r300_destroy_context(struct pipe_context* context)
FREE(r300->vertex_stream_state.state);
}
FREE(r300);
+
+ r300_update_num_contexts(r300->screen, -1);
}
void r300_flush_cb(void *data)
@@ -347,6 +369,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
if (!r300)
return NULL;
+ r300_update_num_contexts(r300screen, 1);
+
r300->rws = rws;
r300->screen = r300screen;
@@ -358,6 +382,10 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300->cs = rws->cs_create(rws);
+ util_mempool_create(&r300->pool_transfers,
+ sizeof(struct pipe_transfer), 64,
+ UTIL_MEMPOOL_SINGLETHREADED);
+
if (!r300screen->caps.has_tcl) {
/* Create a Draw. This is used for SW TCL. */
r300->draw = draw_create(&r300->context);