<div dir="ltr"><div>Yes, please!<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 22, 2017 at 12:12 PM, 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"><span class="">Separate stencil and hiz are only enabled for gen6+.<br>
<br>
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>context.h | 6 +-<br>
</span> src/mesa/drivers/dri/i965/brw_<wbr>misc_state.c | 120 +++--------------------------<br>
2 files changed, 14 insertions(+), 112 deletions(-)<br>
<span class=""><br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_context.h b/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
index 6b37500..379c18f 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
@@ -1200,8 +1200,10 @@ struct brw_context<br>
struct intel_mipmap_tree *stencil_mt;<br>
<br>
/* Inter-tile (page-aligned) byte offsets. */<br>
- uint32_t depth_offset, hiz_offset, stencil_offset;<br>
- /* Intra-tile x,y offsets for drawing to depth/stencil/hiz */<br>
+ uint32_t depth_offset;<br>
+ /* Intra-tile x,y offsets for drawing to combined depth-stencil. Only<br>
+ * used for Gen < 6.<br>
+ */<br>
uint32_t tile_x, tile_y;<br>
} depthstencil;<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c b/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
</span>index 66f8555..6ea1fb0 100644<br>
<span class="">--- a/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
@@ -216,8 +216,6 @@ brw_workaround_depthstencil_<wbr>alignment(struct brw_context *brw,<br>
brw->depthstencil.tile_x = 0;<br>
brw->depthstencil.tile_y = 0;<br>
brw->depthstencil.depth_offset = 0;<br>
- brw->depthstencil.stencil_<wbr>offset = 0;<br>
- brw->depthstencil.hiz_offset = 0;<br>
brw->depthstencil.depth_mt = NULL;<br>
brw->depthstencil.stencil_mt = NULL;<br>
if (depth_irb)<br>
</span>@@ -412,26 +410,15 @@ brw_workaround_depthstencil_<wbr>alignment(struct brw_context *brw,<br>
<span class=""> intel_miptree_get_aligned_<wbr>offset(depth_mt,<br>
depth_irb->draw_x & ~tile_mask_x,<br>
depth_irb->draw_y & ~tile_mask_y);<br>
- if (intel_renderbuffer_has_hiz(<wbr>depth_irb)) {<br>
- brw->depthstencil.hiz_offset =<br>
- intel_miptree_get_aligned_<wbr>offset(depth_mt,<br>
- depth_irb->draw_x & ~tile_mask_x,<br>
- (depth_irb->draw_y & ~tile_mask_y) / 2);<br>
- }<br>
+ assert(!intel_renderbuffer_<wbr>has_hiz(depth_irb));<br>
}<br>
if (stencil_irb) {<br>
stencil_mt = get_stencil_miptree(stencil_<wbr>irb);<br>
<br>
brw->depthstencil.stencil_mt = stencil_mt;<br>
- if (stencil_mt->format == MESA_FORMAT_S_UINT8) {<br>
- /* Note: we can't compute the stencil offset using<br>
- * intel_region_get_aligned_<wbr>offset(), because stencil_region claims<br>
- * that the region is untiled even though it's W tiled.<br>
- */<br>
- brw->depthstencil.stencil_<wbr>offset =<br>
- (stencil_draw_y & ~tile_mask_y) * stencil_mt->pitch +<br>
- (stencil_draw_x & ~tile_mask_x) * 64;<br>
</span>- } else if (!depth_irb) {<br>
<span class="">+ assert(stencil_mt->format != MESA_FORMAT_S_UINT8);<br>
</span>+<br>
+ if (!depth_irb) {<br>
brw->depthstencil.depth_offset =<br>
intel_miptree_get_aligned_<wbr>offset(<br>
stencil_mt,<br>
@@ -539,39 +526,19 @@ brw_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
<span class=""> uint32_t width, uint32_t height,<br>
uint32_t tile_x, uint32_t tile_y)<br>
{<br>
- /* Enable the hiz bit if we're doing separate stencil, because it and the<br>
- * separate stencil bit must have the same value. From Section 2.11.5.6.1.1<br>
- * 3DSTATE_DEPTH_BUFFER, Bit 1.21 "Separate Stencil Enable":<br>
- * [DevIL]: If this field is enabled, Hierarchical Depth Buffer<br>
- * Enable must also be enabled.<br>
- *<br>
- * [DevGT]: This field must be set to the same value (enabled or<br>
- * disabled) as Hierarchical Depth Buffer Enable<br>
- */<br>
- bool enable_hiz_ss = hiz || separate_stencil;<br>
</span>-<br>
<span class="">+ (void)hiz;<br>
+ (void)separate_stencil;<br>
+ (void)stencil_mt;<br>
<br>
</span><span class="">- /* 3DSTATE_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER are both<br>
- * non-pipelined state that will need the PIPE_CONTROL workaround.<br>
- */<br>
- if (brw->gen == 6) {<br>
- brw_emit_depth_stall_flushes(<wbr>brw);<br>
- }<br>
+ assert(!hiz);<br>
+ assert(!separate_stencil);<br>
<br>
</span><span class="">- unsigned int len;<br>
- if (brw->gen >= 6)<br>
- len = 7;<br>
- else if (brw->is_g4x || brw->gen == 5)<br>
- len = 6;<br>
- else<br>
- len = 5;<br>
+ const unsigned len = (brw->is_g4x || brw->gen == 5) ? 6 : 5;<br>
<br>
BEGIN_BATCH(len);<br>
OUT_BATCH(_3DSTATE_DEPTH_<wbr>BUFFER << 16 | (len - 2));<br>
OUT_BATCH((depth_mt ? depth_mt->pitch - 1 : 0) |<br>
(depthbuffer_format << 18) |<br>
- ((enable_hiz_ss ? 1 : 0) << 21) | /* separate stencil enable */<br>
- ((enable_hiz_ss ? 1 : 0) << 22) | /* hiz enable */<br>
(BRW_TILEWALK_YMAJOR << 26) |<br>
((depth_mt ? depth_mt->tiling != I915_TILING_NONE : 1)<br>
<< 27) |<br>
</span>@@ -598,73 +565,6 @@ brw_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
<div class="HOEnZb"><div class="h5"> OUT_BATCH(0);<br>
<br>
ADVANCE_BATCH();<br>
-<br>
- if (hiz || separate_stencil) {<br>
- /*<br>
- * In the 3DSTATE_DEPTH_BUFFER batch emitted above, the 'separate<br>
- * stencil enable' and 'hiz enable' bits were set. Therefore we must<br>
- * emit 3DSTATE_HIER_DEPTH_BUFFER and 3DSTATE_STENCIL_BUFFER. Even if<br>
- * there is no stencil buffer, 3DSTATE_STENCIL_BUFFER must be emitted;<br>
- * failure to do so causes hangs on gen5 and a stall on gen6.<br>
- */<br>
-<br>
- /* Emit hiz buffer. */<br>
- if (hiz) {<br>
- assert(depth_mt);<br>
- BEGIN_BATCH(3);<br>
- OUT_BATCH((_3DSTATE_HIER_<wbr>DEPTH_BUFFER << 16) | (3 - 2));<br>
- OUT_BATCH(depth_mt->hiz_buf-><wbr>aux_base.pitch - 1);<br>
- OUT_RELOC(depth_mt->hiz_buf-><a href="http://aux_base.bo" rel="noreferrer" target="_blank">a<wbr>ux_base.bo</a>,<br>
- I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,<br>
- brw->depthstencil.hiz_offset);<br>
- ADVANCE_BATCH();<br>
- } else {<br>
- BEGIN_BATCH(3);<br>
- OUT_BATCH((_3DSTATE_HIER_<wbr>DEPTH_BUFFER << 16) | (3 - 2));<br>
- OUT_BATCH(0);<br>
- OUT_BATCH(0);<br>
- ADVANCE_BATCH();<br>
- }<br>
-<br>
- /* Emit stencil buffer. */<br>
- if (separate_stencil) {<br>
- BEGIN_BATCH(3);<br>
- OUT_BATCH((_3DSTATE_STENCIL_<wbr>BUFFER << 16) | (3 - 2));<br>
- /* The stencil buffer has quirky pitch requirements. From Vol 2a,<br>
- * 11.5.6.2.1 3DSTATE_STENCIL_BUFFER, field "Surface Pitch":<br>
- * The pitch must be set to 2x the value computed based on width, as<br>
- * the stencil buffer is stored with two rows interleaved.<br>
- */<br>
- OUT_BATCH(2 * stencil_mt->pitch - 1);<br>
- OUT_RELOC(stencil_mt->bo,<br>
- I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,<br>
- brw->depthstencil.stencil_<wbr>offset);<br>
- ADVANCE_BATCH();<br>
- } else {<br>
- BEGIN_BATCH(3);<br>
- OUT_BATCH((_3DSTATE_STENCIL_<wbr>BUFFER << 16) | (3 - 2));<br>
- OUT_BATCH(0);<br>
- OUT_BATCH(0);<br>
- ADVANCE_BATCH();<br>
- }<br>
- }<br>
-<br>
- /*<br>
- * On Gen >= 6, emit clear params for safety. If using hiz, then clear<br>
- * params must be emitted.<br>
- *<br>
- * From Section 2.11.5.6.4.1 3DSTATE_CLEAR_PARAMS:<br>
- * 3DSTATE_CLEAR_PARAMS packet must follow the DEPTH_BUFFER_STATE packet<br>
- * when HiZ is enabled and the DEPTH_BUFFER_STATE changes.<br>
- */<br>
- if (brw->gen >= 6 || hiz) {<br>
- BEGIN_BATCH(2);<br>
- OUT_BATCH(_3DSTATE_CLEAR_<wbr>PARAMS << 16 |<br>
- GEN5_DEPTH_CLEAR_VALID |<br>
- (2 - 2));<br>
- OUT_BATCH(depth_mt ? depth_mt->depth_clear_value : 0);<br>
- ADVANCE_BATCH();<br>
- }<br>
}<br>
<br>
const struct brw_tracked_state brw_depthbuffer = {<br>
--<br>
2.9.3<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>
</div></div></blockquote></div><br></div>