From 12d16e5f14237d86315bf5a5d6a7cf0619a7334e Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Tue, 5 Oct 2010 08:42:42 -0400 Subject: r600g: store reloc information in bo structure Allow fast lookup of relocation information & id which was a CPU time consumming operation. Signed-off-by: Jerome Glisse --- src/gallium/winsys/r600/drm/r600_hw_context.c | 37 ++++++++++----------------- src/gallium/winsys/r600/drm/r600_priv.h | 2 ++ 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/gallium/winsys/r600/drm/r600_hw_context.c b/src/gallium/winsys/r600/drm/r600_hw_context.c index bee0446d58..40c612c4ea 100644 --- a/src/gallium/winsys/r600/drm/r600_hw_context.c +++ b/src/gallium/winsys/r600/drm/r600_hw_context.c @@ -707,33 +707,23 @@ out_err: void r600_context_bo_reloc(struct r600_context *ctx, u32 *pm4, struct r600_bo *rbo) { struct radeon_bo *bo; - int i, reloc_id; bo = r600_bo_get_bo(rbo); assert(bo != NULL); - for (i = 0, reloc_id = -1; i < ctx->creloc; i++) { - if (ctx->reloc[i].handle == bo->handle) { - reloc_id = i * sizeof(struct r600_reloc) / 4; - /* set PKT3 to point to proper reloc */ - *pm4 = reloc_id; - break; - } - } - if (reloc_id == -1) { - /* add new relocation */ - if (ctx->creloc >= ctx->nreloc) { - r600_context_flush(ctx); - } - reloc_id = ctx->creloc * sizeof(struct r600_reloc) / 4; - ctx->reloc[ctx->creloc].handle = bo->handle; - ctx->reloc[ctx->creloc].read_domain = RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM; - ctx->reloc[ctx->creloc].write_domain = RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM; - ctx->reloc[ctx->creloc].flags = 0; - radeon_bo_reference(ctx->radeon, &ctx->bo[ctx->creloc], bo); - ctx->creloc++; - /* set PKT3 to point to proper reloc */ - *pm4 = reloc_id; + if (bo->reloc) { + *pm4 = bo->reloc_id; + return; } + bo->reloc = &ctx->reloc[ctx->creloc]; + bo->reloc_id = ctx->creloc * sizeof(struct r600_reloc) / 4; + ctx->reloc[ctx->creloc].handle = bo->handle; + ctx->reloc[ctx->creloc].read_domain = RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM; + ctx->reloc[ctx->creloc].write_domain = RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM; + ctx->reloc[ctx->creloc].flags = 0; + radeon_bo_reference(ctx->radeon, &ctx->bo[ctx->creloc], bo); + ctx->creloc++; + /* set PKT3 to point to proper reloc */ + *pm4 = bo->reloc_id; } void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_state *state) @@ -1045,6 +1035,7 @@ void r600_context_flush(struct r600_context *ctx) /* restart */ radeon_bo_fencelist(ctx->radeon, ctx->bo, ctx->creloc); for (int i = 0; i < ctx->creloc; i++) { + ctx->bo[i]->reloc = NULL; radeon_bo_reference(ctx->radeon, &ctx->bo[i], NULL); } ctx->creloc = 0; diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h index ee48754625..4619207432 100644 --- a/src/gallium/winsys/r600/drm/r600_priv.h +++ b/src/gallium/winsys/r600/drm/r600_priv.h @@ -66,6 +66,8 @@ struct radeon_bo { boolean shared; int64_t last_busy; boolean set_busy; + struct r600_reloc *reloc; + unsigned reloc_id; }; struct r600_bo { -- cgit v1.2.3