<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 18, 2017 at 1:46 AM, Topi Pohjolainen <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_<wbr>clear.c | 5 +-<br>
src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c | 3 +-<br>
src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 136 +++++++++++++++++---------<br>
3 files changed, 97 insertions(+), 47 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_clear.c b/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
index 7fbaa3a47d..c310d2547a 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
@@ -121,7 +121,8 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
if ((ctx->Scissor.EnableFlags & 1) && !noop_scissor(fb)) {<br>
perf_debug("Failed to fast clear %dx%d depth because of scissors. "<br>
"Possible 5%% performance win if avoided.\n",<br>
- mt->logical_width0, mt->logical_height0);<br>
+ mt->surf.logical_level0_px.<wbr>width,<br>
+ mt->surf.logical_level0_px.<wbr>height);<br>
return false;<br>
}<br>
<br>
@@ -149,7 +150,7 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
* optimization must be disabled.<br>
*/<br>
if (brw->gen == 6 &&<br>
- (minify(mt->physical_width0,<br>
+ (minify(mt->surf.phys_level0_<wbr>sa.width,<br>
depth_irb->mt_level - mt->first_level) % 16) != 0)<br>
return false;<br>
break;<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c b/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c<br>
index c934d0d21a..5cee93ade0 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c<br>
@@ -78,7 +78,8 @@ emit_depth_packets(struct brw_context *brw,<br>
OUT_BATCH(((width - 1) << 4) | ((height - 1) << 18) | lod);<br>
OUT_BATCH(((depth - 1) << 21) | (min_array_element << 10) | mocs_wb);<br>
OUT_BATCH(0);<br>
- OUT_BATCH(((depth - 1) << 21) | (depth_mt ? depth_mt->qpitch >> 2 : 0));<br>
+ OUT_BATCH(((depth - 1) << 21) |<br>
+ (depth_mt ? depth_mt->surf.array_pitch_el_<wbr>rows >> 2 : 0));<br>
ADVANCE_BATCH();<br>
<br>
if (!hiz) {<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
index 702dcd8635..ea8b2662fd 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
@@ -520,43 +520,7 @@ intel_miptree_create_layout(<wbr>struct brw_context *brw,<br>
mt->physical_height0 = height0;<br>
mt->physical_depth0 = depth0;<br>
<br>
- if (needs_separate_stencil(brw, mt, format, layout_flags)) {<br>
- uint32_t stencil_flags = MIPTREE_LAYOUT_ACCELERATED_<wbr>UPLOAD;<br>
- if (brw->gen == 6) {<br>
- stencil_flags |= MIPTREE_LAYOUT_TILING_ANY;<br>
- }<br>
-<br>
- mt->stencil_mt = intel_miptree_create(brw,<br>
- mt->target,<br>
- MESA_FORMAT_S_UINT8,<br>
- mt->first_level,<br>
- mt->last_level,<br>
- mt->logical_width0,<br>
- mt->logical_height0,<br>
- mt->logical_depth0,<br>
- num_samples,<br>
- stencil_flags);<br>
-<br>
- if (!mt->stencil_mt) {<br>
- intel_miptree_release(&mt);<br>
- return NULL;<br>
- }<br>
- mt->stencil_mt->r8stencil_<wbr>needs_update = true;<br>
-<br>
- /* Fix up the Z miptree format for how we're splitting out separate<br>
- * stencil. Gen7 expects there to be no stencil bits in its depth buffer.<br>
- */<br>
- mt->format = intel_depth_format_for_<wbr>depthstencil_format(mt-><wbr>format);<br>
- mt->cpp = 4;<br>
-<br>
- if (format == mt->format) {<br>
- _mesa_problem(NULL, "Unknown format %s in separate stencil mt\n",<br>
- _mesa_get_format_name(mt-><wbr>format));<br>
- }<br>
- }<br>
-<br>
- if (layout_flags & MIPTREE_LAYOUT_GEN6_HIZ_<wbr>STENCIL)<br>
- mt->array_layout = GEN6_HIZ_STENCIL;<br>
+ assert(!needs_separate_<wbr>stencil(brw, mt, format, layout_flags));<br>
<br>
/*<br>
* Obey HALIGN_16 constraints for Gen8 and Gen9 buffers which are<br>
@@ -829,6 +793,40 @@ fail:<br>
return NULL;<br>
}<br>
<br>
+static bool<br>
+separate_stencil_surface(<wbr>struct brw_context *brw,<br>
+ struct intel_mipmap_tree *mt)<br></blockquote><div><br></div><div>make_separate_stencil_surface? Also, it seems perfectly reasonable for this to return the miptree rather than a bool.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+{<br>
+ mt->stencil_mt = make_surface(brw, mt->target, MESA_FORMAT_S_UINT8,<br>
+ 0, mt->surf.levels - 1,<br>
+ mt->surf.logical_level0_px.<wbr>width,<br>
+ mt->surf.logical_level0_px.<wbr>height,<br>
+ mt->surf.dim == ISL_SURF_DIM_3D ?<br>
+ mt->surf.logical_level0_px.<wbr>depth :<br>
+ mt->surf.logical_level0_px.<wbr>array_len,<br>
+ mt->surf.samples, ISL_TILING_W_BIT,<br>
+ ISL_SURF_USAGE_STENCIL_BIT |<br>
+ ISL_SURF_USAGE_TEXTURE_BIT,<br>
+ BO_ALLOC_FOR_RENDER, 0, NULL);<br>
+<br>
+ if (!mt->stencil_mt)<br>
+ return false;<br>
+<br>
+ mt->stencil_mt->r8stencil_<wbr>needs_update = true;<br>
+<br>
+ return true;<br>
+}<br>
+<br>
+static bool<br>
+force_linear_tiling(uint32_t layout_flags)<br>
+{<br>
+ /* ANY includes NONE and Y bit. */<br>
+ if (layout_flags & MIPTREE_LAYOUT_TILING_Y)<br>
+ return false;<br>
+<br>
+ return layout_flags & MIPTREE_LAYOUT_TILING_NONE;<br>
+}<br>
+<br>
static struct intel_mipmap_tree *<br>
miptree_create(struct brw_context *brw,<br>
GLenum target,<br>
@@ -849,6 +847,34 @@ miptree_create(struct brw_context *brw,<br>
ISL_SURF_USAGE_TEXTURE_BIT,<br>
BO_ALLOC_FOR_RENDER, 0, NULL);<br>
<br>
+ const GLenum base_format = _mesa_get_format_base_format(<wbr>format);<br>
+ if ((base_format == GL_DEPTH_COMPONENT ||<br>
+ base_format == GL_DEPTH_STENCIL) &&<br>
+ !force_linear_tiling(layout_<wbr>flags)) {<br>
+ /* Fix up the Z miptree format for how we're splitting out separate<br>
+ * stencil. Gen7 expects there to be no stencil bits in its depth buffer.<br>
+ */<br>
+ const mesa_format depth_only_format =<br>
+ intel_depth_format_for_<wbr>depthstencil_format(format);<br>
+ struct intel_mipmap_tree *mt = make_surface(<br>
+ brw, target, brw->gen >= 6 ? depth_only_format : format,<br>
+ first_level, last_level,<br>
+ width0, height0, depth0, num_samples, ISL_TILING_Y0_BIT,<br>
+ ISL_SURF_USAGE_DEPTH_BIT | ISL_SURF_USAGE_TEXTURE_BIT,<br>
+ BO_ALLOC_FOR_RENDER, 0, NULL);<br></blockquote><div><br></div><div>One argument per line please. This is unreadable.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ if (needs_separate_stencil(brw, mt, format, layout_flags) &&<br>
+ !separate_stencil_surface(brw, mt)) {<br>
+ intel_miptree_release(&mt);<br>
+ return NULL;<br>
+ }<br>
+<br>
+ if (!(layout_flags & MIPTREE_LAYOUT_DISABLE_AUX))<br>
+ intel_miptree_choose_aux_<wbr>usage(brw, mt);<br>
+<br>
+ return mt;<br>
+ }<br>
+<br>
struct intel_mipmap_tree *mt;<br>
mesa_format tex_format = format;<br>
mesa_format etc_format = MESA_FORMAT_NONE;<br>
@@ -970,8 +996,31 @@ intel_miptree_create_for_bo(<wbr>struct brw_context *brw,<br>
struct intel_mipmap_tree *mt;<br>
uint32_t tiling, swizzle;<br>
const GLenum target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;<br>
+ const GLenum base_format = _mesa_get_format_base_format(<wbr>format);<br>
+<br>
+ if ((base_format == GL_DEPTH_COMPONENT ||<br>
+ base_format == GL_DEPTH_STENCIL)) {<br>
+ const mesa_format depth_only_format =<br>
+ intel_depth_format_for_<wbr>depthstencil_format(format);<br>
+ mt = make_surface(brw, target,<br>
+ brw->gen >= 6 ? depth_only_format : format,<br>
+ 0, 0, width, height, depth, 1, ISL_TILING_Y0_BIT,<br>
+ ISL_SURF_USAGE_DEPTH_BIT | ISL_SURF_USAGE_TEXTURE_BIT,<br>
+ BO_ALLOC_FOR_RENDER, pitch, bo);<br>
<br>
- if (format == MESA_FORMAT_S_UINT8) {<br>
+ if (needs_separate_stencil(brw, mt, format, layout_flags) &&<br>
+ !separate_stencil_surface(brw, mt)) {<br></blockquote><div><br></div><div>If someone calls create_for_bo and wants separate stencil, that seems bad to me.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ intel_miptree_release(&mt);<br>
+ return NULL;<br>
+ }<br>
+<br>
+ brw_bo_reference(bo);<br>
+<br>
+ if (!(layout_flags & MIPTREE_LAYOUT_DISABLE_AUX))<br>
+ intel_miptree_choose_aux_<wbr>usage(brw, mt);<br>
+<br>
+ return mt;<br>
+ } else if (format == MESA_FORMAT_S_UINT8) {<br>
mt = make_surface(brw, target, MESA_FORMAT_S_UINT8,<br>
0, 0, width, height, depth, 1,<br>
ISL_TILING_W_BIT,<br>
@@ -1966,10 +2015,11 @@ intel_miptree_level_enable_<wbr>hiz(struct brw_context *brw,<br>
uint32_t level)<br>
{<br>
assert(mt->hiz_buf);<br>
+ assert(mt->surf.size > 0);<br>
<br>
if (brw->gen >= 8 || brw->is_haswell) {<br>
- uint32_t width = minify(mt->physical_width0, level);<br>
- uint32_t height = minify(mt->physical_height0, level);<br>
+ uint32_t width = minify(mt->surf.phys_level0_<wbr>sa.width, level);<br>
+ uint32_t height = minify(mt->surf.phys_level0_<wbr>sa.height, level);<br>
<br>
/* Disable HiZ for LOD > 0 unless the width is 8 aligned<br>
* and the height is 4 aligned. This allows our HiZ support<br>
@@ -2000,12 +2050,10 @@ intel_miptree_alloc_hiz(struct brw_context *brw,<br>
if (!aux_state)<br>
return false;<br>
<br>
- struct isl_surf temp_main_surf;<br>
struct isl_surf temp_hiz_surf;<br>
<br>
- intel_miptree_get_isl_surf(<wbr>brw, mt, &temp_main_surf);<br>
MAYBE_UNUSED bool ok =<br>
- isl_surf_get_hiz_surf(&brw-><wbr>isl_dev, &temp_main_surf, &temp_hiz_surf);<br>
+ isl_surf_get_hiz_surf(&brw-><wbr>isl_dev, &mt->surf, &temp_hiz_surf);<br>
assert(ok);<br>
<br>
const uint32_t alloc_flags = BO_ALLOC_FOR_RENDER;<br>
@@ -2094,7 +2142,7 @@ intel_miptree_sample_with_hiz(<wbr>struct brw_context *brw,<br>
* mipmap levels aren't available in the HiZ buffer. So we need all levels<br>
* of the texture to be HiZ enabled.<br>
*/<br>
- for (unsigned level = mt->first_level; level <= mt->last_level; ++level) {<br>
+ for (unsigned level = 0; level < mt->surf.levels; ++level) {<br>
if (!intel_miptree_level_has_hiz(<wbr>mt, level))<br>
return false;<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.11.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>