[Mesa-dev] [PATCH 5/6] vc4: use the new parent/child pools for transfers
Nicolai Hähnle
nhaehnle at gmail.com
Tue Sep 27 18:21:19 UTC 2016
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
src/gallium/drivers/vc4/vc4_context.c | 5 ++---
src/gallium/drivers/vc4/vc4_context.h | 2 +-
src/gallium/drivers/vc4/vc4_resource.c | 4 ++--
src/gallium/drivers/vc4/vc4_screen.c | 3 +++
src/gallium/drivers/vc4/vc4_screen.h | 3 +++
5 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c
index 3863e44..b780b13 100644
--- a/src/gallium/drivers/vc4/vc4_context.c
+++ b/src/gallium/drivers/vc4/vc4_context.c
@@ -89,21 +89,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);
- slab_destroy(&vc4->transfer_pool);
+ slab_destroy_child(&vc4->transfer_pool);
pipe_surface_reference(&vc4->framebuffer.cbufs[0], NULL);
pipe_surface_reference(&vc4->framebuffer.zsbuf, NULL);
vc4_program_fini(pctx);
ralloc_free(vc4);
}
struct pipe_context *
@@ -132,22 +132,21 @@ 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;
- slab_create(&vc4->transfer_pool, sizeof(struct vc4_transfer),
- 16);
+ slab_create_child(&vc4->transfer_pool, &screen->transfer_pool);
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 87d8c79..0d6b8d0 100644
--- a/src/gallium/drivers/vc4/vc4_context.h
+++ b/src/gallium/drivers/vc4/vc4_context.h
@@ -290,21 +290,21 @@ struct vc4_context {
struct hash_table *jobs;
/**
* Map from vc4_resource to a job writing to that resource.
*
* Primarily for flushing jobs rendering to textures that are now
* being read from.
*/
struct hash_table *write_jobs;
- struct slab_mempool transfer_pool;
+ struct slab_child_pool transfer_pool;
struct blitter_context *blitter;
/** bitfield of VC4_DIRTY_* */
uint32_t dirty;
struct primconvert_context *primconvert;
struct hash_table *fs_cache, *vs_cache;
struct set *fs_inputs_set;
uint32_t next_uncompiled_program_id;
diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c
index bfa8f40..9932bb3 100644
--- a/src/gallium/drivers/vc4/vc4_resource.c
+++ b/src/gallium/drivers/vc4/vc4_resource.c
@@ -113,21 +113,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);
pipe_resource_reference(&trans->ss_resource, NULL);
}
pipe_resource_reference(&ptrans->resource, NULL);
- slab_free_st(&vc4->transfer_pool, ptrans);
+ slab_free(&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));
@@ -189,21 +189,21 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
*/
if (usage & PIPE_TRANSFER_WRITE)
vc4_flush_jobs_reading_resource(vc4, prsc);
else
vc4_flush_jobs_writing_resource(vc4, prsc);
}
if (usage & PIPE_TRANSFER_WRITE)
rsc->writes++;
- trans = slab_alloc_st(&vc4->transfer_pool);
+ trans = slab_alloc(&vc4->transfer_pool);
if (!trans)
return NULL;
/* XXX: Handle DONTBLOCK, DISCARD_RANGE, PERSISTENT, COHERENT. */
/* slab_alloc_st() doesn't zero: */
memset(trans, 0, sizeof(*trans));
ptrans = &trans->base;
pipe_resource_reference(&ptrans->resource, prsc);
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
index 3dc85d5..64bff5d 100644
--- a/src/gallium/drivers/vc4/vc4_screen.c
+++ b/src/gallium/drivers/vc4/vc4_screen.c
@@ -91,20 +91,21 @@ vc4_screen_get_vendor(struct pipe_screen *pscreen)
return "Broadcom";
}
static void
vc4_screen_destroy(struct pipe_screen *pscreen)
{
struct vc4_screen *screen = vc4_screen(pscreen);
util_hash_table_destroy(screen->bo_handles);
vc4_bufmgr_destroy(pscreen);
+ slab_destroy_parent(&screen->transfer_pool);
close(screen->fd);
ralloc_free(pscreen);
}
static int
vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
{
switch (param) {
/* Supported features (boolean caps). */
case PIPE_CAP_VERTEX_COLOR_CLAMPED:
@@ -607,20 +608,22 @@ vc4_screen_create(int fd)
list_inithead(&screen->bo_cache.time_list);
pipe_mutex_init(screen->bo_handles_mutex);
screen->bo_handles = util_hash_table_create(handle_hash, handle_compare);
if (vc4_supports_branches(screen))
screen->has_control_flow = true;
if (!vc4_get_chip_info(screen))
goto fail;
+ slab_create_parent(&screen->transfer_pool, sizeof(struct vc4_transfer), 16);
+
vc4_fence_init(screen);
vc4_debug = debug_get_option_vc4_debug();
if (vc4_debug & VC4_DEBUG_SHADERDB)
vc4_debug |= VC4_DEBUG_NORAST;
#if USE_VC4_SIMULATOR
vc4_simulator_init(screen);
#endif
diff --git a/src/gallium/drivers/vc4/vc4_screen.h b/src/gallium/drivers/vc4/vc4_screen.h
index 36fe1c7..16003cf 100644
--- a/src/gallium/drivers/vc4/vc4_screen.h
+++ b/src/gallium/drivers/vc4/vc4_screen.h
@@ -21,20 +21,21 @@
* IN THE SOFTWARE.
*/
#ifndef VC4_SCREEN_H
#define VC4_SCREEN_H
#include "pipe/p_screen.h"
#include "os/os_thread.h"
#include "state_tracker/drm_driver.h"
#include "util/list.h"
+#include "util/slab.h"
struct vc4_bo;
#define VC4_DEBUG_CL 0x0001
#define VC4_DEBUG_QPU 0x0002
#define VC4_DEBUG_QIR 0x0004
#define VC4_DEBUG_TGSI 0x0008
#define VC4_DEBUG_SHADERDB 0x0010
#define VC4_DEBUG_PERF 0x0020
#define VC4_DEBUG_NORAST 0x0040
@@ -57,20 +58,22 @@ struct vc4_screen {
void *simulator_mem_base;
uint32_t simulator_mem_size;
/** The last seqno we've completed a wait for.
*
* This lets us slightly optimize our waits by skipping wait syscalls
* if we know the job's already done.
*/
uint64_t finished_seqno;
+ struct slab_parent_pool transfer_pool;
+
struct vc4_bo_cache {
/** List of struct vc4_bo freed, by age. */
struct list_head time_list;
/** List of struct vc4_bo freed, per size, by age. */
struct list_head *size_list;
uint32_t size_list_size;
pipe_mutex lock;
uint32_t bo_size;
--
2.7.4
More information about the mesa-dev
mailing list