r300g: remove slab allocator for pipe_resource (used mainly for user buffers)
authorMarek Olšák <maraeo@gmail.com>
Fri, 11 May 2012 20:56:08 +0000 (22:56 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 11 May 2012 22:50:52 +0000 (00:50 +0200)
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_screen.h
src/gallium/drivers/r300/r300_screen_buffer.c

index e1330a42a1d59b7034cc6ce67e6f27bc2cc05f3d..1006336d44e0c0eb911c10271bf3769bbe2f6418 100644 (file)
 #include "r300_screen.h"
 #include "r300_screen_buffer.h"
 
-static void r300_update_num_contexts(struct r300_screen *r300screen,
-                                     int diff)
-{
-    pipe_mutex_lock(r300screen->num_contexts_mutex);
-    if (diff > 0) {
-        r300screen->num_contexts++;
-
-        if (r300screen->num_contexts > 1)
-            util_slab_set_thread_safety(&r300screen->pool_buffers,
-                                        UTIL_SLAB_MULTITHREADED);
-    } else {
-        r300screen->num_contexts--;
-
-        if (r300screen->num_contexts <= 1)
-            util_slab_set_thread_safety(&r300screen->pool_buffers,
-                                        UTIL_SLAB_SINGLETHREADED);
-    }
-    pipe_mutex_unlock(r300screen->num_contexts_mutex);
-}
-
 static void r300_release_referenced_objects(struct r300_context *r300)
 {
     struct pipe_framebuffer_state *fb =
@@ -111,8 +91,6 @@ static void r300_destroy_context(struct pipe_context* context)
     /* XXX: No way to tell if this was initialized or not? */
     util_slab_destroy(&r300->pool_transfers);
 
-    r300_update_num_contexts(r300->screen, -1);
-
     /* Free the structs allocated in r300_setup_atoms() */
     if (r300->aa_state.state) {
         FREE(r300->aa_state.state);
@@ -379,8 +357,6 @@ 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;
 
index 1e7f9276b73dfd35ff6bf016b987375e5ebcf17e..82bde2a39c1dd832bf2f53115868aa56374241f4 100644 (file)
@@ -458,9 +458,6 @@ static void r300_destroy_screen(struct pipe_screen* pscreen)
     struct r300_screen* r300screen = r300_screen(pscreen);
     struct radeon_winsys *rws = radeon_winsys(pscreen);
 
-    util_slab_destroy(&r300screen->pool_buffers);
-    pipe_mutex_destroy(r300screen->num_contexts_mutex);
-
     if (rws)
       rws->destroy(rws);
 
@@ -533,12 +530,6 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws)
     if (r300screen->info.drm_minor < 8)
         r300screen->caps.has_us_format = FALSE;
 
-    pipe_mutex_init(r300screen->num_contexts_mutex);
-
-    util_slab_create(&r300screen->pool_buffers,
-                     sizeof(struct r300_resource), 64,
-                     UTIL_SLAB_SINGLETHREADED);
-
     r300screen->rws = rws;
     r300screen->screen.destroy = r300_destroy_screen;
     r300screen->screen.get_name = r300_get_name;
index 82b2068e7a08ea5b62d8498a4a22d5167dda5528..86bb09cee0112cfc010082e0e01ef870738332cc 100644 (file)
@@ -40,16 +40,8 @@ struct r300_screen {
     struct radeon_info info;
     struct r300_capabilities caps;
 
-    /* Memory pools. */
-    struct util_slab_mempool pool_buffers;
-
     /** Combination of DBG_xxx flags */
     unsigned debug;
-
-    /* The number of created contexts to know whether we have multiple
-     * contexts or not. */
-    int num_contexts;
-    pipe_mutex num_contexts_mutex;
 };
 
 
index 0c3f8702c4a74d9751f222d25a9ebbe2e09380ea..9ab2acd671fe0cf15dfbf73cc4cea206908587de 100644 (file)
@@ -53,7 +53,6 @@ void r300_upload_index_buffer(struct r300_context *r300,
 static void r300_buffer_destroy(struct pipe_screen *screen,
                                struct pipe_resource *buf)
 {
-    struct r300_screen *r300screen = r300_screen(screen);
     struct r300_resource *rbuf = r300_resource(buf);
 
     if (rbuf->constant_buffer)
@@ -62,7 +61,7 @@ static void r300_buffer_destroy(struct pipe_screen *screen,
     if (rbuf->buf)
         pb_reference(&rbuf->buf, NULL);
 
-    util_slab_free(&r300screen->pool_buffers, rbuf);
+    FREE(rbuf);
 }
 
 static struct pipe_transfer*
@@ -151,7 +150,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
     struct r300_resource *rbuf;
     unsigned alignment = 16;
 
-    rbuf = util_slab_alloc(&r300screen->pool_buffers);
+    rbuf = MALLOC_STRUCT(r300_resource);
 
     rbuf->b.b = *templ;
     rbuf->b.vtbl = &r300_buffer_vtbl;
@@ -172,7 +171,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
                                        rbuf->b.b.width0, alignment,
                                        rbuf->b.b.bind, rbuf->domain);
     if (!rbuf->buf) {
-        util_slab_free(&r300screen->pool_buffers, rbuf);
+        FREE(rbuf);
         return NULL;
     }