From 9133784a46b314389b21b8566d821a480edc2cb0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 13 Sep 2014 08:54:41 +0800 Subject: [PATCH] ilo: clean up 3DPRIMITIVE functions Add ILO_PRIM_RECTANGLES to replace the rectlist bool. --- src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c | 4 +-- src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c | 4 +-- src/gallium/drivers/ilo/ilo_blitter_rectlist.c | 1 + src/gallium/drivers/ilo/ilo_builder_3d.h | 37 +++++++++++--------------- src/gallium/drivers/ilo/ilo_common.h | 3 +++ 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c index 7b264bd..55dc7a2 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c @@ -469,7 +469,7 @@ gen6_pipeline_vf_draw(struct ilo_3d_pipeline *p, struct gen6_pipeline_session *session) { /* 3DPRIMITIVE */ - gen6_3DPRIMITIVE(&p->cp->builder, ilo->draw, &ilo->ib, false); + gen6_3DPRIMITIVE(&p->cp->builder, ilo->draw, &ilo->ib); p->state.has_gen6_wa_pipe_control = false; } @@ -1664,7 +1664,7 @@ gen6_rectlist_commands(struct ilo_3d_pipeline *p, gen6_3DSTATE_DRAWING_RECTANGLE(&p->cp->builder, 0, 0, blitter->fb.width, blitter->fb.height); - gen6_3DPRIMITIVE(&p->cp->builder, &blitter->draw, NULL, true); + gen6_3DPRIMITIVE(&p->cp->builder, &blitter->draw, NULL); } static void diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c index 6117c22..db00d79 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c @@ -602,7 +602,7 @@ gen7_pipeline_vf_draw(struct ilo_3d_pipeline *p, struct gen6_pipeline_session *session) { /* 3DPRIMITIVE */ - gen7_3DPRIMITIVE(&p->cp->builder, ilo->draw, &ilo->ib, false); + gen7_3DPRIMITIVE(&p->cp->builder, ilo->draw, &ilo->ib); p->state.has_gen6_wa_pipe_control = false; } @@ -844,7 +844,7 @@ gen7_rectlist_commands(struct ilo_3d_pipeline *p, gen6_3DSTATE_DRAWING_RECTANGLE(&p->cp->builder, 0, 0, blitter->fb.width, blitter->fb.height); - gen7_3DPRIMITIVE(&p->cp->builder, &blitter->draw, NULL, true); + gen7_3DPRIMITIVE(&p->cp->builder, &blitter->draw, NULL); } static void diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c index 5dd0b1e..c77b8e1 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c +++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c @@ -82,6 +82,7 @@ ilo_blitter_set_invariants(struct ilo_blitter *blitter) /* a rectangle has 3 vertices in a RECTLIST */ util_draw_init_info(&blitter->draw); + blitter->draw.mode = ILO_PRIM_RECTANGLES; blitter->draw.count = 3; /** diff --git a/src/gallium/drivers/ilo/ilo_builder_3d.h b/src/gallium/drivers/ilo/ilo_builder_3d.h index c94fd71..4f43bdc 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d.h @@ -38,9 +38,9 @@ * Translate a pipe primitive type to the matching hardware primitive type. */ static inline int -ilo_gpe_gen6_translate_pipe_prim(unsigned prim) +gen6_3d_translate_pipe_prim(unsigned prim) { - static const int prim_mapping[PIPE_PRIM_MAX] = { + static const int prim_mapping[ILO_PRIM_MAX] = { [PIPE_PRIM_POINTS] = GEN6_3DPRIM_POINTLIST, [PIPE_PRIM_LINES] = GEN6_3DPRIM_LINELIST, [PIPE_PRIM_LINE_LOOP] = GEN6_3DPRIM_LINELOOP, @@ -55,6 +55,7 @@ ilo_gpe_gen6_translate_pipe_prim(unsigned prim) [PIPE_PRIM_LINE_STRIP_ADJACENCY] = GEN6_3DPRIM_LINESTRIP_ADJ, [PIPE_PRIM_TRIANGLES_ADJACENCY] = GEN6_3DPRIM_TRILIST_ADJ, [PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = GEN6_3DPRIM_TRISTRIP_ADJ, + [ILO_PRIM_RECTANGLES] = GEN6_3DPRIM_RECTLIST, }; assert(prim_mapping[prim]); @@ -65,27 +66,24 @@ ilo_gpe_gen6_translate_pipe_prim(unsigned prim) static inline void gen6_3DPRIMITIVE(struct ilo_builder *builder, const struct pipe_draw_info *info, - const struct ilo_ib_state *ib, - bool rectlist) + const struct ilo_ib_state *ib) { const uint8_t cmd_len = 6; - const int prim = (rectlist) ? - GEN6_3DPRIM_RECTLIST : ilo_gpe_gen6_translate_pipe_prim(info->mode); + const int prim = gen6_3d_translate_pipe_prim(info->mode); const int vb_access = (info->indexed) ? GEN6_3DPRIM_DW0_ACCESS_RANDOM : GEN6_3DPRIM_DW0_ACCESS_SEQUENTIAL; const uint32_t vb_start = info->start + ((info->indexed) ? ib->draw_start_offset : 0); - uint32_t dw0, *dw; + uint32_t *dw; ILO_DEV_ASSERT(builder->dev, 6, 6); - dw0 = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | - vb_access | - prim << GEN6_3DPRIM_DW0_TYPE__SHIFT | - (cmd_len - 2); - ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | + vb_access | + prim << GEN6_3DPRIM_DW0_TYPE__SHIFT | + (cmd_len - 2); dw[1] = info->count; dw[2] = vb_start; dw[3] = info->instance_count; @@ -96,16 +94,12 @@ gen6_3DPRIMITIVE(struct ilo_builder *builder, static inline void gen7_3DPRIMITIVE(struct ilo_builder *builder, const struct pipe_draw_info *info, - const struct ilo_ib_state *ib, - bool rectlist) + const struct ilo_ib_state *ib) { const uint8_t cmd_len = 7; - const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2); - const int prim = (rectlist) ? - GEN6_3DPRIM_RECTLIST : ilo_gpe_gen6_translate_pipe_prim(info->mode); + const int prim = gen6_3d_translate_pipe_prim(info->mode); const int vb_access = (info->indexed) ? - GEN7_3DPRIM_DW1_ACCESS_RANDOM : - GEN7_3DPRIM_DW1_ACCESS_SEQUENTIAL; + GEN7_3DPRIM_DW1_ACCESS_RANDOM : GEN7_3DPRIM_DW1_ACCESS_SEQUENTIAL; const uint32_t vb_start = info->start + ((info->indexed) ? ib->draw_start_offset : 0); uint32_t *dw; @@ -113,7 +107,8 @@ gen7_3DPRIMITIVE(struct ilo_builder *builder, ILO_DEV_ASSERT(builder->dev, 7, 7.5); ilo_builder_batch_pointer(builder, cmd_len, &dw); - dw[0] = dw0; + + dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2); dw[1] = vb_access | prim; dw[2] = info->count; dw[3] = vb_start; diff --git a/src/gallium/drivers/ilo/ilo_common.h b/src/gallium/drivers/ilo/ilo_common.h index ef38e4d..a2e74bf 100644 --- a/src/gallium/drivers/ilo/ilo_common.h +++ b/src/gallium/drivers/ilo/ilo_common.h @@ -52,6 +52,9 @@ #define ILO_DEV_ASSERT(dev, min_gen, max_gen) \ ilo_dev_assert(dev, ILO_GEN(min_gen), ILO_GEN(max_gen)) +#define ILO_PRIM_RECTANGLES PIPE_PRIM_MAX +#define ILO_PRIM_MAX (PIPE_PRIM_MAX + 1) + enum ilo_debug { ILO_DEBUG_3D = 1 << 0, ILO_DEBUG_VS = 1 << 1, -- 2.7.4