On 7 May 2012 15:05, Chad Versace <span dir="ltr">&lt;<a href="mailto:chad.versace@linux.intel.com" target="_blank">chad.versace@linux.intel.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 05/02/2012 01:52 PM, Paul Berry wrote:<br>
&gt; This patch splits up the gen6_blorp_exec and gen7_blorp_exec<br>
&gt; functions, which were very long, into simple component functions.<br>
&gt; With a few exceptions, there is one function per state packet.<br>
&gt;<br>
&gt; This will allow blit functionality to be added without significantly<br>
&gt; complicating the code.<br>
&gt; ---<br>
&gt;  src/mesa/drivers/dri/i965/brw_blorp.h    |   23 +-<br>
&gt;  src/mesa/drivers/dri/i965/gen6_blorp.cpp |  596 +++++++++++++++++-------------<br>
&gt;  src/mesa/drivers/dri/i965/gen7_blorp.cpp |  448 ++++++++++++-----------<br>
&gt;  3 files changed, 595 insertions(+), 472 deletions(-)<br>
<br>
</div>[snip]<br>
<div class="im"><br>
&gt; +/**<br>
&gt; + * Disable thread dispatch (dw5.19) and enable the HiZ op.<br>
&gt; + */<br>
&gt; +static void<br>
&gt; +gen6_blorp_emit_wm_disable(struct brw_context *brw,<br>
&gt; +                           const brw_blorp_params *params)<br>
<br>
</div>/begin bikeshedding<br>
<br>
I think the name of this function is misleading. In the other<br>
gen6_blorp_emit_UNIT_disable functions, we *really* disable the unit<br>
and don&#39;t care much about the contents of the 3DSTATE_UNIT packet,<br>
because the packet doesn&#39;t instruct the gpu to do anything.<br>
<br>
However, that&#39;s not the case for 3DSTATE_WM. The content of this packet<br>
is paramount; it tells the gpu which hiz op to execute. Technically,<br>
this function *does disable* the WM. But, on the other hand, it does<br>
much more than that.<br>
<br>
Ditto for gen7.<br>
<br>
But, I see that I&#39;m bikeshedding now. I need to continue on and do actual,<br>
*useful* review now :) </blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
/end bikeshedding<br></blockquote><div><br>Hmm, bikeshedding or not, I agree with you.  I had been troubled by the emit_wm_disable functions, and I wasn&#39;t quite able to put my finger on why.  Things get messier in later patches, where we wind up with 5 clumsily related functions:<br>
<br>gen6_emit_wm_disable(): emit 3DSTATE_WM for the case where there&#39;s no WM prog<br>gen6_emit_wm_enable(): emit 3DSTATE_WM for the case where there is a WM prog<br>gen7_emit_wm_disable(): emit 3DSTATE_WM and 3DSTATE_PS for the case where there&#39;s no WM prog<br>
gen7_emit_wm_enable(): emit 3DSTATE_WM for the case where there is a WM prog<br>gen7_emit_ps_config(): emit 3DSTATE_PS for the case where there is a WM prog<br><br>I&#39;ll rework things so they look like this instead:<br>
<br>gen6_emit_wm_config(): emit 3DSTATE_WM correctly, whether there&#39;s a WM prog or not<br>gen7_emit_wm_config(): emit 3DSTATE_WM correctly, whether there&#39;s a WM prog or not<br>gen7_emit_ps_config(): emit 3DSTATE_PS correctly, whether there&#39;s a WM prog or not<br>
 </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
[snip]<br>
<div><div class="h5"><br>
&gt;  /**<br>
&gt; - * \param out_offset is relative to<br>
&gt; - *        CMD_STATE_BASE_ADDRESS.DynamicStateBaseAddress.<br>
&gt; + * \brief Execute a blit or render pass operation.<br>
&gt; + *<br>
&gt; + * To execute the operation, this function manually constructs and emits a<br>
&gt; + * batch to draw a rectangle primitive. The batchbuffer is flushed before<br>
&gt; + * constructing and after emitting the batch.<br>
&gt; + *<br>
&gt; + * This function alters no GL state.<br>
&gt;   */<br>
&gt;  void<br>
&gt; -gen6_blorp_emit_depth_stencil_state(struct brw_context *brw,<br>
&gt; -                                    const brw_blorp_params *params,<br>
&gt; -                                    uint32_t *out_offset)<br>
&gt; +gen6_blorp_exec(struct intel_context *intel,<br>
&gt; +                const brw_blorp_params *params)<br>
&gt;  {<br>
&gt; -   struct gen6_depth_stencil_state *state;<br>
&gt; -   state = (struct gen6_depth_stencil_state *)<br>
&gt; -      brw_state_batch(brw, AUB_TRACE_DEPTH_STENCIL_STATE,<br>
&gt; -                      sizeof(*state), 64,<br>
&gt; -                      out_offset);<br>
&gt; -   memset(state, 0, sizeof(*state));<br>
&gt; +   struct gl_context *ctx = &amp;intel-&gt;ctx;<br>
&gt; +   struct brw_context *brw = brw_context(ctx);<br>
&gt; +   uint32_t depthstencil_offset;<br>
&gt;<br>
&gt; -   /* See the following sections of the Sandy Bridge PRM, Volume 1, Part2:<br>
&gt; -    *   - 7.5.3.1 Depth Buffer Clear<br>
&gt; -    *   - 7.5.3.2 Depth Buffer Resolve<br>
&gt; -    *   - 7.5.3.3 Hierarchical Depth Buffer Resolve<br>
&gt; +   gen6_blorp_emit_batch_head(brw, params);<br>
&gt; +   gen6_blorp_emit_vertices(brw, params);<br>
&gt; +   gen6_blorp_emit_urb_config(brw, params);<br>
&gt; +   depthstencil_offset = gen6_blorp_emit_depth_stencil_state(brw, params);<br>
&gt; +   gen6_blorp_emit_cc_state_pointers(brw, params, depthstencil_offset);<br>
&gt; +   gen6_blorp_emit_vs_disable(brw, params);<br>
&gt; +   gen6_blorp_emit_gs_disable(brw, params);<br>
&gt; +   gen6_blorp_emit_clip_disable(brw, params);<br>
&gt; +   gen6_blorp_emit_sf_config(brw, params);<br>
&gt; +   gen6_blorp_emit_wm_disable(brw, params);<br>
&gt; +<br>
&gt; +   gen6_blorp_emit_depth_stencil_config(brw, params);<br>
&gt; +   gen6_blorp_emit_clear_params(brw, params);<br>
&gt; +   gen6_blorp_emit_drawing_rectangle(brw, params);<br>
&gt; +   gen6_blorp_emit_primitive(brw, params);<br>
&gt; +<br>
&gt; +   /* See comments above at first invocation of intel_flush() in<br>
&gt; +    * gen6_blorp_emit_batch_head().<br>
&gt;      */<br>
&gt; -   state-&gt;ds2.depth_write_enable = 1;<br>
&gt; -   if (params-&gt;hiz_op == GEN6_HIZ_OP_DEPTH_RESOLVE) {<br>
&gt; -      state-&gt;ds2.depth_test_enable = 1;<br>
&gt; -      state-&gt;ds2.depth_test_func = COMPAREFUNC_NEVER;<br>
&gt; -   }<br>
&gt; +   intel_flush(ctx);<br>
&gt; +<br>
&gt; +   /* Be safe. */<br>
&gt; +   brw-&gt;state.dirty.brw = ~0;<br>
&gt; +   brw-&gt;state.dirty.cache = ~0;<br>
&gt;  }<br>
<br>
</div></div>I like the new form of gen6_blorp_exec. I look forward to discover how,<br>
in later patches, you integrate msaa into it.<br>
<br>
Many of the functions introduced by this patch contain a cast<br>
<div class="im">       struct intel_context *intel = &amp;brw-&gt;intel;<br>
</div>but do not use the &#39;intel&#39; variable.</blockquote><div><br>Actually, this variable is used by the macros BEGIN_BATCH, OUT_BATCH, and ADVANCE_BATCH.  I kinda wish intel_context were a class so we could do this:<br>
<br>intel-&gt;begin_batch(n);<br><br>instead of this:<br><br>BEGIN_BATCH(n);<br><br>and then the need for that variable would have been obvious.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
 After cleaning up the<br>
unused variables, this patch is<br>
<br>
Reviewed-by: Chad Versace &lt;<a href="mailto:chad.versace@linux.intel.com">chad.versace@linux.intel.com</a>&gt;<br>
</blockquote></div><br>