diff options
author | Marek Olšák <[email protected]> | 2016-08-28 11:05:14 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-09-06 14:24:04 +0200 |
commit | e7a73b75a0dbd599187b8980b2e1e1cb5dfdaf6d (patch) | |
tree | 4be0121e5c819988b8dbba24eebf8e6c8cdf1e55 | |
parent | 761ff403024e31aacb345efaa527377894724fad (diff) |
gallium: switch drivers to the slab allocator in src/util
30 files changed, 82 insertions, 353 deletions
diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index 093c45b48fe..f8954c90407 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -284,8 +284,6 @@ C_SOURCES := \ util/u_sampler.h \ util/u_simple_shaders.c \ util/u_simple_shaders.h \ - util/u_slab.c \ - util/u_slab.h \ util/u_split_prim.h \ util/u_sse.h \ util/u_string.h \ diff --git a/src/gallium/auxiliary/util/u_slab.c b/src/gallium/auxiliary/util/u_slab.c deleted file mode 100644 index 7e7d43bd830..00000000000 --- a/src/gallium/auxiliary/util/u_slab.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2010 Marek Olšák <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "util/u_slab.h" - -#include "util/u_math.h" -#include "util/u_memory.h" -#include "util/simple_list.h" - -#include <stdio.h> - -#define UTIL_SLAB_MAGIC 0xcafe4321 - -/* The block is either allocated memory or free space. */ -struct util_slab_block { - /* The header. */ - /* The first next free block. */ - struct util_slab_block *next_free; - - intptr_t magic; - - /* Memory after the last member is dedicated to the block itself. - * The allocated size is always larger than this structure. */ -}; - -static struct util_slab_block * -util_slab_get_block(struct util_slab_mempool *pool, - struct util_slab_page *page, unsigned index) -{ - return (struct util_slab_block*) - ((uint8_t*)page + sizeof(struct util_slab_page) + - (pool->block_size * index)); -} - -static void util_slab_add_new_page(struct util_slab_mempool *pool) -{ - struct util_slab_page *page; - struct util_slab_block *block; - unsigned i; - - page = MALLOC(pool->page_size); - insert_at_tail(&pool->list, page); - - /* Mark all blocks as free. */ - for (i = 0; i < pool->num_blocks-1; i++) { - block = util_slab_get_block(pool, page, i); - block->next_free = util_slab_get_block(pool, page, i+1); - block->magic = UTIL_SLAB_MAGIC; - } - - block = util_slab_get_block(pool, page, pool->num_blocks-1); - block->next_free = pool->first_free; - block->magic = UTIL_SLAB_MAGIC; - pool->first_free = util_slab_get_block(pool, page, 0); - pool->num_pages++; - -#if 0 - fprintf(stderr, "New page! Num of pages: %i\n", pool->num_pages); -#endif -} - -static void *util_slab_alloc_st(struct util_slab_mempool *pool) -{ - struct util_slab_block *block; - - if (!pool->first_free) - util_slab_add_new_page(pool); - - block = pool->first_free; - assert(block->magic == UTIL_SLAB_MAGIC); - pool->first_free = block->next_free; - - return (uint8_t*)block + sizeof(struct util_slab_block); -} - -static void util_slab_free_st(struct util_slab_mempool *pool, void *ptr) -{ - struct util_slab_block *block = - (struct util_slab_block*) - ((uint8_t*)ptr - sizeof(struct util_slab_block)); - - assert(block->magic == UTIL_SLAB_MAGIC); - block->next_free = pool->first_free; - pool->first_free = block; -} - -static void *util_slab_alloc_mt(struct util_slab_mempool *pool) -{ - void *mem; - - pipe_mutex_lock(pool->mutex); - mem = util_slab_alloc_st(pool); - pipe_mutex_unlock(pool->mutex); - return mem; -} - -static void util_slab_free_mt(struct util_slab_mempool *pool, void *ptr) -{ - pipe_mutex_lock(pool->mutex); - util_slab_free_st(pool, ptr); - pipe_mutex_unlock(pool->mutex); -} - -void util_slab_set_thread_safety(struct util_slab_mempool *pool, - enum util_slab_threading threading) -{ - pool->threading = threading; - - if (threading) { - pool->alloc = util_slab_alloc_mt; - pool->free = util_slab_free_mt; - } else { - pool->alloc = util_slab_alloc_st; - pool->free = util_slab_free_st; - } -} - -void util_slab_create(struct util_slab_mempool *pool, - unsigned item_size, - unsigned num_blocks, - enum util_slab_threading threading) -{ - item_size = align(item_size, sizeof(intptr_t)); - - pool->num_pages = 0; - pool->num_blocks = num_blocks; - pool->block_size = sizeof(struct util_slab_block) + item_size; - pool->block_size = align(pool->block_size, sizeof(intptr_t)); - pool->page_size = sizeof(struct util_slab_page) + - num_blocks * pool->block_size; - pool->first_free = NULL; - - make_empty_list(&pool->list); - - pipe_mutex_init(pool->mutex); - - util_slab_set_thread_safety(pool, threading); -} - -void util_slab_destroy(struct util_slab_mempool *pool) -{ - struct util_slab_page *page, *temp; - - if (pool->list.next) { - foreach_s(page, temp, &pool->list) { - remove_from_list(page); - FREE(page); - } - } - - pipe_mutex_destroy(pool->mutex); -} diff --git a/src/gallium/auxiliary/util/u_slab.h b/src/gallium/auxiliary/util/u_slab.h deleted file mode 100644 index 0df039bcd57..00000000000 --- a/src/gallium/auxiliary/util/u_slab.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2010 Marek Olšák <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, and/or sell copies of the Software, and to permit persons to whom - * the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/** - * @file - * Simple slab allocator for equally sized memory allocations. - * util_slab_alloc and util_slab_free have time complexity in O(1). - * - * Good for allocations which have very low lifetime and are allocated - * and freed very often. Use a profiler first to know if it's worth using it! - * - * Candidates: transfer_map - * - * @author Marek Olšák - */ - -#ifndef U_SLAB_H -#define U_SLAB_H - -#include "os/os_thread.h" - -enum util_slab_threading { - UTIL_SLAB_SINGLETHREADED = FALSE, - UTIL_SLAB_MULTITHREADED = TRUE -}; - -/* The page is an array of blocks (allocations). */ -struct util_slab_page { - /* The header (linked-list pointers). */ - struct util_slab_page *prev, *next; - - /* Memory after the last member is dedicated to the page itself. - * The allocated size is always larger than this structure. */ -}; - -struct util_slab_mempool { - /* Public members. */ - void *(*alloc)(struct util_slab_mempool *pool); - void (*free)(struct util_slab_mempool *pool, void *ptr); - - /* Private members. */ - struct util_slab_block *first_free; - - struct util_slab_page list; - - unsigned block_size; - unsigned page_size; - unsigned num_blocks; - unsigned num_pages; - enum util_slab_threading threading; - - pipe_mutex mutex; -}; - -void util_slab_create(struct util_slab_mempool *pool, - unsigned item_size, - unsigned num_blocks, - enum util_slab_threading threading); - -void util_slab_destroy(struct util_slab_mempool *pool); - -void util_slab_set_thread_safety(struct util_slab_mempool *pool, - enum util_slab_threading threading); - -static inline void * -util_slab_alloc(struct util_slab_mempool *pool) -{ - return pool->alloc(pool); -} - -static inline void -util_slab_free(struct util_slab_mempool *pool, void *ptr) -{ - pool->free(pool, ptr); -} - -#endif diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index ad62fd605dd..f8604f132ad 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -121,7 +121,7 @@ fd_context_destroy(struct pipe_context *pctx) if (ctx->primconvert) util_primconvert_destroy(ctx->primconvert); - util_slab_destroy(&ctx->transfer_pool); + slab_destroy(&ctx->transfer_pool); for (i = 0; i < ARRAY_SIZE(ctx->pipe); i++) { struct fd_vsc_pipe *pipe = &ctx->pipe[i]; @@ -265,8 +265,8 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen, ctx->batch = fd_bc_alloc_batch(&screen->batch_cache, ctx); } - util_slab_create(&ctx->transfer_pool, sizeof(struct fd_transfer), - 16, UTIL_SLAB_SINGLETHREADED); + slab_create(&ctx->transfer_pool, sizeof(struct fd_transfer), + 16); fd_draw_init(pctx); fd_resource_context_init(pctx); diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index 037c199c245..e1b7b237ad3 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -33,7 +33,7 @@ #include "indices/u_primconvert.h" #include "util/u_blitter.h" #include "util/list.h" -#include "util/u_slab.h" +#include "util/slab.h" #include "util/u_string.h" #include "freedreno_batch.h" @@ -121,11 +121,11 @@ struct fd_context { struct primconvert_context *primconvert; /* slab for pipe_transfer allocations: */ - struct util_slab_mempool transfer_pool; + struct slab_mempool transfer_pool; /* slabs for fd_hw_sample and fd_hw_sample_period allocations: */ - struct util_slab_mempool sample_pool; - struct util_slab_mempool sample_period_pool; + struct slab_mempool sample_pool; + struct slab_mempool sample_period_pool; /* sample-providers for hw queries: */ const struct fd_hw_sample_provider *sample_providers[MAX_HW_SAMPLE_PROVIDERS]; diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c index e5ef51a0b98..470826a94c8 100644 --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c @@ -108,10 +108,10 @@ resume_query(struct fd_batch *batch, struct fd_hw_query *hq, assert(idx >= 0); /* query never would have been created otherwise */ assert(!hq->period); batch->active_providers |= (1 << idx); - hq->period = util_slab_alloc(&batch->ctx->sample_period_pool); + hq->period = slab_alloc_st(&batch->ctx->sample_period_pool); list_inithead(&hq->period->list); hq->period->start = get_sample(batch, ring, hq->base.type); - /* NOTE: util_slab_alloc() does not zero out the buffer: */ + /* NOTE: slab_alloc_st() does not zero out the buffer: */ hq->period->end = NULL; } @@ -137,7 +137,7 @@ destroy_periods(struct fd_context *ctx, struct fd_hw_query *hq) fd_hw_sample_reference(ctx, &period->start, NULL); fd_hw_sample_reference(ctx, &period->end, NULL); list_del(&period->list); - util_slab_free(&ctx->sample_period_pool, period); + slab_free_st(&ctx->sample_period_pool, period); } } @@ -339,13 +339,13 @@ fd_hw_create_query(struct fd_context *ctx, unsigned query_type) struct fd_hw_sample * fd_hw_sample_init(struct fd_batch *batch, uint32_t size) { - struct fd_hw_sample *samp = util_slab_alloc(&batch->ctx->sample_pool); + struct fd_hw_sample *samp = slab_alloc_st(&batch->ctx->sample_pool); pipe_reference_init(&samp->reference, 1); samp->size = size; debug_assert(util_is_power_of_two(size)); batch->next_sample_offset = align(batch->next_sample_offset, size); samp->offset = batch->next_sample_offset; - /* NOTE: util_slab_alloc() does not zero out the buffer: */ + /* NOTE: slab_alloc_st() does not zero out the buffer: */ samp->prsc = NULL; samp->num_tiles = 0; samp->tile_stride = 0; @@ -376,7 +376,7 @@ void __fd_hw_sample_destroy(struct fd_context *ctx, struct fd_hw_sample *samp) { pipe_resource_reference(&samp->prsc, NULL); - util_slab_free(&ctx->sample_pool, samp); + slab_free_st(&ctx->sample_pool, samp); } /* called from gmem code once total storage requirements are known (ie. @@ -486,10 +486,10 @@ fd_hw_query_init(struct pipe_context *pctx) { struct fd_context *ctx = fd_context(pctx); - util_slab_create(&ctx->sample_pool, sizeof(struct fd_hw_sample), - 16, UTIL_SLAB_SINGLETHREADED); - util_slab_create(&ctx->sample_period_pool, sizeof(struct fd_hw_sample_period), - 16, UTIL_SLAB_SINGLETHREADED); + slab_create(&ctx->sample_pool, sizeof(struct fd_hw_sample), + 16); + slab_create(&ctx->sample_period_pool, sizeof(struct fd_hw_sample_period), + 16); list_inithead(&ctx->active_queries); } @@ -498,6 +498,6 @@ fd_hw_query_fini(struct pipe_context *pctx) { struct fd_context *ctx = fd_context(pctx); - util_slab_destroy(&ctx->sample_pool); - util_slab_destroy(&ctx->sample_period_pool); + slab_destroy(&ctx->sample_pool); + slab_destroy(&ctx->sample_period_pool); } diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 2a4fd7442c8..3cc6654b740 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -425,7 +425,7 @@ fd_resource_transfer_unmap(struct pipe_context *pctx, ptrans->box.x + ptrans->box.width); pipe_resource_reference(&ptrans->resource, NULL); - util_slab_free(&ctx->transfer_pool, ptrans); + slab_free_st(&ctx->transfer_pool, ptrans); free(trans->staging); } @@ -451,11 +451,11 @@ fd_resource_transfer_map(struct pipe_context *pctx, DBG("prsc=%p, level=%u, usage=%x, box=%dx%d+%d,%d", prsc, level, usage, box->width, box->height, box->x, box->y); - ptrans = util_slab_alloc(&ctx->transfer_pool); + ptrans = slab_alloc_st(&ctx->transfer_pool); if (!ptrans) return NULL; - /* util_slab_alloc() doesn't zero: */ + /* slab_alloc_st() doesn't zero: */ trans = fd_transfer(ptrans); memset(trans, 0, sizeof(*trans)); diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 82798bbb543..f3324dbc229 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -177,10 +177,10 @@ i915_create_context(struct pipe_screen *screen, void *priv, unsigned flags) i915->base.draw_vbo = i915_draw_vbo; /* init this before draw */ - util_slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer), - 16, UTIL_SLAB_SINGLETHREADED); - util_slab_create(&i915->texture_transfer_pool, sizeof(struct i915_transfer), - 16, UTIL_SLAB_SINGLETHREADED); + slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer), + 16); + slab_create(&i915->texture_transfer_pool, sizeof(struct i915_transfer), + 16); /* Batch stream debugging is a bit hacked up at the moment: */ diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 2adaee30fb9..ea13834c15a 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -37,7 +37,7 @@ #include "tgsi/tgsi_scan.h" -#include "util/u_slab.h" +#include "util/slab.h" #include "util/u_blitter.h" @@ -278,8 +278,8 @@ struct i915_context { struct i915_winsys_buffer *validation_buffers[2 + 1 + I915_TEX_UNITS]; int num_validation_buffers; - struct util_slab_mempool transfer_pool; - struct util_slab_mempool texture_transfer_pool; + struct slab_mempool transfer_pool; + struct slab_mempool texture_transfer_pool; /* state for tracking flushes */ int last_fired_vertices; diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c index 24c954cae34..2572fc40b2c 100644 --- a/src/gallium/drivers/i915/i915_resource_buffer.c +++ b/src/gallium/drivers/i915/i915_resource_buffer.c @@ -70,7 +70,7 @@ i915_buffer_transfer_map(struct pipe_context *pipe, { struct i915_context *i915 = i915_context(pipe); struct i915_buffer *buffer = i915_buffer(resource); - struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool); + struct pipe_transfer *transfer = slab_alloc_st(&i915->transfer_pool); if (!transfer) return NULL; @@ -89,7 +89,7 @@ i915_buffer_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *transfer) { struct i915_context *i915 = i915_context(pipe); - util_slab_free(&i915->transfer_pool, transfer); + slab_free_st(&i915->transfer_pool, transfer); } void diff --git a/src/gallium/drivers/i915/i915_resource_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c index f77bbfde181..4ade04f223c 100644 --- a/src/gallium/drivers/i915/i915_resource_texture.c +++ b/src/gallium/drivers/i915/i915_resource_texture.c @@ -721,7 +721,7 @@ i915_texture_transfer_map(struct pipe_context *pipe, { struct i915_context *i915 = i915_context(pipe); struct i915_texture *tex = i915_texture(resource); - struct i915_transfer *transfer = util_slab_alloc(&i915->texture_transfer_pool); + struct i915_transfer *transfer = slab_alloc_st(&i915->texture_transfer_pool); boolean use_staging_texture = FALSE; struct i915_winsys *iws = i915_screen(pipe->screen)->iws; enum pipe_format format = resource->format; @@ -814,7 +814,7 @@ i915_texture_transfer_unmap(struct pipe_context *pipe, pipe_resource_reference(&itransfer->staging_texture, NULL); } - util_slab_free(&i915->texture_transfer_pool, itransfer); + slab_free_st(&i915->texture_transfer_pool, itransfer); } #if 0 diff --git a/src/gallium/drivers/ilo/ilo_context.c b/src/gallium/drivers/ilo/ilo_context.c index 6bcd0bcb8f5..ad9120290af 100644 --- a/src/gallium/drivers/ilo/ilo_context.c +++ b/src/gallium/drivers/ilo/ilo_context.c @@ -129,7 +129,7 @@ ilo_context_destroy(struct pipe_context *pipe) if (ilo->cp) ilo_cp_destroy(ilo->cp); - util_slab_destroy(&ilo->transfer_mempool); + slab_destroy(&ilo->transfer_mempool); FREE(ilo); } @@ -151,8 +151,8 @@ ilo_context_create(struct pipe_screen *screen, void *priv, unsigned flags) * initialize first, otherwise it may not be safe to call * ilo_context_destroy() on errors */ - util_slab_create(&ilo->transfer_mempool, - sizeof(struct ilo_transfer), 64, UTIL_SLAB_SINGLETHREADED); + slab_create(&ilo->transfer_mempool, + sizeof(struct ilo_transfer), 64); ilo->shader_cache = ilo_shader_cache_create(); ilo->cp = ilo_cp_create(ilo->dev, ilo->winsys, ilo->shader_cache); diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h index 1610358ecd3..25d338ade18 100644 --- a/src/gallium/drivers/ilo/ilo_context.h +++ b/src/gallium/drivers/ilo/ilo_context.h @@ -29,7 +29,7 @@ #define ILO_CONTEXT_H #include "pipe/p_context.h" -#include "util/u_slab.h" +#include "util/slab.h" #include "ilo_common.h" #include "ilo_cp.h" @@ -50,7 +50,7 @@ struct ilo_context { struct intel_winsys *winsys; struct ilo_dev *dev; - struct util_slab_mempool transfer_mempool; + struct slab_mempool transfer_mempool; struct ilo_cp *cp; diff --git a/src/gallium/drivers/ilo/ilo_transfer.c b/src/gallium/drivers/ilo/ilo_transfer.c index d243e38fbe2..87607ebe80d 100644 --- a/src/gallium/drivers/ilo/ilo_transfer.c +++ b/src/gallium/drivers/ilo/ilo_transfer.c @@ -1184,7 +1184,7 @@ ilo_transfer_unmap(struct pipe_context *pipe, pipe_resource_reference(&xfer->base.resource, NULL); - util_slab_free(&ilo->transfer_mempool, xfer); + slab_free_st(&ilo->transfer_mempool, xfer); } static void * @@ -1200,7 +1200,7 @@ ilo_transfer_map(struct pipe_context *pipe, void *ptr; /* note that xfer is not zero'd */ - xfer = util_slab_alloc(&ilo->transfer_mempool); + xfer = slab_alloc_st(&ilo->transfer_mempool); if (!xfer) { *transfer = NULL; return NULL; @@ -1226,7 +1226,7 @@ ilo_transfer_map(struct pipe_context *pipe, if (!ptr) { pipe_resource_reference(&xfer->base.resource, NULL); - util_slab_free(&ilo->transfer_mempool, xfer); + slab_free_st(&ilo->transfer_mempool, xfer); *transfer = NULL; return NULL; } diff --git a/src/gallium/drivers/ilo/shader/toy_compiler.c b/src/gallium/drivers/ilo/shader/toy_compiler.c index 99f1ad1505f..4651c836b90 100644 --- a/src/gallium/drivers/ilo/shader/toy_compiler.c +++ b/src/gallium/drivers/ilo/shader/toy_compiler.c @@ -491,9 +491,9 @@ toy_compiler_cleanup(struct toy_compiler *tc) struct toy_inst *inst, *next; LIST_FOR_EACH_ENTRY_SAFE(inst, next, &tc->instructions, list) - util_slab_free(&tc->mempool, inst); + slab_free_st(&tc->mempool, inst); - util_slab_destroy(&tc->mempool); + slab_destroy(&tc->mempool); } /** @@ -543,8 +543,8 @@ toy_compiler_init(struct toy_compiler *tc, const struct ilo_dev *dev) tc_init_inst_templ(tc); - util_slab_create(&tc->mempool, sizeof(struct toy_inst), - 64, UTIL_SLAB_SINGLETHREADED); + slab_create(&tc->mempool, sizeof(struct toy_inst), + 64); list_inithead(&tc->instructions); /* instructions are added to the tail */ diff --git a/src/gallium/drivers/ilo/shader/toy_compiler.h b/src/gallium/drivers/ilo/shader/toy_compiler.h index d9b56174baf..71f9deaa726 100644 --- a/src/gallium/drivers/ilo/shader/toy_compiler.h +++ b/src/gallium/drivers/ilo/shader/toy_compiler.h @@ -29,7 +29,7 @@ #define TOY_COMPILER_H #include "genhw/genhw.h" -#include "util/u_slab.h" +#include "util/slab.h" #include "ilo_common.h" #include "toy_compiler_reg.h" @@ -153,7 +153,7 @@ struct toy_compiler { const struct ilo_dev *dev; struct toy_inst templ; - struct util_slab_mempool mempool; + struct slab_mempool mempool; struct list_head instructions; struct list_head *iter, *iter_next; @@ -209,7 +209,7 @@ tc_duplicate_inst(struct toy_compiler *tc, const struct toy_inst *inst) { struct toy_inst *new_inst; - new_inst = util_slab_alloc(&tc->mempool); + new_inst = slab_alloc_st(&tc->mempool); if (!new_inst) return NULL; @@ -236,7 +236,7 @@ static inline void tc_discard_inst(struct toy_compiler *tc, struct toy_inst *inst) { list_del(&inst->list); - util_slab_free(&tc->mempool, inst); + slab_free_st(&tc->mempool, inst); } /** diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index d100a9df55b..24d07f0b865 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -100,7 +100,7 @@ static void r300_destroy_context(struct pipe_context* context) rc_destroy_regalloc_state(&r300->fs_regalloc_state); /* XXX: No way to tell if this was initialized or not? */ - util_slab_destroy(&r300->pool_transfers); + slab_destroy(&r300->pool_transfers); /* Free the structs allocated in r300_setup_atoms() */ if (r300->aa_state.state) { @@ -377,9 +377,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.destroy = r300_destroy_context; - util_slab_create(&r300->pool_transfers, - sizeof(struct pipe_transfer), 64, - UTIL_SLAB_SINGLETHREADED); + slab_create(&r300->pool_transfers, + sizeof(struct pipe_transfer), 64); r300->ctx = rws->ctx_create(rws); if (!r300->ctx) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index a4783f396e1..592479a05a9 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -596,7 +596,7 @@ struct r300_context { unsigned nr_vertex_buffers; struct u_upload_mgr *uploader; - struct util_slab_mempool pool_transfers; + struct slab_mempool pool_transfers; /* Stat counter. */ uint64_t flush_counter; diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index e15c3c7de0c..5cd5a4005c3 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -27,7 +27,7 @@ #include "r300_chipset.h" #include "radeon/radeon_winsys.h" #include "pipe/p_screen.h" -#include "util/u_slab.h" +#include "util/slab.h" #include "os/os_thread.h" #include <stdio.h> diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c index 069e9fdc6b0..4747058286e 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.c +++ b/src/gallium/drivers/r300/r300_screen_buffer.c @@ -77,7 +77,7 @@ r300_buffer_transfer_map( struct pipe_context *context, struct pipe_transfer *transfer; uint8_t *map; - transfer = util_slab_alloc(&r300->pool_transfers); + transfer = slab_alloc_st(&r300->pool_transfers); transfer->resource = resource; transfer->level = level; transfer->usage = usage; @@ -129,7 +129,7 @@ r300_buffer_transfer_map( struct pipe_context *context, map = rws->buffer_map(rbuf->buf, r300->cs, usage); if (!map) { - util_slab_free(&r300->pool_transfers, transfer); + slab_free_st(&r300->pool_transfers, transfer); return NULL; } @@ -142,7 +142,7 @@ static void r300_buffer_transfer_unmap( struct pipe_context *pipe, { struct r300_context *r300 = r300_context(pipe); - util_slab_free(&r300->pool_transfers, transfer); + slab_free_st(&r300->pool_transfers, transfer); } static const struct u_resource_vtbl r300_buffer_vtbl = diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c index 6a55de1fe29..a600793e3e6 100644 --- a/src/gallium/drivers/radeon/r600_buffer_common.c +++ b/src/gallium/drivers/radeon/r600_buffer_common.c @@ -283,7 +283,7 @@ static void *r600_buffer_get_transfer(struct pipe_context *ctx, unsigned offset) { struct r600_common_context *rctx = (struct r600_common_context*)ctx; - struct r600_transfer *transfer = util_slab_alloc(&rctx->pool_transfers); + struct r600_transfer *transfer = slab_alloc_st(&rctx->pool_transfers); transfer->transfer.resource = resource; transfer->transfer.level = level; @@ -468,7 +468,7 @@ static void r600_buffer_transfer_unmap(struct pipe_context *ctx, if (rtransfer->staging) r600_resource_reference(&rtransfer->staging, NULL); - util_slab_free(&rctx->pool_transfers, transfer); + slab_free_st(&rctx->pool_transfers, transfer); } void r600_buffer_subdata(struct pipe_context *ctx, diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index 825e4e98658..6d7cc1b5d3c 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -431,9 +431,8 @@ bool r600_common_context_init(struct r600_common_context *rctx, struct r600_common_screen *rscreen, unsigned context_flags) { - util_slab_create(&rctx->pool_transfers, - sizeof(struct r600_transfer), 64, - UTIL_SLAB_SINGLETHREADED); + slab_create(&rctx->pool_transfers, + sizeof(struct r600_transfer), 64); rctx->screen = rscreen; rctx->ws = rscreen->ws; @@ -533,7 +532,7 @@ void r600_common_context_cleanup(struct r600_common_context *rctx) u_upload_destroy(rctx->uploader); } - util_slab_destroy(&rctx->pool_transfers); + slab_destroy(&rctx->pool_transfers); if (rctx->allocator_zeroed_memory) { u_suballocator_destroy(rctx->allocator_zeroed_memory); diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index aa40a54f43d..d9f22e49889 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -39,7 +39,7 @@ #include "util/u_blitter.h" #include "util/list.h" #include "util/u_range.h" -#include "util/u_slab.h" +#include "util/slab.h" #include "util/u_suballoc.h" #include "util/u_transfer.h" @@ -527,7 +527,7 @@ struct r600_common_context { struct u_upload_mgr *uploader; struct u_suballocator *allocator_zeroed_memory; - struct util_slab_mempool pool_transfers; + struct slab_mempool pool_transfers; /* Current unaccounted memory usage. */ uint64_t vram; diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c index eeadea0b1db..a85554a43dd 100644 --- a/src/gallium/drivers/vc4/vc4_context.c +++ b/src/gallium/drivers/vc4/vc4_context.c @@ -200,7 +200,7 @@ vc4_context_destroy(struct pipe_context *pctx) if (vc4->uploader) u_upload_destroy(vc4->uploader); - util_slab_destroy(&vc4->transfer_pool); + slab_destroy(&vc4->transfer_pool); pipe_surface_reference(&vc4->framebuffer.cbufs[0], NULL); pipe_surface_reference(&vc4->framebuffer.zsbuf, NULL); @@ -246,8 +246,8 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) vc4->fd = screen->fd; - util_slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer), - 16, UTIL_SLAB_SINGLETHREADED); + slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer), + 16); vc4->blitter = util_blitter_create(pctx); if (!vc4->blitter) goto fail; diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h index 63a1dfbb15a..ce2c6d4e68e 100644 --- a/src/gallium/drivers/vc4/vc4_context.h +++ b/src/gallium/drivers/vc4/vc4_context.h @@ -29,7 +29,7 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" -#include "util/u_slab.h" +#include "util/slab.h" #define __user #include "vc4_drm.h" @@ -238,7 +238,7 @@ struct vc4_context { bool msaa; /** @} */ - struct util_slab_mempool transfer_pool; + struct slab_mempool transfer_pool; struct blitter_context *blitter; /** bitfield of VC4_DIRTY_* */ diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index 398aa8181df..0d4bb6477d6 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -121,7 +121,7 @@ vc4_resource_transfer_unmap(struct pipe_context *pctx, } pipe_resource_reference(&ptrans->resource, NULL); - util_slab_free(&vc4->transfer_pool, ptrans); + slab_free_st(&vc4->transfer_pool, ptrans); } static struct pipe_resource * @@ -194,13 +194,13 @@ vc4_resource_transfer_map(struct pipe_context *pctx, if (usage & PIPE_TRANSFER_WRITE) rsc->writes++; - trans = util_slab_alloc(&vc4->transfer_pool); + trans = slab_alloc_st(&vc4->transfer_pool); if (!trans) return NULL; /* XXX: Handle DONTBLOCK, DISCARD_RANGE, PERSISTENT, COHERENT. */ - /* util_slab_alloc() doesn't zero: */ + /* slab_alloc_st() doesn't zero: */ memset(trans, 0, sizeof(*trans)); ptrans = &trans->base; diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c index 153df8dd0c9..de997962845 100644 --- a/src/gallium/drivers/virgl/virgl_buffer.c +++ b/src/gallium/drivers/virgl/virgl_buffer.c @@ -62,7 +62,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx, if (doflushwait) ctx->flush(ctx, NULL, 0); - trans = util_slab_alloc(&vctx->texture_transfer_pool); + trans = slab_alloc_st(&vctx->texture_transfer_pool); if (!trans) return NULL; @@ -114,7 +114,7 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx, } } - util_slab_free(&vctx->texture_transfer_pool, trans); + slab_free_st(&vctx->texture_transfer_pool, trans); } static void virgl_buffer_transfer_flush_region(struct pipe_context *ctx, diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index 1bd7f3b6b52..a6c05975986 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -32,7 +32,7 @@ #include "util/u_format.h" #include "util/u_transfer.h" #include "util/u_helpers.h" -#include "util/u_slab.h" +#include "util/slab.h" #include "util/u_upload_mgr.h" #include "util/u_blitter.h" #include "tgsi/tgsi_text.h" @@ -862,7 +862,7 @@ virgl_context_destroy( struct pipe_context *ctx ) u_upload_destroy(vctx->uploader); util_primconvert_destroy(vctx->primconvert); - util_slab_destroy(&vctx->texture_transfer_pool); + slab_destroy(&vctx->texture_transfer_pool); FREE(vctx); } @@ -943,8 +943,8 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen, virgl_init_so_functions(vctx); list_inithead(&vctx->to_flush_bufs); - util_slab_create(&vctx->texture_transfer_pool, sizeof(struct virgl_transfer), - 16, UTIL_SLAB_SINGLETHREADED); + slab_create(&vctx->texture_transfer_pool, sizeof(struct virgl_transfer), + 16); vctx->primconvert = util_primconvert_create(&vctx->base, rs->caps.caps.v1.prim_mask); vctx->uploader = u_upload_create(&vctx->base, 1024 * 1024, diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h index adb8adef33c..3b9901f7e11 100644 --- a/src/gallium/drivers/virgl/virgl_context.h +++ b/src/gallium/drivers/virgl/virgl_context.h @@ -25,7 +25,7 @@ #include "pipe/p_state.h" #include "pipe/p_context.h" -#include "util/u_slab.h" +#include "util/slab.h" #include "util/list.h" struct pipe_screen; @@ -56,7 +56,7 @@ struct virgl_context { struct pipe_framebuffer_state framebuffer; - struct util_slab_mempool texture_transfer_pool; + struct slab_mempool texture_transfer_pool; struct pipe_index_buffer index_buffer; struct u_upload_mgr *uploader; diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c index 64b6744462d..24bbc3ce60b 100644 --- a/src/gallium/drivers/virgl/virgl_texture.c +++ b/src/gallium/drivers/virgl/virgl_texture.c @@ -145,7 +145,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx, if (doflushwait) ctx->flush(ctx, NULL, 0); - trans = util_slab_alloc(&vctx->texture_transfer_pool); + trans = slab_alloc_st(&vctx->texture_transfer_pool); if (!trans) return NULL; @@ -235,7 +235,7 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx, if (trans->resolve_tmp) pipe_resource_reference((struct pipe_resource **)&trans->resolve_tmp, NULL); - util_slab_free(&vctx->texture_transfer_pool, trans); + slab_free_st(&vctx->texture_transfer_pool, trans); } |