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 splits up the gen6_blorp_exec and gen7_blorp_exec<br>
> functions, which were very long, into simple component functions.<br>
> With a few exceptions, there is one function per state packet.<br>
><br>
> This will allow blit functionality to be added without significantly<br>
> complicating the code.<br>
> ---<br>
> src/mesa/drivers/dri/i965/brw_blorp.h | 23 +-<br>
> src/mesa/drivers/dri/i965/gen6_blorp.cpp | 596 +++++++++++++++++-------------<br>
> src/mesa/drivers/dri/i965/gen7_blorp.cpp | 448 ++++++++++++-----------<br>
> 3 files changed, 595 insertions(+), 472 deletions(-)<br>
<br>
</div>[snip]<br>
<div class="im"><br>
> +/**<br>
> + * Disable thread dispatch (dw5.19) and enable the HiZ op.<br>
> + */<br>
> +static void<br>
> +gen6_blorp_emit_wm_disable(struct brw_context *brw,<br>
> + 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't care much about the contents of the 3DSTATE_UNIT packet,<br>
because the packet doesn't instruct the gpu to do anything.<br>
<br>
However, that'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'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'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'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'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'll rework things so they look like this instead:<br>
<br>gen6_emit_wm_config(): emit 3DSTATE_WM correctly, whether there's a WM prog or not<br>gen7_emit_wm_config(): emit 3DSTATE_WM correctly, whether there's a WM prog or not<br>gen7_emit_ps_config(): emit 3DSTATE_PS correctly, whether there'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>
> /**<br>
> - * \param out_offset is relative to<br>
> - * CMD_STATE_BASE_ADDRESS.DynamicStateBaseAddress.<br>
> + * \brief Execute a blit or render pass operation.<br>
> + *<br>
> + * To execute the operation, this function manually constructs and emits a<br>
> + * batch to draw a rectangle primitive. The batchbuffer is flushed before<br>
> + * constructing and after emitting the batch.<br>
> + *<br>
> + * This function alters no GL state.<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>
> +gen6_blorp_exec(struct intel_context *intel,<br>
> + const brw_blorp_params *params)<br>
> {<br>
> - struct gen6_depth_stencil_state *state;<br>
> - state = (struct gen6_depth_stencil_state *)<br>
> - brw_state_batch(brw, AUB_TRACE_DEPTH_STENCIL_STATE,<br>
> - sizeof(*state), 64,<br>
> - out_offset);<br>
> - memset(state, 0, sizeof(*state));<br>
> + struct gl_context *ctx = &intel->ctx;<br>
> + struct brw_context *brw = brw_context(ctx);<br>
> + uint32_t depthstencil_offset;<br>
><br>
> - /* See the following sections of the Sandy Bridge PRM, Volume 1, Part2:<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>
> + gen6_blorp_emit_batch_head(brw, params);<br>
> + gen6_blorp_emit_vertices(brw, params);<br>
> + gen6_blorp_emit_urb_config(brw, params);<br>
> + depthstencil_offset = gen6_blorp_emit_depth_stencil_state(brw, params);<br>
> + gen6_blorp_emit_cc_state_pointers(brw, params, depthstencil_offset);<br>
> + gen6_blorp_emit_vs_disable(brw, params);<br>
> + gen6_blorp_emit_gs_disable(brw, params);<br>
> + gen6_blorp_emit_clip_disable(brw, params);<br>
> + gen6_blorp_emit_sf_config(brw, params);<br>
> + gen6_blorp_emit_wm_disable(brw, params);<br>
> +<br>
> + gen6_blorp_emit_depth_stencil_config(brw, params);<br>
> + gen6_blorp_emit_clear_params(brw, params);<br>
> + gen6_blorp_emit_drawing_rectangle(brw, params);<br>
> + gen6_blorp_emit_primitive(brw, params);<br>
> +<br>
> + /* See comments above at first invocation of intel_flush() in<br>
> + * gen6_blorp_emit_batch_head().<br>
> */<br>
> - state->ds2.depth_write_enable = 1;<br>
> - if (params->hiz_op == GEN6_HIZ_OP_DEPTH_RESOLVE) {<br>
> - state->ds2.depth_test_enable = 1;<br>
> - state->ds2.depth_test_func = COMPAREFUNC_NEVER;<br>
> - }<br>
> + intel_flush(ctx);<br>
> +<br>
> + /* Be safe. */<br>
> + brw->state.dirty.brw = ~0;<br>
> + brw->state.dirty.cache = ~0;<br>
> }<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 = &brw->intel;<br>
</div>but do not use the 'intel' 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->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 <<a href="mailto:chad.versace@linux.intel.com">chad.versace@linux.intel.com</a>><br>
</blockquote></div><br>