ilo: clean up 3DPRIMITIVE functions
authorChia-I Wu <olvaffe@gmail.com>
Sat, 13 Sep 2014 00:54:41 +0000 (08:54 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Sat, 13 Sep 2014 01:33:20 +0000 (09:33 +0800)
Add ILO_PRIM_RECTANGLES to replace the rectlist bool.

src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
src/gallium/drivers/ilo/ilo_blitter_rectlist.c
src/gallium/drivers/ilo/ilo_builder_3d.h
src/gallium/drivers/ilo/ilo_common.h

index 7b264bdb97d52463e4c6b79a8e82c6535ba8bb53..55dc7a2bf4d6f25e66e4cf8b09f6d0b6148d718d 100644 (file)
@@ -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
index 6117c22dea1ccbd058bc661b8ff373e7d7e2568d..db00d79bef3914743ac7b64a9445a3266aa2ac30 100644 (file)
@@ -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
index 5dd0b1ec5a9a940092139f25075f44d439aed6ea..c77b8e14971bef8fe4c24ea87b9928fe76ac1e8c 100644 (file)
@@ -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;
 
    /**
index c94fd718ee32cf289a52403f30e22caf1c91ce5d..4f43bdcff043dc8ff98013cf899f681588305f90 100644 (file)
@@ -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;
index ef38e4d486e3ca53c2635ff65383c97dbf12c7d2..a2e74bf0618753d1c22d8dd11137d56503885c0e 100644 (file)
@@ -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,