diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-04-14 22:42:44 +0000 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-04-19 22:50:20 +0000 |
commit | e008d4f011b62c38be3e1401315dabc0df7e5b29 (patch) | |
tree | fde722ecb415063c74caa2ec029165a621eac947 /src/gallium/drivers/panfrost/pan_drm.c | |
parent | a151500dd1ab1a75ba1f63e7361fed1e3411780c (diff) |
panfrost: Track BO lifetime with jobs and reference counts
This (fairly large) patch continues work surrounding the panfrost_job
abstraction to improve job lifetime management. In particular, we add
infrastructure to track which BOs are used by a particular job
(currently limited to the vertex buffer BOs), to reference count these
BOs, and to automatically manage the BOs memory based on the reference
count. This set of changes serves as a code cleanup, as a way of future
proofing for allowing flushing BOs, and immediately as a bugfix to
workaround the missing reference counting for vertex buffer BOs.
Meanwhile, there are a few cleanups to vertex buffer handling code
itself, so in the short-term, this allows us to remove the costly VBO
staging workaround, since this patch addresses the underlying causes.
v2: Use pipe_reference for BO reference counting, rather than managing
it ourselves. Don't duplicate hash-table key removal. Fix vertex buffer
counting.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost/pan_drm.c')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_drm.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c index 70d8d7498d4..981b1c6ce13 100644 --- a/src/gallium/drivers/panfrost/pan_drm.c +++ b/src/gallium/drivers/panfrost/pan_drm.c @@ -1,5 +1,6 @@ /* * © Copyright 2019 Collabora, Ltd. + * Copyright 2019 Alyssa Rosenzweig * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -138,6 +139,7 @@ panfrost_drm_import_bo(struct panfrost_screen *screen, struct winsys_handle *wha bo->gem_handle = gem_handle; bo->gpu = (mali_ptr) get_bo_offset.offset; + pipe_reference_init(&bo->reference, 1); // TODO map and unmap on demand? mmap_bo.handle = gem_handle; @@ -227,6 +229,7 @@ panfrost_drm_submit_job(struct panfrost_context *ctx, u64 job_desc, int reqs, st } /* TODO: Add here the transient pools */ + /* TODO: Add here the BOs listed in the panfrost_job */ bo_handles[submit.bo_handle_count++] = ctx->shaders.gem_handle; bo_handles[submit.bo_handle_count++] = ctx->scratchpad.gem_handle; bo_handles[submit.bo_handle_count++] = ctx->tiler_heap.gem_handle; @@ -303,6 +306,9 @@ panfrost_drm_force_flush_fragment(struct panfrost_context *ctx, if (!screen->last_fragment_flushed) { drmSyncobjWait(drm->fd, &ctx->out_sync, 1, INT64_MAX, 0, NULL); screen->last_fragment_flushed = true; + + /* The job finished up, so we're safe to clean it up now */ + panfrost_free_job(ctx, screen->last_job); } if (fence) { |