radeonsi: 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>
Sun, 13 May 2012 12:32:57 +0000 (14:32 +0200)
src/gallium/drivers/radeonsi/r600_buffer.c
src/gallium/drivers/radeonsi/radeonsi_pipe.c
src/gallium/drivers/radeonsi/radeonsi_pipe.h

index 8fd7e2774317292b1198b7dc0bb6db1ec8518bf6..15bff912e13ca1cb1f3dbfc9c46be6390236e43e 100644 (file)
@@ -43,7 +43,7 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
        struct r600_resource *rbuffer = r600_resource(buf);
 
        pb_reference(&rbuffer->buf, NULL);
-       util_slab_free(&rscreen->pool_buffers, rbuffer);
+       FREE(rbuffer);
 }
 
 static struct pipe_transfer *r600_get_transfer(struct pipe_context *ctx,
@@ -164,7 +164,7 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
        /* XXX We probably want a different alignment for buffers and textures. */
        unsigned alignment = 4096;
 
-       rbuffer = util_slab_alloc(&rscreen->pool_buffers);
+       rbuffer = MALLOC_STRUCT(r600_resource);
 
        rbuffer->b.b = *templ;
        pipe_reference_init(&rbuffer->b.b.reference, 1);
@@ -172,7 +172,7 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
        rbuffer->b.vtbl = &r600_buffer_vtbl;
 
        if (!r600_init_resource(rscreen, rbuffer, templ->width0, alignment, templ->bind, templ->usage)) {
-               util_slab_free(&rscreen->pool_buffers, rbuffer);
+               FREE(rbuffer);
                return NULL;
        }
        return &rbuffer->b.b;
index aec5af277c5a45ae2fa07abcf5a3db52e9e7c488..5653048fe6d618dfa8284ff992ff8fe51a820998 100644 (file)
@@ -167,25 +167,6 @@ static void r600_flush_from_winsys(void *ctx, unsigned flags)
        radeonsi_flush((struct pipe_context*)ctx, NULL, flags);
 }
 
-static void r600_update_num_contexts(struct r600_screen *rscreen, int diff)
-{
-       pipe_mutex_lock(rscreen->mutex_num_contexts);
-       if (diff > 0) {
-               rscreen->num_contexts++;
-
-               if (rscreen->num_contexts > 1)
-                       util_slab_set_thread_safety(&rscreen->pool_buffers,
-                                                   UTIL_SLAB_MULTITHREADED);
-       } else {
-               rscreen->num_contexts--;
-
-               if (rscreen->num_contexts <= 1)
-                       util_slab_set_thread_safety(&rscreen->pool_buffers,
-                                                   UTIL_SLAB_SINGLETHREADED);
-       }
-       pipe_mutex_unlock(rscreen->mutex_num_contexts);
-}
-
 static void r600_destroy_context(struct pipe_context *context)
 {
        struct r600_context *rctx = (struct r600_context *)context;
@@ -205,9 +186,6 @@ static void r600_destroy_context(struct pipe_context *context)
                u_upload_destroy(rctx->uploader);
        }
        util_slab_destroy(&rctx->pool_transfers);
-
-       r600_update_num_contexts(rctx->screen, -1);
-
        FREE(rctx);
 }
 
@@ -219,8 +197,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
        if (rctx == NULL)
                return NULL;
 
-       r600_update_num_contexts(rscreen, 1);
-
        rctx->context.screen = screen;
        rctx->context.priv = priv;
        rctx->context.destroy = r600_destroy_context;
@@ -527,9 +503,6 @@ static void r600_destroy_screen(struct pipe_screen* pscreen)
        pipe_mutex_destroy(rscreen->fences.mutex);
 
        rscreen->ws->destroy(rscreen->ws);
-
-       util_slab_destroy(&rscreen->pool_buffers);
-       pipe_mutex_destroy(rscreen->mutex_num_contexts);
        FREE(rscreen);
 }
 
@@ -722,12 +695,6 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 
        util_format_s3tc_init();
 
-       util_slab_create(&rscreen->pool_buffers,
-                        sizeof(struct r600_resource), 64,
-                        UTIL_SLAB_SINGLETHREADED);
-
-       pipe_mutex_init(rscreen->mutex_num_contexts);
-
        rscreen->fences.bo = NULL;
        rscreen->fences.data = NULL;
        rscreen->fences.next_index = 0;
index b16ec1069c9eb26199ebac1a0f31b040ab8ae713..bcb5ec64d5cc6d1646bd855cd3c04817b6899cd1 100644 (file)
@@ -114,11 +114,6 @@ struct r600_screen {
        struct r600_tiling_info         tiling_info;
        struct util_slab_mempool        pool_buffers;
        struct r600_pipe_fences         fences;
-
-       unsigned                        num_contexts;
-
-       /* for thread-safe write accessing to num_contexts */
-       pipe_mutex                      mutex_num_contexts;
 };
 
 struct si_pipe_sampler_view {