<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 27, 2017 at 11:41 AM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@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 Mon, Nov 27, 2017 at 11:02:15AM -0800, Nanley Chery wrote:<br>
> When sampling from fast-cleared sRGB textures on gen10, the hardware<br>
> will not decode the clear color to linear. We must therefore do it in<br>
> software.<br>
><br>
> This makes the following piglit tests pass:<br>
> * spec@arb_framebuffer_srgb@arb_<wbr>framebuffer_srgb-fast-clear-<wbr>blend<br>
> * spec@arb_framebuffer_srgb@fbo-<wbr>fast-clear<br>
> * spec@arb_framebuffer_srgb@<wbr>msaa-fast-clear<br>
> * spec@ext_texture_srgb@fbo-<wbr>fast-clear<br>
> * spec@ext_texture_srgb@<wbr>multisample-fast-clear gl_ext_texture_srgb<br>
><br>
> v2 (Jason Ekstrand):<br>
> - Update some comments.<br>
> - Simplify assertions.<br>
> - Use an sRGB-to-linear helper.<br>
><br>
> Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
> ---<br>
>  src/mesa/drivers/dri/i965/brw_<wbr>blorp.c            |  7 +++++++<br>
>  src/mesa/drivers/dri/i965/brw_<wbr>meta_util.c        | 26 ++++++++++++++++++++++++<br>
>  src/mesa/drivers/dri/i965/brw_<wbr>meta_util.h        |  5 +++++<br>
>  src/mesa/drivers/dri/i965/brw_<wbr>wm_surface_state.c |  9 +++++++-<br>
>  4 files changed, 46 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> index 38284d3b85..b10e9b95b7 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> @@ -328,6 +328,13 @@ brw_blorp_blit_miptrees(struct brw_context *brw,<br>
>     struct blorp_surf src_surf, dst_surf;<br>
>     blorp_surf_for_miptree(brw, &src_surf, src_mt, src_aux_usage, false,<br>
>                            &src_level, src_layer, 1, &tmp_surfs[0]);<br>
> +   if (devinfo->gen >= 10 && isl_format_is_srgb(src_isl_<wbr>format) &&<br>
> +       src_clear_supported) {<br>
> +      src_surf.clear_color =<br>
> +         gen10_convert_srgb_fast_clear_<wbr>color(devinfo, src_isl_format,<br>
> +                                             src_mt->fast_clear_color);<br>
> +   }<br>
> +<br>
>     blorp_surf_for_miptree(brw, &dst_surf, dst_mt, dst_aux_usage, true,<br>
>                            &dst_level, dst_layer, 1, &tmp_surfs[1]);<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c b/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c<br>
> index d292f5a8e2..d1ce9d46ea 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c<br>
> @@ -315,6 +315,32 @@ brw_is_color_fast_clear_<wbr>compatible(struct brw_context *brw,<br>
>     return true;<br>
>  }<br>
><br>
> +/* When sampling from fast-cleared sRGB textures on gen10, the hardware<br>
> + * will not decode the clear color to linear. We must therefore do it in<br>
> + * software.<br>
> + */<br>
> +union isl_color_value<br>
> +gen10_convert_srgb_fast_<wbr>clear_color(const struct gen_device_info *devinfo,<br>
> +                                    enum isl_format format,<br>
> +                                    const union isl_color_value color)<br>
> +{<br>
> +   /* Gen10 supports fast-clearing three of GL's sRGB formats. */<br>
> +   assert(devinfo->gen >= 10);<br>
> +   assert(format == ISL_FORMAT_R8G8B8A8_UNORM_SRGB ||<br>
> +          format == ISL_FORMAT_B8G8R8A8_UNORM_SRGB ||<br>
> +          format == ISL_FORMAT_B8G8R8X8_UNORM_<wbr>SRGB);<br>
> +<br>
> +   /* According to do_single_blorp_clear(), fast-clears for texture-views are<br>
> +    * disabled. This means that we only have to do channel-to-channel format<br>
> +    * conversions.<br>
> +    */<br>
> +   union isl_color_value override_color = color;<br>
> +   for (unsigned i = 0; i < 3; i++)<br>
> +      override_color.f32[i] = util_format_srgb_to_linear_<wbr>float(color.f32[i]);<br>
> +<br>
> +   return override_color;<br>
> +}<br>
> +<br>
>  /**<br>
>   * Convert the given color to a bitfield suitable for ORing into DWORD 7 of<br>
>   * SURFACE_STATE (DWORD 12-15 on SKL+).<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.h b/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.h<br>
> index 4b3408df15..ee0b3bd3e1 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.h<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.h<br>
> @@ -42,6 +42,11 @@ brw_meta_mirror_clip_and_<wbr>scissor(const struct gl_context *ctx,<br>
>                                   GLfloat *dstX1, GLfloat *dstY1,<br>
>                                   bool *mirror_x, bool *mirror_y);<br>
><br>
> +union isl_color_value<br>
> +gen10_convert_srgb_fast_<wbr>clear_color(const struct gen_device_info *devinfo,<br>
> +                                    enum isl_format format,<br>
> +                                    const union isl_color_value color);<br>
> +<br>
>  union isl_color_value<br>
>  brw_meta_convert_fast_clear_<wbr>color(const struct brw_context *brw,<br>
>                                    const struct intel_mipmap_tree *mt,<br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
> index adf60a840b..315b96e9c4 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
> @@ -51,6 +51,7 @@<br>
>  #include "intel_buffer_objects.h"<br>
><br>
>  #include "brw_context.h"<br>
> +#include "brw_meta_util.h"<br>
>  #include "brw_state.h"<br>
>  #include "brw_defines.h"<br>
>  #include "brw_wm.h"<br>
> @@ -174,7 +175,13 @@ brw_emit_surface_state(struct brw_context *brw,<br>
>        /* We only really need a clear color if we also have an auxiliary<br>
>         * surface.  Without one, it does nothing.<br>
>         */<br>
> -      clear_color = mt->fast_clear_color;<br>
> +      if (devinfo->gen >= 10 && isl_format_is_srgb(view.<wbr>format)) {<br>
<br>
</div></div>Whoops. I need to check view.usage for<br>
ISL_SURF_USAGE_TEXTURE_BIT.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Really?  If that matters, then I'm very scared.</div><div><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"><span class="HOEnZb"><font color="#888888">
-Nanley<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> +         clear_color =<br>
> +            gen10_convert_srgb_fast_clear_<wbr>color(devinfo, view.format,<br>
> +                                                mt->fast_clear_color);<br>
> +      } else {<br>
> +         clear_color = mt->fast_clear_color;<br>
> +      }<br>
>     }<br>
><br>
>     void *state = brw_state_batch(brw,<br>
> --<br>
> 2.15.0<br>
><br>
______________________________<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>
</div></div></blockquote></div><br></div></div>