On 7 May 2012 15:05, 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_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>
> This patch groups together the parameters used by the HiZ functions<br>
> into a new data structure, brw_hiz_resolve_params, rather than passing<br>
> each parameter individually between the HiZ functions. This data<br>
> structure is a subclass of brw_blorp_params, which represents the<br>
> parameters of a general-purpose blit or resolve operation. A future<br>
> patch will add another subclass for blits.<br>
><br>
> In addition, this patch generalizes the (width, height) parameters to<br>
> a full rect (x0, y0, x1, y1), since blitting operations will need to<br>
> be able to operate on arbitrary rectangles. Also, it renames several<br>
> of the HiZ functions to reflect the expanded role they will serve.<br>
> ---<br>
> src/mesa/drivers/dri/i965/Makefile.sources | 1 +<br>
> src/mesa/drivers/dri/i965/brw_blorp.cpp | 106 ++++++++++++++++++++<br>
> src/mesa/drivers/dri/i965/brw_blorp.h | 130 +++++++++++++++++++++++++<br>
> src/mesa/drivers/dri/i965/gen6_blorp.cpp | 146 +++++++++++-----------------<br>
> src/mesa/drivers/dri/i965/gen6_blorp.h | 38 -------<br>
> src/mesa/drivers/dri/i965/gen7_blorp.cpp | 87 +++++++----------<br>
> 6 files changed, 331 insertions(+), 177 deletions(-)<br>
> create mode 100644 src/mesa/drivers/dri/i965/brw_blorp.cpp<br>
> create mode 100644 src/mesa/drivers/dri/i965/brw_blorp.h<br>
<br>
</div>[snip]<br>
<div class="im"><br>
> +class brw_blorp_params<br>
> +{<br>
> +public:<br>
> + brw_blorp_params();<br>
> +<br>
> + void exec(struct intel_context *intel) const;<br>
<br>
</div>Params can "exec" 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'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>
> +<br>
> + uint32_t x0;<br>
> + uint32_t y0;<br>
> + uint32_t x1;<br>
> + uint32_t y1;<br>
> + brw_blorp_mip_info depth;<br>
> + uint32_t depth_format;<br>
> + enum gen6_hiz_op hiz_op;<br>
> +};<br>
> +<br>
> +/**<br>
> + * Parameters for a HiZ or depth resolve operation.<br>
> + *<br>
> + * For an overview of HiZ ops, see the following sections of the Sandy Bridge<br>
> + * PRM, Volume 1, Part 2:<br>
> + * - 7.5.3.1 Depth Buffer Clear<br>
> + * - 7.5.3.2 Depth Buffer Resolve<br>
> + * - 7.5.3.3 Hierarchical Depth Buffer Resolve<br>
> + */<br>
> +class brw_hiz_resolve_params : public brw_blorp_params<br>
> +{<br>
> +public:<br>
> + brw_hiz_resolve_params(struct intel_mipmap_tree *mt,<br>
> + unsigned int level, unsigned int layer,<br>
> + gen6_hiz_op op);<br>
> +};<br>
<br>
</div></div>Why is the 'hiz_op' 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'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 "hiz_op" is consistent with hiz-related code elsewhere in the driver,<br>
and is the operation's actual name according to some hw docs.<br></blockquote><div><br>Sounds reasonable. I'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>
> +<br>
> +/**<br>
> + * \name BLORP internals<br>
> + * \{<br>
> + *<br>
> + * Used internally by gen6_blorp_exec() and gen7_blorp_exec().<br>
> + */<br>
> +<br>
> +void<br>
> +gen6_blorp_init(struct brw_context *brw);<br>
> +<br>
> +void<br>
> +gen6_blorp_emit_batch_head(struct brw_context *brw,<br>
> + const brw_blorp_params *params);<br>
> +<br>
> +void<br>
> +gen6_blorp_emit_vertices(struct brw_context *brw,<br>
> + const brw_blorp_params *params);<br>
> +<br>
> +void<br>
> +gen6_blorp_emit_depth_stencil_state(struct brw_context *brw,<br>
> + const brw_blorp_params *params,<br>
> + uint32_t *out_offset);<br>
> +/** \} */<br>
<br>
</div><div class="im">> +void<br>
> +gen6_blorp_exec(struct intel_context *intel,<br>
> + const brw_blorp_params *params);<br>
> +<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'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'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>
> +void<br>
> +gen7_blorp_exec(struct intel_context *intel,<br>
> + const brw_blorp_params *params);<br>
<br>
</div>Ditto for this gen7 function.<br>
<div class="im"><br>
> +void<br>
> +gen6_blorp_exec(struct intel_context *intel,<br>
> + const brw_blorp_params *params)<br>
> {<br>
> struct gl_context *ctx = &intel->ctx;<br>
> struct brw_context *brw = brw_context(ctx);<br>
> uint32_t draw_x, draw_y;<br>
> uint32_t tile_mask_x, tile_mask_y;<br>
><br>
> - assert(op != GEN6_HIZ_OP_DEPTH_CLEAR); /* Not implemented yet. */<br>
> - assert(mt->hiz_mt != NULL);<br>
> - intel_miptree_check_level_layer(mt, level, layer);<br>
> -<br>
> - {<br>
> - /* Construct a dummy renderbuffer just to extract tile offsets. */<br>
> - struct intel_renderbuffer rb;<br>
> - <a href="http://rb.mt" target="_blank">rb.mt</a> = mt;<br>
> - rb.mt_level = level;<br>
> - rb.mt_layer = layer;<br>
> - intel_renderbuffer_set_draw_offset(&rb);<br>
> - draw_x = rb.draw_x;<br>
> - draw_y = rb.draw_y;<br>
> - }<br>
> + params->depth.get_draw_offsets(&draw_x, &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>
> /* According to the Sandy Bridge PRM, volume 2 part 1, pp326-327<br>
> * (3DSTATE_DEPTH_BUFFER dw5), in the documentation for "Depth<br>
> @@ -506,27 +482,21 @@ gen6_hiz_exec(struct intel_context *intel,<br>
> tile_x &= ~7;<br>
> tile_y &= ~7;<br>
><br>
> - uint32_t format;<br>
> - switch (mt->format) {<br>
> - case MESA_FORMAT_Z16: format = BRW_DEPTHFORMAT_D16_UNORM; break;<br>
> - case MESA_FORMAT_Z32_FLOAT: format = BRW_DEPTHFORMAT_D32_FLOAT; break;<br>
> - case MESA_FORMAT_X8_Z24: format = BRW_DEPTHFORMAT_D24_UNORM_X8_UINT; break;<br>
> - default: assert(0); break;<br>
> - }<br>
> -<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'll send a v2 out soon.<br>