[Mesa-dev] [PATCH 2/2] gallium: switch drivers to the slab allocator in src/util
Marek Olšák
maraeo at gmail.com
Mon Aug 29 15:29:37 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/Makefile.sources | 2 -
src/gallium/auxiliary/util/u_slab.c | 171 ---------------------
src/gallium/auxiliary/util/u_slab.h | 96 ------------
src/gallium/drivers/freedreno/freedreno_context.c | 6 +-
src/gallium/drivers/freedreno/freedreno_context.h | 8 +-
src/gallium/drivers/freedreno/freedreno_query_hw.c | 24 +--
src/gallium/drivers/freedreno/freedreno_resource.c | 6 +-
src/gallium/drivers/i915/i915_context.c | 8 +-
src/gallium/drivers/i915/i915_context.h | 6 +-
src/gallium/drivers/i915/i915_resource_buffer.c | 4 +-
src/gallium/drivers/i915/i915_resource_texture.c | 4 +-
src/gallium/drivers/ilo/ilo_context.c | 6 +-
src/gallium/drivers/ilo/ilo_context.h | 4 +-
src/gallium/drivers/ilo/ilo_transfer.c | 6 +-
src/gallium/drivers/ilo/shader/toy_compiler.c | 8 +-
src/gallium/drivers/ilo/shader/toy_compiler.h | 8 +-
src/gallium/drivers/r300/r300_context.c | 7 +-
src/gallium/drivers/r300/r300_context.h | 2 +-
src/gallium/drivers/r300/r300_screen.h | 2 +-
src/gallium/drivers/r300/r300_screen_buffer.c | 6 +-
src/gallium/drivers/radeon/r600_buffer_common.c | 4 +-
src/gallium/drivers/radeon/r600_pipe_common.c | 7 +-
src/gallium/drivers/radeon/r600_pipe_common.h | 4 +-
src/gallium/drivers/vc4/vc4_context.c | 6 +-
src/gallium/drivers/vc4/vc4_context.h | 4 +-
src/gallium/drivers/vc4/vc4_resource.c | 6 +-
src/gallium/drivers/virgl/virgl_buffer.c | 4 +-
src/gallium/drivers/virgl/virgl_context.c | 8 +-
src/gallium/drivers/virgl/virgl_context.h | 4 +-
src/gallium/drivers/virgl/virgl_texture.c | 4 +-
30 files changed, 82 insertions(+), 353 deletions(-)
delete mode 100644 src/gallium/auxiliary/util/u_slab.c
delete mode 100644 src/gallium/auxiliary/util/u_slab.h
diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources
index 093c45b..f8954c9 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -277,22 +277,20 @@ C_SOURCES := \
util/u_range.h \
util/u_rect.h \
util/u_resource.c \
util/u_resource.h \
util/u_ringbuffer.c \
util/u_ringbuffer.h \
util/u_sampler.c \
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 \
util/u_suballoc.c \
util/u_suballoc.h \
util/u_surface.c \
util/u_surface.h \
util/u_surfaces.c \
util/u_surfaces.h \
util/u_tests.c \
diff --git a/src/gallium/auxiliary/util/u_slab.c b/src/gallium/auxiliary/util/u_slab.c
deleted file mode 100644
index 7e7d43b..0000000
--- a/src/gallium/auxiliary/util/u_slab.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2010 Marek Olšák <maraeo at gmail.com>
- *
- * 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 0df039b..0000000
--- a/src/gallium/auxiliary/util/u_slab.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2010 Marek Olšák <maraeo at gmail.com>
- *
- * 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 ad62fd6..f8604f1 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -114,21 +114,21 @@ fd_context_destroy(struct pipe_context *pctx)
if (ctx->blitter)
util_blitter_destroy(ctx->blitter);
if (ctx->clear_rs_state)
pctx->delete_rasterizer_state(pctx, ctx->clear_rs_state);
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];
if (!pipe->bo)
break;
fd_bo_del(pipe->bo);
}
fd_device_del(ctx->dev);
@@ -258,22 +258,22 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
pctx->set_debug_callback = fd_set_debug_callback;
/* TODO what about compute? Ideally it creates it's own independent
* batches per compute job (since it isn't using tiling, so no point
* in getting involved with the re-ordering madness)..
*/
if (!screen->reorder) {
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);
fd_query_context_init(pctx);
fd_texture_init(pctx);
fd_state_init(pctx);
fd_hw_query_init(pctx);
ctx->blitter = util_blitter_create(pctx);
if (!ctx->blitter)
diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h
index 037c199..e1b7b23 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.h
+++ b/src/gallium/drivers/freedreno/freedreno_context.h
@@ -26,21 +26,21 @@
* Rob Clark <robclark at freedesktop.org>
*/
#ifndef FREEDRENO_CONTEXT_H_
#define FREEDRENO_CONTEXT_H_
#include "pipe/p_context.h"
#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"
#include "freedreno_screen.h"
#include "freedreno_gmem.h"
#include "freedreno_util.h"
#define BORDER_COLOR_UPLOAD_SIZE (2 * PIPE_MAX_SAMPLERS * BORDERCOLOR_SIZE)
struct fd_vertex_stateobj;
@@ -114,25 +114,25 @@ struct fd_context {
struct fd_device *dev;
struct fd_screen *screen;
struct util_queue flush_queue;
struct blitter_context *blitter;
void *clear_rs_state;
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];
/* list of active queries: */
struct list_head active_queries;
/* table with PIPE_PRIM_MAX entries mapping PIPE_PRIM_x to
* DI_PT_x value to use for draw initiator. There are some
* slight differences between generation:
diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c
index e5ef51a..470826a 100644
--- a/src/gallium/drivers/freedreno/freedreno_query_hw.c
+++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c
@@ -101,24 +101,24 @@ is_active(struct fd_hw_query *hq, enum fd_render_stage stage)
static void
resume_query(struct fd_batch *batch, struct fd_hw_query *hq,
struct fd_ringbuffer *ring)
{
int idx = pidx(hq->provider->query_type);
DBG("%p", 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;
}
static void
pause_query(struct fd_batch *batch, struct fd_hw_query *hq,
struct fd_ringbuffer *ring)
{
int idx = pidx(hq->provider->query_type);
DBG("%p", hq);
assert(idx >= 0); /* query never would have been created otherwise */
@@ -130,21 +130,21 @@ pause_query(struct fd_batch *batch, struct fd_hw_query *hq,
}
static void
destroy_periods(struct fd_context *ctx, struct fd_hw_query *hq)
{
struct fd_hw_sample_period *period, *s;
LIST_FOR_EACH_ENTRY_SAFE(period, s, &hq->periods, list) {
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);
}
}
static void
fd_hw_destroy_query(struct fd_context *ctx, struct fd_query *q)
{
struct fd_hw_query *hq = fd_hw_query(q);
DBG("%p: active=%d", q, q->active);
@@ -332,27 +332,27 @@ fd_hw_create_query(struct fd_context *ctx, unsigned query_type)
q = &hq->base;
q->funcs = &hw_query_funcs;
q->type = query_type;
return q;
}
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;
batch->next_sample_offset += size;
if (!batch->query_buf) {
struct pipe_screen *pscreen = &batch->ctx->screen->base;
struct pipe_resource templ = {
.target = PIPE_BUFFER,
.format = PIPE_FORMAT_R8_UNORM,
@@ -369,21 +369,21 @@ fd_hw_sample_init(struct fd_batch *batch, uint32_t size)
pipe_resource_reference(&samp->prsc, batch->query_buf);
return samp;
}
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.
* number of samples times number of tiles)
*/
void
fd_hw_query_prepare(struct fd_batch *batch, uint32_t num_tiles)
{
uint32_t tile_stride = batch->next_sample_offset;
@@ -479,25 +479,25 @@ fd_hw_query_register_provider(struct pipe_context *pctx,
assert(!ctx->sample_providers[idx]);
ctx->sample_providers[idx] = provider;
}
void
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);
}
void
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 2a4fd74..3cc6654 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -418,21 +418,21 @@ fd_resource_transfer_unmap(struct pipe_context *pctx,
fd_bo_cpu_fini(rsc->bo);
if (rsc->stencil)
fd_bo_cpu_fini(rsc->stencil->bo);
}
util_range_add(&rsc->valid_buffer_range,
ptrans->box.x,
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);
}
static void *
fd_resource_transfer_map(struct pipe_context *pctx,
struct pipe_resource *prsc,
unsigned level, unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **pptrans)
@@ -444,25 +444,25 @@ fd_resource_transfer_map(struct pipe_context *pctx,
struct pipe_transfer *ptrans;
enum pipe_format format = prsc->format;
uint32_t op = 0;
uint32_t offset;
char *buf;
int ret = 0;
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));
pipe_resource_reference(&ptrans->resource, prsc);
ptrans->level = level;
ptrans->usage = usage;
ptrans->box = *box;
ptrans->stride = util_format_get_nblocksx(format, slice->pitch) * rsc->cpp;
ptrans->layer_stride = rsc->layer_first ? rsc->layer_size : slice->size0;
diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c
index 82798bb..f3324db 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -170,24 +170,24 @@ i915_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
i915->base.destroy = i915_destroy;
if (i915_screen(screen)->debug.use_blitter)
i915->base.clear = i915_clear_blitter;
else
i915->base.clear = i915_clear_render;
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:
*/
i915->batch = i915->iws->batchbuffer_create(i915->iws);
/*
* Create drawing context and plug our rendering stage into it.
*/
i915->draw = draw_create(&i915->base);
assert(i915->draw);
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index 2adaee3..ea13834 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -30,21 +30,21 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
#include "draw/draw_vertex.h"
#include "tgsi/tgsi_scan.h"
-#include "util/u_slab.h"
+#include "util/slab.h"
#include "util/u_blitter.h"
struct i915_winsys;
struct i915_winsys_buffer;
struct i915_winsys_batchbuffer;
#define I915_TEX_UNITS 8
@@ -271,22 +271,22 @@ struct i915_context {
struct i915_state current;
unsigned hardware_dirty;
unsigned immediate_dirty : I915_MAX_IMMEDIATE;
unsigned dynamic_dirty : I915_MAX_DYNAMIC;
unsigned static_dirty : 4;
unsigned flush_dirty : 2;
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;
int fired_vertices;
int queued_vertices;
/** blitter/hw-clear */
struct blitter_context* blitter;
};
diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c
index 24c954c..2572fc4 100644
--- a/src/gallium/drivers/i915/i915_resource_buffer.c
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -63,40 +63,40 @@ i915_buffer_destroy(struct pipe_screen *screen,
static void *
i915_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer)
{
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;
transfer->resource = resource;
transfer->level = level;
transfer->usage = usage;
transfer->box = *box;
*ptransfer = transfer;
return buffer->data + transfer->box.x;
}
static void
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
i915_buffer_subdata(struct pipe_context *rm_ctx,
struct pipe_resource *resource,
unsigned usage, unsigned offset,
unsigned size, const void *data)
{
struct i915_buffer *buffer = i915_buffer(resource);
diff --git a/src/gallium/drivers/i915/i915_resource_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c
index f77bbfd..4ade04f 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -714,21 +714,21 @@ i915_texture_destroy(struct pipe_screen *screen,
static void *
i915_texture_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer)
{
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;
unsigned offset;
char *map;
if (!transfer)
return NULL;
transfer->b.resource = resource;
@@ -807,21 +807,21 @@ i915_texture_transfer_unmap(struct pipe_context *pipe,
u_box_origin_2d(itransfer->b.box.width, itransfer->b.box.height, &sbox);
pipe->resource_copy_region(pipe, itransfer->b.resource, itransfer->b.level,
itransfer->b.box.x, itransfer->b.box.y, itransfer->b.box.z,
itransfer->staging_texture,
0, &sbox);
pipe->flush(pipe, NULL, 0);
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
static void i915_texture_subdata(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
const void *data,
unsigned stride,
diff --git a/src/gallium/drivers/ilo/ilo_context.c b/src/gallium/drivers/ilo/ilo_context.c
index 6bcd0bc..ad91202 100644
--- a/src/gallium/drivers/ilo/ilo_context.c
+++ b/src/gallium/drivers/ilo/ilo_context.c
@@ -122,21 +122,21 @@ ilo_context_destroy(struct pipe_context *pipe)
if (ilo->blitter)
ilo_blitter_destroy(ilo->blitter);
if (ilo->render)
ilo_render_destroy(ilo->render);
if (ilo->shader_cache)
ilo_shader_cache_destroy(ilo->shader_cache);
if (ilo->cp)
ilo_cp_destroy(ilo->cp);
- util_slab_destroy(&ilo->transfer_mempool);
+ slab_destroy(&ilo->transfer_mempool);
FREE(ilo);
}
static struct pipe_context *
ilo_context_create(struct pipe_screen *screen, void *priv, unsigned flags)
{
struct ilo_screen *is = ilo_screen(screen);
struct ilo_context *ilo;
@@ -144,22 +144,22 @@ ilo_context_create(struct pipe_screen *screen, void *priv, unsigned flags)
if (!ilo)
return NULL;
ilo->winsys = is->dev.winsys;
ilo->dev = &is->dev;
/*
* 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);
if (ilo->cp)
ilo->render = ilo_render_create(&ilo->cp->builder);
if (!ilo->cp || !ilo->shader_cache || !ilo->render) {
ilo_context_destroy(&ilo->base);
return NULL;
}
diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h
index 1610358..25d338a 100644
--- a/src/gallium/drivers/ilo/ilo_context.h
+++ b/src/gallium/drivers/ilo/ilo_context.h
@@ -22,42 +22,42 @@
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Chia-I Wu <olv at lunarg.com>
*/
#ifndef ILO_CONTEXT_H
#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"
#include "ilo_draw.h"
#include "ilo_state.h"
struct u_upload_mgr;
struct intel_winsys;
struct ilo_blitter;
struct ilo_render;
struct ilo_screen;
struct ilo_shader_cache;
struct ilo_context {
struct pipe_context base;
struct intel_winsys *winsys;
struct ilo_dev *dev;
- struct util_slab_mempool transfer_mempool;
+ struct slab_mempool transfer_mempool;
struct ilo_cp *cp;
struct ilo_shader_cache *shader_cache;
struct ilo_blitter *blitter;
struct ilo_render *render;
struct u_upload_mgr *uploader;
struct ilo_state_vector state_vector;
diff --git a/src/gallium/drivers/ilo/ilo_transfer.c b/src/gallium/drivers/ilo/ilo_transfer.c
index d243e38..87607eb 100644
--- a/src/gallium/drivers/ilo/ilo_transfer.c
+++ b/src/gallium/drivers/ilo/ilo_transfer.c
@@ -1177,37 +1177,37 @@ ilo_transfer_unmap(struct pipe_context *pipe,
case ILO_TRANSFER_MAP_SW_ZS:
tex_staging_sys_writeback(xfer);
align_free(xfer->staging.sys);
break;
default:
break;
}
pipe_resource_reference(&xfer->base.resource, NULL);
- util_slab_free(&ilo->transfer_mempool, xfer);
+ slab_free_st(&ilo->transfer_mempool, xfer);
}
static void *
ilo_transfer_map(struct pipe_context *pipe,
struct pipe_resource *res,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **transfer)
{
struct ilo_context *ilo = ilo_context(pipe);
struct ilo_transfer *xfer;
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;
}
xfer->base.resource = NULL;
pipe_resource_reference(&xfer->base.resource, res);
xfer->base.level = level;
xfer->base.usage = usage;
xfer->base.box = *box;
@@ -1219,21 +1219,21 @@ ilo_transfer_map(struct pipe_context *pipe,
ptr = buf_map(xfer);
else
ptr = tex_map(xfer);
}
else {
ptr = NULL;
}
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;
}
*transfer = &xfer->base;
return ptr;
}
static void ilo_buffer_subdata(struct pipe_context *pipe,
diff --git a/src/gallium/drivers/ilo/shader/toy_compiler.c b/src/gallium/drivers/ilo/shader/toy_compiler.c
index 99f1ad1..4651c83 100644
--- a/src/gallium/drivers/ilo/shader/toy_compiler.c
+++ b/src/gallium/drivers/ilo/shader/toy_compiler.c
@@ -484,23 +484,23 @@ toy_compiler_dump(struct toy_compiler *tc)
/**
* Clean up the toy compiler.
*/
void
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);
}
/**
* Initialize the instruction template, from which tc_add() initializes the
* newly added instructions.
*/
static void
tc_init_inst_templ(struct toy_compiler *tc)
{
struct toy_inst *templ = &tc->templ;
@@ -536,22 +536,22 @@ tc_init_inst_templ(struct toy_compiler *tc)
*/
void
toy_compiler_init(struct toy_compiler *tc, const struct ilo_dev *dev)
{
memset(tc, 0, sizeof(*tc));
tc->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 */
tc_tail(tc);
tc->rect_linear_width = 1;
/* skip 0 so that util_hash_table_get() never returns NULL */
tc->next_vrf = 1;
}
diff --git a/src/gallium/drivers/ilo/shader/toy_compiler.h b/src/gallium/drivers/ilo/shader/toy_compiler.h
index d9b5617..71f9dea 100644
--- a/src/gallium/drivers/ilo/shader/toy_compiler.h
+++ b/src/gallium/drivers/ilo/shader/toy_compiler.h
@@ -22,21 +22,21 @@
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Chia-I Wu <olv at lunarg.com>
*/
#ifndef TOY_COMPILER_H
#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"
/**
* Toy opcodes.
*/
enum toy_opcode {
/* 0..127 are reserved for GEN6_OPCODE_x */
TOY_OPCODE_LAST_HW = 127,
@@ -146,21 +146,21 @@ struct toy_compaction_table {
uint64_t source_3src[4];
};
/**
* Toy compiler.
*/
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;
/* this is not set until toy_compiler_legalize_for_asm() */
int num_instructions;
int rect_linear_width;
int next_vrf;
bool fail;
@@ -202,21 +202,21 @@ tc_alloc_tmp4(struct toy_compiler *tc, struct toy_dst *tmp)
}
/**
* Duplicate an instruction at the current location.
*/
static inline struct toy_inst *
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;
*new_inst = *inst;
list_addtail(&new_inst->list, tc->iter_next);
return new_inst;
}
/**
@@ -229,21 +229,21 @@ tc_move_inst(struct toy_compiler *tc, struct toy_inst *inst)
list_addtail(&inst->list, tc->iter_next);
}
/**
* Discard an instruction.
*/
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);
}
/**
* Add a new instruction at the current location, using tc->templ as the
* template.
*/
static inline struct toy_inst *
tc_add(struct toy_compiler *tc)
{
return tc_duplicate_inst(tc, &tc->templ);
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index d100a9d..24d07f0 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? */
- util_slab_destroy(&r300->pool_transfers);
+ slab_destroy(&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);
@@ -370,23 +370,22 @@ 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;
- 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)
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 a4783f3..592479a 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 util_slab_mempool pool_transfers;
+ struct slab_mempool 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.h b/src/gallium/drivers/r300/r300_screen.h
index e15c3c7..5cd5a40 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -20,21 +20,21 @@
* 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. */
#ifndef R300_SCREEN_H
#define R300_SCREEN_H
#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>
struct r300_screen {
/* Parent class */
struct pipe_screen screen;
struct radeon_winsys *rws;
/* Chipset info and capabilities. */
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 069e9fd..4747058 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 = util_slab_alloc(&r300->pool_transfers);
+ transfer = slab_alloc_st(&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,34 +122,34 @@ 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) {
- util_slab_free(&r300->pool_transfers, transfer);
+ slab_free_st(&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 )
{
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 =
{
NULL, /* get_handle */
r300_buffer_destroy, /* resource_destroy */
r300_buffer_transfer_map, /* transfer_map */
NULL, /* transfer_flush_region */
r300_buffer_transfer_unmap, /* transfer_unmap */
};
diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c
index 6a55de1..a600793 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -276,21 +276,21 @@ void r600_invalidate_resource(struct pipe_context *ctx,
static void *r600_buffer_get_transfer(struct pipe_context *ctx,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer,
void *data, struct r600_resource *staging,
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;
transfer->transfer.usage = usage;
transfer->transfer.box = *box;
transfer->transfer.stride = 0;
transfer->transfer.layer_stride = 0;
transfer->offset = offset;
transfer->staging = staging;
*ptransfer = &transfer->transfer;
@@ -461,21 +461,21 @@ static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
struct r600_common_context *rctx = (struct r600_common_context*)ctx;
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
if (transfer->usage & PIPE_TRANSFER_WRITE &&
!(transfer->usage & PIPE_TRANSFER_FLUSH_EXPLICIT))
r600_buffer_do_flush_region(ctx, transfer, &transfer->box);
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,
struct pipe_resource *buffer,
unsigned usage, unsigned offset,
unsigned size, const void *data)
{
struct pipe_transfer *transfer = NULL;
struct pipe_box box;
uint8_t *map = NULL;
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 32486c8..4cfdf67 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -424,23 +424,22 @@ static void r600_set_debug_callback(struct pipe_context *ctx,
if (cb)
rctx->debug = *cb;
else
memset(&rctx->debug, 0, sizeof(rctx->debug));
}
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;
rctx->family = rscreen->family;
rctx->chip_class = rscreen->chip_class;
if (rscreen->chip_class >= CIK)
rctx->max_db = MAX2(8, rscreen->info.num_render_backends);
else if (rscreen->chip_class >= EVERGREEN)
rctx->max_db = 8;
@@ -526,21 +525,21 @@ void r600_common_context_cleanup(struct r600_common_context *rctx)
rctx->ws->cs_destroy(rctx->gfx.cs);
if (rctx->dma.cs)
rctx->ws->cs_destroy(rctx->dma.cs);
if (rctx->ctx)
rctx->ws->ctx_destroy(rctx->ctx);
if (rctx->uploader) {
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);
}
rctx->ws->fence_reference(&rctx->last_gfx_fence, NULL);
rctx->ws->fence_reference(&rctx->last_sdma_fence, NULL);
}
void r600_context_add_resource_size(struct pipe_context *ctx, struct pipe_resource *r)
{
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index aa40a54..d9f22e4 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -32,21 +32,21 @@
#ifndef R600_PIPE_COMMON_H
#define R600_PIPE_COMMON_H
#include <stdio.h>
#include "radeon/radeon_winsys.h"
#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"
#define ATI_VENDOR_ID 0x1002
#define R600_RESOURCE_FLAG_TRANSFER (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
#define R600_RESOURCE_FLAG_FLUSHED_DEPTH (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
#define R600_RESOURCE_FLAG_FORCE_TILING (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
#define R600_RESOURCE_FLAG_DISABLE_DCC (PIPE_RESOURCE_FLAG_DRV_PRIV << 3)
@@ -520,21 +520,21 @@ struct r600_common_context {
struct pipe_fence_handle *last_sdma_fence;
unsigned num_gfx_cs_flushes;
unsigned initial_gfx_cs_size;
unsigned gpu_reset_counter;
unsigned last_dirty_fb_counter;
unsigned last_compressed_colortex_counter;
unsigned last_dirty_tex_descriptor_counter;
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;
uint64_t gtt;
/* States. */
struct r600_streamout streamout;
struct r600_scissors scissors;
struct r600_viewports viewports;
bool scissor_enabled;
diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c
index eeadea0..a85554a 100644
--- a/src/gallium/drivers/vc4/vc4_context.c
+++ b/src/gallium/drivers/vc4/vc4_context.c
@@ -193,21 +193,21 @@ vc4_context_destroy(struct pipe_context *pctx)
if (vc4->blitter)
util_blitter_destroy(vc4->blitter);
if (vc4->primconvert)
util_primconvert_destroy(vc4->primconvert);
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);
pipe_surface_reference(&vc4->color_write, NULL);
pipe_surface_reference(&vc4->color_read, NULL);
vc4_program_fini(pctx);
ralloc_free(vc4);
@@ -239,22 +239,22 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
vc4_draw_init(pctx);
vc4_state_init(pctx);
vc4_program_init(pctx);
vc4_query_init(pctx);
vc4_resource_context_init(pctx);
vc4_job_init(vc4);
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;
vc4->primconvert = util_primconvert_create(pctx,
(1 << PIPE_PRIM_QUADS) - 1);
if (!vc4->primconvert)
goto fail;
vc4->uploader = u_upload_create(pctx, 16 * 1024,
diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h
index 63a1dfb..ce2c6d4 100644
--- a/src/gallium/drivers/vc4/vc4_context.h
+++ b/src/gallium/drivers/vc4/vc4_context.h
@@ -22,21 +22,21 @@
* IN THE SOFTWARE.
*/
#ifndef VC4_CONTEXT_H
#define VC4_CONTEXT_H
#include <stdio.h>
#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"
#include "vc4_bufmgr.h"
#include "vc4_resource.h"
#include "vc4_cl.h"
#include "vc4_qir.h"
#ifdef USE_VC4_SIMULATOR
#define using_vc4_simulator true
@@ -231,21 +231,21 @@ struct vc4_context {
/** @{ Tile information, depending on MSAA and float color buffer. */
uint32_t draw_tiles_x; /** @< Number of tiles wide for framebuffer. */
uint32_t draw_tiles_y; /** @< Number of tiles high for framebuffer. */
uint32_t tile_width; /** @< Width of a tile. */
uint32_t tile_height; /** @< Height of a tile. */
/** Whether the current rendering is in a 4X MSAA tile buffer. */
bool msaa;
/** @} */
- struct util_slab_mempool transfer_pool;
+ struct slab_mempool transfer_pool;
struct blitter_context *blitter;
/** bitfield of VC4_DIRTY_* */
uint32_t dirty;
/* Bitmask of PIPE_CLEAR_* of buffers that were cleared before the
* first rendering.
*/
uint32_t cleared;
/* Bitmask of PIPE_CLEAR_* of buffers that have been rendered to
* (either clears or draws).
diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c
index 398aa81..0d4bb64 100644
--- a/src/gallium/drivers/vc4/vc4_resource.c
+++ b/src/gallium/drivers/vc4/vc4_resource.c
@@ -114,21 +114,21 @@ vc4_resource_transfer_unmap(struct pipe_context *pctx,
blit.mask = util_format_get_mask(ptrans->resource->format);
blit.filter = PIPE_TEX_FILTER_NEAREST;
pctx->blit(pctx, &blit);
vc4_flush(pctx);
pipe_resource_reference(&trans->ss_resource, NULL);
}
pipe_resource_reference(&ptrans->resource, NULL);
- util_slab_free(&vc4->transfer_pool, ptrans);
+ slab_free_st(&vc4->transfer_pool, ptrans);
}
static struct pipe_resource *
vc4_get_temp_resource(struct pipe_context *pctx,
struct pipe_resource *prsc,
const struct pipe_box *box)
{
struct pipe_resource temp_setup;
memset(&temp_setup, 0, sizeof(temp_setup));
@@ -187,27 +187,27 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
vc4->dirty |= VC4_DIRTY_VTXBUF;
} else {
vc4_flush(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;
pipe_resource_reference(&ptrans->resource, prsc);
ptrans->level = level;
ptrans->usage = usage;
ptrans->box = *box;
/* If the resource is multisampled, we need to resolve to single
* sample. This seems like it should be handled at a higher layer.
diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c
index 153df8d..de99796 100644
--- a/src/gallium/drivers/virgl/virgl_buffer.c
+++ b/src/gallium/drivers/virgl/virgl_buffer.c
@@ -55,21 +55,21 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
bool doflushwait = false;
if ((usage & PIPE_TRANSFER_READ) && (vbuf->on_list == TRUE))
doflushwait = true;
else
doflushwait = virgl_res_needs_flush_wait(vctx, &vbuf->base, usage);
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;
trans->base.resource = resource;
trans->base.level = level;
trans->base.usage = usage;
trans->base.box = *box;
trans->base.stride = 0;
trans->base.layer_stride = 0;
@@ -107,21 +107,21 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
if (!(transfer->usage & PIPE_TRANSFER_FLUSH_EXPLICIT)) {
struct virgl_screen *vs = virgl_screen(ctx->screen);
vbuf->base.clean = FALSE;
vctx->num_transfers++;
vs->vws->transfer_put(vs->vws, vbuf->base.hw_res,
&transfer->box, trans->base.stride, trans->base.layer_stride, trans->offset, transfer->level);
}
}
- 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,
struct pipe_transfer *transfer,
const struct pipe_box *box)
{
struct virgl_context *vctx = virgl_context(ctx);
struct virgl_buffer *vbuf = virgl_buffer(transfer->resource);
if (!vbuf->on_list) {
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index 615bb50..c69b506 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -25,21 +25,21 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
#include "util/u_inlines.h"
#include "util/u_memory.h"
#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"
#include "indices/u_primconvert.h"
#include "pipebuffer/pb_buffer.h"
#include "virgl_encode.h"
#include "virgl_context.h"
#include "virgl_protocol.h"
@@ -854,21 +854,21 @@ virgl_context_destroy( struct pipe_context *ctx )
vctx->framebuffer.zsbuf = NULL;
vctx->framebuffer.nr_cbufs = 0;
virgl_encoder_destroy_sub_ctx(vctx, vctx->hw_sub_ctx_id);
virgl_flush_eq(vctx, vctx);
rs->vws->cmd_buf_destroy(vctx->cbuf);
if (vctx->uploader)
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);
}
struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
void *priv,
unsigned flags)
{
struct virgl_context *vctx;
struct virgl_screen *rs = virgl_screen(pscreen);
vctx = CALLOC_STRUCT(virgl_context);
@@ -935,22 +935,22 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
vctx->base.resource_copy_region = virgl_resource_copy_region;
vctx->base.flush_resource = virgl_flush_resource;
vctx->base.blit = virgl_blit;
virgl_init_context_resource_functions(&vctx->base);
virgl_init_query_functions(vctx);
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,
PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM);
if (!vctx->uploader)
goto fail;
vctx->hw_sub_ctx_id = rs->sub_ctx_id++;
virgl_encoder_create_sub_ctx(vctx, vctx->hw_sub_ctx_id);
diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h
index adb8ade..3b9901f 100644
--- a/src/gallium/drivers/virgl/virgl_context.h
+++ b/src/gallium/drivers/virgl/virgl_context.h
@@ -18,21 +18,21 @@
* 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.
*/
#ifndef VIRGL_CONTEXT_H
#define VIRGL_CONTEXT_H
#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;
struct tgsi_token;
struct u_upload_mgr;
struct virgl_cmd_buf;
struct virgl_sampler_view {
struct pipe_sampler_view base;
uint32_t handle;
@@ -49,21 +49,21 @@ struct virgl_textures_info {
};
struct virgl_context {
struct pipe_context base;
struct virgl_cmd_buf *cbuf;
struct virgl_textures_info samplers[PIPE_SHADER_TYPES];
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;
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
unsigned num_vertex_buffers;
boolean vertex_array_dirty;
struct virgl_so_target so_targets[PIPE_MAX_SO_BUFFERS];
unsigned num_so_targets;
diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c
index 64b6744..24bbc3c 100644
--- a/src/gallium/drivers/virgl/virgl_texture.c
+++ b/src/gallium/drivers/virgl/virgl_texture.c
@@ -138,21 +138,21 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
const unsigned h = u_minify(vtex->base.u.b.height0, level);
const unsigned nblocksy = util_format_get_nblocksy(format, h);
bool is_depth = util_format_has_depth(util_format_description(resource->format));
uint32_t l_stride;
bool doflushwait;
doflushwait = virgl_res_needs_flush_wait(vctx, &vtex->base, usage);
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;
trans->base.resource = resource;
trans->base.level = level;
trans->base.usage = usage;
trans->base.box = *box;
trans->base.stride = vtex->stride[level];
trans->base.layer_stride = trans->base.stride * nblocksy;
@@ -228,21 +228,21 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
vctx->num_transfers++;
vs->vws->transfer_put(vs->vws, vtex->base.hw_res,
&transfer->box, trans->base.stride, l_stride, trans->offset, transfer->level);
}
}
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);
}
static boolean
vrend_resource_layout(struct virgl_texture *res,
uint32_t *total_size)
{
struct pipe_resource *pt = &res->base.u.b;
unsigned level;
unsigned width = pt->width0;
--
2.7.4
More information about the mesa-dev
mailing list