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:

committed by
Alyssa Rosenzweig

parent
54d716a034
commit
d289209ea6
@@ -78,22 +78,6 @@ panfrost_vt_emit_shared_memory(struct panfrost_batch *batch)
|
||||
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
|
||||
* 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
|
||||
@@ -1787,46 +1771,21 @@ panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
|
||||
|
||||
void
|
||||
panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
|
||||
struct mali_vertex_tiler_prefix *vertex_prefix,
|
||||
struct mali_draw_packed *vertex_draw,
|
||||
struct mali_vertex_tiler_prefix *tiler_prefix,
|
||||
struct mali_draw_packed *tiler_draw,
|
||||
union midgard_primitive_size *primitive_size)
|
||||
void *vertex_job,
|
||||
void *tiler_job)
|
||||
{
|
||||
struct panfrost_context *ctx = batch->ctx;
|
||||
struct panfrost_device *device = pan_device(ctx->base.screen);
|
||||
bool wallpapering = ctx->wallpaper_batch && batch->scoreboard.tiler_dep;
|
||||
struct bifrost_payload_vertex bifrost_vertex = {0,};
|
||||
struct bifrost_payload_tiler bifrost_tiler = {0,};
|
||||
struct midgard_payload_vertex_tiler midgard_vertex = {0,};
|
||||
struct midgard_payload_vertex_tiler midgard_tiler = {0,};
|
||||
void *vp, *tp;
|
||||
size_t vp_size, tp_size;
|
||||
|
||||
if (device->quirks & IS_BIFROST) {
|
||||
bifrost_vertex.prefix = *vertex_prefix;
|
||||
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);
|
||||
}
|
||||
void *vp = vertex_job + MALI_JOB_HEADER_LENGTH;
|
||||
size_t vp_size = MALI_COMPUTE_JOB_LENGTH -
|
||||
MALI_JOB_HEADER_LENGTH;
|
||||
void *tp = tiler_job + MALI_JOB_HEADER_LENGTH;
|
||||
bool is_bifrost = device->quirks & IS_BIFROST;
|
||||
size_t tp_size = (is_bifrost ?
|
||||
MALI_BIFROST_TILER_JOB_LENGTH :
|
||||
MALI_MIDGARD_TILER_JOB_LENGTH) -
|
||||
MALI_JOB_HEADER_LENGTH;
|
||||
|
||||
if (wallpapering) {
|
||||
/* Inject in reverse order, with "predicted" job indices.
|
||||
|
@@ -84,16 +84,8 @@ panfrost_emit_varying_descriptor(struct panfrost_batch *batch,
|
||||
|
||||
void
|
||||
panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
|
||||
struct mali_vertex_tiler_prefix *vertex_prefix,
|
||||
struct mali_draw_packed *vertex_draw,
|
||||
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);
|
||||
void *vertex_job,
|
||||
void *tiler_job);
|
||||
|
||||
mali_ptr
|
||||
panfrost_emit_sample_locations(struct panfrost_batch *batch);
|
||||
|
@@ -104,9 +104,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
|
||||
ctx->compute_grid = info;
|
||||
|
||||
/* TODO: Stub */
|
||||
struct midgard_payload_vertex_tiler payload = { 0 };
|
||||
struct mali_invocation_packed invocation;
|
||||
struct mali_draw_packed postfix;
|
||||
struct mali_compute_job_packed job = { 0 };
|
||||
|
||||
/* We implement OpenCL inputs as uniforms (or a UBO -- same thing), so
|
||||
* reuse the graphics path for this by lowering to Gallium */
|
||||
@@ -121,7 +119,25 @@ panfrost_launch_grid(struct pipe_context *pipe,
|
||||
if (info->input)
|
||||
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.state = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_COMPUTE);
|
||||
cfg.shared = panfrost_emit_shared_memory(batch, info);
|
||||
@@ -133,28 +149,12 @@ panfrost_launch_grid(struct pipe_context *pipe,
|
||||
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,
|
||||
MALI_JOB_TYPE_COMPUTE, true, 0, &payload,
|
||||
sizeof(payload), false);
|
||||
MALI_JOB_TYPE_COMPUTE, true, 0,
|
||||
((void *)&job) + MALI_JOB_HEADER_LENGTH,
|
||||
MALI_COMPUTE_JOB_LENGTH -
|
||||
MALI_JOB_HEADER_LENGTH,
|
||||
false);
|
||||
panfrost_flush_all_batches(ctx, 0);
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
panfrost_draw_vbo(
|
||||
struct pipe_context *pipe,
|
||||
@@ -328,49 +454,33 @@ panfrost_draw_vbo(
|
||||
ctx->instance_count = info->instance_count;
|
||||
ctx->active_prim = info->mode;
|
||||
|
||||
struct mali_vertex_tiler_prefix vertex_prefix = { 0 }, tiler_prefix = { 0 };
|
||||
struct mali_draw_packed vertex_postfix, tiler_postfix;
|
||||
struct mali_primitive_packed primitive;
|
||||
struct mali_invocation_packed invocation;
|
||||
union midgard_primitive_size primitive_size;
|
||||
/* bifrost tiler is bigger than midgard's one, so let's use it as a
|
||||
* generic container for both.
|
||||
*/
|
||||
struct mali_bifrost_tiler_job_packed tiler = {};
|
||||
struct mali_compute_job_packed vertex = {};
|
||||
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_batch_reserve_framebuffer(batch);
|
||||
|
||||
struct pipe_rasterizer_state *rast = &ctx->rasterizer->base;
|
||||
unsigned min_index = 0, max_index = 0;
|
||||
mali_ptr indices = 0;
|
||||
|
||||
pan_pack(&primitive, PRIMITIVE, cfg) {
|
||||
cfg.draw_mode = pan_draw_mode(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) {
|
||||
indices = panfrost_get_index_buffer_bounded(ctx, info,
|
||||
&min_index,
|
||||
&max_index);
|
||||
|
||||
if (info->index_size) {
|
||||
cfg.index_type = panfrost_translate_index_size(info->index_size);
|
||||
cfg.indices = panfrost_get_index_buffer_bounded(ctx, info,
|
||||
&min_index, &max_index);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
/* Use the corresponding values */
|
||||
vertex_count = max_index - min_index + 1;
|
||||
ctx->offset_start = min_index + info->index_bias;
|
||||
} else {
|
||||
ctx->offset_start = info->start;
|
||||
}
|
||||
|
||||
vertex_prefix.primitive.opaque[0] = (5) << 26; /* XXX */
|
||||
memcpy(&tiler_prefix.primitive, &primitive, sizeof(primitive));
|
||||
|
||||
/* Encode the padded vertex count */
|
||||
|
||||
if (info->instance_count > 1)
|
||||
@@ -380,12 +490,10 @@ panfrost_draw_vbo(
|
||||
|
||||
panfrost_statistics_record(ctx, info);
|
||||
|
||||
struct mali_invocation_packed invocation;
|
||||
panfrost_pack_work_groups_compute(&invocation,
|
||||
1, vertex_count, info->instance_count,
|
||||
1, 1, 1, true);
|
||||
|
||||
vertex_prefix.invocation = invocation;
|
||||
tiler_prefix.invocation = invocation;
|
||||
1, vertex_count, info->instance_count,
|
||||
1, 1, 1, true);
|
||||
|
||||
/* Emit all sort of descriptors. */
|
||||
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,
|
||||
&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 */
|
||||
panfrost_emit_vertex_tiler_jobs(batch, &vertex_prefix, &vertex_postfix,
|
||||
&tiler_prefix, &tiler_postfix,
|
||||
&primitive_size);
|
||||
panfrost_draw_emit_vertex(batch, info, &invocation, shared_mem,
|
||||
vs_vary, varyings, &vertex);
|
||||
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. */
|
||||
panfrost_batch_adjust_stack_size(batch);
|
||||
|
@@ -188,18 +188,13 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog,
|
||||
|
||||
memcpy(shader->cpu, prog.compiled.data, prog.compiled.size);
|
||||
|
||||
struct bifrost_payload_vertex payload = {
|
||||
.prefix = {
|
||||
.primitive = {
|
||||
.opaque = { (5) << 26 }
|
||||
}
|
||||
},
|
||||
};
|
||||
struct mali_compute_job_packed job;
|
||||
|
||||
struct mali_draw_packed draw;
|
||||
struct mali_invocation_packed invocation;
|
||||
pan_section_pack(&job, COMPUTE_JOB, PARAMETERS, cfg) {
|
||||
cfg.job_task_split = 5;
|
||||
}
|
||||
|
||||
pan_pack(&draw, DRAW, cfg) {
|
||||
pan_section_pack(&job, COMPUTE_JOB, DRAW, cfg) {
|
||||
cfg.unknown_1 = 0x2;
|
||||
cfg.shared = shmem->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;
|
||||
}
|
||||
|
||||
|
||||
panfrost_pack_work_groups_compute(&invocation,
|
||||
1, 1, 1,
|
||||
1, 1, 1,
|
||||
true);
|
||||
|
||||
payload.prefix.invocation = invocation;
|
||||
payload.postfix = draw;
|
||||
void *invocation = pan_section_ptr(&job, COMPUTE_JOB, INVOCATION);
|
||||
panfrost_pack_work_groups_compute(invocation,
|
||||
1, 1, 1,
|
||||
1, 1, 1,
|
||||
true);
|
||||
|
||||
struct panfrost_bo *bos[] = {
|
||||
shmem, shader, shader_desc, ubo, var, attr
|
||||
};
|
||||
|
||||
bool succ = bit_submit(dev, MALI_JOB_TYPE_VERTEX, &payload,
|
||||
sizeof(payload), bos, ARRAY_SIZE(bos), debug);
|
||||
bool succ = bit_submit(dev, MALI_JOB_TYPE_VERTEX,
|
||||
((void *)&job) + MALI_JOB_HEADER_LENGTH,
|
||||
MALI_COMPUTE_JOB_LENGTH - MALI_JOB_HEADER_LENGTH,
|
||||
bos, ARRAY_SIZE(bos), debug);
|
||||
|
||||
/* Check the output varyings */
|
||||
|
||||
|
@@ -361,47 +361,6 @@ struct bifrost_blend_rt {
|
||||
* 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)
|
||||
* texture is stored as (63, 63) in these fields. This adjusts for that.
|
||||
* There's an identical pattern in the framebuffer descriptor. Even vertex
|
||||
|
@@ -736,13 +736,12 @@ bits(u32 word, u32 lo, u32 hi)
|
||||
}
|
||||
|
||||
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
|
||||
* invocation_count for an explanation.
|
||||
*/
|
||||
struct mali_invocation_packed invocation_packed = p->invocation;
|
||||
pan_unpack(&invocation_packed, INVOCATION, invocation);
|
||||
pan_unpack(i, INVOCATION, invocation);
|
||||
|
||||
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;
|
||||
@@ -763,7 +762,7 @@ pandecode_vertex_tiler_prefix(struct mali_vertex_tiler_prefix *p, int job_no, bo
|
||||
struct mali_invocation_packed ref;
|
||||
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");
|
||||
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",
|
||||
size_x, size_y, size_z,
|
||||
groups_x, groups_y, groups_z);
|
||||
}
|
||||
|
||||
struct mali_primitive_packed prim_packed = p->primitive;
|
||||
pan_unpack(&prim_packed, PRIMITIVE, primitive);
|
||||
static void
|
||||
pandecode_primitive(const void *p)
|
||||
{
|
||||
pan_unpack(p, PRIMITIVE, primitive);
|
||||
DUMP_UNPACKED(PRIMITIVE, primitive, "Primitive:\n");
|
||||
|
||||
/* 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
|
||||
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;
|
||||
|
||||
pandecode_log(".primitive_size = {\n");
|
||||
pandecode_indent++;
|
||||
|
||||
if (constant) {
|
||||
pandecode_prop("constant = %f", u.constant);
|
||||
} else {
|
||||
MEMORY_PROP((&u), pointer);
|
||||
}
|
||||
|
||||
pandecode_indent--;
|
||||
pandecode_log("},\n");
|
||||
DUMP_UNPACKED(PRIMITIVE_SIZE, ps, "Primitive Size:\n")
|
||||
}
|
||||
|
||||
static int
|
||||
pandecode_vertex_job_bfr(const struct MALI_JOB_HEADER *h,
|
||||
const struct pandecode_mapped_memory *mem,
|
||||
mali_ptr payload, int job_no, unsigned gpu_id)
|
||||
static void
|
||||
pandecode_vertex_compute_geometry_job(const struct MALI_JOB_HEADER *h,
|
||||
const struct pandecode_mapped_memory *mem,
|
||||
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;
|
||||
memcpy(&draw_packed, &v->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_prefix(&v->prefix, job_no, false);
|
||||
DUMP_CL(DRAW, &draw_packed, "Draw:\n");
|
||||
|
||||
return sizeof(*v);
|
||||
pandecode_log("Vertex Job Payload:\n");
|
||||
pandecode_indent++;
|
||||
pandecode_invocation(pan_section_ptr(p, COMPUTE_JOB, INVOCATION),
|
||||
h->type != MALI_JOB_TYPE_COMPUTE);
|
||||
DUMP_SECTION(COMPUTE_JOB, PARAMETERS, p, "Vertex Job Parameters:\n");
|
||||
DUMP_UNPACKED(DRAW, draw, "Draw:\n");
|
||||
pandecode_indent--;
|
||||
pandecode_log("\n");
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
pandecode_tiler_job_bfr(const struct MALI_JOB_HEADER *h,
|
||||
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_draw_packed draw_packed;
|
||||
memcpy(&draw_packed, &t->postfix, sizeof(draw_packed));
|
||||
pan_unpack(&draw_packed, DRAW, draw);
|
||||
struct mali_bifrost_tiler_job_packed *PANDECODE_PTR_VAR(p, mem, job);
|
||||
pan_section_unpack(p, BIFROST_TILER_JOB, DRAW, draw);
|
||||
pan_section_unpack(p, BIFROST_TILER_JOB, TILER, tiler_ptr);
|
||||
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 */
|
||||
pandecode_primitive_size(t->primitive_size, true);
|
||||
|
||||
if (t->zero1 || t->zero2 || t->zero3 || t->zero4 || t->zero5
|
||||
|| t->zero6) {
|
||||
pandecode_msg("XXX: tiler only zero tripped\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);
|
||||
pandecode_primitive_size(pan_section_ptr(p, BIFROST_TILER_JOB, PRIMITIVE_SIZE), true);
|
||||
pan_section_unpack(p, BIFROST_TILER_JOB, PADDING, padding);
|
||||
DUMP_UNPACKED(DRAW, draw, "Draw:\n");
|
||||
pandecode_indent--;
|
||||
pandecode_log("\n");
|
||||
}
|
||||
|
||||
static int
|
||||
pandecode_vertex_or_tiler_job_mdg(const struct MALI_JOB_HEADER *h,
|
||||
const struct pandecode_mapped_memory *mem,
|
||||
mali_ptr payload, int job_no, unsigned gpu_id)
|
||||
static void
|
||||
pandecode_tiler_job_mdg(const struct MALI_JOB_HEADER *h,
|
||||
const struct pandecode_mapped_memory *mem,
|
||||
mali_ptr job, int job_no, unsigned gpu_id)
|
||||
{
|
||||
struct midgard_payload_vertex_tiler *PANDECODE_PTR_VAR(v, mem, payload);
|
||||
bool is_graphics = (h->type == MALI_JOB_TYPE_VERTEX) || (h->type == MALI_JOB_TYPE_TILER);
|
||||
|
||||
struct mali_draw_packed draw_packed;
|
||||
memcpy(&draw_packed, &v->postfix, sizeof(draw_packed));
|
||||
pan_unpack(&draw_packed, DRAW, draw);
|
||||
struct mali_midgard_tiler_job_packed *PANDECODE_PTR_VAR(p, mem, job);
|
||||
pan_section_unpack(p, MIDGARD_TILER_JOB, DRAW, draw);
|
||||
pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", false, gpu_id);
|
||||
|
||||
pandecode_vertex_tiler_prefix(&v->prefix, job_no, is_graphics);
|
||||
DUMP_CL(DRAW, &draw_packed, "Draw:\n");
|
||||
pandecode_log("Tiler Job Payload:\n", job + MALI_JOB_HEADER_LENGTH);
|
||||
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_unpack(&prim_packed, PRIMITIVE, primitive);
|
||||
|
||||
pandecode_primitive_size(v->primitive_size, primitive.point_size_array == 0);
|
||||
|
||||
return sizeof(*v);
|
||||
pan_section_unpack(p, MIDGARD_TILER_JOB, PRIMITIVE, primitive);
|
||||
pandecode_primitive_size(pan_section_ptr(p, MIDGARD_TILER_JOB, PRIMITIVE_SIZE),
|
||||
primitive.point_size_array == 0);
|
||||
pandecode_indent--;
|
||||
pandecode_log("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1505,11 +1489,10 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
|
||||
do {
|
||||
struct pandecode_mapped_memory *mem =
|
||||
pandecode_find_mapped_gpu_mem_containing(jc_gpu_va);
|
||||
|
||||
pan_unpack(PANDECODE_PTR(mem, jc_gpu_va, struct mali_job_header_packed),
|
||||
JOB_HEADER, h);
|
||||
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++;
|
||||
|
||||
@@ -1526,16 +1509,16 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal)
|
||||
break;
|
||||
|
||||
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_COMPUTE:
|
||||
if (bifrost) {
|
||||
if (h.type == MALI_JOB_TYPE_TILER)
|
||||
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);
|
||||
|
||||
pandecode_vertex_compute_geometry_job(&h, mem, jc_gpu_va, job_no,
|
||||
bifrost, gpu_id);
|
||||
break;
|
||||
|
||||
case MALI_JOB_TYPE_FRAGMENT:
|
||||
|
@@ -1096,4 +1096,42 @@
|
||||
<section name="Header" offset="0" type="Job Header"/>
|
||||
<section name="Payload" offset="32" type="Write Value Job Payload"/>
|
||||
</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>
|
||||
|
@@ -340,12 +340,9 @@ panfrost_load_midg(
|
||||
}
|
||||
}
|
||||
|
||||
struct midgard_payload_vertex_tiler payload = {};
|
||||
struct mali_primitive_packed primitive;
|
||||
struct mali_draw_packed draw;
|
||||
struct mali_invocation_packed invocation;
|
||||
struct mali_midgard_tiler_job_packed payload = {};
|
||||
|
||||
pan_pack(&draw, DRAW, cfg) {
|
||||
pan_section_pack(&payload, MIDGARD_TILER_JOB, DRAW, cfg) {
|
||||
cfg.unknown_1 = 0x7;
|
||||
cfg.position = coordinates;
|
||||
cfg.textures = panfrost_pool_upload(pool, &texture_t.gpu, sizeof(texture_t.gpu));
|
||||
@@ -357,17 +354,16 @@ panfrost_load_midg(
|
||||
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.index_count = vertex_count;
|
||||
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;
|
||||
memcpy(&payload.postfix, &draw, MALI_DRAW_LENGTH);
|
||||
payload.prefix.invocation = invocation;
|
||||
|
||||
panfrost_new_job(pool, scoreboard, MALI_JOB_TYPE_TILER, false, 0, &payload, sizeof(payload), true);
|
||||
panfrost_new_job(pool, scoreboard, MALI_JOB_TYPE_TILER, false, 0,
|
||||
pan_section_ptr(&payload, MIDGARD_TILER_JOB, INVOCATION),
|
||||
MALI_MIDGARD_TILER_JOB_LENGTH - MALI_JOB_HEADER_LENGTH, true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user