<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 3, 2016 at 10:19 AM, 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 Wed, Aug 31, 2016 at 02:22:34PM -0700, Jason Ekstrand wrote:<br>
> ---<br>
> src/intel/blorp/blorp_blit.c | 61 ++++++++++++++++++++++++++++++<wbr>++++++++++++++<br>
> src/intel/blorp/blorp_priv.h | 6 +++++<br>
> 2 files changed, 67 insertions(+)<br>
><br>
> diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c<br>
> index 42a502c..1790f0b 100644<br>
> --- a/src/intel/blorp/blorp_blit.c<br>
> +++ b/src/intel/blorp/blorp_blit.c<br>
> @@ -1191,6 +1191,27 @@ brw_blorp_build_nir_shader(<wbr>struct blorp_context *blorp,<br>
> }<br>
> }<br>
><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 pick off the appropriate component<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>
> + nir_channel(&b, color, 0),<br>
> + nir_bcsel(&b, nir_ieq(&b, comp, nir_imm_int(&b, 1)),<br>
> + nir_channel(&b, color, 1),<br>
> + nir_channel(&b, color, 2)));<br>
> +<br>
> + nir_ssa_def *u = nir_ssa_undef(&b, 1, 32);<br>
> + color = nir_vec4(&b, color_component, u, u, u);<br>
> + }<br>
> +<br>
> nir_store_var(&b, v.color_out, color, 0xf);<br>
><br>
> return b.shader;<br>
> @@ -1767,6 +1788,40 @@ surf_convert_to_uncompressed(<wbr>const struct isl_device *isl_dev,<br>
> info->surf.format = get_copy_format_for_bpb(fmtl-><wbr>bpb);<br>
> }<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>
> +{<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>
> + case ISL_FORMAT_R8G8B8_UNORM:<br>
> + red_format = ISL_FORMAT_R8_UNORM;<br>
> + break;<br>
> + case ISL_FORMAT_R16G16B16_UNORM:<br>
> + red_format = ISL_FORMAT_R16_UNORM;<br>
> + break;<br>
> + case ISL_FORMAT_R32G32B32_UINT:<br>
> + red_format = ISL_FORMAT_R32_UINT;<br>
> + break;<br>
> + default:<br>
> + unreachable("Invalid RGB copy destination format");<br>
> + }<br>
> + assert(isl_format_get_layout(<wbr>red_format)->channels.r.type ==<br>
> + isl_format_get_layout(info-><wbr>view.format)->channels.r.type)<wbr>;<br>
> + assert(isl_format_get_layout(<wbr>red_format)->channels.r.bits ==<br>
> + isl_format_get_layout(info-><wbr>view.format)->channels.r.bits)<wbr>;<br>
> +<br>
> + info->surf.format = info->view.format = red_format;<br>
> +}<br>
> +<br>
> void<br>
> blorp_copy(struct blorp_batch *batch,<br>
> const struct blorp_surf *src_surf,<br>
> @@ -1813,6 +1868,12 @@ blorp_copy(struct blorp_batch *batch,<br>
> uint32_t dst_width = src_width;<br>
> uint32_t dst_height = src_height;<br>
><br>
> + if (dst_fmtl->bpb % 3 == 0) {<br>
> + surf_fake_rgb_with_red(batch-><wbr>blorp->isl_dev, ¶ms.dst,<br>
> + &dst_x, &dst_width);<br>
> + wm_prog_key.dst_rgb = true;<br>
> + }<br>
> +<br>
> do_blorp_blit(batch, ¶ms, &wm_prog_key,<br>
> src_x, src_y, src_x + src_width, src_y + src_height,<br>
> dst_x, dst_y, dst_x + dst_width, dst_y + dst_height,<br>
> diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h<br>
> index 46ff272..99d45a9 100644<br>
> --- a/src/intel/blorp/blorp_priv.h<br>
> +++ b/src/intel/blorp/blorp_priv.h<br>
> @@ -245,6 +245,12 @@ struct brw_blorp_blit_prog_key<br>
> */<br>
> bool dst_tiled_w;<br>
><br>
> + /* True if the destination is an RGB format. If true, the surface state<br>
> + * for the render target must be configured as red with three times the<br>
> + * normal width.<br>
<br>
</div></div>And this is because we don't have any native renderable RGB formats?<span class=""><br></span></blockquote><div><br></div><div>Yes, you can only render to power-of-two formats<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>
> + bool dst_rgb;<br>
> +<br>
> /* True if all source samples should be blended together to produce each<br>
> * destination pixel. If true, src_tiled_w must be false, tex_samples must<br>
> * equal src_samples, and tex_samples must be nonzero.<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>