panfrost: Unify bifrost_scratchpad with mali_shared_memory

It looks like these are the same structure, so this allows us to reuse
mali_shared_memory across architectures, and dispels with the
Bifrost-specific mystery of the scratchpads... nothing so mysterious
after all, just stack.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3835>
This commit is contained in:
Alyssa Rosenzweig 2020-02-10 08:47:09 -05:00
parent 254f40fd53
commit 6dc105555b
4 changed files with 18 additions and 52 deletions

View file

@ -131,7 +131,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
.shared_workgroup_count = ~0
};
payload->postfix.framebuffer =
payload->postfix.shared_memory =
panfrost_upload_transient(batch, &shared, sizeof(shared));
/* Invoke according to the grid info */

View file

@ -141,6 +141,9 @@ panfrost_clear(
panfrost_batch_clear(batch, buffers, color, depth, stencil);
}
/* TODO: Bifrost requires just a mali_shared_memory, without the rest of the
* framebuffer */
static void
panfrost_attach_vt_framebuffer(struct panfrost_context *ctx)
{
@ -162,7 +165,7 @@ panfrost_attach_vt_framebuffer(struct panfrost_context *ctx)
}
for (unsigned i = 0; i < PIPE_SHADER_TYPES; ++i)
ctx->payloads[i].postfix.framebuffer = batch->framebuffer.gpu;
ctx->payloads[i].postfix.shared_memory = batch->framebuffer.gpu;
}
/* Reset per-frame context, called on context initialisation as well as after
@ -172,7 +175,7 @@ void
panfrost_invalidate_frame(struct panfrost_context *ctx)
{
for (unsigned i = 0; i < PIPE_SHADER_TYPES; ++i)
ctx->payloads[i].postfix.framebuffer = 0;
ctx->payloads[i].postfix.shared_memory = 0;
if (ctx->rasterizer)
ctx->dirty |= PAN_DIRTY_RASTERIZER;

View file

@ -1056,17 +1056,6 @@ struct bifrost_tiler_only {
u64 zero8;
} __attribute__((packed));
struct bifrost_scratchpad {
u32 zero;
u32 flags; // = 0x1f
/* This is a pointer to a CPU-inaccessible buffer, 16 pages, allocated
* during startup. It seems to serve the same purpose as the
* gpu_scratchpad in the SFBD for Midgard, although it's slightly
* larger.
*/
mali_ptr gpu_scratchpad;
} __attribute__((packed));
struct mali_vertex_tiler_postfix {
/* Zero for vertex jobs. Pointer to the position (gl_Position) varying
* output from the vertex shader for tiler jobs.
@ -1100,11 +1089,10 @@ struct mali_vertex_tiler_postfix {
u64 viewport;
u64 occlusion_counter; /* A single bit as far as I can tell */
/* Note: on Bifrost, this isn't actually the FBD. It points to
* bifrost_scratchpad instead. However, it does point to the same thing
* in vertex and tiler jobs.
*/
mali_ptr framebuffer;
/* On Bifrost, this points directly to a mali_shared_memory structure.
* On Midgard, this points to a framebuffer (either SFBD or MFBD as
* tagged), which embeds a mali_shared_memory structure */
mali_ptr shared_memory;
} __attribute__((packed));
struct midgard_payload_vertex_tiler {

View file

@ -1809,29 +1809,6 @@ pandecode_uniforms(mali_ptr uniforms, unsigned uniform_count)
free(ptr);
}
static void
pandecode_scratchpad(uintptr_t pscratchpad, int job_no, char *suffix)
{
struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(pscratchpad);
struct bifrost_scratchpad *PANDECODE_PTR_VAR(scratchpad, mem, pscratchpad);
if (scratchpad->zero) {
pandecode_msg("XXX: scratchpad zero tripped");
pandecode_prop("zero = 0x%x\n", scratchpad->zero);
}
pandecode_log("struct bifrost_scratchpad scratchpad_%"PRIx64"_%d%s = {\n", pscratchpad, job_no, suffix);
pandecode_indent++;
pandecode_prop("flags = 0x%x", scratchpad->flags);
MEMORY_PROP(scratchpad, gpu_scratchpad);
pandecode_indent--;
pandecode_log("};\n");
}
static const char *
shader_type_for_job(unsigned type)
{
@ -2137,14 +2114,15 @@ pandecode_vertex_tiler_postfix_pre(
.rt_count = 1
};
if (is_bifrost)
pandecode_scratchpad(p->framebuffer & ~1, job_no, suffix);
else if (p->framebuffer & MALI_MFBD)
fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->framebuffer) & FBD_MASK, job_no, false, job_type == JOB_TYPE_COMPUTE);
if (is_bifrost) {
pandecode_log_cont("\t/* %X %/\n", p->shared_memory & 1);
pandecode_compute_fbd(p->shared_memory & ~1, job_no);
} else if (p->shared_memory & MALI_MFBD)
fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->shared_memory) & FBD_MASK, job_no, false, job_type == JOB_TYPE_COMPUTE);
else if (job_type == JOB_TYPE_COMPUTE)
pandecode_compute_fbd((u64) (uintptr_t) p->framebuffer, job_no);
pandecode_compute_fbd((u64) (uintptr_t) p->shared_memory, job_no);
else
fbd_info = pandecode_sfbd((u64) (uintptr_t) p->framebuffer, job_no, false, gpu_id);
fbd_info = pandecode_sfbd((u64) (uintptr_t) p->shared_memory, job_no, false, gpu_id);
int varying_count = 0, attribute_count = 0, uniform_count = 0, uniform_buffer_count = 0;
int texture_count = 0, sampler_count = 0;
@ -2309,7 +2287,7 @@ pandecode_vertex_tiler_postfix_pre(
/* MRT blend fields are used whenever MFBD is used, with
* per-RT descriptors */
if (job_type == JOB_TYPE_TILER && p->framebuffer & MALI_MFBD) {
if (job_type == JOB_TYPE_TILER && p->shared_memory & MALI_MFBD) {
void* blend_base = (void *) (s + 1);
for (unsigned i = 0; i < fbd_info.rt_count; i++) {
@ -2759,9 +2737,6 @@ pandecode_fragment_job(const struct pandecode_mapped_memory *mem,
bool is_mfbd = s->framebuffer & MALI_MFBD;
/* Bifrost theoretically may retain support for SFBD on compute jobs,
* but for graphics workloads with a FRAGMENT payload, use MFBD */
if (!is_mfbd && is_bifrost)
pandecode_msg("XXX: Bifrost fragment must use MFBD\n");