[Mesa-dev] [PATCH v3 16/25] panfrost: Pass a batch to panfrost_{allocate, upload}_transient()
Boris Brezillon
boris.brezillon at collabora.com
Thu Sep 5 19:41:41 UTC 2019
We need that if we want to emit CMDs to a job that's not currenlty
bound to the context, which in turn will be needed if we want to relax
the job serialization we have right now (only flush jobs when we need
to: on a flush request, or when one job depends on results of other
jobs).
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
---
src/gallium/drivers/panfrost/pan_allocate.c | 10 ++--
src/gallium/drivers/panfrost/pan_allocate.h | 7 +--
src/gallium/drivers/panfrost/pan_compute.c | 10 ++--
src/gallium/drivers/panfrost/pan_context.c | 51 +++++++++++--------
src/gallium/drivers/panfrost/pan_fragment.c | 2 +-
src/gallium/drivers/panfrost/pan_instancing.c | 2 +-
src/gallium/drivers/panfrost/pan_mfbd.c | 3 +-
src/gallium/drivers/panfrost/pan_scoreboard.c | 3 +-
src/gallium/drivers/panfrost/pan_sfbd.c | 2 +-
src/gallium/drivers/panfrost/pan_varyings.c | 8 +--
10 files changed, 57 insertions(+), 41 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_allocate.c b/src/gallium/drivers/panfrost/pan_allocate.c
index beebb0bc6d7e..7938196e3e4f 100644
--- a/src/gallium/drivers/panfrost/pan_allocate.c
+++ b/src/gallium/drivers/panfrost/pan_allocate.c
@@ -40,10 +40,9 @@
* into the pool and copy there */
struct panfrost_transfer
-panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz)
+panfrost_allocate_transient(struct panfrost_batch *batch, size_t sz)
{
- struct panfrost_screen *screen = pan_screen(ctx->base.screen);
- struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+ struct panfrost_screen *screen = pan_screen(batch->ctx->base.screen);
/* Pad the size */
sz = ALIGN_POT(sz, ALIGNMENT);
@@ -90,9 +89,10 @@ panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz)
}
mali_ptr
-panfrost_upload_transient(struct panfrost_context *ctx, const void *data, size_t sz)
+panfrost_upload_transient(struct panfrost_batch *batch, const void *data,
+ size_t sz)
{
- struct panfrost_transfer transfer = panfrost_allocate_transient(ctx, sz);
+ struct panfrost_transfer transfer = panfrost_allocate_transient(batch, sz);
memcpy(transfer.cpu, data, sz);
return transfer.gpu;
}
diff --git a/src/gallium/drivers/panfrost/pan_allocate.h b/src/gallium/drivers/panfrost/pan_allocate.h
index 91c2af9c4f17..f18218fb32a1 100644
--- a/src/gallium/drivers/panfrost/pan_allocate.h
+++ b/src/gallium/drivers/panfrost/pan_allocate.h
@@ -33,7 +33,7 @@
#include "util/list.h"
-struct panfrost_context;
+struct panfrost_batch;
/* Represents a fat pointer for GPU-mapped memory, returned from the transient
* allocator and not used for much else */
@@ -44,9 +44,10 @@ struct panfrost_transfer {
};
struct panfrost_transfer
-panfrost_allocate_transient(struct panfrost_context *ctx, size_t sz);
+panfrost_allocate_transient(struct panfrost_batch *batch, size_t sz);
mali_ptr
-panfrost_upload_transient(struct panfrost_context *ctx, const void *data, size_t sz);
+panfrost_upload_transient(struct panfrost_batch *batch, const void *data,
+ size_t sz);
#endif /* __PAN_ALLOCATE_H__ */
diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c
index 51967fe481ef..4639c1b03c38 100644
--- a/src/gallium/drivers/panfrost/pan_compute.c
+++ b/src/gallium/drivers/panfrost/pan_compute.c
@@ -87,6 +87,9 @@ panfrost_launch_grid(struct pipe_context *pipe,
{
struct panfrost_context *ctx = pan_context(pipe);
+ /* TODO: Do we want a special compute-only batch? */
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+
ctx->compute_grid = info;
struct mali_job_descriptor_header job = {
@@ -113,7 +116,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
};
payload->postfix.framebuffer =
- panfrost_upload_transient(ctx, &compute_fbd, sizeof(compute_fbd));
+ panfrost_upload_transient(batch, &compute_fbd, sizeof(compute_fbd));
/* Invoke according to the grid info */
@@ -123,13 +126,10 @@ panfrost_launch_grid(struct pipe_context *pipe,
/* Upload the payload */
- struct panfrost_transfer transfer = panfrost_allocate_transient(ctx, sizeof(job) + sizeof(*payload));
+ struct panfrost_transfer transfer = panfrost_allocate_transient(batch, sizeof(job) + sizeof(*payload));
memcpy(transfer.cpu, &job, sizeof(job));
memcpy(transfer.cpu + sizeof(job), payload, sizeof(*payload));
- /* TODO: Do we want a special compute-only batch? */
- struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
-
/* Queue the job */
panfrost_scoreboard_queue_compute_job(batch, transfer);
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index fdc62d2f957f..a1b112c08919 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -168,17 +168,19 @@ panfrost_clear(
static mali_ptr
panfrost_attach_vt_mfbd(struct panfrost_context *ctx)
{
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
struct bifrost_framebuffer mfbd = panfrost_emit_mfbd(ctx, ~0);
- return panfrost_upload_transient(ctx, &mfbd, sizeof(mfbd)) | MALI_MFBD;
+ return panfrost_upload_transient(batch, &mfbd, sizeof(mfbd)) | MALI_MFBD;
}
static mali_ptr
panfrost_attach_vt_sfbd(struct panfrost_context *ctx)
{
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
struct mali_single_framebuffer sfbd = panfrost_emit_sfbd(ctx, ~0);
- return panfrost_upload_transient(ctx, &sfbd, sizeof(sfbd)) | MALI_SFBD;
+ return panfrost_upload_transient(batch, &sfbd, sizeof(sfbd)) | MALI_SFBD;
}
static void
@@ -435,6 +437,7 @@ panfrost_default_shader_backend(struct panfrost_context *ctx)
struct panfrost_transfer
panfrost_vertex_tiler_job(struct panfrost_context *ctx, bool is_tiler)
{
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
struct mali_job_descriptor_header job = {
.job_type = is_tiler ? JOB_TYPE_TILER : JOB_TYPE_VERTEX,
.job_descriptor_size = 1,
@@ -442,7 +445,7 @@ panfrost_vertex_tiler_job(struct panfrost_context *ctx, bool is_tiler)
struct midgard_payload_vertex_tiler *payload = is_tiler ? &ctx->payloads[PIPE_SHADER_FRAGMENT] : &ctx->payloads[PIPE_SHADER_VERTEX];
- struct panfrost_transfer transfer = panfrost_allocate_transient(ctx, sizeof(job) + sizeof(*payload));
+ struct panfrost_transfer transfer = panfrost_allocate_transient(batch, sizeof(job) + sizeof(*payload));
memcpy(transfer.cpu, &job, sizeof(job));
memcpy(transfer.cpu + sizeof(job), payload, sizeof(*payload));
return transfer;
@@ -472,10 +475,11 @@ panfrost_writes_point_size(struct panfrost_context *ctx)
static void
panfrost_stage_attributes(struct panfrost_context *ctx)
{
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
struct panfrost_vertex_state *so = ctx->vertex;
size_t sz = sizeof(struct mali_attr_meta) * so->num_elements;
- struct panfrost_transfer transfer = panfrost_allocate_transient(ctx, sz);
+ struct panfrost_transfer transfer = panfrost_allocate_transient(batch, sz);
struct mali_attr_meta *target = (struct mali_attr_meta *) transfer.cpu;
/* Copy as-is for the first pass */
@@ -528,6 +532,7 @@ panfrost_stage_attributes(struct panfrost_context *ctx)
static void
panfrost_upload_sampler_descriptors(struct panfrost_context *ctx)
{
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
size_t desc_size = sizeof(struct mali_sampler_descriptor);
for (int t = 0; t <= PIPE_SHADER_FRAGMENT; ++t) {
@@ -537,7 +542,7 @@ panfrost_upload_sampler_descriptors(struct panfrost_context *ctx)
size_t transfer_size = desc_size * ctx->sampler_count[t];
struct panfrost_transfer transfer =
- panfrost_allocate_transient(ctx, transfer_size);
+ panfrost_allocate_transient(batch, transfer_size);
struct mali_sampler_descriptor *desc =
(struct mali_sampler_descriptor *) transfer.cpu;
@@ -627,13 +632,15 @@ panfrost_upload_tex(
}
}
- return panfrost_upload_transient(ctx, &view->hw,
+ return panfrost_upload_transient(batch, &view->hw,
sizeof(struct mali_texture_descriptor));
}
static void
panfrost_upload_texture_descriptors(struct panfrost_context *ctx)
{
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+
for (int t = 0; t <= PIPE_SHADER_FRAGMENT; ++t) {
mali_ptr trampoline = 0;
@@ -644,7 +651,7 @@ panfrost_upload_texture_descriptors(struct panfrost_context *ctx)
trampolines[i] =
panfrost_upload_tex(ctx, ctx->sampler_views[t][i]);
- trampoline = panfrost_upload_transient(ctx, trampolines, sizeof(uint64_t) * ctx->sampler_view_count[t]);
+ trampoline = panfrost_upload_transient(batch, trampolines, sizeof(uint64_t) * ctx->sampler_view_count[t]);
}
ctx->payloads[t].postfix.texture_trampoline = trampoline;
@@ -790,12 +797,14 @@ panfrost_map_constant_buffer_gpu(
struct pipe_constant_buffer *cb = &buf->cb[index];
struct panfrost_resource *rsrc = pan_resource(cb->buffer);
- if (rsrc)
+ if (rsrc) {
return rsrc->bo->gpu;
- else if (cb->user_buffer)
- return panfrost_upload_transient(ctx, cb->user_buffer, cb->buffer_size);
- else
+ } else if (cb->user_buffer) {
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+ return panfrost_upload_transient(batch, cb->user_buffer, cb->buffer_size);
+ } else {
unreachable("No constant buffer");
+ }
}
/* Compute number of UBOs active (more specifically, compute the highest UBO
@@ -832,9 +841,10 @@ panfrost_patch_shader_state(
* transient uploaded */
if (should_upload) {
- return panfrost_upload_transient(ctx,
- ss->tripipe,
- sizeof(struct mali_shader_meta));
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+
+ return panfrost_upload_transient(batch, ss->tripipe,
+ sizeof(struct mali_shader_meta));
}
/* If we don't need an upload, don't bother */
@@ -1021,7 +1031,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
}
size_t size = sizeof(struct mali_shader_meta) + (sizeof(struct midgard_blend_rt) * rt_count);
- struct panfrost_transfer transfer = panfrost_allocate_transient(ctx, size);
+ struct panfrost_transfer transfer = panfrost_allocate_transient(batch, size);
memcpy(transfer.cpu, &ctx->fragment_shader_core, sizeof(struct mali_shader_meta));
ctx->payloads[PIPE_SHADER_FRAGMENT].postfix._shader_upper = (transfer.gpu) >> 4;
@@ -1112,7 +1122,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
size_t sys_size = sizeof(float) * 4 * ss->sysval_count;
size_t uniform_size = has_uniforms ? (buf->cb[0].buffer_size) : 0;
size_t size = sys_size + uniform_size;
- struct panfrost_transfer transfer = panfrost_allocate_transient(ctx, size);
+ struct panfrost_transfer transfer = panfrost_allocate_transient(batch, size);
/* Upload sysvals requested by the shader */
panfrost_upload_sysvals(ctx, transfer.cpu, ss, i);
@@ -1168,7 +1178,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
ubos[ubo].ptr = gpu >> 2;
}
- mali_ptr ubufs = panfrost_upload_transient(ctx, ubos, sz);
+ mali_ptr ubufs = panfrost_upload_transient(batch, ubos, sz);
postfix->uniforms = transfer.gpu;
postfix->uniform_buffers = ubufs;
@@ -1268,7 +1278,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
view.clip_maxz = maxz;
ctx->payloads[PIPE_SHADER_FRAGMENT].postfix.viewport =
- panfrost_upload_transient(ctx,
+ panfrost_upload_transient(batch,
&view,
sizeof(struct mali_viewport));
@@ -1385,7 +1395,7 @@ panfrost_get_index_buffer_mapped(struct panfrost_context *ctx, const struct pipe
} else {
/* Otherwise, we need to upload to transient memory */
const uint8_t *ibuf8 = (const uint8_t *) info->index.user;
- return panfrost_upload_transient(ctx, ibuf8 + offset, info->count * info->index_size);
+ return panfrost_upload_transient(batch, ibuf8 + offset, info->count * info->index_size);
}
}
@@ -2444,13 +2454,14 @@ panfrost_begin_query(struct pipe_context *pipe, struct pipe_query *q)
{
struct panfrost_context *ctx = pan_context(pipe);
struct panfrost_query *query = (struct panfrost_query *) q;
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
switch (query->type) {
case PIPE_QUERY_OCCLUSION_COUNTER:
case PIPE_QUERY_OCCLUSION_PREDICATE:
case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
/* Allocate a word for the query results to be stored */
- query->transfer = panfrost_allocate_transient(ctx, sizeof(unsigned));
+ query->transfer = panfrost_allocate_transient(batch, sizeof(unsigned));
ctx->occlusion_query = query;
break;
diff --git a/src/gallium/drivers/panfrost/pan_fragment.c b/src/gallium/drivers/panfrost/pan_fragment.c
index f92bf4e35226..dc89bce1b76b 100644
--- a/src/gallium/drivers/panfrost/pan_fragment.c
+++ b/src/gallium/drivers/panfrost/pan_fragment.c
@@ -108,7 +108,7 @@ panfrost_fragment_job(struct panfrost_context *ctx, bool has_draws)
* shared with 64-bit Bifrost systems, and accordingly there is 4-bytes
* of zero padding in between. */
- struct panfrost_transfer transfer = panfrost_allocate_transient(ctx, sizeof(header) + sizeof(payload));
+ struct panfrost_transfer transfer = panfrost_allocate_transient(batch, sizeof(header) + sizeof(payload));
memcpy(transfer.cpu, &header, sizeof(header));
memcpy(transfer.cpu + sizeof(header), &payload, sizeof(payload));
return transfer.gpu;
diff --git a/src/gallium/drivers/panfrost/pan_instancing.c b/src/gallium/drivers/panfrost/pan_instancing.c
index bcdcbe429394..806823f0da0d 100644
--- a/src/gallium/drivers/panfrost/pan_instancing.c
+++ b/src/gallium/drivers/panfrost/pan_instancing.c
@@ -342,7 +342,7 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch)
/* Upload whatever we emitted and go */
ctx->payloads[PIPE_SHADER_VERTEX].postfix.attributes =
- panfrost_upload_transient(ctx, attrs, k * sizeof(union mali_attr));
+ panfrost_upload_transient(batch, attrs, k * sizeof(union mali_attr));
}
diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c
index c89b0b44a47c..46a28ff6c94c 100644
--- a/src/gallium/drivers/panfrost/pan_mfbd.c
+++ b/src/gallium/drivers/panfrost/pan_mfbd.c
@@ -365,8 +365,9 @@ panfrost_mfbd_upload(
(has_extra ? sizeof(struct bifrost_fb_extra) : 0) +
sizeof(struct bifrost_render_target) * 4;
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
struct panfrost_transfer m_f_trans =
- panfrost_allocate_transient(ctx, total_sz);
+ panfrost_allocate_transient(batch, total_sz);
/* Do the transfer */
diff --git a/src/gallium/drivers/panfrost/pan_scoreboard.c b/src/gallium/drivers/panfrost/pan_scoreboard.c
index 776833a13aba..f0771a2c5b56 100644
--- a/src/gallium/drivers/panfrost/pan_scoreboard.c
+++ b/src/gallium/drivers/panfrost/pan_scoreboard.c
@@ -282,7 +282,8 @@ panfrost_set_value_job(struct panfrost_context *ctx, mali_ptr polygon_list)
.unknown = 0x3,
};
- struct panfrost_transfer transfer = panfrost_allocate_transient(ctx, sizeof(job) + sizeof(payload));
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+ struct panfrost_transfer transfer = panfrost_allocate_transient(batch, sizeof(job) + sizeof(payload));
memcpy(transfer.cpu, &job, sizeof(job));
memcpy(transfer.cpu + sizeof(job), &payload, sizeof(payload));
diff --git a/src/gallium/drivers/panfrost/pan_sfbd.c b/src/gallium/drivers/panfrost/pan_sfbd.c
index 2d12904e9393..835c7dbbf95e 100644
--- a/src/gallium/drivers/panfrost/pan_sfbd.c
+++ b/src/gallium/drivers/panfrost/pan_sfbd.c
@@ -148,5 +148,5 @@ panfrost_sfbd_fragment(struct panfrost_context *ctx, bool has_draws)
if (batch->requirements & PAN_REQ_MSAA)
fb.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
- return panfrost_upload_transient(ctx, &fb, sizeof(fb)) | MALI_SFBD;
+ return panfrost_upload_transient(batch, &fb, sizeof(fb)) | MALI_SFBD;
}
diff --git a/src/gallium/drivers/panfrost/pan_varyings.c b/src/gallium/drivers/panfrost/pan_varyings.c
index 02f2e670eaf6..9dbd1e2ebacf 100644
--- a/src/gallium/drivers/panfrost/pan_varyings.c
+++ b/src/gallium/drivers/panfrost/pan_varyings.c
@@ -39,8 +39,9 @@ panfrost_emit_varyings(
slot->size = stride * count;
slot->shift = slot->extra_flags = 0;
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
struct panfrost_transfer transfer =
- panfrost_allocate_transient(ctx, slot->size);
+ panfrost_allocate_transient(batch, slot->size);
slot->elements = transfer.gpu | MALI_ATTR_LINEAR;
@@ -180,7 +181,8 @@ panfrost_emit_varying_descriptor(
size_t vs_size = sizeof(struct mali_attr_meta) * vs->tripipe->varying_count;
size_t fs_size = sizeof(struct mali_attr_meta) * fs->tripipe->varying_count;
- struct panfrost_transfer trans = panfrost_allocate_transient(ctx,
+ struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
+ struct panfrost_transfer trans = panfrost_allocate_transient(batch,
vs_size + fs_size);
struct pipe_stream_output_info so = vs->stream_output;
@@ -399,7 +401,7 @@ panfrost_emit_varying_descriptor(
}
}
- mali_ptr varyings_p = panfrost_upload_transient(ctx, &varyings, idx * sizeof(union mali_attr));
+ mali_ptr varyings_p = panfrost_upload_transient(batch, &varyings, idx * sizeof(union mali_attr));
ctx->payloads[PIPE_SHADER_VERTEX].postfix.varyings = varyings_p;
ctx->payloads[PIPE_SHADER_FRAGMENT].postfix.varyings = varyings_p;
--
2.21.0
More information about the mesa-dev
mailing list