* 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;
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;
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 */
/* 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);
/* 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 */
u32 workgroups_x_shift_3 : 6;
- /* Negative of draw_start for TILER jobs from what I've seen */
- int32_t negative_start;
+ /* Negative of min_index. This is used to compute
+ * the unbiased index in tiler/fragment shader runs.
+ *
+ * The hardware adds offset_bias_correction in each run,
+ * so that absent an index bias, the first vertex processed is
+ * genuinely the first vertex (0). But with an index bias,
+ * the first vertex process is numbered the same as the bias.
+ *
+ * To represent this more conviniently:
+ * unbiased_index = lower_bound_index +
+ * index_bias +
+ * offset_bias_correction
+ *
+ * This is done since the hardware doesn't accept a index_bias
+ * and this allows it to recover the unbiased index.
+ */
+ int32_t offset_bias_correction;
u32 zero1;
/* Like many other strictly nonzero quantities, index_count is
u8 zero4;
/* Offset for first vertex in buffer */
- u32 draw_start;
+ u32 offset_start;
u64 zero5;
if (p->index_count)
pandecode_prop("index_count = MALI_POSITIVE(%" PRId32 ")", p->index_count + 1);
- if (p->negative_start)
- pandecode_prop("negative_start = %d", p->negative_start);
+ if (p->offset_bias_correction)
+ pandecode_prop("offset_bias_correction = %d", p->offset_bias_correction);
DYN_MEMORY_PROP(p, job_no, indices);
pandecode_padded_vertices(v->instance_shift, v->instance_odd);
}
- if (v->draw_start)
- pandecode_prop("draw_start = %d", v->draw_start);
+ if (v->offset_start)
+ pandecode_prop("offset_start = %d", v->offset_start);
if (v->zero5) {
pandecode_msg("Zero tripped\n");