ilo: add ilo_image_can_enable_aux()
authorChia-I Wu <olvaffe@gmail.com>
Sat, 2 May 2015 07:36:59 +0000 (15:36 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Sat, 2 May 2015 14:14:07 +0000 (22:14 +0800)
It replaces ilo_texture_can_enable_hiz().

src/gallium/drivers/ilo/core/ilo_image.c
src/gallium/drivers/ilo/core/ilo_image.h
src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c
src/gallium/drivers/ilo/ilo_blit.c
src/gallium/drivers/ilo/ilo_blit.h
src/gallium/drivers/ilo/ilo_blitter_rectlist.c
src/gallium/drivers/ilo/ilo_resource.c
src/gallium/drivers/ilo/ilo_resource.h
src/gallium/drivers/ilo/ilo_transfer.c

index 3a599bccc1042ae50981dfb029065c156687181e..22c8ef2620ad518928fa6d726bda2437bd712b2b 100644 (file)
@@ -878,9 +878,8 @@ img_align(struct ilo_image *img, struct ilo_image_params *params)
       align_h = MAX2(align_h, 2);
 
    /*
-    * Depth Buffer Clear/Resolve works in 8x4 sample blocks.  In
-    * ilo_texture_can_enable_hiz(), we always return true for the first slice.
-    * To avoid out-of-bound access, we have to pad.
+    * Depth Buffer Clear/Resolve works in 8x4 sample blocks.  Pad to allow HiZ
+    * for unaligned non-mipmapped and non-array images.
     */
    if (img->aux.type == ILO_IMAGE_AUX_HIZ &&
        templ->last_level == 0 &&
index e3c51005d19d82f17661b4901df21354b8f524fd..4956bdae2ee3bb85cbf9466ade67b78c8548c95d 100644 (file)
@@ -179,6 +179,12 @@ ilo_image_set_aux_bo(struct ilo_image *img, struct intel_bo *bo)
    img->aux.bo = intel_bo_ref(bo);
 }
 
+static inline bool
+ilo_image_can_enable_aux(const struct ilo_image *img, unsigned level)
+{
+   return (img->aux.bo && (img->aux.enables & (1 << level)));
+}
+
 /**
  * Convert from pixel position to 2D memory offset.
  */
index 91c9bd2197da76eca245d3e50bfd2bcef36621b2..a3cbc523d26174cf60c5c91618d0b6c0b39c0e10 100644 (file)
@@ -974,8 +974,7 @@ zs_init_info(const struct ilo_dev *dev,
        *      same value (enabled or disabled) as Hierarchical Depth Buffer
        *      Enable."
        */
-      separate_stencil =
-         ilo_texture_can_enable_hiz(tex, level, first_layer, num_layers);
+      separate_stencil = ilo_image_can_enable_aux(&tex->image, level);
    }
 
    /*
@@ -1073,7 +1072,7 @@ zs_init_info(const struct ilo_dev *dev,
       }
    }
 
-   if (ilo_texture_can_enable_hiz(tex, level, first_layer, num_layers)) {
+   if (ilo_image_can_enable_aux(&tex->image, level)) {
       info->hiz.bo = tex->image.aux.bo;
       info->hiz.stride = tex->image.aux.bo_stride;
 
index 42072c2fed0955f66192a97e80444cd28a93d164..f88f1e8dc92d1261667bbadcf2f59b45711061c0 100644 (file)
@@ -166,7 +166,7 @@ ilo_blit_resolve_slices_for_hiz(struct ilo_context *ilo,
    unsigned i;
 
    assert(tex->base.target != PIPE_BUFFER &&
-          ilo_texture_can_enable_hiz(tex, level, first_slice, num_slices));
+          ilo_image_can_enable_aux(&tex->image, level));
 
    if (resolve_flags & ILO_TEXTURE_RENDER_WRITE) {
       /*
index fed8776e4be6e305b0c6b03b33214d0ee9c6633a..da0bfe9c4c9e3a99bd77c1d588a6b8d8ebc19337 100644 (file)
@@ -58,10 +58,10 @@ ilo_blit_resolve_slices(struct ilo_context *ilo,
     * As it is only used to resolve HiZ right now, return early when there is
     * no HiZ.
     */
-   if (!ilo_texture_can_enable_hiz(tex, level, first_slice, num_slices))
+   if (!ilo_image_can_enable_aux(&tex->image, level))
       return;
 
-   if (ilo_texture_can_enable_hiz(tex, level, first_slice, num_slices)) {
+   if (ilo_image_can_enable_aux(&tex->image, level)) {
       ilo_blit_resolve_slices_for_hiz(ilo, res, level,
             first_slice, num_slices, resolve_flags);
    }
index 02051299675ad783308918c1be381ebb87f5400e..6d8afed9dca2ae2f3418427a03c0308cda4b6323 100644 (file)
@@ -331,9 +331,7 @@ ilo_blitter_rectlist_clear_zs(struct ilo_blitter *blitter,
    struct pipe_depth_stencil_alpha_state dsa_state;
    uint32_t uses, clear_value;
 
-   if (!ilo_texture_can_enable_hiz(tex,
-            zs->u.tex.level, zs->u.tex.first_layer,
-            zs->u.tex.last_layer - zs->u.tex.first_layer + 1))
+   if (!ilo_image_can_enable_aux(&tex->image, zs->u.tex.level))
       return false;
 
    if (!hiz_can_clear_zs(blitter, tex))
@@ -427,7 +425,7 @@ ilo_blitter_rectlist_resolve_z(struct ilo_blitter *blitter,
    const struct ilo_texture_slice *s =
       ilo_texture_get_slice(tex, level, slice);
 
-   if (!ilo_texture_can_enable_hiz(tex, level, slice, 1))
+   if (!ilo_image_can_enable_aux(&tex->image, level))
       return;
 
    /*
@@ -462,7 +460,7 @@ ilo_blitter_rectlist_resolve_hiz(struct ilo_blitter *blitter,
    struct ilo_texture *tex = ilo_texture(res);
    struct pipe_depth_stencil_alpha_state dsa_state;
 
-   if (!ilo_texture_can_enable_hiz(tex, level, slice, 1))
+   if (!ilo_image_can_enable_aux(&tex->image, level))
       return;
 
    /*
index 2aa850855593502bdaab38a1d00233b3640ea700..ad4852278d02d7ad3647c4f96c71e43d28cfcded 100644 (file)
@@ -217,7 +217,6 @@ tex_create_hiz(struct ilo_texture *tex)
    const struct pipe_resource *templ = &tex->base;
    struct ilo_screen *is = ilo_screen(tex->base.screen);
    struct intel_bo *bo;
-   unsigned lv;
 
    bo = intel_winsys_alloc_bo(is->dev.winsys, "hiz texture",
          tex->image.aux.bo_stride * tex->image.aux.bo_height, false);
@@ -226,17 +225,18 @@ tex_create_hiz(struct ilo_texture *tex)
 
    ilo_image_set_aux_bo(&tex->image, bo);
 
-   for (lv = 0; lv <= templ->last_level; lv++) {
-      if (tex->image.aux.enables & (1 << lv)) {
-         const unsigned num_slices = (templ->target == PIPE_TEXTURE_3D) ?
-            u_minify(templ->depth0, lv) : templ->array_size;
-         unsigned flags = ILO_TEXTURE_HIZ;
+   if (tex->imported) {
+      unsigned lv;
 
-         /* this will trigger a HiZ resolve */
-         if (tex->imported)
-            flags |= ILO_TEXTURE_CPU_WRITE;
+      for (lv = 0; lv <= templ->last_level; lv++) {
+         if (tex->image.aux.enables & (1 << lv)) {
+            const unsigned num_slices = (templ->target == PIPE_TEXTURE_3D) ?
+               u_minify(templ->depth0, lv) : templ->array_size;
+            /* this will trigger HiZ resolves */
+            const unsigned flags = ILO_TEXTURE_CPU_WRITE;
 
-         ilo_texture_set_slice_flags(tex, lv, 0, num_slices, flags, flags);
+            ilo_texture_set_slice_flags(tex, lv, 0, num_slices, flags, flags);
+         }
       }
    }
 
index 0a835d99210ee02d2fba2d0e07a8259d6c6285b9..d602e0cbf7020af274dad040b8f5ee40cb522ecb 100644 (file)
@@ -66,16 +66,6 @@ enum ilo_texture_flags {
     * flags, the slice has been cleared to ilo_texture_slice::clear_value.
     */
    ILO_TEXTURE_CLEAR          = 1 << 6,
-
-   /*
-    * Set when HiZ can be enabled.
-    *
-    * It is never set in resolve flags.  When set in slice flags, the slice
-    * can have HiZ enabled.  It is to be noted that this bit is always set for
-    * either all or none of the slices in a level, allowing quick check in
-    * case of layered rendering.
-    */
-   ILO_TEXTURE_HIZ            = 1 << 7,
 };
 
 /**
@@ -189,18 +179,4 @@ ilo_texture_set_slice_clear_value(struct ilo_texture *tex, unsigned level,
    }
 }
 
-static inline bool
-ilo_texture_can_enable_hiz(const struct ilo_texture *tex, unsigned level,
-                           unsigned first_slice, unsigned num_slices)
-{
-   /*
-    * Either all or none of the slices in the same level have ILO_TEXTURE_HIZ
-    * set.  It suffices to check only the first slice.
-    */
-   const struct ilo_texture_slice *slice =
-      ilo_texture_get_slice(tex, level, 0);
-
-   return (tex->image.aux.bo && (slice->flags & ILO_TEXTURE_HIZ));
-}
-
 #endif /* ILO_RESOURCE_H */
index 56e6787088187459cc1ab2e9b7741abb98df556a..ec41473f94ac68d87f1c914712974c28c542fee9 100644 (file)
@@ -96,8 +96,7 @@ resource_get_transfer_method(struct pipe_resource *res,
       if (tex->image.tiling == GEN8_TILING_W || tex->separate_s8) {
          /* on GEN6, separate stencil is enabled only when HiZ is */
          if (ilo_dev_gen(&is->dev) >= ILO_GEN(7) ||
-             ilo_texture_can_enable_hiz(tex, transfer->level,
-                transfer->box.z, transfer->box.depth)) {
+             ilo_image_can_enable_aux(&tex->image, transfer->level)) {
             m = ILO_TRANSFER_MAP_SW_ZS;
             need_convert = true;
          }