ilo: use a helper to determine if HiZ is enabled
authorChia-I Wu <olvaffe@gmail.com>
Tue, 14 Jan 2014 05:50:12 +0000 (13:50 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 14 Jan 2014 07:43:20 +0000 (15:43 +0800)
Add ilo_texture_can_enable_hiz and replace all checks for tex->hiz.bo by calls
to ilo_texture_can_enable_hiz().

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_gpe_gen6.c
src/gallium/drivers/ilo/ilo_resource.h

index 17193ab7dc6753f235e6b2190763b921737c9b61..ab1ec5bbd61d924f3ab1e1ac81492cfb814e6b6c 100644 (file)
@@ -155,7 +155,8 @@ ilo_blit_resolve_slices_for_hiz(struct ilo_context *ilo,
       ILO_TEXTURE_CPU_WRITE;
    unsigned i;
 
-   assert(tex->base.target != PIPE_BUFFER && tex->hiz.bo);
+   assert(tex->base.target != PIPE_BUFFER &&
+          ilo_texture_can_enable_hiz(tex, level, first_slice, num_slices));
 
    if (flags & ILO_TEXTURE_RENDER_WRITE) {
       /*
index 6e85f79724d37d01afec154e30417201da21d4ee..61fa322c9f523bcf3b0aff3ff23c090ffaad08d5 100644 (file)
@@ -60,7 +60,7 @@ 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 (!tex->hiz.bo)
+   if (!ilo_texture_can_enable_hiz(tex, level, first_slice, num_slices))
       return;
 
    /*
@@ -74,7 +74,7 @@ ilo_blit_resolve_slices(struct ilo_context *ilo,
     * It is assumed there is at most one writer, and that readers read before
     * writers write.
     */
-   if (tex->hiz.bo) {
+   if (ilo_texture_can_enable_hiz(tex, level, first_slice, num_slices)) {
       ilo_blit_resolve_slices_for_hiz(ilo, res, level,
             first_slice, num_slices, flags);
    }
index 6314c35fd2d9efe6f162644b38e2b5d32f95d1fb..015cfa459a5cb78918f1d3ecbd5d81b74891b60e 100644 (file)
@@ -382,7 +382,9 @@ ilo_blitter_rectlist_clear_zs(struct ilo_blitter *blitter,
    struct pipe_depth_stencil_alpha_state dsa_state;
    uint32_t uses;
 
-   if (!tex->hiz.bo)
+   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))
       return false;
 
    if (!hiz_can_clear_zs(blitter, tex))
@@ -464,7 +466,7 @@ ilo_blitter_rectlist_resolve_z(struct ilo_blitter *blitter,
    struct ilo_texture *tex = ilo_texture(res);
    struct pipe_depth_stencil_alpha_state dsa_state;
 
-   if (!tex->hiz.bo)
+   if (!ilo_texture_can_enable_hiz(tex, level, slice, 1))
       return;
 
    /*
@@ -499,7 +501,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 (!tex->hiz.bo)
+   if (!ilo_texture_can_enable_hiz(tex, level, slice, 1))
       return;
 
    /*
index 1351e1967d92f9193992fd5e4e247a05d250b499..b3957272cf04dd4e1fa1cd6b35e35abd84aaa1ec 100644 (file)
@@ -1020,7 +1020,8 @@ zs_init_info(const struct ilo_dev_info *dev,
        *      same value (enabled or disabled) as Hierarchical Depth Buffer
        *      Enable."
        */
-      separate_stencil = (tex->hiz.bo != NULL);
+      separate_stencil =
+         ilo_texture_can_enable_hiz(tex, level, first_layer, num_layers);
    }
 
    /*
@@ -1109,7 +1110,7 @@ zs_init_info(const struct ilo_dev_info *dev,
       }
    }
 
-   if (tex->hiz.bo) {
+   if (ilo_texture_can_enable_hiz(tex, level, first_layer, num_layers)) {
       info->hiz.bo = tex->hiz.bo;
       info->hiz.stride = tex->hiz.bo_stride;
       info->hiz.tiling = INTEL_TILING_Y;
index afb49ff48b4cba8be7c7290c9e2176beb4b38c3f..125535a2771a864b314832295d6712c2c522454f 100644 (file)
@@ -157,4 +157,11 @@ ilo_texture_set_slice_flags(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)
+{
+   return (tex->hiz.bo != NULL);
+}
+
 #endif /* ILO_RESOURCE_H */