<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 25, 2017 at 10:46 PM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.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 Tue, Jan 24, 2017 at 03:45:48PM -0800, Jason Ekstrand wrote:<br>
> The previous version was sort-of strapped on in that it just adjusted<br>
> the blit rectangle and trusted in the fact that we would use texelFetch<br>
> and round to the nearest integer to ensure that the component positions<br>
> matched. This new version, while slightly more complicated, is more<br>
> accurate because all three components end up with exactly the same<br>
> dst_pos and so they will get interpolated and sampled at the same<br>
> texture coordinate. This makes the workaround suitable for using with<br>
> scaled blits.<br>
> ---<br>
> src/intel/blorp/blorp_blit.c | 60 ++++++++++++++++++++++--------<wbr>--------------<br>
> 1 file changed, 30 insertions(+), 30 deletions(-)<br>
><br>
> diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c<br>
> index 111f1c1..fc76fd4 100644<br>
> --- a/src/intel/blorp/blorp_blit.c<br>
> +++ b/src/intel/blorp/blorp_blit.c<br>
> @@ -1138,6 +1138,20 @@ brw_blorp_build_nir_shader(<wbr>struct blorp_context *blorp, void *mem_ctx,<br>
> key->dst_layout);<br>
> }<br>
><br>
> + nir_ssa_def *comp = NULL;<br>
> + if (key->dst_rgb) {<br>
> + /* The destination image is bound as a red texture three times as wide<br>
> + * as the actual image. Our shader is effectively running one color<br>
> + * component at a time. We need to save off the component and adjust<br>
> + * the destination position.<br>
> + */<br>
> + assert(dst_pos->num_components == 2);<br>
> + nir_ssa_def *dst_x = nir_channel(&b, dst_pos, 0);<br>
> + comp = nir_umod(&b, dst_x, nir_imm_int(&b, 3));<br>
> + dst_pos = nir_vec2(&b, nir_idiv(&b, dst_x, nir_imm_int(&b, 3)),<br>
> + nir_channel(&b, dst_pos, 1));<br>
<br>
</div></div>Just to check that I understood correctly, before we had this scale-factor of<br>
three in v_coord_transform. Now we have it here explicitly?<br></blockquote><div><br></div><div>Yes, that's correct.<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>
> +<br>
> /* Now (X, Y, S) = decode_msaa(dst_samples, detile(dst_tiling, offset)).<br>
> *<br>
> * That is: X, Y and S now contain the true coordinates and sample index of<br>
> @@ -1267,8 +1281,6 @@ brw_blorp_build_nir_shader(<wbr>struct blorp_context *blorp, void *mem_ctx,<br>
> * from the source color and write that to destination red.<br>
> */<br>
> assert(dst_pos->num_components == 2);<br>
> - nir_ssa_def *comp =<br>
> - nir_umod(&b, nir_channel(&b, dst_pos, 0), nir_imm_int(&b, 3));<br>
><br>
> nir_ssa_def *color_component =<br>
> nir_bcsel(&b, nir_ieq(&b, comp, nir_imm_int(&b, 0)),<br>
> @@ -1543,15 +1555,12 @@ struct blt_coords {<br>
><br>
> static void<br>
> surf_fake_rgb_with_red(const struct isl_device *isl_dev,<br>
> - struct brw_blorp_surface_info *info,<br>
> - uint32_t *x, uint32_t *width)<br>
> + struct brw_blorp_surface_info *info)<br>
> {<br>
> surf_convert_to_single_slice(<wbr>isl_dev, info);<br>
><br>
> info->surf.logical_level0_px.<wbr>width *= 3;<br>
> info->surf.phys_level0_sa.<wbr>width *= 3;<br>
> - *x *= 3;<br>
> - *width *= 3;<br>
><br>
> enum isl_format red_format;<br>
> switch (info->view.format) {<br>
> @@ -1581,28 +1590,6 @@ surf_fake_rgb_with_red(const struct isl_device *isl_dev,<br>
> info->surf.format = info->view.format = red_format;<br>
> }<br>
><br>
> -static void<br>
> -fake_dest_rgb_with_red(const struct isl_device *dev,<br>
> - struct blorp_params *params,<br>
> - struct brw_blorp_blit_prog_key *wm_prog_key,<br>
> - struct blt_coords *coords)<br>
> -{<br>
> - /* Handle RGB destinations for blorp_copy */<br>
> - const struct isl_format_layout *dst_fmtl =<br>
> - isl_format_get_layout(params-><wbr>dst.surf.format);<br>
> -<br>
> - if (dst_fmtl->bpb % 3 == 0) {<br>
> - uint32_t dst_x = coords->x.dst0;<br>
> - uint32_t dst_width = coords->x.dst1 - dst_x;<br>
> - surf_fake_rgb_with_red(dev, ¶ms->dst,<br>
> - &dst_x, &dst_width);<br>
> - coords->x.dst0 = dst_x;<br>
> - coords->x.dst1 = dst_x + dst_width;<br>
> - wm_prog_key->dst_rgb = true;<br>
> - wm_prog_key->need_dst_offset = true;<br>
> - }<br>
> -}<br>
> -<br>
> enum blit_shrink_status {<br>
> BLIT_NO_SHRINK = 0,<br>
> BLIT_WIDTH_SHRINK = 1,<br>
> @@ -1621,8 +1608,6 @@ try_blorp_blit(struct blorp_batch *batch,<br>
> {<br>
> const struct gen_device_info *devinfo = batch->blorp->isl_dev->info;<br>
><br>
> - fake_dest_rgb_with_red(batch-><wbr>blorp->isl_dev, params, wm_prog_key, coords);<br>
> -<br>
> if (isl_format_has_sint_channel(<wbr>params->src.view.format)) {<br>
> wm_prog_key->texture_data_type = nir_type_int;<br>
> } else if (isl_format_has_uint_channel(<wbr>params->src.view.format)) {<br>
> @@ -1799,6 +1784,21 @@ try_blorp_blit(struct blorp_batch *batch,<br>
><br>
> params->num_samples = params->dst.surf.samples;<br>
><br>
> + if (isl_format_get_layout(params-<wbr>>dst.view.format)->bpb % 3 == 0) {<br>
> + /* We can't render to RGB formats natively because they aren't a<br>
> + * power-of-two size. Instead, we fake them by using a red format<br>
> + * with the same channel type and size and emitting shader code to<br>
> + * only write one channel at a time.<br>
> + */<br>
> + params->x0 *= 3;<br>
> + params->x1 *= 3;<br>
<br>
</div></div>It looks to me that we stop adjusting v_discard_rect as well. Before it<br>
was calculated against adjusted coords. Now we only adjust the vertices.<br>
This means blorp_nir_discard_if_outside_<wbr>rect() isn't used for the rgb-trick -<br>
otherwise it would clip too much in the right hand side. Or am I missing<br>
something? If not, can we add?<br></blockquote><div><br></div><div>Yes, that's correct.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
assert(!wm_prog_key->use_kill)<wbr>;<span class=""><br></span></blockquote><div><br></div><div>i don't really see why it's needed but I'm happy to add it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +<br>
> + surf_fake_rgb_with_red(batch-><wbr>blorp->isl_dev, ¶ms->dst);<br>
> +<br>
> + wm_prog_key->dst_rgb = true;<br>
> + wm_prog_key->need_dst_offset = true;<br>
> + }<br>
> +<br>
> if (params->src.tile_x_sa || params->src.tile_y_sa) {<br>
> assert(wm_prog_key->need_src_<wbr>offset);<br>
> surf_get_intratile_offset_px(&<wbr>params->src,<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</span>> ______________________________<wbr>_________________<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/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>