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 groups together the parameters used by the HiZ functions<br>
&gt; into a new data structure, brw_hiz_resolve_params, rather than passing<br>
&gt; each parameter individually between the HiZ functions.  This data<br>
&gt; structure is a subclass of brw_blorp_params, which represents the<br>
&gt; parameters of a general-purpose blit or resolve operation.  A future<br>
&gt; patch will add another subclass for blits.<br>
&gt;<br>
&gt; In addition, this patch generalizes the (width, height) parameters to<br>
&gt; a full rect (x0, y0, x1, y1), since blitting operations will need to<br>
&gt; be able to operate on arbitrary rectangles.  Also, it renames several<br>
&gt; of the HiZ functions to reflect the expanded role they will serve.<br>
&gt; ---<br>
&gt;  src/mesa/drivers/dri/i965/Makefile.sources |    1 +<br>
&gt;  src/mesa/drivers/dri/i965/brw_blorp.cpp    |  106 ++++++++++++++++++++<br>
&gt;  src/mesa/drivers/dri/i965/brw_blorp.h      |  130 +++++++++++++++++++++++++<br>
&gt;  src/mesa/drivers/dri/i965/gen6_blorp.cpp   |  146 +++++++++++-----------------<br>
&gt;  src/mesa/drivers/dri/i965/gen6_blorp.h     |   38 -------<br>
&gt;  src/mesa/drivers/dri/i965/gen7_blorp.cpp   |   87 +++++++----------<br>
&gt;  6 files changed, 331 insertions(+), 177 deletions(-)<br>
&gt;  create mode 100644 src/mesa/drivers/dri/i965/brw_blorp.cpp<br>
&gt;  create mode 100644 src/mesa/drivers/dri/i965/brw_blorp.h<br>
<br>
</div>[snip]<br>
<div class="im"><br>
&gt; +class brw_blorp_params<br>
&gt; +{<br>
&gt; +public:<br>
&gt; +   brw_blorp_params();<br>
&gt; +<br>
&gt; +   void exec(struct intel_context *intel) const;<br>
<br>
</div>Params can &quot;exec&quot; themselves? This feels like an abuse of the method concept.<br>
<br>
The method does one thing: it inspects the gen and dispatches to gen6_blorp_exec<br>
gen7_blorp_exec. I think it&#39;s sensible to replace the method with brw_blorp_exec<br>
that does the same thing. <br></blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
&gt; +<br>
&gt; +   uint32_t x0;<br>
&gt; +   uint32_t y0;<br>
&gt; +   uint32_t x1;<br>
&gt; +   uint32_t y1;<br>
&gt; +   brw_blorp_mip_info depth;<br>
&gt; +   uint32_t depth_format;<br>
&gt; +   enum gen6_hiz_op hiz_op;<br>
&gt; +};<br>
&gt; +<br>
&gt; +/**<br>
&gt; + * Parameters for a HiZ or depth resolve operation.<br>
&gt; + *<br>
&gt; + * For an overview of HiZ ops, see the following sections of the Sandy Bridge<br>
&gt; + * PRM, Volume 1, Part 2:<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; + */<br>
&gt; +class brw_hiz_resolve_params : public brw_blorp_params<br>
&gt; +{<br>
&gt; +public:<br>
&gt; +   brw_hiz_resolve_params(struct intel_mipmap_tree *mt,<br>
&gt; +                          unsigned int level, unsigned int layer,<br>
&gt; +                          gen6_hiz_op op);<br>
&gt; +};<br>
<br>
</div></div>Why is the &#39;hiz_op&#39; field in brw_blorp_params, not in brw_hiz_resolve_params?<br>
named brw_hiz_resolve_params? The latter seems like the appropriate place for<br>
it.<br></blockquote><div><br>Agreed, it would make more sense to put it in brw_hiz_resolve_params.  The problem is that gen6_blorp_exec() and gen7_blorp_exec() just have a pointer to a brw_blorp_params, and they need to be able to find out what HiZ op to program the hardware to.  We could solve this by putting a virtual function get_hiz_op() in brw_blorp_params, and then override it in br_hiz_resolve_params to return the correct op, but that seems like a lot of machinery for just this one little enum.  Still, I&#39;d be willing to go along with it if you feel strongly.<br>
<br>Incidentally, I think a similar situation exists for several other fields of this data structure (src, dst, and wm_push_consts, which are only used for blits).<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>
A remark about naming. The brw_hiz_resolve_params struct is the parameter<br>
list not only for hiz resolves, but also for depth resolves and depth clears.<br>
I think the class should be renamed to the more generic brw_hiz_op_params.<br>
The term &quot;hiz_op&quot; is consistent with hiz-related code elsewhere in the driver,<br>
and is the operation&#39;s actual name according to some hw docs.<br></blockquote><div><br>Sounds reasonable.  I&#39;ll make that change.<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 class="im"><br>
&gt; +<br>
&gt; +/**<br>
&gt; + * \name BLORP internals<br>
&gt; + * \{<br>
&gt; + *<br>
&gt; + * Used internally by gen6_blorp_exec() and gen7_blorp_exec().<br>
&gt; + */<br>
&gt; +<br>
&gt; +void<br>
&gt; +gen6_blorp_init(struct brw_context *brw);<br>
&gt; +<br>
&gt; +void<br>
&gt; +gen6_blorp_emit_batch_head(struct brw_context *brw,<br>
&gt; +                           const brw_blorp_params *params);<br>
&gt; +<br>
&gt; +void<br>
&gt; +gen6_blorp_emit_vertices(struct brw_context *brw,<br>
&gt; +                         const brw_blorp_params *params);<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; +/** \} */<br>
<br>
</div><div class="im">&gt; +void<br>
&gt; +gen6_blorp_exec(struct intel_context *intel,<br>
&gt; +                const brw_blorp_params *params);<br>
&gt; +<br>
<br>
</div>Is there a reason you moved the gen6 prototypes into brw_blorp.h? Since<br>
the functions are implemented in gen6_blorp.cpp, I think the prototypes<br>
should remain in their original location, gen6_blorp.h.<br>
Any other organizational scheme feels ad-hoc and makes it more difficult<br>
to guess, at encountering a prototype, where its implemention lives.<br></blockquote><div><br>No, there&#39;s no good reason.  Most likely this was the result of my thrashing about trying to figure out the best way to implement things.  I agree that gen{6,7}_blorp.h is the proper place for these functions.  I&#39;ll move them.<br>
 </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
<br>
&gt; +void<br>
&gt; +gen7_blorp_exec(struct intel_context *intel,<br>
&gt; +                const brw_blorp_params *params);<br>
<br>
</div>Ditto for this gen7 function.<br>
<div class="im"><br>
&gt; +void<br>
&gt; +gen6_blorp_exec(struct intel_context *intel,<br>
&gt; +                const brw_blorp_params *params)<br>
&gt;  {<br>
&gt;     struct gl_context *ctx = &amp;intel-&gt;ctx;<br>
&gt;     struct brw_context *brw = brw_context(ctx);<br>
&gt;     uint32_t draw_x, draw_y;<br>
&gt;     uint32_t tile_mask_x, tile_mask_y;<br>
&gt;<br>
&gt; -   assert(op != GEN6_HIZ_OP_DEPTH_CLEAR); /* Not implemented yet. */<br>
&gt; -   assert(mt-&gt;hiz_mt != NULL);<br>
&gt; -   intel_miptree_check_level_layer(mt, level, layer);<br>
&gt; -<br>
&gt; -   {<br>
&gt; -      /* Construct a dummy renderbuffer just to extract tile offsets. */<br>
&gt; -      struct intel_renderbuffer rb;<br>
&gt; -      <a href="http://rb.mt" target="_blank">rb.mt</a> = mt;<br>
&gt; -      rb.mt_level = level;<br>
&gt; -      rb.mt_layer = layer;<br>
&gt; -      intel_renderbuffer_set_draw_offset(&amp;rb);<br>
&gt; -      draw_x = rb.draw_x;<br>
&gt; -      draw_y = rb.draw_y;<br>
&gt; -   }<br>
&gt; +   params-&gt;depth.get_draw_offsets(&amp;draw_x, &amp;draw_y);<br>
<br>
</div>Nice cleanup here.<br></blockquote><div><br>Thanks :)<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 class="im"><br>
&gt;        /* According to the Sandy Bridge PRM, volume 2 part 1, pp326-327<br>
&gt;         * (3DSTATE_DEPTH_BUFFER dw5), in the documentation for &quot;Depth<br>
&gt; @@ -506,27 +482,21 @@ gen6_hiz_exec(struct intel_context *intel,<br>
&gt;        tile_x &amp;= ~7;<br>
&gt;        tile_y &amp;= ~7;<br>
&gt;<br>
&gt; -      uint32_t format;<br>
&gt; -      switch (mt-&gt;format) {<br>
&gt; -      case MESA_FORMAT_Z16:       format = BRW_DEPTHFORMAT_D16_UNORM; break;<br>
&gt; -      case MESA_FORMAT_Z32_FLOAT: format = BRW_DEPTHFORMAT_D32_FLOAT; break;<br>
&gt; -      case MESA_FORMAT_X8_Z24:    format = BRW_DEPTHFORMAT_D24_UNORM_X8_UINT; break;<br>
&gt; -      default:                    assert(0); break;<br>
&gt; -      }<br>
&gt; -<br>
<br>
</div>Again, nice to see removal of duplicate code.<br>
<br>
----<br>
Chad Versace<br>
<a href="mailto:chad.versace@linux.intel.com">chad.versace@linux.intel.com</a><br>
</blockquote></div><br>I have a few other minor fixes to this patch queued up--I&#39;ll send a v2 out soon.<br>