From: Chia-I Wu Date: Tue, 14 Jan 2014 05:50:12 +0000 (+0800) Subject: ilo: use a helper to determine if HiZ is enabled X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=18645d1533032e0ee64714731977e12ee16d959b;p=mesa.git ilo: use a helper to determine if HiZ is enabled Add ilo_texture_can_enable_hiz and replace all checks for tex->hiz.bo by calls to ilo_texture_can_enable_hiz(). --- diff --git a/src/gallium/drivers/ilo/ilo_blit.c b/src/gallium/drivers/ilo/ilo_blit.c index 17193ab7dc6..ab1ec5bbd61 100644 --- a/src/gallium/drivers/ilo/ilo_blit.c +++ b/src/gallium/drivers/ilo/ilo_blit.c @@ -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) { /* diff --git a/src/gallium/drivers/ilo/ilo_blit.h b/src/gallium/drivers/ilo/ilo_blit.h index 6e85f79724d..61fa322c9f5 100644 --- a/src/gallium/drivers/ilo/ilo_blit.h +++ b/src/gallium/drivers/ilo/ilo_blit.h @@ -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); } diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c index 6314c35fd2d..015cfa459a5 100644 --- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c +++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c @@ -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; /* diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.c b/src/gallium/drivers/ilo/ilo_gpe_gen6.c index 1351e1967d9..b3957272cf0 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen6.c +++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.c @@ -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; diff --git a/src/gallium/drivers/ilo/ilo_resource.h b/src/gallium/drivers/ilo/ilo_resource.h index afb49ff48b4..125535a2771 100644 --- a/src/gallium/drivers/ilo/ilo_resource.h +++ b/src/gallium/drivers/ilo/ilo_resource.h @@ -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 */