[Mesa-dev] [PATCH 3/6] r300: use the new parent/child pools for transfers

Nicolai Hähnle nhaehnle at gmail.com
Tue Sep 27 18:21:17 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/gallium/drivers/r300/r300_context.c       | 5 ++---
 src/gallium/drivers/r300/r300_context.h       | 2 +-
 src/gallium/drivers/r300/r300_screen.c        | 3 +++
 src/gallium/drivers/r300/r300_screen.h        | 2 ++
 src/gallium/drivers/r300/r300_screen_buffer.c | 4 ++--
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 3e5f1d6..b914cdb 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -93,21 +93,21 @@ static void r300_destroy_context(struct pipe_context* context)
     r300_release_referenced_objects(r300);
 
     if (r300->cs)
         r300->rws->cs_destroy(r300->cs);
     if (r300->ctx)
         r300->rws->ctx_destroy(r300->ctx);
 
     rc_destroy_regalloc_state(&r300->fs_regalloc_state);
 
     /* XXX: No way to tell if this was initialized or not? */
-    slab_destroy(&r300->pool_transfers);
+    slab_destroy_child(&r300->pool_transfers);
 
     /* Free the structs allocated in r300_setup_atoms() */
     if (r300->aa_state.state) {
         FREE(r300->aa_state.state);
         FREE(r300->blend_color_state.state);
         FREE(r300->clip_state.state);
         FREE(r300->fb_state.state);
         FREE(r300->gpu_flush.state);
         FREE(r300->hyperz_state.state);
         FREE(r300->invariant_state.state);
@@ -378,22 +378,21 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
         return NULL;
 
     r300->rws = rws;
     r300->screen = r300screen;
 
     r300->context.screen = screen;
     r300->context.priv = priv;
 
     r300->context.destroy = r300_destroy_context;
 
-    slab_create(&r300->pool_transfers,
-                     sizeof(struct pipe_transfer), 64);
+    slab_create_child(&r300->pool_transfers, &r300screen->pool_transfers);
 
     r300->ctx = rws->ctx_create(rws);
     if (!r300->ctx)
         goto fail;
 
     r300->cs = rws->cs_create(r300->ctx, RING_GFX, r300_flush_callback, r300);
     if (r300->cs == NULL)
         goto fail;
 
     if (!r300screen->caps.has_tcl) {
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 592479a..264ace5 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -589,21 +589,21 @@ struct r300_context {
     boolean alpha_to_one;
     boolean alpha_to_coverage;
 
     void *dsa_decompress_zmask;
 
     struct pipe_index_buffer index_buffer;
     struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
     unsigned nr_vertex_buffers;
     struct u_upload_mgr *uploader;
 
-    struct slab_mempool pool_transfers;
+    struct slab_child_pool pool_transfers;
 
     /* Stat counter. */
     uint64_t flush_counter;
 
     /* const tracking for VS */
     int vs_const_base;
 
     /* Vertex array state info */
     boolean vertex_arrays_dirty;
     boolean vertex_arrays_indexed;
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index f6949ce..4d41693 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -669,20 +669,21 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
 
 static void r300_destroy_screen(struct pipe_screen* pscreen)
 {
     struct r300_screen* r300screen = r300_screen(pscreen);
     struct radeon_winsys *rws = radeon_winsys(pscreen);
 
     if (rws && !rws->unref(rws))
       return;
 
     pipe_mutex_destroy(r300screen->cmask_mutex);
+    slab_destroy_parent(&r300screen->pool_transfers);
 
     if (rws)
       rws->destroy(rws);
 
     FREE(r300screen);
 }
 
 static void r300_fence_reference(struct pipe_screen *screen,
                                  struct pipe_fence_handle **ptr,
                                  struct pipe_fence_handle *fence)
@@ -731,15 +732,17 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws)
     r300screen->screen.get_paramf = r300_get_paramf;
     r300screen->screen.get_video_param = r300_get_video_param;
     r300screen->screen.is_format_supported = r300_is_format_supported;
     r300screen->screen.is_video_format_supported = vl_video_buffer_is_format_supported;
     r300screen->screen.context_create = r300_create_context;
     r300screen->screen.fence_reference = r300_fence_reference;
     r300screen->screen.fence_finish = r300_fence_finish;
 
     r300_init_screen_resource_functions(r300screen);
 
+    slab_create_parent(&r300screen->pool_transfers, sizeof(struct pipe_transfer), 64);
+
     util_format_s3tc_init();
     pipe_mutex_init(r300screen->cmask_mutex);
 
     return &r300screen->screen;
 }
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
index 5cd5a40..4b783af 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -37,20 +37,22 @@ struct r300_screen {
 
     struct radeon_winsys *rws;
 
     /* Chipset info and capabilities. */
     struct radeon_info info;
     struct r300_capabilities caps;
 
     /** Combination of DBG_xxx flags */
     unsigned debug;
 
+    struct slab_parent_pool pool_transfers;
+
     /* The MSAA texture with CMASK access; */
     struct pipe_resource *cmask_resource;
     pipe_mutex cmask_mutex;
 };
 
 
 /* Convenience cast wrappers. */
 static inline struct r300_screen* r300_screen(struct pipe_screen* screen) {
     return (struct r300_screen*)screen;
 }
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 4747058..4bf1634 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -70,21 +70,21 @@ r300_buffer_transfer_map( struct pipe_context *context,
                           unsigned usage,
                           const struct pipe_box *box,
                           struct pipe_transfer **ptransfer )
 {
     struct r300_context *r300 = r300_context(context);
     struct radeon_winsys *rws = r300->screen->rws;
     struct r300_resource *rbuf = r300_resource(resource);
     struct pipe_transfer *transfer;
     uint8_t *map;
 
-    transfer = slab_alloc_st(&r300->pool_transfers);
+    transfer = slab_alloc(&r300->pool_transfers);
     transfer->resource = resource;
     transfer->level = level;
     transfer->usage = usage;
     transfer->box = *box;
     transfer->stride = 0;
     transfer->layer_stride = 0;
 
     if (rbuf->malloced_buffer) {
         *ptransfer = transfer;
         return rbuf->malloced_buffer + box->x;
@@ -122,21 +122,21 @@ r300_buffer_transfer_map( struct pipe_context *context,
 
     /* Buffers are never used for write, therefore mapping for read can be
      * unsynchronized. */
     if (!(usage & PIPE_TRANSFER_WRITE)) {
        usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
     }
 
     map = rws->buffer_map(rbuf->buf, r300->cs, usage);
 
     if (!map) {
-        slab_free_st(&r300->pool_transfers, transfer);
+        slab_free(&r300->pool_transfers, transfer);
         return NULL;
     }
 
     *ptransfer = transfer;
     return map + box->x;
 }
 
 static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
                                         struct pipe_transfer *transfer )
 {
-- 
2.7.4



More information about the mesa-dev mailing list