<div dir="ltr">On 27 March 2013 20:43, Chad Versace <span dir="ltr"><<a href="mailto:chad.versace@linux.intel.com" target="_blank">chad.versace@linux.intel.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I like this patch. The final result feels cleaner than the present code.<br>
Comments below.<br>
<div><div class="h5"><br>
<br>
On Tue, Mar 26, 2013 at 09:54:18PM -0700, Paul Berry wrote:<br>
> This patch consolidates duplicate code in the brw_depthbuffer and<br>
> gen7_depthbuffer state atoms. Previously, these state atoms contained<br>
> 5 chunks of code for emitting the _3DSTATE_DEPTH_BUFFER packet (3 for<br>
> Gen4-6 and 2 for Gen7). Also a lot of logic for determining the<br>
> appropriate buffer setup was duplicated between the Gen4-6 and Gen7<br>
> functions.<br>
><br>
> This refactor splits the code into three separate functions:<br>
> brw_emit_depthbuffer(), which determines the appropriate buffer setup<br>
> in a mostly generation-independent way, brw_emit_depth_stencil_hiz(),<br>
> which emits the appropriate state packets for Gen4-6, and<br>
> gen7_emit_depth_stencil_hiz(), which emits the appropriate state<br>
> packets for Gen7.<br>
><br>
> Tested using Piglit on Gen5-7 (no regressions).<br>
> ---<br>
> src/mesa/drivers/dri/i965/brw_context.h | 23 ++++<br>
> src/mesa/drivers/dri/i965/brw_misc_state.c | 189 +++++++++++++++-------------<br>
> src/mesa/drivers/dri/i965/brw_vtbl.c | 2 +<br>
> src/mesa/drivers/dri/i965/gen7_misc_state.c | 93 +++++---------<br>
> src/mesa/drivers/dri/intel/intel_context.h | 16 +++<br>
> 5 files changed, 171 insertions(+), 152 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h<br>
> index 8ff70c9..1ea038f 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_context.h<br>
> +++ b/src/mesa/drivers/dri/i965/brw_context.h<br>
> @@ -1347,6 +1347,29 @@ struct opcode_desc {<br>
><br>
> extern const struct opcode_desc opcode_descs[128];<br>
><br>
> +void<br>
> +brw_emit_depthbuffer(struct brw_context *brw);<br>
> +<br>
> +void<br>
> +brw_emit_depth_stencil_hiz(struct brw_context *brw,<br>
> + struct intel_mipmap_tree *depth_mt,<br>
> + uint32_t depth_offset, uint32_t depthbuffer_format,<br>
> + uint32_t depth_surface_type,<br>
> + struct intel_mipmap_tree *stencil_mt,<br>
> + struct intel_mipmap_tree *hiz_mt,<br>
> + bool separate_stencil, uint32_t width,<br>
> + uint32_t height, uint32_t tile_x, uint32_t tile_y);<br>
> +<br>
> +void<br>
> +gen7_emit_depth_stencil_hiz(struct brw_context *brw,<br>
> + struct intel_mipmap_tree *depth_mt,<br>
> + uint32_t depth_offset, uint32_t depthbuffer_format,<br>
> + uint32_t depth_surface_type,<br>
> + struct intel_mipmap_tree *stencil_mt,<br>
> + struct intel_mipmap_tree *hiz_mt,<br>
> + bool separate_stencil, uint32_t width,<br>
> + uint32_t height, uint32_t tile_x, uint32_t tile_y);<br>
> +<br>
> #ifdef __cplusplus<br>
> }<br>
> #endif<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c<br>
> index d6bd86c..3821eda 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_misc_state.c<br>
> +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c<br>
> @@ -561,7 +561,8 @@ brw_workaround_depthstencil_alignment(struct brw_context *brw,<br>
> }<br>
> }<br>
><br>
> -static void emit_depthbuffer(struct brw_context *brw)<br>
> +void<br>
> +brw_emit_depthbuffer(struct brw_context *brw)<br>
> {<br>
> struct intel_context *intel = &brw->intel;<br>
> struct gl_context *ctx = &intel->ctx;<br>
> @@ -574,20 +575,23 @@ static void emit_depthbuffer(struct brw_context *brw)<br>
> struct intel_mipmap_tree *hiz_mt = brw->depthstencil.hiz_mt;<br>
> uint32_t tile_x = brw->depthstencil.tile_x;<br>
> uint32_t tile_y = brw->depthstencil.tile_y;<br>
> - unsigned int len;<br>
> bool separate_stencil = false;<br>
> + uint32_t depth_surface_type = BRW_SURFACE_NULL;<br>
> + uint32_t depthbuffer_format = BRW_DEPTHFORMAT_D32_FLOAT;<br>
> + uint32_t depth_offset = 0;<br>
> + uint32_t width = 1, height = 1;<br>
><br>
> - if (stencil_mt && stencil_mt->format == MESA_FORMAT_S8)<br>
> - separate_stencil = true;<br>
> + if (stencil_mt) {<br>
> + separate_stencil = stencil_mt->format == MESA_FORMAT_S8;<br>
><br>
> - /* 3DSTATE_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER are both<br>
> - * non-pipelined state that will need the PIPE_CONTROL workaround.<br>
> - */<br>
> - if (intel->gen == 6) {<br>
> - intel_emit_post_sync_nonzero_flush(intel);<br>
> - intel_emit_depth_stall_flushes(intel);<br>
> + /* Gen7 only supports separate stencil */<br>
<br>
</div></div>The order of words here confuse me. The "only" is adjacent to "Gen7", not<br>
"separate stencil", so I read it as "Only Gen7 supports separate stencil."<br>
Please move "only" to be adjacent to "separate stencil".<br></blockquote><div><br></div><div>Wow, that interpretation really surprises me. I wonder if this is a difference between our dialects. "Gen7 supports only separate stencil" seems a little more awkward to me, but it still carries my intended meaning, so I'm fine with the change.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
> + assert(separate_stencil || intel->gen < 7);<br>
> }<br>
><br>
> + /* Gen7 only supports separate stencil */<br>
> + assert(intel->gen < 6 || !depth_mt ||<br>
> + !_mesa_is_format_packed_depth_stencil(depth_mt->format));<br>
> +<br>
<br>
</div>I don't understand the comment for the above the assertion. The comment<br>
mentions only gen7, but the assertion applies to gen >= 6.<br>
<br>
Also, the assertion is incorrect. It will fail on gen6 if hiz is disabled.<br></blockquote><div><br></div><div>You're right--I meant to type "intel->gen <= 6".<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
How about moving this assertion into the `if (depth_irb)` branch below and<br>
doing something like this:<br>
<br>
/* When 3DSTATE_DEPTH_BUFFER.Separate_Stencil_Enable is set, then<br>
* 3DSTATE_DEPTH_BUFFER.Surface_Format is not permitted to be a packed<br>
* depthstencil format.<br>
*<br>
* Gens prior to 7 require that HiZ_Enable and Separate_Stencil_Enable be<br>
* set to the same value. Gens after 7 implicitly always set<br>
* Separate_Stencil_Enable; software cannot disable it.<br>
*/<br>
if ((intel->gen < 7 && depth_mt->hiz_mt) || intel->gen >= 7) {<br>
assert(!_mesa_is_format_packed_depth_stencil(depth_mt->format));<br>
<div><div class="h5"> }<br></div></div></blockquote><div><br></div>I think I'm ok with this but I'll want to give it another piglit run on Gen6 just to be sure. In particular, the assertion you propose is more stringent--it prohibits the following combination of circumstances, which my patch allowed:<br>
</div><div class="gmail_quote"><br>- intel->gen == 6<br></div><div class="gmail_quote">- depth_mt is non-null<br>- depth_mt->hiz_mt is non-null<br></div><div class="gmail_quote"><div>- _mesa_is_format_packed_depth_stencil(depth_mt->format)<br>
<br></div><div>I'm pretty sure that is fine--this combination of conditions should never occur. I'll follow up if piglit finds an exception.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5">
<br>
> /* If there's a packed depth/stencil bound to stencil only, we need to<br>
> * emit the packed depth/stencil buffer packet.<br>
> */<br>
> @@ -596,31 +600,21 @@ static void emit_depthbuffer(struct brw_context *brw)<br>
> depth_mt = stencil_mt;<br>
> }<br>
><br>
> - if (intel->gen >= 6)<br>
> - len = 7;<br>
> - else if (intel->is_g4x || intel->gen == 5)<br>
> - len = 6;<br>
> - else<br>
> - len = 5;<br>
> -<br>
> - if (!depth_irb && !separate_stencil) {<br>
> - BEGIN_BATCH(len);<br>
> - OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (len - 2));<br>
> - OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) |<br>
> - (BRW_SURFACE_NULL << 29));<br>
> - OUT_BATCH(0);<br>
> - OUT_BATCH(0);<br>
> - OUT_BATCH(0);<br>
> -<br>
> - if (intel->is_g4x || intel->gen >= 5)<br>
> - OUT_BATCH(0);<br>
> + if (depth_irb) {<br>
> + struct intel_region *region = depth_mt->region;<br>
><br>
> - if (intel->gen >= 6)<br>
> - OUT_BATCH(0);<br>
> + /* Prior to Gen7, if using separate stencil, hiz must be enabled. */<br>
> + assert(intel->gen >= 7 || !separate_stencil || hiz_mt);<br>
><br>
> - ADVANCE_BATCH();<br>
> + assert(intel->gen < 6 || region->tiling == I915_TILING_Y);<br>
> + assert(!hiz_mt || region->tiling == I915_TILING_Y);<br>
><br>
> - } else if (!depth_irb && separate_stencil) {<br>
> + depthbuffer_format = brw_depthbuffer_format(brw);<br>
> + depth_surface_type = BRW_SURFACE_2D;<br>
> + depth_offset = brw->depthstencil.depth_offset;<br>
> + width = depth_irb->Base.Base.Width;<br>
> + height = depth_irb->Base.Base.Height;<br>
> + } else if (separate_stencil) {<br>
> /*<br>
> * There exists a separate stencil buffer but no depth buffer.<br>
> *<br>
> @@ -628,80 +622,95 @@ static void emit_depthbuffer(struct brw_context *brw)<br>
> * 3DSTATE_DEPTH_BUFFER: namely the tile walk, surface type, width, and<br>
> * height.<br>
> *<br>
> - * Enable the hiz bit because it and the separate stencil bit must have<br>
> - * the same value. From Section 2.11.5.6.1.1 3DSTATE_DEPTH_BUFFER, Bit<br>
> - * 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>
> * The tiled bit must be set. From the Sandybridge PRM, Volume 2, Part 1,<br>
> * Section 7.5.5.1.1 3DSTATE_DEPTH_BUFFER, Bit 1.27 Tiled Surface:<br>
> * [DevGT+]: This field must be set to TRUE.<br>
> */<br>
> assert(intel->has_separate_stencil);<br>
><br>
> - BEGIN_BATCH(len);<br>
> - OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (len - 2));<br>
> - OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) |<br>
> - (1 << 21) | /* separate stencil enable */<br>
> - (1 << 22) | /* hiz enable */<br>
> - (BRW_TILEWALK_YMAJOR << 26) |<br>
> - (1 << 27) | /* tiled surface */<br>
> - (BRW_SURFACE_2D << 29));<br>
> - OUT_BATCH(0);<br>
> - OUT_BATCH(((stencil_irb->Base.Base.Width + tile_x - 1) << 6) |<br>
> - (stencil_irb->Base.Base.Height + tile_y - 1) << 19);<br>
> - OUT_BATCH(0);<br>
> + depth_surface_type = BRW_SURFACE_2D;<br>
> + width = stencil_irb->Base.Base.Width;<br>
> + height = stencil_irb->Base.Base.Height;<br>
> + }<br>
><br>
> - if (intel->is_g4x || intel->gen >= 5)<br>
> - OUT_BATCH(tile_x | (tile_y << 16));<br>
> - else<br>
> - assert(tile_x == 0 && tile_y == 0);<br>
> + intel->vtbl.emit_depth_stencil_hiz(brw, depth_mt, depth_offset,<br>
> + depthbuffer_format, depth_surface_type,<br>
> + stencil_mt, hiz_mt, separate_stencil,<br>
> + width, height, tile_x, tile_y);<br>
> +}<br>
><br>
> - if (intel->gen >= 6)<br>
> - OUT_BATCH(0);<br>
> +void<br>
> +brw_emit_depth_stencil_hiz(struct brw_context *brw,<br>
> + struct intel_mipmap_tree *depth_mt,<br>
> + uint32_t depth_offset, uint32_t depthbuffer_format,<br>
> + uint32_t depth_surface_type,<br>
> + struct intel_mipmap_tree *stencil_mt,<br>
> + struct intel_mipmap_tree *hiz_mt,<br>
> + bool separate_stencil, uint32_t width,<br>
> + uint32_t height, uint32_t tile_x, uint32_t tile_y)<br>
> +{<br>
> + struct intel_context *intel = &brw->intel;<br>
><br>
> - ADVANCE_BATCH();<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_mt || separate_stencil;<br>
><br>
> - } else {<br>
> - struct intel_region *region = depth_mt->region;<br>
><br>
> - /* If using separate stencil, hiz must be enabled. */<br>
> - assert(!separate_stencil || hiz_mt);<br>
> + /* 3DSTATE_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER are both<br>
> + * non-pipelined state that will need the PIPE_CONTROL workaround.<br>
> + */<br>
> + if (intel->gen == 6) {<br>
> + intel_emit_post_sync_nonzero_flush(intel);<br>
> + intel_emit_depth_stall_flushes(intel);<br>
> + }<br>
><br>
> - assert(intel->gen < 6 || region->tiling == I915_TILING_Y);<br>
> - assert(!hiz_mt || region->tiling == I915_TILING_Y);<br>
> + unsigned int len;<br>
> + if (intel->gen >= 6)<br>
> + len = 7;<br>
> + else if (intel->is_g4x || intel->gen == 5)<br>
> + len = 6;<br>
> + else<br>
> + len = 5;<br>
><br>
> - BEGIN_BATCH(len);<br>
> - OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (len - 2));<br>
> - OUT_BATCH((region->pitch - 1) |<br>
> - (brw_depthbuffer_format(brw) << 18) |<br>
> - ((hiz_mt ? 1 : 0) << 21) | /* separate stencil enable */<br>
> - ((hiz_mt ? 1 : 0) << 22) | /* hiz enable */<br>
> - (BRW_TILEWALK_YMAJOR << 26) |<br>
> - ((region->tiling != I915_TILING_NONE) << 27) |<br>
> - (BRW_SURFACE_2D << 29));<br>
> - OUT_RELOC(region->bo,<br>
> + BEGIN_BATCH(len);<br>
> + OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (len - 2));<br>
> + OUT_BATCH((depth_mt ? depth_mt->region->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->region->tiling != I915_TILING_NONE : 1)<br>
> + << 27) |<br>
> + (depth_surface_type << 29));<br>
<br>
<br>
</div></div>Indentation quirkiness above.<br></blockquote><div><br></div><div>This looks correctly indented to me. What seems quirky to you?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
<br>
> +<br>
> + if (depth_mt) {<br>
> + OUT_RELOC(depth_mt->region->bo,<br>
> I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,<br>
> - brw->depthstencil.depth_offset);<br>
> - OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1) |<br>
> - (((depth_irb->Base.Base.Width + tile_x) - 1) << 6) |<br>
> - (((depth_irb->Base.Base.Height + tile_y) - 1) << 19));<br>
> + depth_offset);<br>
> + } else {<br>
> OUT_BATCH(0);<br>
> + }<br>
><br>
> - if (intel->is_g4x || intel->gen >= 5)<br>
> - OUT_BATCH(tile_x | (tile_y << 16));<br>
> - else<br>
> - assert(tile_x == 0 && tile_y == 0);<br>
> + OUT_BATCH(((width + tile_x - 1) << 6) |<br>
> + ((height + tile_y - 1) << 19));<br>
> + OUT_BATCH(0);<br>
<br>
<br>
</div>Did you intend to delete setting the mipmap layout? I suspect that the<br>
deletion caused no regressions because the enum is defined as 0.<br></blockquote><div><br></div><div>The old code was inconsistent about it--it left it out of the "else if (!depth_irb && separate_stencil)" block but included it in the final else block. It was a rather arbitrary choice since as you mention the enum is 0. I'd be happy to put it back in if you think it's clearer.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
<br>
><br>
> - if (intel->gen >= 6)<br>
> - OUT_BATCH(0);<br>
> + if (intel->is_g4x || intel->gen >= 5)<br>
> + OUT_BATCH(tile_x | (tile_y << 16));<br>
> + else<br>
> + assert(tile_x == 0 && tile_y == 0);<br>
><br>
> - ADVANCE_BATCH();<br>
> - }<br>
> + if (intel->gen >= 6)<br>
> + OUT_BATCH(0);<br>
> +<br>
> + ADVANCE_BATCH();<br>
><br>
> if (hiz_mt || separate_stencil) {<br>
> /*<br>
> @@ -770,7 +779,7 @@ static void emit_depthbuffer(struct brw_context *brw)<br>
> OUT_BATCH(_3DSTATE_CLEAR_PARAMS << 16 |<br>
> GEN5_DEPTH_CLEAR_VALID |<br>
> (2 - 2));<br>
> - OUT_BATCH(depth_irb ? depth_irb->mt->depth_clear_value : 0);<br>
> + OUT_BATCH(depth_mt ? depth_mt->depth_clear_value : 0);<br>
> ADVANCE_BATCH();<br>
> }<br>
> }<br>
> @@ -781,7 +790,7 @@ const struct brw_tracked_state brw_depthbuffer = {<br>
> .brw = BRW_NEW_BATCH,<br>
> .cache = 0,<br>
> },<br>
> - .emit = emit_depthbuffer,<br>
> + .emit = brw_emit_depthbuffer,<br>
> };<br>
><br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c<br>
> index cb25be9..4ca83e4 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_vtbl.c<br>
> +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c<br>
> @@ -267,7 +267,9 @@ void brwInitVtbl( struct brw_context *brw )<br>
> assert(brw->intel.gen >= 4);<br>
> if (brw->intel.gen >= 7) {<br>
> gen7_init_vtable_surface_functions(brw);<br>
> + brw->intel.vtbl.emit_depth_stencil_hiz = gen7_emit_depth_stencil_hiz;<br>
> } else if (brw->intel.gen >= 4) {<br>
> gen4_init_vtable_surface_functions(brw);<br>
> + brw->intel.vtbl.emit_depth_stencil_hiz = brw_emit_depth_stencil_hiz;<br>
> }<br>
> }<br>
> diff --git a/src/mesa/drivers/dri/i965/gen7_misc_state.c b/src/mesa/drivers/dri/i965/gen7_misc_state.c<br>
> index 7e46398..2009070 100644<br>
> --- a/src/mesa/drivers/dri/i965/gen7_misc_state.c<br>
> +++ b/src/mesa/drivers/dri/i965/gen7_misc_state.c<br>
> @@ -29,77 +29,46 @@<br>
> #include "brw_state.h"<br>
> #include "brw_defines.h"<br>
><br>
> -static void emit_depthbuffer(struct brw_context *brw)<br>
> +void<br>
> +gen7_emit_depth_stencil_hiz(struct brw_context *brw,<br>
> + struct intel_mipmap_tree *depth_mt,<br>
> + uint32_t depth_offset, uint32_t depthbuffer_format,<br>
> + uint32_t depth_surface_type,<br>
> + struct intel_mipmap_tree *stencil_mt,<br>
> + struct intel_mipmap_tree *hiz_mt,<br>
> + bool separate_stencil, uint32_t width,<br>
> + uint32_t height, uint32_t tile_x, uint32_t tile_y)<br>
> {<br>
> struct intel_context *intel = &brw->intel;<br>
> struct gl_context *ctx = &intel->ctx;<br>
> - struct gl_framebuffer *fb = ctx->DrawBuffer;<br>
> -<br>
> - /* _NEW_BUFFERS */<br>
> - struct intel_renderbuffer *drb = intel_get_renderbuffer(fb, BUFFER_DEPTH);<br>
> - struct intel_renderbuffer *srb = intel_get_renderbuffer(fb, BUFFER_STENCIL);<br>
> - struct intel_mipmap_tree *depth_mt = brw->depthstencil.depth_mt;<br>
> - struct intel_mipmap_tree *stencil_mt = brw->depthstencil.stencil_mt;<br>
> - struct intel_mipmap_tree *hiz_mt = brw->depthstencil.hiz_mt;<br>
> - uint32_t tile_x = brw->depthstencil.tile_x;<br>
> - uint32_t tile_y = brw->depthstencil.tile_y;<br>
> -<br>
> - /* Gen7 only supports separate stencil */<br>
> - assert(!stencil_mt || stencil_mt->format == MESA_FORMAT_S8);<br>
> - assert(!depth_mt || !_mesa_is_format_packed_depth_stencil(depth_mt->format));<br>
><br>
> intel_emit_depth_stall_flushes(intel);<br>
><br>
> - if (depth_mt == NULL) {<br>
> - uint32_t dw1 = BRW_DEPTHFORMAT_D32_FLOAT << 18;<br>
> - uint32_t dw3 = 0;<br>
> -<br>
> - if (stencil_mt == NULL) {<br>
> - dw1 |= (BRW_SURFACE_NULL << 29);<br>
> - } else {<br>
> - /* _NEW_STENCIL: enable stencil buffer writes */<br>
> - dw1 |= ((ctx->Stencil.WriteMask != 0) << 27);<br>
> -<br>
> - /* 3DSTATE_STENCIL_BUFFER inherits surface type and dimensions. */<br>
> - dw1 |= (BRW_SURFACE_2D << 29);<br>
> - dw3 = ((srb->Base.Base.Width + tile_x - 1) << 4) |<br>
> - ((srb->Base.Base.Height + tile_y - 1) << 18);<br>
> - }<br>
> -<br>
> - BEGIN_BATCH(7);<br>
> - OUT_BATCH(GEN7_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2));<br>
> - OUT_BATCH(dw1);<br>
> - OUT_BATCH(0);<br>
> - OUT_BATCH(dw3);<br>
> - OUT_BATCH(0);<br>
> - OUT_BATCH(tile_x | (tile_y << 16));<br>
> - OUT_BATCH(0);<br>
> - ADVANCE_BATCH();<br>
> - } else {<br>
> - struct intel_region *region = depth_mt->region;<br>
> -<br>
> - assert(region->tiling == I915_TILING_Y);<br>
> -<br>
> - /* _NEW_DEPTH, _NEW_STENCIL */<br>
> - BEGIN_BATCH(7);<br>
> - OUT_BATCH(GEN7_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2));<br>
> - OUT_BATCH((region->pitch - 1) |<br>
> - (brw_depthbuffer_format(brw) << 18) |<br>
> - ((hiz_mt ? 1 : 0) << 22) | /* hiz enable */<br>
> - ((stencil_mt != NULL && ctx->Stencil.WriteMask != 0) << 27) |<br>
> - ((ctx->Depth.Mask != 0) << 28) |<br>
> - (BRW_SURFACE_2D << 29));<br>
> - OUT_RELOC(region->bo,<br>
> + /* _NEW_DEPTH, _NEW_STENCIL */<br>
> + BEGIN_BATCH(7);<br>
> + OUT_BATCH(GEN7_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2));<br>
> + OUT_BATCH((depth_mt ? depth_mt->region->pitch - 1 : 0) |<br>
> + (depthbuffer_format << 18) |<br>
> + ((hiz_mt ? 1 : 0) << 22) |<br>
> + ((stencil_mt != NULL && ctx->Stencil.WriteMask != 0) << 27) |<br>
> + ((ctx->Depth.Mask != 0) << 28) |<br>
> + (depth_surface_type << 29));<br>
> +<br>
> + if (depth_mt) {<br>
> + OUT_RELOC(depth_mt->region->bo,<br>
> I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,<br>
> - brw->depthstencil.depth_offset);<br>
> - OUT_BATCH((((drb->Base.Base.Width + tile_x) - 1) << 4) |<br>
> - (((drb->Base.Base.Height + tile_y) - 1) << 18));<br>
> - OUT_BATCH(0);<br>
> - OUT_BATCH(tile_x | (tile_y << 16));<br>
> + depth_offset);<br>
> + } else {<br>
> OUT_BATCH(0);<br>
> - ADVANCE_BATCH();<br>
> }<br>
><br>
> + OUT_BATCH(((width + tile_x - 1) << 4) |<br>
> + ((height + tile_y - 1) << 18));<br>
> + OUT_BATCH(0);<br>
> + OUT_BATCH(tile_x | (tile_y << 16));<br>
> + OUT_BATCH(0);<br>
> + ADVANCE_BATCH();<br>
> +<br>
> if (hiz_mt == NULL) {<br>
> BEGIN_BATCH(3);<br>
> OUT_BATCH(GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16 | (3 - 2));<br>
> @@ -166,5 +135,5 @@ const struct brw_tracked_state gen7_depthbuffer = {<br>
> .brw = BRW_NEW_BATCH,<br>
> .cache = 0,<br>
> },<br>
> - .emit = emit_depthbuffer,<br>
> + .emit = brw_emit_depthbuffer,<br>
> };<br>
> diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h<br>
> index 59cf197..1605c30 100644<br>
> --- a/src/mesa/drivers/dri/intel/intel_context.h<br>
> +++ b/src/mesa/drivers/dri/intel/intel_context.h<br>
> @@ -205,6 +205,22 @@ struct intel_context<br>
> int width,<br>
> uint32_t *out_offset);<br>
> /** \} */<br>
> +<br>
> + /**<br>
> + * Sent the appropriate state packets to configure depth, stencil, and<br>
</div></div> ^^^^<br>
Send<br></blockquote><div><br></div><div>Oops, thanks :)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class=""><div class="h5"><br>
<br>
> + * HiZ buffers (i965+ only)<br>
> + */<br>
> + void (*emit_depth_stencil_hiz)(struct brw_context *brw,<br>
> + struct intel_mipmap_tree *depth_mt,<br>
> + uint32_t depth_offset,<br>
> + uint32_t depthbuffer_format,<br>
> + uint32_t depth_surface_type,<br>
> + struct intel_mipmap_tree *stencil_mt,<br>
> + struct intel_mipmap_tree *hiz_mt,<br>
> + bool separate_stencil,<br>
> + uint32_t width, uint32_t height,<br>
> + uint32_t tile_x, uint32_t tile_y);<br>
> +<br>
> } vtbl;<br>
><br>
> GLbitfield Fallback; /**< mask of INTEL_FALLBACK_x bits */<br>
> --<br>
> 1.8.2<br>
><br>
</div></div></blockquote></div><br></div></div>