From 16edd56fccad7ba0e1b938a60f0f5e927a104585 Mon Sep 17 00:00:00 2001 From: Rohan Garg Date: Wed, 17 Jul 2019 18:50:13 +0200 Subject: panfrost: Take into account a index_bias for glDrawElementsBaseVertex calls Midgard does not accept a index_bias directly and relies instead on a bias correction offset (offset_bias_correction) in order to calculate the unbiased vertex index. We need to make sure we adjust offset_start and vertex_count in order to take into account the index_bias as required by a glDrawElementsBaseVertex call and then supply a additional offset_bias_correction to the hardware. Signed-off-by: Rohan Garg Reviewed-by: Alyssa Rosenzweig --- src/gallium/drivers/panfrost/pan_context.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index e9d18605dd0..284c246677d 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -672,7 +672,7 @@ panfrost_stage_attributes(struct panfrost_context *ctx) * QED. */ - unsigned start = ctx->payloads[PIPE_SHADER_VERTEX].draw_start; + unsigned start = ctx->payloads[PIPE_SHADER_VERTEX].offset_start; for (unsigned i = 0; i < so->num_elements; ++i) { unsigned vbi = so->pipe[i].vertex_buffer_index; @@ -1617,8 +1617,8 @@ panfrost_draw_vbo( if (panfrost_scissor_culls_everything(ctx)) return; - ctx->payloads[PIPE_SHADER_VERTEX].draw_start = info->start; - ctx->payloads[PIPE_SHADER_FRAGMENT].draw_start = info->start; + ctx->payloads[PIPE_SHADER_VERTEX].offset_start = info->start; + ctx->payloads[PIPE_SHADER_FRAGMENT].offset_start = info->start; int mode = info->mode; @@ -1655,7 +1655,8 @@ panfrost_draw_vbo( ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.draw_mode = g2m_draw_mode(mode); - ctx->vertex_count = info->count; + /* Take into account a negative bias */ + ctx->vertex_count = info->count + abs(info->index_bias); ctx->instance_count = info->instance_count; /* For non-indexed draws, they're the same */ @@ -1704,14 +1705,13 @@ panfrost_draw_vbo( /* Use the corresponding values */ vertex_count = max_index - min_index + 1; - ctx->payloads[PIPE_SHADER_VERTEX].draw_start = min_index; - ctx->payloads[PIPE_SHADER_FRAGMENT].draw_start = min_index; + ctx->payloads[PIPE_SHADER_VERTEX].offset_start = min_index + info->index_bias; + ctx->payloads[PIPE_SHADER_FRAGMENT].offset_start = min_index + info->index_bias; - ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.negative_start = -min_index; + ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.offset_bias_correction = -min_index; ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.index_count = MALI_POSITIVE(info->count); //assert(!info->restart_index); /* TODO: Research */ - assert(!info->index_bias); draw_flags |= panfrost_translate_index_size(info->index_size); ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.indices = panfrost_get_index_buffer_mapped(ctx, info); @@ -1719,7 +1719,7 @@ panfrost_draw_vbo( /* Index count == vertex count, if no indexing is applied, as * if it is internally indexed in the expected order */ - ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.negative_start = 0; + ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.offset_bias_correction = 0; ctx->payloads[PIPE_SHADER_FRAGMENT].prefix.index_count = MALI_POSITIVE(ctx->vertex_count); /* Reverse index state */ -- cgit v1.2.3