panfrost: Emit IDVS jobs

When trying to draw with an IDVS capable shader.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14154>
This commit is contained in:
Alyssa Rosenzweig 2021-12-09 18:42:01 -05:00 committed by Marge Bot
parent e5b0c514d8
commit 3a49f4798c

View file

@ -2690,7 +2690,8 @@ panfrost_draw_emit_tiler(struct panfrost_batch *batch,
const struct pipe_draw_start_count_bias *draw,
void *invocation_template,
mali_ptr indices, mali_ptr fs_vary, mali_ptr varyings,
mali_ptr pos, mali_ptr psiz, void *job)
mali_ptr pos, mali_ptr psiz, bool secondary_shader,
void *job)
{
struct panfrost_context *ctx = batch->ctx;
struct pipe_rasterizer_state *rast = &ctx->rasterizer->base;
@ -2731,6 +2732,10 @@ panfrost_draw_emit_tiler(struct panfrost_batch *batch,
cfg.indices = indices;
cfg.base_vertex_offset = draw->index_bias - ctx->offset_start;
}
#if PAN_ARCH >= 6
cfg.secondary_shader = secondary_shader;
#endif
}
bool points = info->mode == PIPE_PRIM_POINTS;
@ -2810,10 +2815,23 @@ panfrost_direct_draw(struct panfrost_batch *batch,
ctx->active_prim = info->mode;
ctx->drawid = drawid_offset;
struct panfrost_ptr tiler =
pan_pool_alloc_desc(&batch->pool.base, TILER_JOB);
struct panfrost_ptr vertex =
pan_pool_alloc_desc(&batch->pool.base, COMPUTE_JOB);
struct panfrost_shader_state *vs = panfrost_get_shader_state(ctx, PIPE_SHADER_VERTEX);
bool idvs = vs->info.vs.idvs;
bool secondary_shader = vs->info.vs.secondary_enable;
struct panfrost_ptr tiler, vertex;
if (idvs) {
#if PAN_ARCH >= 6
tiler = pan_pool_alloc_desc(&batch->pool.base, INDEXED_VERTEX_JOB);
#else
unreachable("IDVS is unsupported on Midgard");
#endif
} else {
vertex = pan_pool_alloc_desc(&batch->pool.base, COMPUTE_JOB);
tiler = pan_pool_alloc_desc(&batch->pool.base, TILER_JOB);
}
unsigned vertex_count = ctx->vertex_count;
@ -2875,11 +2893,26 @@ panfrost_direct_draw(struct panfrost_batch *batch,
panfrost_clean_state_3d(ctx);
/* Fire off the draw itself */
panfrost_draw_emit_vertex(batch, info, &invocation,
vs_vary, varyings, attribs, attrib_bufs, vertex.cpu);
panfrost_draw_emit_tiler(batch, info, draw, &invocation, indices,
fs_vary, varyings, pos, psiz, tiler.cpu);
panfrost_emit_vertex_tiler_jobs(batch, &vertex, &tiler);
fs_vary, varyings, pos, psiz, secondary_shader,
tiler.cpu);
if (idvs) {
#if PAN_ARCH >= 6
panfrost_draw_emit_vertex_section(batch,
vs_vary, varyings,
attribs, attrib_bufs,
pan_section_ptr(tiler.cpu, INDEXED_VERTEX_JOB, VERTEX_DRAW));
panfrost_add_job(&batch->pool.base, &batch->scoreboard,
MALI_JOB_TYPE_INDEXED_VERTEX, false, false,
0, 0, &tiler, false);
#endif
} else {
panfrost_draw_emit_vertex(batch, info, &invocation,
vs_vary, varyings, attribs, attrib_bufs, vertex.cpu);
panfrost_emit_vertex_tiler_jobs(batch, &vertex, &tiler);
}
/* Increment transform feedback offsets */
panfrost_update_streamout_offsets(ctx);
@ -2907,13 +2940,23 @@ panfrost_indirect_draw(struct panfrost_batch *batch,
ctx->drawid = drawid_offset;
ctx->indirect_draw = true;
struct panfrost_ptr tiler =
pan_pool_alloc_desc(&batch->pool.base, TILER_JOB);
struct panfrost_ptr vertex =
pan_pool_alloc_desc(&batch->pool.base, COMPUTE_JOB);
struct panfrost_shader_state *vs = panfrost_get_shader_state(ctx, PIPE_SHADER_VERTEX);
struct panfrost_shader_state *vs =
panfrost_get_shader_state(ctx, PIPE_SHADER_VERTEX);
bool idvs = vs->info.vs.idvs;
bool secondary_shader = vs->info.vs.secondary_enable;
struct panfrost_ptr tiler = { 0 }, vertex = { 0 };
if (idvs) {
#if PAN_ARCH >= 6
tiler = pan_pool_alloc_desc(&batch->pool.base, INDEXED_VERTEX_JOB);
#else
unreachable("IDVS is unsupported on Midgard");
#endif
} else {
vertex = pan_pool_alloc_desc(&batch->pool.base, COMPUTE_JOB);
tiler = pan_pool_alloc_desc(&batch->pool.base, TILER_JOB);
}
struct panfrost_bo *index_buf = NULL;
@ -2959,11 +3002,21 @@ panfrost_indirect_draw(struct panfrost_batch *batch,
static struct mali_invocation_packed invocation;
/* Fire off the draw itself */
panfrost_draw_emit_vertex(batch, info, &invocation, vs_vary, varyings,
attribs, attrib_bufs, vertex.cpu);
panfrost_draw_emit_tiler(batch, info, draw, &invocation,
index_buf ? index_buf->ptr.gpu : 0,
fs_vary, varyings, pos, psiz, tiler.cpu);
fs_vary, varyings, pos, psiz, secondary_shader,
tiler.cpu);
if (idvs) {
#if PAN_ARCH >= 6
panfrost_draw_emit_vertex_section(batch,
vs_vary, varyings,
attribs, attrib_bufs,
pan_section_ptr(tiler.cpu, INDEXED_VERTEX_JOB, VERTEX_DRAW));
#endif
} else {
panfrost_draw_emit_vertex(batch, info, &invocation,
vs_vary, varyings, attribs, attrib_bufs, vertex.cpu);
}
/* Add the varying heap BO to the batch if we're allocating varyings. */
if (varyings) {
@ -3005,6 +3058,8 @@ panfrost_indirect_draw(struct panfrost_batch *batch,
if (vs->info.vs.writes_point_size)
draw_info.flags |= PAN_INDIRECT_DRAW_HAS_PSIZ;
if (idvs)
draw_info.flags |= PAN_INDIRECT_DRAW_IDVS;
if (info->primitive_restart) {
draw_info.restart_index = info->restart_index;
@ -3017,7 +3072,13 @@ panfrost_indirect_draw(struct panfrost_batch *batch,
&draw_info,
&batch->indirect_draw_ctx);
panfrost_emit_vertex_tiler_jobs(batch, &vertex, &tiler);
if (idvs) {
panfrost_add_job(&batch->pool.base, &batch->scoreboard,
MALI_JOB_TYPE_INDEXED_VERTEX, false, false,
0, 0, &tiler, false);
} else {
panfrost_emit_vertex_tiler_jobs(batch, &vertex, &tiler);
}
}
#endif