From 74a87cdaa6ff47256abc68fc5ff5662397986e80 Mon Sep 17 00:00:00 2001 From: "Kristian H. Kristensen" Date: Fri, 21 Sep 2018 12:07:22 -0700 Subject: [PATCH] freedreno/a6xx: Simplify draw_emit() branches a bit Now that we've copied the emit logic into each branch of the if (info->index_size) statement, we can simplify the logic a bit according to which case we're in. Signed-off-by: Kristian H. Kristensen --- src/gallium/drivers/freedreno/a6xx/fd6_draw.c | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c index c8d595c5d15..0b9ff43ead1 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c @@ -81,22 +81,18 @@ draw_emit(struct fd_batch *batch, struct fd_ringbuffer *ring, const struct pipe_draw_info *info, unsigned index_offset) { - struct pipe_resource *idx_buffer = NULL; - enum a4xx_index_size idx_type; enum pc_di_src_sel src_sel; - uint32_t idx_size, idx_offset; if (info->index_size) { assert(!info->has_user_indices); - idx_buffer = info->index.resource; - idx_type = fd4_size2indextype(info->index_size); - idx_size = info->index_size * info->count; - idx_offset = index_offset + info->start * info->index_size; + struct pipe_resource *idx_buffer = info->index.resource; + uint32_t idx_size = info->index_size * info->count; + uint32_t idx_offset = index_offset + info->start * info->index_size; + enum a4xx_index_size idx_type = fd4_size2indextype(info->index_size); src_sel = DI_SRC_SEL_DMA; - - OUT_PKT7(ring, CP_DRAW_INDX_OFFSET, idx_buffer ? 7 : 3); + OUT_PKT7(ring, CP_DRAW_INDX_OFFSET, 7); if (vismode == USE_VISIBILITY) { /* leave vis mode blank for now, it will be patched up when * we know if we are binning or not @@ -112,21 +108,17 @@ draw_emit(struct fd_batch *batch, struct fd_ringbuffer *ring, OUT_RELOC(ring, fd_resource(idx_buffer)->bo, idx_offset, 0, 0); OUT_RING (ring, idx_size); } else { - idx_buffer = NULL; - idx_type = INDEX4_SIZE_32_BIT; - idx_size = 0; - idx_offset = 0; src_sel = DI_SRC_SEL_AUTO_INDEX; - OUT_PKT7(ring, CP_DRAW_INDX_OFFSET, idx_buffer ? 7 : 3); + OUT_PKT7(ring, CP_DRAW_INDX_OFFSET, 3); if (vismode == USE_VISIBILITY) { /* leave vis mode blank for now, it will be patched up when * we know if we are binning or not */ - OUT_RINGP(ring, DRAW4(primtype, src_sel, idx_type, 0) | 0x2000, + OUT_RINGP(ring, DRAW4(primtype, src_sel, INDEX4_SIZE_32_BIT, 0) | 0x2000, &batch->draw_patches); } else { - OUT_RING(ring, DRAW4(primtype, src_sel, idx_type, vismode) | 0x2000); + OUT_RING(ring, DRAW4(primtype, src_sel, INDEX4_SIZE_32_BIT, vismode) | 0x2000); } OUT_RING(ring, info->instance_count); /* NumInstances */ OUT_RING(ring, info->count); /* NumIndices */ -- 2.30.2