panfrost: XML-ify the compute job descriptor

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6797>
This commit is contained in:
Boris Brezillon 2020-09-08 19:41:51 +02:00 committed by Alyssa Rosenzweig
parent 54d716a034
commit d289209ea6
9 changed files with 318 additions and 324 deletions

View file

@ -78,22 +78,6 @@ panfrost_vt_emit_shared_memory(struct panfrost_batch *batch)
return t.gpu; return t.gpu;
} }
void
panfrost_vt_update_primitive_size(struct panfrost_context *ctx,
bool points,
union midgard_primitive_size *primitive_size)
{
struct panfrost_rasterizer *rasterizer = ctx->rasterizer;
if (!panfrost_writes_point_size(ctx)) {
float val = points ?
rasterizer->base.point_size :
rasterizer->base.line_width;
primitive_size->constant = val;
}
}
/* Gets a GPU address for the associated index buffer. Only gauranteed to be /* Gets a GPU address for the associated index buffer. Only gauranteed to be
* good for the duration of the draw (transient), could last longer. Also get * good for the duration of the draw (transient), could last longer. Also get
* the bounds on the index buffer for the range accessed by the draw. We do * the bounds on the index buffer for the range accessed by the draw. We do
@ -1787,46 +1771,21 @@ panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
void void
panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch, panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
struct mali_vertex_tiler_prefix *vertex_prefix, void *vertex_job,
struct mali_draw_packed *vertex_draw, void *tiler_job)
struct mali_vertex_tiler_prefix *tiler_prefix,
struct mali_draw_packed *tiler_draw,
union midgard_primitive_size *primitive_size)
{ {
struct panfrost_context *ctx = batch->ctx; struct panfrost_context *ctx = batch->ctx;
struct panfrost_device *device = pan_device(ctx->base.screen); struct panfrost_device *device = pan_device(ctx->base.screen);
bool wallpapering = ctx->wallpaper_batch && batch->scoreboard.tiler_dep; bool wallpapering = ctx->wallpaper_batch && batch->scoreboard.tiler_dep;
struct bifrost_payload_vertex bifrost_vertex = {0,}; void *vp = vertex_job + MALI_JOB_HEADER_LENGTH;
struct bifrost_payload_tiler bifrost_tiler = {0,}; size_t vp_size = MALI_COMPUTE_JOB_LENGTH -
struct midgard_payload_vertex_tiler midgard_vertex = {0,}; MALI_JOB_HEADER_LENGTH;
struct midgard_payload_vertex_tiler midgard_tiler = {0,}; void *tp = tiler_job + MALI_JOB_HEADER_LENGTH;
void *vp, *tp; bool is_bifrost = device->quirks & IS_BIFROST;
size_t vp_size, tp_size; size_t tp_size = (is_bifrost ?
MALI_BIFROST_TILER_JOB_LENGTH :
if (device->quirks & IS_BIFROST) { MALI_MIDGARD_TILER_JOB_LENGTH) -
bifrost_vertex.prefix = *vertex_prefix; MALI_JOB_HEADER_LENGTH;
memcpy(&bifrost_vertex.postfix, vertex_draw, MALI_DRAW_LENGTH);
vp = &bifrost_vertex;
vp_size = sizeof(bifrost_vertex);
bifrost_tiler.prefix = *tiler_prefix;
bifrost_tiler.primitive_size = *primitive_size;
bifrost_tiler.tiler_meta = panfrost_batch_get_bifrost_tiler(batch, ~0);
memcpy(&bifrost_tiler.postfix, tiler_draw, MALI_DRAW_LENGTH);
tp = &bifrost_tiler;
tp_size = sizeof(bifrost_tiler);
} else {
midgard_vertex.prefix = *vertex_prefix;
memcpy(&midgard_vertex.postfix, vertex_draw, MALI_DRAW_LENGTH);
vp = &midgard_vertex;
vp_size = sizeof(midgard_vertex);
midgard_tiler.prefix = *tiler_prefix;
memcpy(&midgard_tiler.postfix, tiler_draw, MALI_DRAW_LENGTH);
midgard_tiler.primitive_size = *primitive_size;
tp = &midgard_tiler;
tp_size = sizeof(midgard_tiler);
}
if (wallpapering) { if (wallpapering) {
/* Inject in reverse order, with "predicted" job indices. /* Inject in reverse order, with "predicted" job indices.

View file

@ -84,16 +84,8 @@ panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
void void
panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch, panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
struct mali_vertex_tiler_prefix *vertex_prefix, void *vertex_job,
struct mali_draw_packed *vertex_draw, void *tiler_job);
struct mali_vertex_tiler_prefix *tiler_prefix,
struct mali_draw_packed *tiler_draw,
union midgard_primitive_size *primitive_size);
void
panfrost_vt_update_primitive_size(struct panfrost_context *ctx,
bool points,
union midgard_primitive_size *primitive_size);
mali_ptr mali_ptr
panfrost_emit_sample_locations(struct panfrost_batch *batch); panfrost_emit_sample_locations(struct panfrost_batch *batch);

View file

@ -104,9 +104,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
ctx->compute_grid = info; ctx->compute_grid = info;
/* TODO: Stub */ /* TODO: Stub */
struct midgard_payload_vertex_tiler payload = { 0 }; struct mali_compute_job_packed job = { 0 };
struct mali_invocation_packed invocation;
struct mali_draw_packed postfix;
/* We implement OpenCL inputs as uniforms (or a UBO -- same thing), so /* We implement OpenCL inputs as uniforms (or a UBO -- same thing), so
* reuse the graphics path for this by lowering to Gallium */ * reuse the graphics path for this by lowering to Gallium */
@ -121,7 +119,25 @@ panfrost_launch_grid(struct pipe_context *pipe,
if (info->input) if (info->input)
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, &ubuf); pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, &ubuf);
pan_pack(&postfix, DRAW, cfg) { /* Invoke according to the grid info */
void *invocation =
pan_section_ptr(&job, COMPUTE_JOB, INVOCATION);
panfrost_pack_work_groups_compute(invocation,
info->grid[0], info->grid[1],
info->grid[2],
info->block[0], info->block[1],
info->block[2],
false);
pan_section_pack(&job, COMPUTE_JOB, PARAMETERS, cfg) {
cfg.job_task_split =
util_logbase2_ceil(info->block[0] + 1) +
util_logbase2_ceil(info->block[1] + 1) +
util_logbase2_ceil(info->block[2] + 1);
}
pan_section_pack(&job, COMPUTE_JOB, DRAW, cfg) {
cfg.unknown_1 = (dev->quirks & IS_BIFROST) ? 0x2 : 0x6; cfg.unknown_1 = (dev->quirks & IS_BIFROST) ? 0x2 : 0x6;
cfg.state = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_COMPUTE); cfg.state = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_COMPUTE);
cfg.shared = panfrost_emit_shared_memory(batch, info); cfg.shared = panfrost_emit_shared_memory(batch, info);
@ -133,28 +149,12 @@ panfrost_launch_grid(struct pipe_context *pipe,
PIPE_SHADER_COMPUTE); PIPE_SHADER_COMPUTE);
} }
unsigned magic =
util_logbase2_ceil(info->block[0] + 1) +
util_logbase2_ceil(info->block[1] + 1) +
util_logbase2_ceil(info->block[2] + 1);
payload.prefix.primitive.opaque[0] = (magic) << 26; /* XXX */
memcpy(&payload.postfix, &postfix, sizeof(postfix));
/* Invoke according to the grid info */
panfrost_pack_work_groups_compute(&invocation,
info->grid[0], info->grid[1],
info->grid[2],
info->block[0], info->block[1],
info->block[2],
false);
payload.prefix.invocation = invocation;
panfrost_new_job(&batch->pool, &batch->scoreboard, panfrost_new_job(&batch->pool, &batch->scoreboard,
MALI_JOB_TYPE_COMPUTE, true, 0, &payload, MALI_JOB_TYPE_COMPUTE, true, 0,
sizeof(payload), false); ((void *)&job) + MALI_JOB_HEADER_LENGTH,
MALI_COMPUTE_JOB_LENGTH -
MALI_JOB_HEADER_LENGTH,
false);
panfrost_flush_all_batches(ctx, 0); panfrost_flush_all_batches(ctx, 0);
} }

View file

@ -277,6 +277,132 @@ panfrost_translate_index_size(unsigned size)
} }
} }
static void
panfrost_draw_emit_vertex(struct panfrost_batch *batch,
const struct pipe_draw_info *info,
void *invocation_template,
mali_ptr shared_mem, mali_ptr vs_vary,
mali_ptr varyings, void *job)
{
struct panfrost_context *ctx = batch->ctx;
struct panfrost_device *device = pan_device(ctx->base.screen);
void *section =
pan_section_ptr(job, COMPUTE_JOB, INVOCATION);
memcpy(section, invocation_template, MALI_INVOCATION_LENGTH);
pan_section_pack(job, COMPUTE_JOB, PARAMETERS, cfg) {
cfg.job_task_split = 5;
}
pan_section_pack(job, COMPUTE_JOB, DRAW, cfg) {
cfg.unknown_1 = (device->quirks & IS_BIFROST) ? 0x2 : 0x6;
cfg.state = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_VERTEX);
cfg.attributes = panfrost_emit_vertex_data(batch, &cfg.attribute_buffers);
cfg.varyings = vs_vary;
cfg.varying_buffers = varyings;
cfg.shared = shared_mem;
pan_emit_draw_descs(batch, &cfg, PIPE_SHADER_VERTEX);
}
}
static void
panfrost_emit_primitive_size(struct panfrost_context *ctx,
bool points, mali_ptr size_array,
void *prim_size)
{
struct panfrost_rasterizer *rast = ctx->rasterizer;
pan_pack(prim_size, PRIMITIVE_SIZE, cfg) {
if (panfrost_writes_point_size(ctx)) {
cfg.size_array = size_array;
} else {
cfg.constant = points ?
rast->base.point_size :
rast->base.line_width;
}
}
}
static void
panfrost_draw_emit_tiler(struct panfrost_batch *batch,
const struct pipe_draw_info *info,
void *invocation_template,
mali_ptr shared_mem, mali_ptr indices,
mali_ptr fs_vary, mali_ptr varyings,
mali_ptr pos, mali_ptr psiz, void *job)
{
struct panfrost_context *ctx = batch->ctx;
struct pipe_rasterizer_state *rast = &ctx->rasterizer->base;
struct panfrost_device *device = pan_device(ctx->base.screen);
bool is_bifrost = device->quirks & IS_BIFROST;
void *section = is_bifrost ?
pan_section_ptr(job, BIFROST_TILER_JOB, INVOCATION) :
pan_section_ptr(job, MIDGARD_TILER_JOB, INVOCATION);
memcpy(section, invocation_template, MALI_INVOCATION_LENGTH);
section = is_bifrost ?
pan_section_ptr(job, BIFROST_TILER_JOB, PRIMITIVE) :
pan_section_ptr(job, MIDGARD_TILER_JOB, PRIMITIVE);
pan_pack(section, PRIMITIVE, cfg) {
cfg.draw_mode = pan_draw_mode(info->mode);
cfg.point_size_array = panfrost_writes_point_size(ctx);
cfg.first_provoking_vertex = rast->flatshade_first;
cfg.primitive_restart = info->primitive_restart;
cfg.unknown_3 = 6;
if (info->index_size) {
cfg.index_type = panfrost_translate_index_size(info->index_size);
cfg.indices = indices;
cfg.base_vertex_offset = info->index_bias - ctx->offset_start;
cfg.index_count = info->count;
} else {
cfg.index_count = info->count_from_stream_output ?
pan_so_target(info->count_from_stream_output)->offset :
ctx->vertex_count;
}
}
bool points = info->mode == PIPE_PRIM_POINTS;
void *prim_size = is_bifrost ?
pan_section_ptr(job, BIFROST_TILER_JOB, PRIMITIVE_SIZE) :
pan_section_ptr(job, MIDGARD_TILER_JOB, PRIMITIVE_SIZE);
if (is_bifrost)
panfrost_emit_primitive_size(ctx, points, psiz, prim_size);
section = is_bifrost ?
pan_section_ptr(job, BIFROST_TILER_JOB, DRAW) :
pan_section_ptr(job, MIDGARD_TILER_JOB, DRAW);
pan_pack(section, DRAW, cfg) {
cfg.unknown_1 = (device->quirks & IS_BIFROST) ? 0x3 : 0x7;
cfg.front_face_ccw = rast->front_ccw;
cfg.cull_front_face = rast->cull_face & PIPE_FACE_FRONT;
cfg.cull_back_face = rast->cull_face & PIPE_FACE_BACK;
cfg.position = pos;
cfg.state = panfrost_emit_frag_shader_meta(batch);
cfg.viewport = panfrost_emit_viewport(batch);
cfg.varyings = fs_vary;
cfg.varying_buffers = varyings;
cfg.shared = shared_mem;
pan_emit_draw_descs(batch, &cfg, PIPE_SHADER_FRAGMENT);
if (ctx->occlusion_query) {
cfg.occlusion_query = MALI_OCCLUSION_MODE_PREDICATE;
cfg.occlusion = ctx->occlusion_query->bo->gpu;
panfrost_batch_add_bo(ctx->batch, ctx->occlusion_query->bo,
PAN_BO_ACCESS_SHARED |
PAN_BO_ACCESS_RW |
PAN_BO_ACCESS_FRAGMENT);
}
}
if (!is_bifrost)
panfrost_emit_primitive_size(ctx, points, psiz, prim_size);
}
static void static void
panfrost_draw_vbo( panfrost_draw_vbo(
struct pipe_context *pipe, struct pipe_context *pipe,
@ -328,49 +454,33 @@ panfrost_draw_vbo(
ctx->instance_count = info->instance_count; ctx->instance_count = info->instance_count;
ctx->active_prim = info->mode; ctx->active_prim = info->mode;
struct mali_vertex_tiler_prefix vertex_prefix = { 0 }, tiler_prefix = { 0 }; /* bifrost tiler is bigger than midgard's one, so let's use it as a
struct mali_draw_packed vertex_postfix, tiler_postfix; * generic container for both.
struct mali_primitive_packed primitive; */
struct mali_invocation_packed invocation; struct mali_bifrost_tiler_job_packed tiler = {};
union midgard_primitive_size primitive_size; struct mali_compute_job_packed vertex = {};
unsigned vertex_count = ctx->vertex_count; unsigned vertex_count = ctx->vertex_count;
bool is_bifrost = device->quirks & IS_BIFROST;
mali_ptr shared_mem = (device->quirks & IS_BIFROST) ? mali_ptr shared_mem = is_bifrost ?
panfrost_vt_emit_shared_memory(batch) : panfrost_vt_emit_shared_memory(batch) :
panfrost_batch_reserve_framebuffer(batch); panfrost_batch_reserve_framebuffer(batch);
struct pipe_rasterizer_state *rast = &ctx->rasterizer->base;
unsigned min_index = 0, max_index = 0; unsigned min_index = 0, max_index = 0;
mali_ptr indices = 0;
pan_pack(&primitive, PRIMITIVE, cfg) { if (info->index_size) {
cfg.draw_mode = pan_draw_mode(mode); indices = panfrost_get_index_buffer_bounded(ctx, info,
cfg.point_size_array = panfrost_writes_point_size(ctx); &min_index,
cfg.first_provoking_vertex = rast->flatshade_first; &max_index);
cfg.primitive_restart = info->primitive_restart;
cfg.unknown_3 = 6;
if (info->index_size) { /* Use the corresponding values */
cfg.index_type = panfrost_translate_index_size(info->index_size); vertex_count = max_index - min_index + 1;
cfg.indices = panfrost_get_index_buffer_bounded(ctx, info, ctx->offset_start = min_index + info->index_bias;
&min_index, &max_index); } else {
ctx->offset_start = info->start;
/* Use the corresponding values */
vertex_count = max_index - min_index + 1;
ctx->offset_start = min_index + info->index_bias;
cfg.base_vertex_offset = -min_index;
cfg.index_count = info->count;
} else {
ctx->offset_start = info->start;
cfg.index_count = info->count_from_stream_output ?
pan_so_target(info->count_from_stream_output)->offset :
ctx->vertex_count;
}
} }
vertex_prefix.primitive.opaque[0] = (5) << 26; /* XXX */
memcpy(&tiler_prefix.primitive, &primitive, sizeof(primitive));
/* Encode the padded vertex count */ /* Encode the padded vertex count */
if (info->instance_count > 1) if (info->instance_count > 1)
@ -380,12 +490,10 @@ panfrost_draw_vbo(
panfrost_statistics_record(ctx, info); panfrost_statistics_record(ctx, info);
struct mali_invocation_packed invocation;
panfrost_pack_work_groups_compute(&invocation, panfrost_pack_work_groups_compute(&invocation,
1, vertex_count, info->instance_count, 1, vertex_count, info->instance_count,
1, 1, 1, true); 1, 1, 1, true);
vertex_prefix.invocation = invocation;
tiler_prefix.invocation = invocation;
/* Emit all sort of descriptors. */ /* Emit all sort of descriptors. */
mali_ptr varyings = 0, vs_vary = 0, fs_vary = 0, pos = 0, psiz = 0; mali_ptr varyings = 0, vs_vary = 0, fs_vary = 0, pos = 0, psiz = 0;
@ -396,47 +504,12 @@ panfrost_draw_vbo(
&vs_vary, &fs_vary, &varyings, &vs_vary, &fs_vary, &varyings,
&pos, &psiz); &pos, &psiz);
pan_pack(&vertex_postfix, DRAW, cfg) {
cfg.unknown_1 = (device->quirks & IS_BIFROST) ? 0x2 : 0x6;
cfg.state = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_VERTEX);
cfg.attributes = panfrost_emit_vertex_data(batch, &cfg.attribute_buffers);
cfg.varyings = vs_vary;
cfg.varying_buffers = varyings;
cfg.shared = shared_mem;
pan_emit_draw_descs(batch, &cfg, PIPE_SHADER_VERTEX);
}
pan_pack(&tiler_postfix, DRAW, cfg) {
cfg.unknown_1 = (device->quirks & IS_BIFROST) ? 0x3 : 0x7;
cfg.front_face_ccw = rast->front_ccw;
cfg.cull_front_face = rast->cull_face & PIPE_FACE_FRONT;
cfg.cull_back_face = rast->cull_face & PIPE_FACE_BACK;
cfg.position = pos;
cfg.state = panfrost_emit_frag_shader_meta(batch);
cfg.viewport = panfrost_emit_viewport(batch);
cfg.varyings = fs_vary;
cfg.varying_buffers = varyings;
cfg.shared = shared_mem;
pan_emit_draw_descs(batch, &cfg, PIPE_SHADER_FRAGMENT);
if (ctx->occlusion_query) {
cfg.occlusion_query = MALI_OCCLUSION_MODE_PREDICATE;
cfg.occlusion = ctx->occlusion_query->bo->gpu;
panfrost_batch_add_bo(ctx->batch, ctx->occlusion_query->bo,
PAN_BO_ACCESS_SHARED |
PAN_BO_ACCESS_RW |
PAN_BO_ACCESS_FRAGMENT);
}
}
primitive_size.pointer = psiz;
panfrost_vt_update_primitive_size(ctx, info->mode == PIPE_PRIM_POINTS, &primitive_size);
/* Fire off the draw itself */ /* Fire off the draw itself */
panfrost_emit_vertex_tiler_jobs(batch, &vertex_prefix, &vertex_postfix, panfrost_draw_emit_vertex(batch, info, &invocation, shared_mem,
&tiler_prefix, &tiler_postfix, vs_vary, varyings, &vertex);
&primitive_size); panfrost_draw_emit_tiler(batch, info, &invocation, shared_mem, indices,
fs_vary, varyings, pos, psiz, &tiler);
panfrost_emit_vertex_tiler_jobs(batch, &vertex, &tiler);
/* Adjust the batch stack size based on the new shader stack sizes. */ /* Adjust the batch stack size based on the new shader stack sizes. */
panfrost_batch_adjust_stack_size(batch); panfrost_batch_adjust_stack_size(batch);

View file

@ -188,18 +188,13 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog,
memcpy(shader->cpu, prog.compiled.data, prog.compiled.size); memcpy(shader->cpu, prog.compiled.data, prog.compiled.size);
struct bifrost_payload_vertex payload = { struct mali_compute_job_packed job;
.prefix = {
.primitive = {
.opaque = { (5) << 26 }
}
},
};
struct mali_draw_packed draw; pan_section_pack(&job, COMPUTE_JOB, PARAMETERS, cfg) {
struct mali_invocation_packed invocation; cfg.job_task_split = 5;
}
pan_pack(&draw, DRAW, cfg) { pan_section_pack(&job, COMPUTE_JOB, DRAW, cfg) {
cfg.unknown_1 = 0x2; cfg.unknown_1 = 0x2;
cfg.shared = shmem->gpu; cfg.shared = shmem->gpu;
cfg.state = shader_desc->gpu; cfg.state = shader_desc->gpu;
@ -211,21 +206,20 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog,
cfg.varying_buffers = var->gpu + 256; cfg.varying_buffers = var->gpu + 256;
} }
void *invocation = pan_section_ptr(&job, COMPUTE_JOB, INVOCATION);
panfrost_pack_work_groups_compute(&invocation, panfrost_pack_work_groups_compute(invocation,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
true); true);
payload.prefix.invocation = invocation;
payload.postfix = draw;
struct panfrost_bo *bos[] = { struct panfrost_bo *bos[] = {
shmem, shader, shader_desc, ubo, var, attr shmem, shader, shader_desc, ubo, var, attr
}; };
bool succ = bit_submit(dev, MALI_JOB_TYPE_VERTEX, &payload, bool succ = bit_submit(dev, MALI_JOB_TYPE_VERTEX,
sizeof(payload), bos, ARRAY_SIZE(bos), debug); ((void *)&job) + MALI_JOB_HEADER_LENGTH,
MALI_COMPUTE_JOB_LENGTH - MALI_JOB_HEADER_LENGTH,
bos, ARRAY_SIZE(bos), debug);
/* Check the output varyings */ /* Check the output varyings */

View file

@ -361,47 +361,6 @@ struct bifrost_blend_rt {
* 4. Otherwise, set magic_divisor = m and extra_flags = 0. * 4. Otherwise, set magic_divisor = m and extra_flags = 0.
*/ */
/* On Bifrost, these fields are the same between the vertex and tiler payloads.
* They also seem to be the same between Bifrost and Midgard. They're shared in
* fused payloads.
*/
struct mali_vertex_tiler_prefix {
struct mali_invocation_packed invocation;
struct mali_primitive_packed primitive;
} __attribute__((packed));
/* Point size / line width can either be specified as a 32-bit float (for
* constant size) or as a [machine word size]-bit GPU pointer (for varying size). If a pointer
* is selected, by setting the appropriate MALI_DRAW_VARYING_SIZE bit in the tiler
* payload, the contents of varying_pointer will be intepreted as an array of
* fp16 sizes, one for each vertex. gl_PointSize is therefore implemented by
* creating a special MALI_R16F varying writing to varying_pointer. */
union midgard_primitive_size {
float constant;
u64 pointer;
};
struct midgard_payload_vertex_tiler {
struct mali_vertex_tiler_prefix prefix;
struct mali_draw_packed postfix;
union midgard_primitive_size primitive_size;
} __attribute__((packed));
struct bifrost_payload_vertex {
struct mali_vertex_tiler_prefix prefix;
struct mali_draw_packed postfix;
} __attribute__((packed));
struct bifrost_payload_tiler {
struct mali_vertex_tiler_prefix prefix;
union midgard_primitive_size primitive_size;
mali_ptr tiler_meta;
u64 zero1, zero2, zero3, zero4, zero5, zero6;
struct mali_draw_packed postfix;
} __attribute__((packed));
/* Purposeful off-by-one in width, height fields. For example, a (64, 64) /* Purposeful off-by-one in width, height fields. For example, a (64, 64)
* texture is stored as (63, 63) in these fields. This adjusts for that. * texture is stored as (63, 63) in these fields. This adjusts for that.
* There's an identical pattern in the framebuffer descriptor. Even vertex * There's an identical pattern in the framebuffer descriptor. Even vertex

View file

@ -736,13 +736,12 @@ bits(u32 word, u32 lo, u32 hi)
} }
static void static void
pandecode_vertex_tiler_prefix(struct mali_vertex_tiler_prefix *p, int job_no, bool graphics) pandecode_invocation(const void *i, bool graphics)
{ {
/* Decode invocation_count. See the comment before the definition of /* Decode invocation_count. See the comment before the definition of
* invocation_count for an explanation. * invocation_count for an explanation.
*/ */
struct mali_invocation_packed invocation_packed = p->invocation; pan_unpack(i, INVOCATION, invocation);
pan_unpack(&invocation_packed, INVOCATION, invocation);
unsigned size_x = bits(invocation.invocations, 0, invocation.size_y_shift) + 1; unsigned size_x = bits(invocation.invocations, 0, invocation.size_y_shift) + 1;
unsigned size_y = bits(invocation.invocations, invocation.size_y_shift, invocation.size_z_shift) + 1; unsigned size_y = bits(invocation.invocations, invocation.size_y_shift, invocation.size_z_shift) + 1;
@ -763,7 +762,7 @@ pandecode_vertex_tiler_prefix(struct mali_vertex_tiler_prefix *p, int job_no, bo
struct mali_invocation_packed ref; struct mali_invocation_packed ref;
panfrost_pack_work_groups_compute(&ref, groups_x, groups_y, groups_z, size_x, size_y, size_z, graphics); panfrost_pack_work_groups_compute(&ref, groups_x, groups_y, groups_z, size_x, size_y, size_z, graphics);
if (memcmp(&ref, &invocation_packed, sizeof(ref))) { if (memcmp(&ref, i, sizeof(ref))) {
pandecode_msg("XXX: non-canonical workgroups packing\n"); pandecode_msg("XXX: non-canonical workgroups packing\n");
DUMP_UNPACKED(INVOCATION, invocation, "Invocation:\n") DUMP_UNPACKED(INVOCATION, invocation, "Invocation:\n")
} }
@ -772,9 +771,12 @@ pandecode_vertex_tiler_prefix(struct mali_vertex_tiler_prefix *p, int job_no, bo
pandecode_log("Invocation (%d, %d, %d) x (%d, %d, %d)\n", pandecode_log("Invocation (%d, %d, %d) x (%d, %d, %d)\n",
size_x, size_y, size_z, size_x, size_y, size_z,
groups_x, groups_y, groups_z); groups_x, groups_y, groups_z);
}
struct mali_primitive_packed prim_packed = p->primitive; static void
pan_unpack(&prim_packed, PRIMITIVE, primitive); pandecode_primitive(const void *p)
{
pan_unpack(p, PRIMITIVE, primitive);
DUMP_UNPACKED(PRIMITIVE, primitive, "Primitive:\n"); DUMP_UNPACKED(PRIMITIVE, primitive, "Primitive:\n");
/* Validate an index buffer is present if we need one. TODO: verify /* Validate an index buffer is present if we need one. TODO: verify
@ -1305,98 +1307,80 @@ pandecode_bifrost_tiler(mali_ptr gpu_va, int job_no)
} }
static void static void
pandecode_primitive_size(union midgard_primitive_size u, bool constant) pandecode_primitive_size(const void *s, bool constant)
{ {
if (u.pointer == 0x0) pan_unpack(s, PRIMITIVE_SIZE, ps);
if (ps.size_array == 0x0)
return; return;
pandecode_log(".primitive_size = {\n"); DUMP_UNPACKED(PRIMITIVE_SIZE, ps, "Primitive Size:\n")
pandecode_indent++;
if (constant) {
pandecode_prop("constant = %f", u.constant);
} else {
MEMORY_PROP((&u), pointer);
}
pandecode_indent--;
pandecode_log("},\n");
} }
static int static void
pandecode_vertex_job_bfr(const struct MALI_JOB_HEADER *h, pandecode_vertex_compute_geometry_job(const struct MALI_JOB_HEADER *h,
const struct pandecode_mapped_memory *mem, const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id) mali_ptr job, int job_no, bool is_bifrost,
unsigned gpu_id)
{ {
struct bifrost_payload_vertex *PANDECODE_PTR_VAR(v, mem, payload); struct mali_compute_job_packed *PANDECODE_PTR_VAR(p, mem, job);
pan_section_unpack(p, COMPUTE_JOB, DRAW, draw);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", is_bifrost, gpu_id);
struct mali_draw_packed draw_packed; pandecode_log("Vertex Job Payload:\n");
memcpy(&draw_packed, &v->postfix, sizeof(draw_packed)); pandecode_indent++;
pan_unpack(&draw_packed, DRAW, draw); pandecode_invocation(pan_section_ptr(p, COMPUTE_JOB, INVOCATION),
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", true, gpu_id); h->type != MALI_JOB_TYPE_COMPUTE);
DUMP_SECTION(COMPUTE_JOB, PARAMETERS, p, "Vertex Job Parameters:\n");
pandecode_vertex_tiler_prefix(&v->prefix, job_no, false); DUMP_UNPACKED(DRAW, draw, "Draw:\n");
DUMP_CL(DRAW, &draw_packed, "Draw:\n"); pandecode_indent--;
pandecode_log("\n");
return sizeof(*v);
} }
static int static void
pandecode_tiler_job_bfr(const struct MALI_JOB_HEADER *h, pandecode_tiler_job_bfr(const struct MALI_JOB_HEADER *h,
const struct pandecode_mapped_memory *mem, const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id) mali_ptr job, int job_no, unsigned gpu_id)
{ {
struct bifrost_payload_tiler *PANDECODE_PTR_VAR(t, mem, payload); struct mali_bifrost_tiler_job_packed *PANDECODE_PTR_VAR(p, mem, job);
pan_section_unpack(p, BIFROST_TILER_JOB, DRAW, draw);
struct mali_draw_packed draw_packed; pan_section_unpack(p, BIFROST_TILER_JOB, TILER, tiler_ptr);
memcpy(&draw_packed, &t->postfix, sizeof(draw_packed));
pan_unpack(&draw_packed, DRAW, draw);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", true, gpu_id); pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", true, gpu_id);
pandecode_bifrost_tiler(t->tiler_meta, job_no);
pandecode_vertex_tiler_prefix(&t->prefix, job_no, false); pandecode_log("Tiler Job Payload:\n");
pandecode_indent++;
pandecode_bifrost_tiler(tiler_ptr.address, job_no);
pandecode_invocation(pan_section_ptr(p, BIFROST_TILER_JOB, INVOCATION), true);
pandecode_primitive(pan_section_ptr(p, BIFROST_TILER_JOB, PRIMITIVE));
/* TODO: gl_PointSize on Bifrost */ /* TODO: gl_PointSize on Bifrost */
pandecode_primitive_size(t->primitive_size, true); pandecode_primitive_size(pan_section_ptr(p, BIFROST_TILER_JOB, PRIMITIVE_SIZE), true);
pan_section_unpack(p, BIFROST_TILER_JOB, PADDING, padding);
if (t->zero1 || t->zero2 || t->zero3 || t->zero4 || t->zero5 DUMP_UNPACKED(DRAW, draw, "Draw:\n");
|| t->zero6) { pandecode_indent--;
pandecode_msg("XXX: tiler only zero tripped\n"); pandecode_log("\n");
pandecode_prop("zero1 = 0x%" PRIx64, t->zero1);
pandecode_prop("zero2 = 0x%" PRIx64, t->zero2);
pandecode_prop("zero3 = 0x%" PRIx64, t->zero3);
pandecode_prop("zero4 = 0x%" PRIx64, t->zero4);
pandecode_prop("zero5 = 0x%" PRIx64, t->zero5);
pandecode_prop("zero6 = 0x%" PRIx64, t->zero6);
}
DUMP_CL(DRAW, &draw_packed, "Draw:\n");
return sizeof(*t);
} }
static int static void
pandecode_vertex_or_tiler_job_mdg(const struct MALI_JOB_HEADER *h, pandecode_tiler_job_mdg(const struct MALI_JOB_HEADER *h,
const struct pandecode_mapped_memory *mem, const struct pandecode_mapped_memory *mem,
mali_ptr payload, int job_no, unsigned gpu_id) mali_ptr job, int job_no, unsigned gpu_id)
{ {
struct midgard_payload_vertex_tiler *PANDECODE_PTR_VAR(v, mem, payload); struct mali_midgard_tiler_job_packed *PANDECODE_PTR_VAR(p, mem, job);
bool is_graphics = (h->type == MALI_JOB_TYPE_VERTEX) || (h->type == MALI_JOB_TYPE_TILER); pan_section_unpack(p, MIDGARD_TILER_JOB, DRAW, draw);
struct mali_draw_packed draw_packed;
memcpy(&draw_packed, &v->postfix, sizeof(draw_packed));
pan_unpack(&draw_packed, DRAW, draw);
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", false, gpu_id); pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", false, gpu_id);
pandecode_vertex_tiler_prefix(&v->prefix, job_no, is_graphics); pandecode_log("Tiler Job Payload:\n", job + MALI_JOB_HEADER_LENGTH);
DUMP_CL(DRAW, &draw_packed, "Draw:\n"); pandecode_indent++;
pandecode_invocation(pan_section_ptr(p, MIDGARD_TILER_JOB, INVOCATION), true);
pandecode_primitive(pan_section_ptr(p, MIDGARD_TILER_JOB, PRIMITIVE));
DUMP_UNPACKED(DRAW, draw, "Draw:\n");
struct mali_primitive_packed prim_packed = v->prefix.primitive; pan_section_unpack(p, MIDGARD_TILER_JOB, PRIMITIVE, primitive);
pan_unpack(&prim_packed, PRIMITIVE, primitive); pandecode_primitive_size(pan_section_ptr(p, MIDGARD_TILER_JOB, PRIMITIVE_SIZE),
primitive.point_size_array == 0);
pandecode_primitive_size(v->primitive_size, primitive.point_size_array == 0); pandecode_indent--;
pandecode_log("\n");
return sizeof(*v);
} }
static void static void
@ -1505,11 +1489,10 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
do { do {
struct pandecode_mapped_memory *mem = struct pandecode_mapped_memory *mem =
pandecode_find_mapped_gpu_mem_containing(jc_gpu_va); pandecode_find_mapped_gpu_mem_containing(jc_gpu_va);
pan_unpack(PANDECODE_PTR(mem, jc_gpu_va, struct mali_job_header_packed), pan_unpack(PANDECODE_PTR(mem, jc_gpu_va, struct mali_job_header_packed),
JOB_HEADER, h); JOB_HEADER, h);
next_job = h.next; next_job = h.next;
mali_ptr payload_ptr = jc_gpu_va + MALI_JOB_HEADER_LENGTH;
pandecode_fetch_gpu_mem(mem, payload_ptr, 64);
int job_no = job_descriptor_number++; int job_no = job_descriptor_number++;
@ -1526,16 +1509,16 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
break; break;
case MALI_JOB_TYPE_TILER: case MALI_JOB_TYPE_TILER:
if (bifrost)
pandecode_tiler_job_bfr(&h, mem, jc_gpu_va, job_no, gpu_id);
else
pandecode_tiler_job_mdg(&h, mem, jc_gpu_va, job_no, gpu_id);
break;
case MALI_JOB_TYPE_VERTEX: case MALI_JOB_TYPE_VERTEX:
case MALI_JOB_TYPE_COMPUTE: case MALI_JOB_TYPE_COMPUTE:
if (bifrost) { pandecode_vertex_compute_geometry_job(&h, mem, jc_gpu_va, job_no,
if (h.type == MALI_JOB_TYPE_TILER) bifrost, gpu_id);
pandecode_tiler_job_bfr(&h, mem, payload_ptr, job_no, gpu_id);
else
pandecode_vertex_job_bfr(&h, mem, payload_ptr, job_no, gpu_id);
} else
pandecode_vertex_or_tiler_job_mdg(&h, mem, payload_ptr, job_no, gpu_id);
break; break;
case MALI_JOB_TYPE_FRAGMENT: case MALI_JOB_TYPE_FRAGMENT:

View file

@ -1096,4 +1096,42 @@
<section name="Header" offset="0" type="Job Header"/> <section name="Header" offset="0" type="Job Header"/>
<section name="Payload" offset="32" type="Write Value Job Payload"/> <section name="Payload" offset="32" type="Write Value Job Payload"/>
</aggregate> </aggregate>
<struct name="Compute Job Parameters" size="6">
<field name="Job Task Split" size="4" start="0:26" type="uint"/>
</struct>
<!-- Compute job also covers vertex and geometry operations -->
<aggregate name="Compute Job">
<section name="Header" offset="0" type="Job Header"/>
<section name="Invocation" offset="32" type="Invocation"/>
<section name="Parameters" offset="40" type="Compute Job Parameters"/>
<section name="Draw" offset="64" type="Draw"/>
</aggregate>
<struct name="Primitive Size">
<field name="Constant" size="32" start="0:0" type="float"/>
<field name="Size Array" size="64" start="0:0" type="uint"/>
</struct>
<aggregate name="Midgard Tiler Job" size="192">
<section name="Header" offset="0" type="Job Header"/>
<section name="Invocation" offset="32" type="Invocation"/>
<section name="Primitive" offset="40" type="Primitive"/>
<section name="Draw" offset="64" type="Draw"/>
<section name="Primitive Size" offset="184" type="Primitive Size"/>
</aggregate>
<struct name="Bifrost Tiler Job Padding" size="12">
</struct>
<aggregate name="Bifrost Tiler Job" size="256">
<section name="Header" offset="0" type="Job Header"/>
<section name="Invocation" offset="32" type="Invocation"/>
<section name="Primitive" offset="40" type="Primitive"/>
<section name="Primitive Size" offset="64" type="Primitive Size"/>
<section name="Tiler" offset="72" type="Bifrost Tiler Pointer"/>
<section name="Padding" offset="80" type="Bifrost Tiler Job Padding"/>
<section name="Draw" offset="128" type="Draw"/>
</aggregate>
</panxml> </panxml>

View file

@ -340,12 +340,9 @@ panfrost_load_midg(
} }
} }
struct midgard_payload_vertex_tiler payload = {}; struct mali_midgard_tiler_job_packed payload = {};
struct mali_primitive_packed primitive;
struct mali_draw_packed draw;
struct mali_invocation_packed invocation;
pan_pack(&draw, DRAW, cfg) { pan_section_pack(&payload, MIDGARD_TILER_JOB, DRAW, cfg) {
cfg.unknown_1 = 0x7; cfg.unknown_1 = 0x7;
cfg.position = coordinates; cfg.position = coordinates;
cfg.textures = panfrost_pool_upload(pool, &texture_t.gpu, sizeof(texture_t.gpu)); cfg.textures = panfrost_pool_upload(pool, &texture_t.gpu, sizeof(texture_t.gpu));
@ -357,17 +354,16 @@ panfrost_load_midg(
cfg.shared = fbd; cfg.shared = fbd;
} }
pan_pack(&primitive, PRIMITIVE, cfg) { pan_section_pack(&payload, MIDGARD_TILER_JOB, PRIMITIVE, cfg) {
cfg.draw_mode = MALI_DRAW_MODE_TRIANGLES; cfg.draw_mode = MALI_DRAW_MODE_TRIANGLES;
cfg.index_count = vertex_count; cfg.index_count = vertex_count;
cfg.unknown_3 = 6; cfg.unknown_3 = 6;
} }
panfrost_pack_work_groups_compute(&invocation, 1, vertex_count, 1, 1, 1, 1, true); panfrost_pack_work_groups_compute(pan_section_ptr(&payload, MIDGARD_TILER_JOB, INVOCATION),
1, vertex_count, 1, 1, 1, 1, true);
payload.prefix.primitive = primitive; panfrost_new_job(pool, scoreboard, MALI_JOB_TYPE_TILER, false, 0,
memcpy(&payload.postfix, &draw, MALI_DRAW_LENGTH); pan_section_ptr(&payload, MIDGARD_TILER_JOB, INVOCATION),
payload.prefix.invocation = invocation; MALI_MIDGARD_TILER_JOB_LENGTH - MALI_JOB_HEADER_LENGTH, true);
panfrost_new_job(pool, scoreboard, MALI_JOB_TYPE_TILER, false, 0, &payload, sizeof(payload), true);
} }