summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/r600/drm
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2010-09-17 13:37:31 +1000
committerDave Airlie <[email protected]>2010-09-17 15:29:31 +1000
commita927d0477a47e29d72e518880979e11e8c0f98e7 (patch)
tree2f77bc4606b176c52bd8fdb86798059c476e7a35 /src/gallium/winsys/r600/drm
parentda96313afe3cff66d8ae0c9675a6299b3d7510f9 (diff)
r600g: add winsys bo caching.
this adds the bo caching layer and uses it for vertex/index/constant bos. ctx needs to take references on hw bos so the flushing works okay, also needs to flush the maps.
Diffstat (limited to 'src/gallium/winsys/r600/drm')
-rw-r--r--src/gallium/winsys/r600/drm/radeon.c4
-rw-r--r--src/gallium/winsys/r600/drm/radeon_ctx.c44
-rw-r--r--src/gallium/winsys/r600/drm/radeon_priv.h3
-rw-r--r--src/gallium/winsys/r600/drm/radeon_ws_bo.c4
4 files changed, 24 insertions, 31 deletions
diff --git a/src/gallium/winsys/r600/drm/radeon.c b/src/gallium/winsys/r600/drm/radeon.c
index 8a5acf62562..f39d020559c 100644
--- a/src/gallium/winsys/r600/drm/radeon.c
+++ b/src/gallium/winsys/r600/drm/radeon.c
@@ -133,6 +133,9 @@ struct radeon *radeon_new(int fd, unsigned device)
radeon->kman = radeon_bo_pbmgr_create(radeon);
if (!radeon->kman)
return NULL;
+ radeon->cman = pb_cache_manager_create(radeon->kman, 100000);
+ if (!radeon->cman)
+ return NULL;
return radeon;
}
@@ -153,6 +156,7 @@ struct radeon *radeon_decref(struct radeon *radeon)
}
radeon->mman->destroy(radeon->mman);
+ radeon->cman->destroy(radeon->cman);
radeon->kman->destroy(radeon->kman);
drmClose(radeon->fd);
free(radeon);
diff --git a/src/gallium/winsys/r600/drm/radeon_ctx.c b/src/gallium/winsys/r600/drm/radeon_ctx.c
index 4bec79861c4..ca3e40ffdc1 100644
--- a/src/gallium/winsys/r600/drm/radeon_ctx.c
+++ b/src/gallium/winsys/r600/drm/radeon_ctx.c
@@ -34,28 +34,12 @@ static int radeon_ctx_set_bo_new(struct radeon_ctx *ctx, struct radeon_ws_bo *bo
{
if (ctx->nbo >= RADEON_CTX_MAX_PM4)
return -EBUSY;
- radeon_ws_bo_reference(ctx->radeon, &ctx->bo[ctx->nbo], bo);
+ /* take a reference to the kernel bo */
+ radeon_bo_reference(ctx->radeon, &ctx->bo[ctx->nbo], radeon_bo_pb_get_bo(bo->pb));
ctx->nbo++;
return 0;
}
-static struct radeon_ws_bo *radeon_ctx_get_bo(struct radeon_ctx *ctx, unsigned reloc)
-{
- struct radeon_cs_reloc *greloc;
- unsigned i;
- struct radeon_ws_bo *bo;
-
- greloc = (void *)(((u8 *)ctx->reloc) + reloc * 4);
- for (i = 0; i < ctx->nbo; i++) {
- if (radeon_ws_bo_get_handle(ctx->bo[i]) == greloc->handle) {
- radeon_ws_bo_reference(ctx->radeon, &bo, ctx->bo[i]);
- return bo;
- }
- }
- fprintf(stderr, "%s no bo for reloc[%d 0x%08X] %d\n", __func__, reloc, greloc->handle, ctx->nbo);
- return NULL;
-}
-
static void radeon_ctx_get_placement(struct radeon_ctx *ctx, unsigned reloc, u32 *placement)
{
struct radeon_cs_reloc *greloc;
@@ -65,7 +49,7 @@ static void radeon_ctx_get_placement(struct radeon_ctx *ctx, unsigned reloc, u32
placement[1] = 0;
greloc = (void *)(((u8 *)ctx->reloc) + reloc * 4);
for (i = 0; i < ctx->nbo; i++) {
- if (radeon_ws_bo_get_handle(ctx->bo[i]) == greloc->handle) {
+ if (ctx->bo[i]->handle == greloc->handle) {
placement[0] = greloc->read_domain | greloc->write_domain;
placement[1] = placement[0];
return;
@@ -76,7 +60,7 @@ static void radeon_ctx_get_placement(struct radeon_ctx *ctx, unsigned reloc, u32
void radeon_ctx_clear(struct radeon_ctx *ctx)
{
for (int i = 0; i < ctx->nbo; i++) {
- radeon_ws_bo_reference(ctx->radeon, &ctx->bo[i], NULL);
+ radeon_bo_reference(ctx->radeon, &ctx->bo[i], NULL);
}
ctx->ndwords = RADEON_CTX_MAX_PM4;
ctx->cdwords = 0;
@@ -118,7 +102,7 @@ void radeon_ctx_fini(struct radeon_ctx *ctx)
return;
for (i = 0; i < ctx->nbo; i++) {
- radeon_ws_bo_reference(ctx->radeon, &ctx->bo[i], NULL);
+ radeon_bo_reference(ctx->radeon, &ctx->bo[i], NULL);
}
ctx->radeon = radeon_decref(ctx->radeon);
free(ctx->bo);
@@ -131,12 +115,13 @@ static int radeon_ctx_state_bo(struct radeon_ctx *ctx, struct radeon_state *stat
{
unsigned i, j;
int r;
-
+ struct radeon_bo *state_bo;
if (state == NULL)
return 0;
for (i = 0; i < state->nbo; i++) {
for (j = 0; j < ctx->nbo; j++) {
- if (state->bo[i] == ctx->bo[j])
+ state_bo = radeon_bo_pb_get_bo(state->bo[i]->pb);
+ if (state_bo == ctx->bo[j])
break;
}
if (j == ctx->nbo) {
@@ -158,6 +143,8 @@ int radeon_ctx_submit(struct radeon_ctx *ctx)
if (!ctx->cdwords)
return 0;
+
+ radeon_bo_pbmgr_flush_maps(ctx->radeon->kman);
#if 0
for (r = 0; r < ctx->cdwords; r++) {
fprintf(stderr, "0x%08X\n", ctx->pm4[r]);
@@ -310,7 +297,6 @@ void radeon_ctx_dump_bof(struct radeon_ctx *ctx, const char *file)
{
bof_t *bcs, *blob, *array, *bo, *size, *handle, *device_id, *root;
unsigned i;
- void *data;
unsigned bo_size;
root = device_id = bcs = blob = array = bo = size = handle = NULL;
root = bof_object();
@@ -347,7 +333,7 @@ void radeon_ctx_dump_bof(struct radeon_ctx *ctx, const char *file)
bo = bof_object();
if (bo == NULL)
goto out_err;
- bo_size = radeon_ws_bo_get_size(ctx->bo[i]);
+ bo_size = ctx->bo[i]->size;
size = bof_int32(bo_size);
if (size == NULL)
goto out_err;
@@ -355,16 +341,16 @@ void radeon_ctx_dump_bof(struct radeon_ctx *ctx, const char *file)
goto out_err;
bof_decref(size);
size = NULL;
- handle = bof_int32(radeon_ws_bo_get_handle(ctx->bo[i]));
+ handle = bof_int32(ctx->bo[i]->handle);
if (handle == NULL)
goto out_err;
if (bof_object_set(bo, "handle", handle))
goto out_err;
bof_decref(handle);
handle = NULL;
- data = radeon_ws_bo_map(ctx->radeon, ctx->bo[i], 0, NULL);
- blob = bof_blob(bo_size, data);
- radeon_ws_bo_unmap(ctx->radeon, ctx->bo[i]);
+ radeon_bo_map(ctx->radeon, ctx->bo[i]);
+ blob = bof_blob(bo_size, ctx->bo[i]->data);
+ radeon_bo_unmap(ctx->radeon, ctx->bo[i]);
if (blob == NULL)
goto out_err;
if (bof_object_set(bo, "data", blob))
diff --git a/src/gallium/winsys/r600/drm/radeon_priv.h b/src/gallium/winsys/r600/drm/radeon_priv.h
index bbcf8ec4a4b..c284f6aa7d1 100644
--- a/src/gallium/winsys/r600/drm/radeon_priv.h
+++ b/src/gallium/winsys/r600/drm/radeon_priv.h
@@ -75,7 +75,7 @@ struct radeon_ctx {
unsigned nreloc;
struct radeon_cs_reloc *reloc;
unsigned nbo;
- struct radeon_ws_bo **bo;
+ struct radeon_bo **bo;
};
struct radeon {
@@ -89,6 +89,7 @@ struct radeon {
boolean use_mem_constant; /* true for evergreen */
struct pb_manager *mman; /* malloc manager */
struct pb_manager *kman; /* kernel bo manager */
+ struct pb_manager *cman; /* cached bo manager */
};
struct radeon_ws_bo {
diff --git a/src/gallium/winsys/r600/drm/radeon_ws_bo.c b/src/gallium/winsys/r600/drm/radeon_ws_bo.c
index c63e926daba..ccaedb4777d 100644
--- a/src/gallium/winsys/r600/drm/radeon_ws_bo.c
+++ b/src/gallium/winsys/r600/drm/radeon_ws_bo.c
@@ -15,7 +15,9 @@ struct radeon_ws_bo *radeon_ws_bo(struct radeon *radeon,
if (radeon->use_mem_constant && (usage & PIPE_BIND_CONSTANT_BUFFER)) {
man = radeon->mman;
- } else
+ } else if (usage & (PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER))
+ man = radeon->cman;
+ else
man = radeon->kman;
ws_bo->pb = man->create_buffer(man, size, &desc);