summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2010-10-05 08:42:42 -0400
committerJerome Glisse <jglisse@redhat.com>2010-10-05 10:42:56 -0400
commit12d16e5f14237d86315bf5a5d6a7cf0619a7334e (patch)
tree3f5aacedc4471c5727e6fcf036bf35b1a1f24ac6 /src/gallium/winsys
parentbf21b7006c63c3dc47045c22d4f372dfe6c7ce67 (diff)
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 <jglisse@redhat.com>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/r600/drm/r600_hw_context.c37
-rw-r--r--src/gallium/winsys/r600/drm/r600_priv.h2
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 {