It replaces ilo_texture_can_enable_hiz().
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 &&
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.
*/
* 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);
}
/*
}
}
- 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;
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) {
/*
* 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);
}
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))
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;
/*
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;
/*
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);
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);
+ }
}
}
* 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,
};
/**
}
}
-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 */
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;
}