<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 23, 2016 at 8:35 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@intel.com" target="_blank">topi.pohjolainen@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Apr 22, 2016 at 04:19:10PM -0700, Jason Ekstrand wrote:<br>
> They didn't really add anything other than a key and extra layers of<br>
> function calls.  This commit just inlines the extra functions and gets rid<br>
> of the extra classes.<br>
> ---<br>
>  src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 224 ++++++++++----------------<br>
>  1 file changed, 87 insertions(+), 137 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
> index c7e57bc..b16102c 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
> @@ -44,43 +44,6 @@ struct brw_blorp_const_color_prog_key<br>
>     bool pad[3];<br>
>  };<br>
><br>
> -/**<br>
> - * Parameters for a blorp operation where the fragment shader outputs a<br>
> - * constant color.  This is used for both fast color clears and color<br>
> - * resolves.<br>
> - */<br>
> -class brw_blorp_const_color_params : public brw_blorp_params<br>
> -{<br>
> -public:<br>
> -   brw_blorp_const_color_prog_key wm_prog_key;<br>
> -};<br>
> -<br>
> -class brw_blorp_clear_params : public brw_blorp_const_color_params<br>
> -{<br>
> -public:<br>
> -   brw_blorp_clear_params(struct brw_context *brw,<br>
> -                          struct gl_framebuffer *fb,<br>
> -                          struct gl_renderbuffer *rb,<br>
> -                          GLubyte *color_mask,<br>
> -                          bool partial_clear,<br>
> -                          bool encode_srgb,<br>
> -                          unsigned layer);<br>
> -};<br>
> -<br>
> -<br>
> -/**<br>
> - * Parameters for a blorp operation that performs a "render target resolve".<br>
> - * This is used to resolve pending fast clear pixels before a color buffer is<br>
> - * used for texturing, ReadPixels, or scanout.<br>
> - */<br>
> -class brw_blorp_rt_resolve_params : public brw_blorp_const_color_params<br>
> -{<br>
> -public:<br>
> -   brw_blorp_rt_resolve_params(struct brw_context *brw,<br>
> -                               struct intel_mipmap_tree *mt);<br>
> -};<br>
> -<br>
> -<br>
>  class brw_blorp_const_color_program<br>
>  {<br>
>  public:<br>
> @@ -151,102 +114,6 @@ brw_blorp_params_get_clear_kernel(struct brw_context *brw,<br>
>     }<br>
>  }<br>
><br>
> -brw_blorp_clear_params::brw_blorp_clear_params(struct brw_context *brw,<br>
> -                                               struct gl_framebuffer *fb,<br>
> -                                               struct gl_renderbuffer *rb,<br>
> -                                               GLubyte *color_mask,<br>
> -                                               bool partial_clear,<br>
> -                                               bool encode_srgb,<br>
> -                                               unsigned layer)<br>
<br>
</div></div>I would have kept this similarly you changed the default constructors to<br>
init() functions (do_single_blorp_clear() becomes way over 100 lines long).<br>
Maybe<br>
<br>
static void<br>
set_clear_params(struct brw_context *brw,<br>
                 struct gl_framebuffer *fb,<br>
                 struct gl_renderbuffer *rb,<br>
                 bool partial_clear,<br>
                 bool encode_srgb,<br>
                 unsigned layer)<br>
{<br>
   const GLubyte *color_mask = brw->ctx.Color.ColorMask[buf];<br>
<br>
But I don't care too much. I suppose you have further plans for this anyway.<br></blockquote><div><br></div><div>Right.  My thinking was mostly that we had a bunch of logic for handling different cases and half of it was in the constructor and half was in do_single_blorp_clear and there didn't seem to be a particularly good reason why any given piece was in one or the other.  So I figured it't be easier to see what was going on if they were all together.  It may be worth splitting it back out again in the future.<br><br></div><div>Also, one of the things I hope to do eventually is to start using ISL internally in blorp.  If we do this, we'll have to divide the logic back up but the lines will be drawn differently.<br><br></div><div>If you want it kept split up, I can do that but that's my reasoning for just cramming it together.<br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> -{<br>
> -   struct gl_context *ctx = &brw->ctx;<br>
> -   struct intel_renderbuffer *irb = intel_renderbuffer(rb);<br>
> -   mesa_format format = irb->mt->format;<br>
> -<br>
> -   if (!encode_srgb && _mesa_get_format_color_encoding(format) == GL_SRGB)<br>
> -      format = _mesa_get_srgb_format_linear(format);<br>
> -<br>
> -   dst.set(brw, irb->mt, irb->mt_level, layer, format, true);<br>
> -<br>
> -   /* Override the surface format according to the context's sRGB rules. */<br>
> -   dst.brw_surfaceformat = brw->render_target_format[format];<br>
> -<br>
> -   x0 = fb->_Xmin;<br>
> -   x1 = fb->_Xmax;<br>
> -   if (rb->Name != 0) {<br>
> -      y0 = fb->_Ymin;<br>
> -      y1 = fb->_Ymax;<br>
> -   } else {<br>
> -      y0 = rb->Height - fb->_Ymax;<br>
> -      y1 = rb->Height - fb->_Ymin;<br>
> -   }<br>
> -<br>
> -   memcpy(&wm_push_consts.dst_x0, ctx->Color.ClearColor.f, sizeof(float) * 4);<br>
> -<br>
> -   memset(&wm_prog_key, 0, sizeof(wm_prog_key));<br>
> -<br>
> -   wm_prog_key.use_simd16_replicated_data = true;<br>
> -<br>
> -   /* From the SNB PRM (Vol4_Part1):<br>
> -    *<br>
> -    *     "Replicated data (Message Type = 111) is only supported when<br>
> -    *      accessing tiled memory.  Using this Message Type to access linear<br>
> -    *      (untiled) memory is UNDEFINED."<br>
> -    */<br>
> -   if (irb->mt->tiling == I915_TILING_NONE)<br>
> -      wm_prog_key.use_simd16_replicated_data = false;<br>
> -<br>
> -   /* Constant color writes ignore everyting in blend and color calculator<br>
> -    * state.  This is not documented.<br>
> -    */<br>
> -   for (int i = 0; i < 4; i++) {<br>
> -      if (_mesa_format_has_color_component(irb->mt->format, i) &&<br>
> -          !color_mask[i]) {<br>
> -         color_write_disable[i] = true;<br>
> -         wm_prog_key.use_simd16_replicated_data = false;<br>
> -      }<br>
> -   }<br>
> -<br>
> -   if (irb->mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_NO_MCS &&<br>
> -       !partial_clear && wm_prog_key.use_simd16_replicated_data &&<br>
> -       brw_is_color_fast_clear_compatible(brw, irb->mt,<br>
> -                                          &ctx->Color.ClearColor)) {<br>
> -      memset(&wm_push_consts, 0xff, 4*sizeof(float));<br>
> -      fast_clear_op = GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE;<br>
> -<br>
> -      brw_get_fast_clear_rect(brw, fb, irb->mt, &x0, &y0, &x1, &y1);<br>
> -   } else {<br>
> -      brw_meta_get_buffer_rect(fb, &x0, &y0, &x1, &y1);<br>
> -   }<br>
> -<br>
> -   brw_blorp_params_get_clear_kernel(brw, this, &wm_prog_key);<br>
> -}<br>
> -<br>
> -<br>
> -brw_blorp_rt_resolve_params::brw_blorp_rt_resolve_params(<br>
> -      struct brw_context *brw,<br>
> -      struct intel_mipmap_tree *mt)<br>
> -{<br>
> -   const mesa_format format = _mesa_get_srgb_format_linear(mt->format);<br>
> -<br>
> -   dst.set(brw, mt, 0 /* level */, 0 /* layer */, format, true);<br>
> -<br>
> -   brw_get_resolve_rect(brw, mt, &x0, &y0, &x1, &y1);<br>
> -<br>
> -   fast_clear_op = GEN7_PS_RENDER_TARGET_RESOLVE_ENABLE;<br>
> -<br>
> -   /* Note: there is no need to initialize push constants because it doesn't<br>
> -    * matter what data gets dispatched to the render target.  However, we must<br>
> -    * ensure that the fragment shader delivers the data using the "replicated<br>
> -    * color" message.<br>
> -    */<br>
> -   memset(&wm_prog_key, 0, sizeof(wm_prog_key));<br>
> -   wm_prog_key.use_simd16_replicated_data = true;<br>
> -<br>
> -   brw_blorp_params_get_clear_kernel(brw, this, &wm_prog_key);<br>
> -}<br>
> -<br>
> -<br>
>  void<br>
>  brw_blorp_const_color_program::alloc_regs()<br>
>  {<br>
> @@ -339,9 +206,71 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
>  {<br>
>     struct gl_context *ctx = &brw->ctx;<br>
>     struct intel_renderbuffer *irb = intel_renderbuffer(rb);<br>
> +   mesa_format format = irb->mt->format;<br>
> +<br>
> +   brw_blorp_params params;<br>
> +<br>
> +   if (!encode_srgb && _mesa_get_format_color_encoding(format) == GL_SRGB)<br>
> +      format = _mesa_get_srgb_format_linear(format);<br>
> +<br>
> +   params.dst.set(brw, irb->mt, irb->mt_level, layer, format, true);<br>
> +<br>
> +   /* Override the surface format according to the context's sRGB rules. */<br>
> +   params.dst.brw_surfaceformat = brw->render_target_format[format];<br>
> +<br>
> +   params.x0 = fb->_Xmin;<br>
> +   params.x1 = fb->_Xmax;<br>
> +   if (rb->Name != 0) {<br>
> +      params.y0 = fb->_Ymin;<br>
> +      params.y1 = fb->_Ymax;<br>
> +   } else {<br>
> +      params.y0 = rb->Height - fb->_Ymax;<br>
> +      params.y1 = rb->Height - fb->_Ymin;<br>
> +   }<br>
> +<br>
> +   memcpy(&params.wm_push_consts.dst_x0,<br>
> +          ctx->Color.ClearColor.f, sizeof(float) * 4);<br>
> +<br>
> +   brw_blorp_const_color_prog_key wm_prog_key;<br>
> +   memset(&wm_prog_key, 0, sizeof(wm_prog_key));<br>
> +<br>
> +   wm_prog_key.use_simd16_replicated_data = true;<br>
> +<br>
> +   /* From the SNB PRM (Vol4_Part1):<br>
> +    *<br>
> +    *     "Replicated data (Message Type = 111) is only supported when<br>
> +    *      accessing tiled memory.  Using this Message Type to access linear<br>
> +    *      (untiled) memory is UNDEFINED."<br>
> +    */<br>
> +   if (irb->mt->tiling == I915_TILING_NONE)<br>
> +      wm_prog_key.use_simd16_replicated_data = false;<br>
> +<br>
> +   /* Constant color writes ignore everyting in blend and color calculator<br>
> +    * state.  This is not documented.<br>
> +    */<br>
> +   for (int i = 0; i < 4; i++) {<br>
> +      if (_mesa_format_has_color_component(irb->mt->format, i) &&<br>
> +          !ctx->Color.ColorMask[buf][i]) {<br>
> +         params.color_write_disable[i] = true;<br>
> +         wm_prog_key.use_simd16_replicated_data = false;<br>
> +      }<br>
> +   }<br>
<br>
</div></div>Just a heads up, you need a little rebase here. I pushed the RGBX fix, and<br>
this now rests in its own function.<br>
<div><div class="h5"><br>
> +<br>
> +   if (irb->mt->fast_clear_state != INTEL_FAST_CLEAR_STATE_NO_MCS &&<br>
> +       !partial_clear && wm_prog_key.use_simd16_replicated_data &&<br>
> +       brw_is_color_fast_clear_compatible(brw, irb->mt,<br>
> +                                          &ctx->Color.ClearColor)) {<br>
> +      memset(&params.wm_push_consts, 0xff, 4*sizeof(float));<br>
> +      params.fast_clear_op = GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE;<br>
> +<br>
> +      brw_get_fast_clear_rect(brw, fb, irb->mt, &params.x0, &params.y0,<br>
> +                              &params.x1, &params.y1);<br>
> +   } else {<br>
> +      brw_meta_get_buffer_rect(fb, &params.x0, &params.y0,<br>
> +                               &params.x1, &params.y1);<br>
> +   }<br>
><br>
> -   brw_blorp_clear_params params(brw, fb, rb, ctx->Color.ColorMask[buf],<br>
> -                                 partial_clear, encode_srgb, layer);<br>
> +   brw_blorp_params_get_clear_kernel(brw, &params, &wm_prog_key);<br>
><br>
>     const bool is_fast_clear =<br>
>        params.fast_clear_op == GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE;<br>
> @@ -375,7 +304,7 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
>     const char *clear_type;<br>
>     if (is_fast_clear)<br>
>        clear_type = "fast";<br>
> -   else if (params.wm_prog_key.use_simd16_replicated_data)<br>
> +   else if (wm_prog_key.use_simd16_replicated_data)<br>
>        clear_type = "replicated";<br>
>     else<br>
>        clear_type = "slow";<br>
> @@ -448,7 +377,28 @@ brw_blorp_resolve_color(struct brw_context *brw, struct intel_mipmap_tree *mt)<br>
>  {<br>
>     DBG("%s to mt %p\n", __FUNCTION__, mt);<br>
><br>
> -   brw_blorp_rt_resolve_params params(brw, mt);<br>
> +   const mesa_format format = _mesa_get_srgb_format_linear(mt->format);<br>
> +<br>
> +   brw_blorp_params params;<br>
> +<br>
> +   params.dst.set(brw, mt, 0 /* level */, 0 /* layer */, format, true);<br>
> +<br>
> +   brw_get_resolve_rect(brw, mt, &params.x0, &params.y0,<br>
> +                        &params.x1, &params.y1);<br>
> +<br>
> +   params.fast_clear_op = GEN7_PS_RENDER_TARGET_RESOLVE_ENABLE;<br>
> +<br>
> +   /* Note: there is no need to initialize push constants because it doesn't<br>
> +    * matter what data gets dispatched to the render target.  However, we must<br>
> +    * ensure that the fragment shader delivers the data using the "replicated<br>
> +    * color" message.<br>
> +    */<br>
> +   brw_blorp_const_color_prog_key wm_prog_key;<br>
> +   memset(&wm_prog_key, 0, sizeof(wm_prog_key));<br>
> +   wm_prog_key.use_simd16_replicated_data = true;<br>
> +<br>
> +   brw_blorp_params_get_clear_kernel(brw, &params, &wm_prog_key);<br>
> +<br>
>     brw_blorp_exec(brw, &params);<br>
>     mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_RESOLVED;<br>
>  }<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>