ilo: add variants of 3DSTATE_WM
authorChia-I Wu <olvaffe@gmail.com>
Tue, 11 Nov 2014 02:25:20 +0000 (10:25 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 11 Nov 2014 05:51:28 +0000 (13:51 +0800)
Add gen6_hiz_3DSTATE_WM() and gen7_hiz_3DSTATE_WM() for HiZ ops without
dispatching.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/gallium/drivers/ilo/ilo_builder_3d_bottom.h
src/gallium/drivers/ilo/ilo_render_gen6.c
src/gallium/drivers/ilo/ilo_render_gen7.c

index 3207843cbcd331be5c70d8c5ef1713ef0722170f..15921855b0f84ccc4a452d669f57c16c4d6d4e42 100644 (file)
@@ -282,41 +282,20 @@ static inline void
 gen6_3DSTATE_WM(struct ilo_builder *builder,
                 const struct ilo_shader_state *fs,
                 const struct ilo_rasterizer_state *rasterizer,
-                bool dual_blend, bool cc_may_kill,
-                uint32_t hiz_op)
+                bool dual_blend, bool cc_may_kill)
 {
    const uint8_t cmd_len = 9;
-   const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
    const int num_samples = 1;
-   const struct ilo_shader_cso *fs_cso;
+   const struct ilo_shader_cso *cso;
    uint32_t dw2, dw4, dw5, dw6, *dw;
 
    ILO_DEV_ASSERT(builder->dev, 6, 6);
 
-   if (!fs) {
-      /* see brwCreateContext() */
-      const int max_threads = (builder->dev->gt == 2) ? 80 : 40;
-
-      ilo_builder_batch_pointer(builder, cmd_len, &dw);
-      dw[0] = dw0;
-      dw[1] = 0;
-      dw[2] = 0;
-      dw[3] = 0;
-      dw[4] = hiz_op;
-      /* honor the valid range even if dispatching is disabled */
-      dw[5] = (max_threads - 1) << GEN6_WM_DW5_MAX_THREADS__SHIFT;
-      dw[6] = 0;
-      dw[7] = 0;
-      dw[8] = 0;
-
-      return;
-   }
-
-   fs_cso = ilo_shader_get_kernel_cso(fs);
-   dw2 = fs_cso->payload[0];
-   dw4 = fs_cso->payload[1];
-   dw5 = fs_cso->payload[2];
-   dw6 = fs_cso->payload[3];
+   cso = ilo_shader_get_kernel_cso(fs);
+   dw2 = cso->payload[0];
+   dw4 = cso->payload[1];
+   dw5 = cso->payload[2];
+   dw6 = cso->payload[3];
 
    /*
     * From the Sandy Bridge PRM, volume 2 part 1, page 248:
@@ -325,7 +304,6 @@ gen6_3DSTATE_WM(struct ilo_builder *builder,
     *      bits is set: Depth Buffer Clear , Hierarchical Depth Buffer Resolve
     *      Enable or Depth Buffer Resolve Enable."
     */
-   assert(!hiz_op);
    dw4 |= GEN6_WM_DW4_STATISTICS;
 
    if (cc_may_kill)
@@ -344,7 +322,8 @@ gen6_3DSTATE_WM(struct ilo_builder *builder,
    }
 
    ilo_builder_batch_pointer(builder, cmd_len, &dw);
-   dw[0] = dw0;
+
+   dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
    dw[1] = ilo_shader_get_kernel_offset(fs);
    dw[2] = dw2;
    dw[3] = 0; /* scratch */
@@ -355,37 +334,51 @@ gen6_3DSTATE_WM(struct ilo_builder *builder,
    dw[8] = 0; /* kernel 2 */
 }
 
+static inline void
+gen6_hiz_3DSTATE_WM(struct ilo_builder *builder, uint32_t hiz_op)
+{
+   const uint8_t cmd_len = 9;
+   const int max_threads = (builder->dev->gt == 2) ? 80 : 40;
+   uint32_t *dw;
+
+   ILO_DEV_ASSERT(builder->dev, 6, 6);
+
+   ilo_builder_batch_pointer(builder, cmd_len, &dw);
+
+   dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
+   dw[1] = 0;
+   dw[2] = 0;
+   dw[3] = 0;
+   dw[4] = hiz_op;
+   /* honor the valid range even if dispatching is disabled */
+   dw[5] = (max_threads - 1) << GEN6_WM_DW5_MAX_THREADS__SHIFT;
+   dw[6] = 0;
+   dw[7] = 0;
+   dw[8] = 0;
+}
+
 static inline void
 gen7_3DSTATE_WM(struct ilo_builder *builder,
                 const struct ilo_shader_state *fs,
                 const struct ilo_rasterizer_state *rasterizer,
-                bool cc_may_kill, uint32_t hiz_op)
+                bool cc_may_kill)
 {
    const uint8_t cmd_len = 3;
-   const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
    const int num_samples = 1;
+   const struct ilo_shader_cso *cso;
    uint32_t dw1, dw2, *dw;
 
    ILO_DEV_ASSERT(builder->dev, 7, 7.5);
 
-   /* see ilo_gpe_init_rasterizer_wm() */
-   if (rasterizer) {
-      dw1 = rasterizer->wm.payload[0];
-      dw2 = rasterizer->wm.payload[1];
+   /* see rasterizer_init_wm_gen7() */
+   dw1 = rasterizer->wm.payload[0];
+   dw2 = rasterizer->wm.payload[1];
 
-      assert(!hiz_op);
-      dw1 |= GEN7_WM_DW1_STATISTICS;
-   }
-   else {
-      dw1 = hiz_op;
-      dw2 = 0;
-   }
-
-   if (fs) {
-      const struct ilo_shader_cso *fs_cso = ilo_shader_get_kernel_cso(fs);
+   /* see fs_init_cso_gen7() */
+   cso = ilo_shader_get_kernel_cso(fs);
+   dw1 |= cso->payload[3];
 
-      dw1 |= fs_cso->payload[3];
-   }
+   dw1 |= GEN7_WM_DW1_STATISTICS;
 
    if (cc_may_kill)
       dw1 |= GEN7_WM_DW1_PS_ENABLE | GEN7_WM_DW1_PS_KILL;
@@ -396,11 +389,26 @@ gen7_3DSTATE_WM(struct ilo_builder *builder,
    }
 
    ilo_builder_batch_pointer(builder, cmd_len, &dw);
-   dw[0] = dw0;
+
+   dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
    dw[1] = dw1;
    dw[2] = dw2;
 }
 
+static inline void
+gen7_hiz_3DSTATE_WM(struct ilo_builder *builder, uint32_t hiz_op)
+{
+   const uint8_t cmd_len = 3;
+   uint32_t *dw;
+
+   ILO_DEV_ASSERT(builder->dev, 7, 7.5);
+
+   ilo_builder_batch_pointer(builder, cmd_len, &dw);
+   dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
+   dw[1] = hiz_op;
+   dw[2] = 0;
+}
+
 static inline void
 gen7_3DSTATE_PS(struct ilo_builder *builder,
                 const struct ilo_shader_state *fs,
index 70a7400d5dd7382a69f3b1923219709336cf719b..4e3bd18b3091dff0e839735897d1c48855960e74 100644 (file)
@@ -698,7 +698,7 @@ gen6_draw_wm(struct ilo_render *r,
          gen6_wa_pre_3dstate_wm_max_threads(r);
 
       gen6_3DSTATE_WM(r->builder, vec->fs,
-            vec->rasterizer, dual_blend, cc_may_kill, 0);
+            vec->rasterizer, dual_blend, cc_may_kill);
    }
 }
 
@@ -879,7 +879,7 @@ gen6_rectlist_wm(struct ilo_render *r,
    gen6_3DSTATE_CONSTANT_PS(r->builder, NULL, NULL, 0);
 
    gen6_wa_pre_3dstate_wm_max_threads(r);
-   gen6_3DSTATE_WM(r->builder, NULL, NULL, false, false, hiz_op);
+   gen6_hiz_3DSTATE_WM(r->builder, hiz_op);
 }
 
 static void
index 79d147a7a25385d3520e0899bbff6fa7bb7e1fb3..ab27a3d0b623fa72226a24482437cb92480cfd64 100644 (file)
@@ -512,8 +512,7 @@ gen7_draw_wm(struct ilo_render *r,
       const bool cc_may_kill = (vec->dsa->dw_alpha ||
                                 vec->blend->alpha_to_coverage);
 
-      gen7_3DSTATE_WM(r->builder, vec->fs,
-            vec->rasterizer, cc_may_kill, 0);
+      gen7_3DSTATE_WM(r->builder, vec->fs, vec->rasterizer, cc_may_kill);
    }
 
    /* 3DSTATE_BINDING_TABLE_POINTERS_PS */
@@ -766,7 +765,7 @@ gen7_rectlist_wm(struct ilo_render *r,
       break;
    }
 
-   gen7_3DSTATE_WM(r->builder, NULL, NULL, false, hiz_op);
+   gen7_hiz_3DSTATE_WM(r->builder, hiz_op);
 
    gen7_3DSTATE_CONSTANT_PS(r->builder, NULL, NULL, 0);