freedreno: Add private-BO tracking

There are some internally used buffers that we should just attach to
every submit up-front.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25465>
This commit is contained in:
Rob Clark
2023-10-02 10:53:54 -07:00
committed by Marge Bot
parent c6f17d89c7
commit 8a3b4b69a2
6 changed files with 26 additions and 4 deletions
@@ -308,6 +308,8 @@ fd6_context_create(struct pipe_screen *pscreen, void *priv,
fd6_ctx->control_mem =
fd_bo_new(screen->dev, 0x1000, 0, "control");
fd_context_add_private_bo(&fd6_ctx->base, fd6_ctx->control_mem);
memset(fd_bo_map(fd6_ctx->control_mem), 0, sizeof(struct fd6_control));
fd_context_setup_common_vbos(&fd6_ctx->base);
@@ -952,16 +952,13 @@ fd6_emit_restore(struct fd_batch *batch, struct fd_ringbuffer *ring)
struct fd6_context *fd6_ctx = fd6_context(batch->ctx);
struct fd_bo *bcolor_mem = fd6_ctx->bcolor_mem;
OUT_PKT4(ring, REG_A6XX_SP_TP_BORDER_COLOR_BASE_ADDR, 2);
OUT_RELOC(ring, bcolor_mem, 0, 0, 0);
OUT_PKT4(ring, REG_A6XX_SP_PS_TP_BORDER_COLOR_BASE_ADDR, 2);
OUT_RELOC(ring, bcolor_mem, 0, 0, 0);
fd_ringbuffer_attach_bo(ring, bcolor_mem);
fd_ringbuffer_attach_bo(ring, fd6_ctx->control_mem);
if (!batch->nondraw) {
trace_end_state_restore(&batch->trace, ring);
}
@@ -882,6 +882,8 @@ fd6_texture_init(struct pipe_context *pctx) disable_thread_safety_analysis
FD6_MAX_BORDER_COLORS * FD6_BORDER_COLOR_SIZE,
0, "bcolor");
fd_context_add_private_bo(ctx, fd6_ctx->bcolor_mem);
fd6_ctx->tex_cache = _mesa_hash_table_create(NULL, tex_key_hash, tex_key_equals);
util_idalloc_init(&fd6_ctx->tex_ids, 256);
}
@@ -119,6 +119,10 @@ fd_batch_create(struct fd_context *ctx, bool nondraw)
}
}
/* Pre-attach private BOs: */
for (unsigned i = 0; i < ctx->num_private_bos; i++)
fd_ringbuffer_attach_bo(batch->gmem, ctx->private_bos[i]);
batch->subpass = subpass_create(batch);
batch->in_fence_fd = -1;
@@ -323,6 +323,13 @@ fd_context_switch_to(struct fd_context *ctx, struct fd_batch *batch)
}
}
void
fd_context_add_private_bo(struct fd_context *ctx, struct fd_bo *bo)
{
assert(ctx->num_private_bos < ARRAY_SIZE(ctx->private_bos));
ctx->private_bos[ctx->num_private_bos++] = bo;
}
/**
* Return a reference to the current batch, caller must unref.
*/
@@ -447,6 +447,14 @@ struct fd_context {
/* Per vsc pipe bo's (a2xx-a5xx): */
struct fd_bo *vsc_pipe_bo[32] dt;
/* Table of bo's attached to all batches up-front (because they
* are commonly used, and that is easier than attaching on-use).
* In particular, these are driver internal buffers which do not
* participate in batch resource tracking.
*/
struct fd_bo *private_bos[3];
unsigned num_private_bos;
/* Maps generic gallium oriented fd_dirty_3d_state bits to generation
* specific bitmask of state "groups".
*/
@@ -671,6 +679,8 @@ fd_stream_output_target(struct pipe_stream_output_target *target)
return (struct fd_stream_output_target *)target;
}
void fd_context_add_private_bo(struct fd_context *ctx, struct fd_bo *bo);
/* Mark specified non-shader-stage related state as dirty: */
static inline void
fd_context_dirty(struct fd_context *ctx, BITMASK_ENUM(fd_dirty_3d_state) dirty)