ilo: precalculate aligned depth buffer size
authorChia-I Wu <olvaffe@gmail.com>
Tue, 30 Sep 2014 07:18:09 +0000 (15:18 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 30 Sep 2014 08:41:31 +0000 (16:41 +0800)
To replace the hacky zs_align_surface().

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/gallium/drivers/ilo/ilo_blitter_rectlist.c
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
src/gallium/drivers/ilo/ilo_state.h
src/gallium/drivers/ilo/ilo_state_gen.h
src/gallium/drivers/ilo/ilo_state_gen6.c

index 699a7decbef94e024141b569d01d3cfbeac10649..579c9c7eca3dd5e2f50fdf15abd1f745592f3f71 100644 (file)
@@ -31,7 +31,7 @@
 #include "ilo_builder_3d_top.h" /* for ve_init_cso_with_components() */
 #include "ilo_draw.h"
 #include "ilo_state.h"
-#include "ilo_state_gen.h" /* for zs_align_surface() */
+#include "ilo_state_gen.h"
 #include "ilo_blit.h"
 #include "ilo_blitter.h"
 
@@ -254,10 +254,6 @@ hiz_align_fb(struct ilo_blitter *blitter)
    if (blitter->fb.width % align_w || blitter->fb.height % align_h) {
       blitter->fb.width = align(blitter->fb.width, align_w);
       blitter->fb.height = align(blitter->fb.height, align_h);
-
-      assert(!blitter->fb.dst.is_rt);
-      zs_align_surface(blitter->ilo->dev, align_w, align_h,
-            &blitter->fb.dst.u.zs);
    }
 }
 
index 83b266e03293917b9f7a224b8df308d4a2ca56c9..73b5fae47aea04002aae04f23d47d01f3af5539f 100644 (file)
@@ -747,7 +747,8 @@ gen6_3DSTATE_AA_LINE_PARAMETERS(struct ilo_builder *builder)
 
 static inline void
 gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder,
-                          const struct ilo_zs_surface *zs)
+                          const struct ilo_zs_surface *zs,
+                          bool aligned_8x4)
 {
    const uint32_t cmd = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ?
       GEN7_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER) :
@@ -762,7 +763,7 @@ gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder,
 
    dw[0] = cmd | (cmd_len - 2);
    dw[1] = zs->payload[0];
-   dw[3] = zs->payload[2];
+   dw[3] = (aligned_8x4) ? zs->dw_aligned_8x4 : zs->payload[2];
    dw[4] = zs->payload[3];
    dw[5] = zs->payload[4];
    dw[6] = zs->payload[5];
index 9369f6326d51c2845d4023c8342333b5c67e1c5e..2c66b973baaa88afcfbab8055c8163a72b0024fd 100644 (file)
@@ -788,7 +788,7 @@ gen6_draw_wm_depth(struct ilo_render *r,
          gen6_wa_pre_depth(r);
       }
 
-      gen6_3DSTATE_DEPTH_BUFFER(r->builder, zs);
+      gen6_3DSTATE_DEPTH_BUFFER(r->builder, zs, false);
       gen6_3DSTATE_HIER_DEPTH_BUFFER(r->builder, zs);
       gen6_3DSTATE_STENCIL_BUFFER(r->builder, zs);
       gen6_3DSTATE_CLEAR_PARAMS(r->builder, clear_params);
@@ -919,7 +919,7 @@ gen6_rectlist_wm_depth(struct ilo_render *r,
    if (blitter->uses & (ILO_BLITTER_USE_FB_DEPTH |
                         ILO_BLITTER_USE_FB_STENCIL)) {
       gen6_3DSTATE_DEPTH_BUFFER(r->builder,
-            &blitter->fb.dst.u.zs);
+            &blitter->fb.dst.u.zs, true);
    }
 
    if (blitter->uses & ILO_BLITTER_USE_FB_DEPTH) {
index a39944e67b2b06e95642acd4810fe7a854d917cf..373f800e071ad72959193cf288a7d489f5059bb0 100644 (file)
@@ -602,7 +602,7 @@ gen7_draw_wm(struct ilo_render *r,
          clear_params = 0;
       }
 
-      gen6_3DSTATE_DEPTH_BUFFER(r->builder, zs);
+      gen6_3DSTATE_DEPTH_BUFFER(r->builder, zs, false);
       gen6_3DSTATE_HIER_DEPTH_BUFFER(r->builder, zs);
       gen6_3DSTATE_STENCIL_BUFFER(r->builder, zs);
       gen7_3DSTATE_CLEAR_PARAMS(r->builder, clear_params);
@@ -789,7 +789,7 @@ gen7_rectlist_wm_depth(struct ilo_render *r,
    if (blitter->uses & (ILO_BLITTER_USE_FB_DEPTH |
                         ILO_BLITTER_USE_FB_STENCIL)) {
       gen6_3DSTATE_DEPTH_BUFFER(r->builder,
-            &blitter->fb.dst.u.zs);
+            &blitter->fb.dst.u.zs, true);
    }
 
    if (blitter->uses & ILO_BLITTER_USE_FB_DEPTH) {
index d62c00a279037cd97e648d822024c1786e7514da..7f68118d4b6b5f63818e20e184d04c1029df91bb 100644 (file)
@@ -335,6 +335,8 @@ struct ilo_surface_cso {
       struct ilo_view_surface rt;
       struct ilo_zs_surface {
          uint32_t payload[10];
+         uint32_t dw_aligned_8x4;
+
          struct intel_bo *bo;
          struct intel_bo *hiz_bo;
          struct intel_bo *separate_s8_bo;
index 9e4f0ebaafd363000a678d0dc3550f0a86551e04..a4faad5134bd526d96e66eb6c8bd7f89c61ed1fa 100644 (file)
@@ -80,41 +80,6 @@ ilo_gpe_gen6_translate_texture(enum pipe_texture_target target)
    }
 }
 
-static inline void
-zs_align_surface(const struct ilo_dev_info *dev,
-                 unsigned align_w, unsigned align_h,
-                 struct ilo_zs_surface *zs)
-{
-   unsigned mask, shift_w, shift_h;
-   unsigned width, height;
-   uint32_t dw3;
-
-   ILO_DEV_ASSERT(dev, 6, 7.5);
-
-   if (ilo_dev_gen(dev) >= ILO_GEN(7)) {
-      shift_w = 4;
-      shift_h = 18;
-      mask = 0x3fff;
-   }
-   else {
-      shift_w = 6;
-      shift_h = 19;
-      mask = 0x1fff;
-   }
-
-   dw3 = zs->payload[2];
-
-   /* aligned width and height */
-   width = align(((dw3 >> shift_w) & mask) + 1, align_w);
-   height = align(((dw3 >> shift_h) & mask) + 1, align_h);
-
-   dw3 = (dw3 & ~((mask << shift_w) | (mask << shift_h))) |
-      (width - 1) << shift_w |
-      (height - 1) << shift_h;
-
-   zs->payload[2] = dw3;
-}
-
 void
 ilo_gpe_init_ve(const struct ilo_dev_info *dev,
                 unsigned num_states,
index 0fb226dc1c4df3eb27605335225fef1a5a3b5cff..6950f275908675c062c209d7505e5f40d771134a 100644 (file)
@@ -1140,13 +1140,35 @@ ilo_gpe_init_zs_surface(const struct ilo_dev_info *dev,
    const int max_array_size = (ilo_dev_gen(dev) >= ILO_GEN(7)) ? 2048 : 512;
    struct ilo_zs_surface_info info;
    uint32_t dw1, dw2, dw3, dw4, dw5, dw6;
+   int align_w = 8, align_h = 4;
 
    ILO_DEV_ASSERT(dev, 6, 7.5);
 
-   if (tex)
+   if (tex) {
       zs_init_info(dev, tex, format, level, first_layer, num_layers, &info);
-   else
+
+      switch (tex->base.nr_samples) {
+      case 2:
+         align_w /= 2;
+         break;
+      case 4:
+         align_w /= 2;
+         align_h /= 2;
+         break;
+      case 8:
+         align_w /= 4;
+         align_h /= 2;
+         break;
+      case 16:
+         align_w /= 4;
+         align_h /= 4;
+         break;
+      default:
+         break;
+      }
+   } else {
       zs_init_info_null(dev, &info);
+   }
 
    switch (info.surface_type) {
    case GEN6_SURFTYPE_NULL:
@@ -1209,6 +1231,10 @@ ilo_gpe_init_zs_surface(const struct ilo_dev_info *dev,
             (info.width - 1) << 4 |
             info.lod;
 
+      zs->dw_aligned_8x4 = (align(info.height, align_h) - 1) << 18 |
+                           (align(info.width, align_w) - 1) << 4 |
+                           info.lod;
+
       dw4 = (info.depth - 1) << 21 |
             info.first_layer << 10;
 
@@ -1231,6 +1257,11 @@ ilo_gpe_init_zs_surface(const struct ilo_dev_info *dev,
             info.lod << 2 |
             GEN6_DEPTH_DW3_MIPLAYOUT_BELOW;
 
+      zs->dw_aligned_8x4 = (align(info.height, align_h) - 1) << 19 |
+                           (align(info.width, align_w) - 1) << 6 |
+                           info.lod << 2 |
+                           GEN6_DEPTH_DW3_MIPLAYOUT_BELOW;
+
       dw4 = (info.depth - 1) << 21 |
             info.first_layer << 10 |
             (info.num_layers - 1) << 1;