mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 11:20:11 +01:00
gallium: switch drivers to the slab allocator in src/util
This commit is contained in:
parent
761ff40302
commit
e7a73b75a0
30 changed files with 82 additions and 353 deletions
|
|
@ -284,8 +284,6 @@ C_SOURCES := \
|
||||||
util/u_sampler.h \
|
util/u_sampler.h \
|
||||||
util/u_simple_shaders.c \
|
util/u_simple_shaders.c \
|
||||||
util/u_simple_shaders.h \
|
util/u_simple_shaders.h \
|
||||||
util/u_slab.c \
|
|
||||||
util/u_slab.h \
|
|
||||||
util/u_split_prim.h \
|
util/u_split_prim.h \
|
||||||
util/u_sse.h \
|
util/u_sse.h \
|
||||||
util/u_string.h \
|
util/u_string.h \
|
||||||
|
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2010 Marek Olšák <maraeo@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);
|
|
||||||
}
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2010 Marek Olšák <maraeo@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
|
|
||||||
|
|
@ -121,7 +121,7 @@ fd_context_destroy(struct pipe_context *pctx)
|
||||||
if (ctx->primconvert)
|
if (ctx->primconvert)
|
||||||
util_primconvert_destroy(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++) {
|
for (i = 0; i < ARRAY_SIZE(ctx->pipe); i++) {
|
||||||
struct fd_vsc_pipe *pipe = &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);
|
ctx->batch = fd_bc_alloc_batch(&screen->batch_cache, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
util_slab_create(&ctx->transfer_pool, sizeof(struct fd_transfer),
|
slab_create(&ctx->transfer_pool, sizeof(struct fd_transfer),
|
||||||
16, UTIL_SLAB_SINGLETHREADED);
|
16);
|
||||||
|
|
||||||
fd_draw_init(pctx);
|
fd_draw_init(pctx);
|
||||||
fd_resource_context_init(pctx);
|
fd_resource_context_init(pctx);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
#include "indices/u_primconvert.h"
|
#include "indices/u_primconvert.h"
|
||||||
#include "util/u_blitter.h"
|
#include "util/u_blitter.h"
|
||||||
#include "util/list.h"
|
#include "util/list.h"
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
#include "util/u_string.h"
|
#include "util/u_string.h"
|
||||||
|
|
||||||
#include "freedreno_batch.h"
|
#include "freedreno_batch.h"
|
||||||
|
|
@ -121,11 +121,11 @@ struct fd_context {
|
||||||
struct primconvert_context *primconvert;
|
struct primconvert_context *primconvert;
|
||||||
|
|
||||||
/* slab for pipe_transfer allocations: */
|
/* 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: */
|
/* slabs for fd_hw_sample and fd_hw_sample_period allocations: */
|
||||||
struct util_slab_mempool sample_pool;
|
struct slab_mempool sample_pool;
|
||||||
struct util_slab_mempool sample_period_pool;
|
struct slab_mempool sample_period_pool;
|
||||||
|
|
||||||
/* sample-providers for hw queries: */
|
/* sample-providers for hw queries: */
|
||||||
const struct fd_hw_sample_provider *sample_providers[MAX_HW_SAMPLE_PROVIDERS];
|
const struct fd_hw_sample_provider *sample_providers[MAX_HW_SAMPLE_PROVIDERS];
|
||||||
|
|
|
||||||
|
|
@ -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(idx >= 0); /* query never would have been created otherwise */
|
||||||
assert(!hq->period);
|
assert(!hq->period);
|
||||||
batch->active_providers |= (1 << idx);
|
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);
|
list_inithead(&hq->period->list);
|
||||||
hq->period->start = get_sample(batch, ring, hq->base.type);
|
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;
|
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->start, NULL);
|
||||||
fd_hw_sample_reference(ctx, &period->end, NULL);
|
fd_hw_sample_reference(ctx, &period->end, NULL);
|
||||||
list_del(&period->list);
|
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 *
|
struct fd_hw_sample *
|
||||||
fd_hw_sample_init(struct fd_batch *batch, uint32_t size)
|
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);
|
pipe_reference_init(&samp->reference, 1);
|
||||||
samp->size = size;
|
samp->size = size;
|
||||||
debug_assert(util_is_power_of_two(size));
|
debug_assert(util_is_power_of_two(size));
|
||||||
batch->next_sample_offset = align(batch->next_sample_offset, size);
|
batch->next_sample_offset = align(batch->next_sample_offset, size);
|
||||||
samp->offset = batch->next_sample_offset;
|
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->prsc = NULL;
|
||||||
samp->num_tiles = 0;
|
samp->num_tiles = 0;
|
||||||
samp->tile_stride = 0;
|
samp->tile_stride = 0;
|
||||||
|
|
@ -376,7 +376,7 @@ void
|
||||||
__fd_hw_sample_destroy(struct fd_context *ctx, struct fd_hw_sample *samp)
|
__fd_hw_sample_destroy(struct fd_context *ctx, struct fd_hw_sample *samp)
|
||||||
{
|
{
|
||||||
pipe_resource_reference(&samp->prsc, NULL);
|
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.
|
/* 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);
|
struct fd_context *ctx = fd_context(pctx);
|
||||||
|
|
||||||
util_slab_create(&ctx->sample_pool, sizeof(struct fd_hw_sample),
|
slab_create(&ctx->sample_pool, sizeof(struct fd_hw_sample),
|
||||||
16, UTIL_SLAB_SINGLETHREADED);
|
16);
|
||||||
util_slab_create(&ctx->sample_period_pool, sizeof(struct fd_hw_sample_period),
|
slab_create(&ctx->sample_period_pool, sizeof(struct fd_hw_sample_period),
|
||||||
16, UTIL_SLAB_SINGLETHREADED);
|
16);
|
||||||
list_inithead(&ctx->active_queries);
|
list_inithead(&ctx->active_queries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -498,6 +498,6 @@ fd_hw_query_fini(struct pipe_context *pctx)
|
||||||
{
|
{
|
||||||
struct fd_context *ctx = fd_context(pctx);
|
struct fd_context *ctx = fd_context(pctx);
|
||||||
|
|
||||||
util_slab_destroy(&ctx->sample_pool);
|
slab_destroy(&ctx->sample_pool);
|
||||||
util_slab_destroy(&ctx->sample_period_pool);
|
slab_destroy(&ctx->sample_period_pool);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -425,7 +425,7 @@ fd_resource_transfer_unmap(struct pipe_context *pctx,
|
||||||
ptrans->box.x + ptrans->box.width);
|
ptrans->box.x + ptrans->box.width);
|
||||||
|
|
||||||
pipe_resource_reference(&ptrans->resource, NULL);
|
pipe_resource_reference(&ptrans->resource, NULL);
|
||||||
util_slab_free(&ctx->transfer_pool, ptrans);
|
slab_free_st(&ctx->transfer_pool, ptrans);
|
||||||
|
|
||||||
free(trans->staging);
|
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,
|
DBG("prsc=%p, level=%u, usage=%x, box=%dx%d+%d,%d", prsc, level, usage,
|
||||||
box->width, box->height, box->x, box->y);
|
box->width, box->height, box->x, box->y);
|
||||||
|
|
||||||
ptrans = util_slab_alloc(&ctx->transfer_pool);
|
ptrans = slab_alloc_st(&ctx->transfer_pool);
|
||||||
if (!ptrans)
|
if (!ptrans)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* util_slab_alloc() doesn't zero: */
|
/* slab_alloc_st() doesn't zero: */
|
||||||
trans = fd_transfer(ptrans);
|
trans = fd_transfer(ptrans);
|
||||||
memset(trans, 0, sizeof(*trans));
|
memset(trans, 0, sizeof(*trans));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,10 +177,10 @@ i915_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
|
||||||
i915->base.draw_vbo = i915_draw_vbo;
|
i915->base.draw_vbo = i915_draw_vbo;
|
||||||
|
|
||||||
/* init this before draw */
|
/* init this before draw */
|
||||||
util_slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer),
|
slab_create(&i915->transfer_pool, sizeof(struct pipe_transfer),
|
||||||
16, UTIL_SLAB_SINGLETHREADED);
|
16);
|
||||||
util_slab_create(&i915->texture_transfer_pool, sizeof(struct i915_transfer),
|
slab_create(&i915->texture_transfer_pool, sizeof(struct i915_transfer),
|
||||||
16, UTIL_SLAB_SINGLETHREADED);
|
16);
|
||||||
|
|
||||||
/* Batch stream debugging is a bit hacked up at the moment:
|
/* Batch stream debugging is a bit hacked up at the moment:
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#include "tgsi/tgsi_scan.h"
|
#include "tgsi/tgsi_scan.h"
|
||||||
|
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
#include "util/u_blitter.h"
|
#include "util/u_blitter.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -278,8 +278,8 @@ struct i915_context {
|
||||||
struct i915_winsys_buffer *validation_buffers[2 + 1 + I915_TEX_UNITS];
|
struct i915_winsys_buffer *validation_buffers[2 + 1 + I915_TEX_UNITS];
|
||||||
int num_validation_buffers;
|
int num_validation_buffers;
|
||||||
|
|
||||||
struct util_slab_mempool transfer_pool;
|
struct slab_mempool transfer_pool;
|
||||||
struct util_slab_mempool texture_transfer_pool;
|
struct slab_mempool texture_transfer_pool;
|
||||||
|
|
||||||
/* state for tracking flushes */
|
/* state for tracking flushes */
|
||||||
int last_fired_vertices;
|
int last_fired_vertices;
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ i915_buffer_transfer_map(struct pipe_context *pipe,
|
||||||
{
|
{
|
||||||
struct i915_context *i915 = i915_context(pipe);
|
struct i915_context *i915 = i915_context(pipe);
|
||||||
struct i915_buffer *buffer = i915_buffer(resource);
|
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)
|
if (!transfer)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -89,7 +89,7 @@ i915_buffer_transfer_unmap(struct pipe_context *pipe,
|
||||||
struct pipe_transfer *transfer)
|
struct pipe_transfer *transfer)
|
||||||
{
|
{
|
||||||
struct i915_context *i915 = i915_context(pipe);
|
struct i915_context *i915 = i915_context(pipe);
|
||||||
util_slab_free(&i915->transfer_pool, transfer);
|
slab_free_st(&i915->transfer_pool, transfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -721,7 +721,7 @@ i915_texture_transfer_map(struct pipe_context *pipe,
|
||||||
{
|
{
|
||||||
struct i915_context *i915 = i915_context(pipe);
|
struct i915_context *i915 = i915_context(pipe);
|
||||||
struct i915_texture *tex = i915_texture(resource);
|
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;
|
boolean use_staging_texture = FALSE;
|
||||||
struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
|
struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
|
||||||
enum pipe_format format = resource->format;
|
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);
|
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
|
#if 0
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ ilo_context_destroy(struct pipe_context *pipe)
|
||||||
if (ilo->cp)
|
if (ilo->cp)
|
||||||
ilo_cp_destroy(ilo->cp);
|
ilo_cp_destroy(ilo->cp);
|
||||||
|
|
||||||
util_slab_destroy(&ilo->transfer_mempool);
|
slab_destroy(&ilo->transfer_mempool);
|
||||||
|
|
||||||
FREE(ilo);
|
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
|
* initialize first, otherwise it may not be safe to call
|
||||||
* ilo_context_destroy() on errors
|
* ilo_context_destroy() on errors
|
||||||
*/
|
*/
|
||||||
util_slab_create(&ilo->transfer_mempool,
|
slab_create(&ilo->transfer_mempool,
|
||||||
sizeof(struct ilo_transfer), 64, UTIL_SLAB_SINGLETHREADED);
|
sizeof(struct ilo_transfer), 64);
|
||||||
|
|
||||||
ilo->shader_cache = ilo_shader_cache_create();
|
ilo->shader_cache = ilo_shader_cache_create();
|
||||||
ilo->cp = ilo_cp_create(ilo->dev, ilo->winsys, ilo->shader_cache);
|
ilo->cp = ilo_cp_create(ilo->dev, ilo->winsys, ilo->shader_cache);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#define ILO_CONTEXT_H
|
#define ILO_CONTEXT_H
|
||||||
|
|
||||||
#include "pipe/p_context.h"
|
#include "pipe/p_context.h"
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
|
|
||||||
#include "ilo_common.h"
|
#include "ilo_common.h"
|
||||||
#include "ilo_cp.h"
|
#include "ilo_cp.h"
|
||||||
|
|
@ -50,7 +50,7 @@ struct ilo_context {
|
||||||
struct intel_winsys *winsys;
|
struct intel_winsys *winsys;
|
||||||
struct ilo_dev *dev;
|
struct ilo_dev *dev;
|
||||||
|
|
||||||
struct util_slab_mempool transfer_mempool;
|
struct slab_mempool transfer_mempool;
|
||||||
|
|
||||||
struct ilo_cp *cp;
|
struct ilo_cp *cp;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1184,7 +1184,7 @@ ilo_transfer_unmap(struct pipe_context *pipe,
|
||||||
|
|
||||||
pipe_resource_reference(&xfer->base.resource, NULL);
|
pipe_resource_reference(&xfer->base.resource, NULL);
|
||||||
|
|
||||||
util_slab_free(&ilo->transfer_mempool, xfer);
|
slab_free_st(&ilo->transfer_mempool, xfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
|
@ -1200,7 +1200,7 @@ ilo_transfer_map(struct pipe_context *pipe,
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
/* note that xfer is not zero'd */
|
/* note that xfer is not zero'd */
|
||||||
xfer = util_slab_alloc(&ilo->transfer_mempool);
|
xfer = slab_alloc_st(&ilo->transfer_mempool);
|
||||||
if (!xfer) {
|
if (!xfer) {
|
||||||
*transfer = NULL;
|
*transfer = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1226,7 +1226,7 @@ ilo_transfer_map(struct pipe_context *pipe,
|
||||||
|
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
pipe_resource_reference(&xfer->base.resource, NULL);
|
pipe_resource_reference(&xfer->base.resource, NULL);
|
||||||
util_slab_free(&ilo->transfer_mempool, xfer);
|
slab_free_st(&ilo->transfer_mempool, xfer);
|
||||||
*transfer = NULL;
|
*transfer = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -491,9 +491,9 @@ toy_compiler_cleanup(struct toy_compiler *tc)
|
||||||
struct toy_inst *inst, *next;
|
struct toy_inst *inst, *next;
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY_SAFE(inst, next, &tc->instructions, list)
|
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);
|
tc_init_inst_templ(tc);
|
||||||
|
|
||||||
util_slab_create(&tc->mempool, sizeof(struct toy_inst),
|
slab_create(&tc->mempool, sizeof(struct toy_inst),
|
||||||
64, UTIL_SLAB_SINGLETHREADED);
|
64);
|
||||||
|
|
||||||
list_inithead(&tc->instructions);
|
list_inithead(&tc->instructions);
|
||||||
/* instructions are added to the tail */
|
/* instructions are added to the tail */
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#define TOY_COMPILER_H
|
#define TOY_COMPILER_H
|
||||||
|
|
||||||
#include "genhw/genhw.h"
|
#include "genhw/genhw.h"
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
|
|
||||||
#include "ilo_common.h"
|
#include "ilo_common.h"
|
||||||
#include "toy_compiler_reg.h"
|
#include "toy_compiler_reg.h"
|
||||||
|
|
@ -153,7 +153,7 @@ struct toy_compiler {
|
||||||
const struct ilo_dev *dev;
|
const struct ilo_dev *dev;
|
||||||
|
|
||||||
struct toy_inst templ;
|
struct toy_inst templ;
|
||||||
struct util_slab_mempool mempool;
|
struct slab_mempool mempool;
|
||||||
struct list_head instructions;
|
struct list_head instructions;
|
||||||
struct list_head *iter, *iter_next;
|
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;
|
struct toy_inst *new_inst;
|
||||||
|
|
||||||
new_inst = util_slab_alloc(&tc->mempool);
|
new_inst = slab_alloc_st(&tc->mempool);
|
||||||
if (!new_inst)
|
if (!new_inst)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ static inline void
|
||||||
tc_discard_inst(struct toy_compiler *tc, struct toy_inst *inst)
|
tc_discard_inst(struct toy_compiler *tc, struct toy_inst *inst)
|
||||||
{
|
{
|
||||||
list_del(&inst->list);
|
list_del(&inst->list);
|
||||||
util_slab_free(&tc->mempool, inst);
|
slab_free_st(&tc->mempool, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ static void r300_destroy_context(struct pipe_context* context)
|
||||||
rc_destroy_regalloc_state(&r300->fs_regalloc_state);
|
rc_destroy_regalloc_state(&r300->fs_regalloc_state);
|
||||||
|
|
||||||
/* XXX: No way to tell if this was initialized or not? */
|
/* 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() */
|
/* Free the structs allocated in r300_setup_atoms() */
|
||||||
if (r300->aa_state.state) {
|
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;
|
r300->context.destroy = r300_destroy_context;
|
||||||
|
|
||||||
util_slab_create(&r300->pool_transfers,
|
slab_create(&r300->pool_transfers,
|
||||||
sizeof(struct pipe_transfer), 64,
|
sizeof(struct pipe_transfer), 64);
|
||||||
UTIL_SLAB_SINGLETHREADED);
|
|
||||||
|
|
||||||
r300->ctx = rws->ctx_create(rws);
|
r300->ctx = rws->ctx_create(rws);
|
||||||
if (!r300->ctx)
|
if (!r300->ctx)
|
||||||
|
|
|
||||||
|
|
@ -596,7 +596,7 @@ struct r300_context {
|
||||||
unsigned nr_vertex_buffers;
|
unsigned nr_vertex_buffers;
|
||||||
struct u_upload_mgr *uploader;
|
struct u_upload_mgr *uploader;
|
||||||
|
|
||||||
struct util_slab_mempool pool_transfers;
|
struct slab_mempool pool_transfers;
|
||||||
|
|
||||||
/* Stat counter. */
|
/* Stat counter. */
|
||||||
uint64_t flush_counter;
|
uint64_t flush_counter;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "r300_chipset.h"
|
#include "r300_chipset.h"
|
||||||
#include "radeon/radeon_winsys.h"
|
#include "radeon/radeon_winsys.h"
|
||||||
#include "pipe/p_screen.h"
|
#include "pipe/p_screen.h"
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
#include "os/os_thread.h"
|
#include "os/os_thread.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ r300_buffer_transfer_map( struct pipe_context *context,
|
||||||
struct pipe_transfer *transfer;
|
struct pipe_transfer *transfer;
|
||||||
uint8_t *map;
|
uint8_t *map;
|
||||||
|
|
||||||
transfer = util_slab_alloc(&r300->pool_transfers);
|
transfer = slab_alloc_st(&r300->pool_transfers);
|
||||||
transfer->resource = resource;
|
transfer->resource = resource;
|
||||||
transfer->level = level;
|
transfer->level = level;
|
||||||
transfer->usage = usage;
|
transfer->usage = usage;
|
||||||
|
|
@ -129,7 +129,7 @@ r300_buffer_transfer_map( struct pipe_context *context,
|
||||||
map = rws->buffer_map(rbuf->buf, r300->cs, usage);
|
map = rws->buffer_map(rbuf->buf, r300->cs, usage);
|
||||||
|
|
||||||
if (!map) {
|
if (!map) {
|
||||||
util_slab_free(&r300->pool_transfers, transfer);
|
slab_free_st(&r300->pool_transfers, transfer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
|
||||||
{
|
{
|
||||||
struct r300_context *r300 = r300_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 =
|
static const struct u_resource_vtbl r300_buffer_vtbl =
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ static void *r600_buffer_get_transfer(struct pipe_context *ctx,
|
||||||
unsigned offset)
|
unsigned offset)
|
||||||
{
|
{
|
||||||
struct r600_common_context *rctx = (struct r600_common_context*)ctx;
|
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.resource = resource;
|
||||||
transfer->transfer.level = level;
|
transfer->transfer.level = level;
|
||||||
|
|
@ -468,7 +468,7 @@ static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
|
||||||
if (rtransfer->staging)
|
if (rtransfer->staging)
|
||||||
r600_resource_reference(&rtransfer->staging, NULL);
|
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,
|
void r600_buffer_subdata(struct pipe_context *ctx,
|
||||||
|
|
|
||||||
|
|
@ -431,9 +431,8 @@ bool r600_common_context_init(struct r600_common_context *rctx,
|
||||||
struct r600_common_screen *rscreen,
|
struct r600_common_screen *rscreen,
|
||||||
unsigned context_flags)
|
unsigned context_flags)
|
||||||
{
|
{
|
||||||
util_slab_create(&rctx->pool_transfers,
|
slab_create(&rctx->pool_transfers,
|
||||||
sizeof(struct r600_transfer), 64,
|
sizeof(struct r600_transfer), 64);
|
||||||
UTIL_SLAB_SINGLETHREADED);
|
|
||||||
|
|
||||||
rctx->screen = rscreen;
|
rctx->screen = rscreen;
|
||||||
rctx->ws = rscreen->ws;
|
rctx->ws = rscreen->ws;
|
||||||
|
|
@ -533,7 +532,7 @@ void r600_common_context_cleanup(struct r600_common_context *rctx)
|
||||||
u_upload_destroy(rctx->uploader);
|
u_upload_destroy(rctx->uploader);
|
||||||
}
|
}
|
||||||
|
|
||||||
util_slab_destroy(&rctx->pool_transfers);
|
slab_destroy(&rctx->pool_transfers);
|
||||||
|
|
||||||
if (rctx->allocator_zeroed_memory) {
|
if (rctx->allocator_zeroed_memory) {
|
||||||
u_suballocator_destroy(rctx->allocator_zeroed_memory);
|
u_suballocator_destroy(rctx->allocator_zeroed_memory);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
#include "util/u_blitter.h"
|
#include "util/u_blitter.h"
|
||||||
#include "util/list.h"
|
#include "util/list.h"
|
||||||
#include "util/u_range.h"
|
#include "util/u_range.h"
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
#include "util/u_suballoc.h"
|
#include "util/u_suballoc.h"
|
||||||
#include "util/u_transfer.h"
|
#include "util/u_transfer.h"
|
||||||
|
|
||||||
|
|
@ -527,7 +527,7 @@ struct r600_common_context {
|
||||||
|
|
||||||
struct u_upload_mgr *uploader;
|
struct u_upload_mgr *uploader;
|
||||||
struct u_suballocator *allocator_zeroed_memory;
|
struct u_suballocator *allocator_zeroed_memory;
|
||||||
struct util_slab_mempool pool_transfers;
|
struct slab_mempool pool_transfers;
|
||||||
|
|
||||||
/* Current unaccounted memory usage. */
|
/* Current unaccounted memory usage. */
|
||||||
uint64_t vram;
|
uint64_t vram;
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ vc4_context_destroy(struct pipe_context *pctx)
|
||||||
if (vc4->uploader)
|
if (vc4->uploader)
|
||||||
u_upload_destroy(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.cbufs[0], NULL);
|
||||||
pipe_surface_reference(&vc4->framebuffer.zsbuf, 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;
|
vc4->fd = screen->fd;
|
||||||
|
|
||||||
util_slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer),
|
slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer),
|
||||||
16, UTIL_SLAB_SINGLETHREADED);
|
16);
|
||||||
vc4->blitter = util_blitter_create(pctx);
|
vc4->blitter = util_blitter_create(pctx);
|
||||||
if (!vc4->blitter)
|
if (!vc4->blitter)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#include "pipe/p_context.h"
|
#include "pipe/p_context.h"
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
|
|
||||||
#define __user
|
#define __user
|
||||||
#include "vc4_drm.h"
|
#include "vc4_drm.h"
|
||||||
|
|
@ -238,7 +238,7 @@ struct vc4_context {
|
||||||
bool msaa;
|
bool msaa;
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
struct util_slab_mempool transfer_pool;
|
struct slab_mempool transfer_pool;
|
||||||
struct blitter_context *blitter;
|
struct blitter_context *blitter;
|
||||||
|
|
||||||
/** bitfield of VC4_DIRTY_* */
|
/** bitfield of VC4_DIRTY_* */
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ vc4_resource_transfer_unmap(struct pipe_context *pctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe_resource_reference(&ptrans->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 *
|
static struct pipe_resource *
|
||||||
|
|
@ -194,13 +194,13 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
|
||||||
if (usage & PIPE_TRANSFER_WRITE)
|
if (usage & PIPE_TRANSFER_WRITE)
|
||||||
rsc->writes++;
|
rsc->writes++;
|
||||||
|
|
||||||
trans = util_slab_alloc(&vc4->transfer_pool);
|
trans = slab_alloc_st(&vc4->transfer_pool);
|
||||||
if (!trans)
|
if (!trans)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* XXX: Handle DONTBLOCK, DISCARD_RANGE, PERSISTENT, COHERENT. */
|
/* XXX: Handle DONTBLOCK, DISCARD_RANGE, PERSISTENT, COHERENT. */
|
||||||
|
|
||||||
/* util_slab_alloc() doesn't zero: */
|
/* slab_alloc_st() doesn't zero: */
|
||||||
memset(trans, 0, sizeof(*trans));
|
memset(trans, 0, sizeof(*trans));
|
||||||
ptrans = &trans->base;
|
ptrans = &trans->base;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
|
||||||
if (doflushwait)
|
if (doflushwait)
|
||||||
ctx->flush(ctx, NULL, 0);
|
ctx->flush(ctx, NULL, 0);
|
||||||
|
|
||||||
trans = util_slab_alloc(&vctx->texture_transfer_pool);
|
trans = slab_alloc_st(&vctx->texture_transfer_pool);
|
||||||
if (!trans)
|
if (!trans)
|
||||||
return NULL;
|
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,
|
static void virgl_buffer_transfer_flush_region(struct pipe_context *ctx,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
#include "util/u_format.h"
|
#include "util/u_format.h"
|
||||||
#include "util/u_transfer.h"
|
#include "util/u_transfer.h"
|
||||||
#include "util/u_helpers.h"
|
#include "util/u_helpers.h"
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
#include "util/u_upload_mgr.h"
|
#include "util/u_upload_mgr.h"
|
||||||
#include "util/u_blitter.h"
|
#include "util/u_blitter.h"
|
||||||
#include "tgsi/tgsi_text.h"
|
#include "tgsi/tgsi_text.h"
|
||||||
|
|
@ -862,7 +862,7 @@ virgl_context_destroy( struct pipe_context *ctx )
|
||||||
u_upload_destroy(vctx->uploader);
|
u_upload_destroy(vctx->uploader);
|
||||||
util_primconvert_destroy(vctx->primconvert);
|
util_primconvert_destroy(vctx->primconvert);
|
||||||
|
|
||||||
util_slab_destroy(&vctx->texture_transfer_pool);
|
slab_destroy(&vctx->texture_transfer_pool);
|
||||||
FREE(vctx);
|
FREE(vctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -943,8 +943,8 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
|
||||||
virgl_init_so_functions(vctx);
|
virgl_init_so_functions(vctx);
|
||||||
|
|
||||||
list_inithead(&vctx->to_flush_bufs);
|
list_inithead(&vctx->to_flush_bufs);
|
||||||
util_slab_create(&vctx->texture_transfer_pool, sizeof(struct virgl_transfer),
|
slab_create(&vctx->texture_transfer_pool, sizeof(struct virgl_transfer),
|
||||||
16, UTIL_SLAB_SINGLETHREADED);
|
16);
|
||||||
|
|
||||||
vctx->primconvert = util_primconvert_create(&vctx->base, rs->caps.caps.v1.prim_mask);
|
vctx->primconvert = util_primconvert_create(&vctx->base, rs->caps.caps.v1.prim_mask);
|
||||||
vctx->uploader = u_upload_create(&vctx->base, 1024 * 1024,
|
vctx->uploader = u_upload_create(&vctx->base, 1024 * 1024,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
#include "pipe/p_context.h"
|
#include "pipe/p_context.h"
|
||||||
#include "util/u_slab.h"
|
#include "util/slab.h"
|
||||||
#include "util/list.h"
|
#include "util/list.h"
|
||||||
|
|
||||||
struct pipe_screen;
|
struct pipe_screen;
|
||||||
|
|
@ -56,7 +56,7 @@ struct virgl_context {
|
||||||
|
|
||||||
struct pipe_framebuffer_state framebuffer;
|
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 pipe_index_buffer index_buffer;
|
||||||
struct u_upload_mgr *uploader;
|
struct u_upload_mgr *uploader;
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
|
||||||
if (doflushwait)
|
if (doflushwait)
|
||||||
ctx->flush(ctx, NULL, 0);
|
ctx->flush(ctx, NULL, 0);
|
||||||
|
|
||||||
trans = util_slab_alloc(&vctx->texture_transfer_pool);
|
trans = slab_alloc_st(&vctx->texture_transfer_pool);
|
||||||
if (!trans)
|
if (!trans)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -235,7 +235,7 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
|
||||||
if (trans->resolve_tmp)
|
if (trans->resolve_tmp)
|
||||||
pipe_resource_reference((struct pipe_resource **)&trans->resolve_tmp, NULL);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue