[Mesa-stable] [Mesa-dev] [PATCH v2] i965: Handle lum, intensity and missing components in the fast clear

Neil Roberts neil at linux.intel.com
Mon Nov 23 08:17:02 PST 2015


I've pushed this patch to master but I think it would be a good
candidate to go on the 11.1 branch as well. Do I have to do something to
make that happen?

- Neil

Neil Roberts <neil at linux.intel.com> writes:

> It looks like the sampler hardware doesn't take into account the
> surface format when sampling a cleared color after a fast clear has
> been done. So for example if you clear a GL_RED surface to 1,1,1,1
> then the sampling instructions will return 1,1,1,1 instead of 1,0,0,1.
> This patch makes it override the color that is programmed in the
> surface state in order to swizzle for luminance and intensity as well
> as overriding the missing components.
>
> v2: Handle luminance and intensity formats
> ---
>
> I made a more extensive test case which tests all of the formats in
> fbo_formats.h as well as using more than one test color here:
>
> http://patchwork.freedesktop.org/patch/64578/
>
> In the process I noticed that there is a similar problem with
> luminance and intensity textures so here is a v2 to cope with that.
>
> I've made another version of this patch which is rebased on top of
> Ben's skl-fast-clear branch so we can take whichever version depending
> on which lands first:
>
> https://github.com/bpeel/mesa/commit/da7edcb6dfd93c7dd86b2e148c44dff7
>
>  src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 38 +++++++++++++++++++++++--
>  1 file changed, 35 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
> index 69fe7b4..3071590 100644
> --- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
> +++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
> @@ -361,12 +361,43 @@ is_color_fast_clear_compatible(struct brw_context *brw,
>   * SURFACE_STATE.
>   */
>  static uint32_t
> -compute_fast_clear_color_bits(const union gl_color_union *color)
> +compute_fast_clear_color_bits(mesa_format format,
> +                              const union gl_color_union *color)
>  {
> +   union gl_color_union override_color = *color;
>     uint32_t bits = 0;
> +
> +   /* The sampler doesn't look at the format of the surface when the fast
> +    * clear color is used so we need to implement luminance, intensity and
> +    * missing components manually.
> +    */
> +   switch (_mesa_get_format_base_format(format)) {
> +   case GL_INTENSITY:
> +      override_color.ui[3] = override_color.ui[0];
> +      /* flow through */
> +   case GL_LUMINANCE:
> +   case GL_LUMINANCE_ALPHA:
> +      override_color.ui[1] = override_color.ui[0];
> +      override_color.ui[2] = override_color.ui[0];
> +      break;
> +   default:
> +      for (int i = 0; i < 3; i++) {
> +         if (!_mesa_format_has_color_component(format, i))
> +            override_color.ui[i] = 0;
> +      }
> +      break;
> +   }
> +
> +   if (!_mesa_format_has_color_component(format, 3)) {
> +      if (_mesa_is_format_integer_color(format))
> +         override_color.ui[3] = 1;
> +      else
> +         override_color.f[3] = 1.0f;
> +   }
> +
>     for (int i = 0; i < 4; i++) {
>        /* Testing for non-0 works for integer and float colors */
> -      if (color->f[i] != 0.0f)
> +      if (override_color.f[i] != 0.0f)
>           bits |= 1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i));
>     }
>     return bits;
> @@ -505,7 +536,8 @@ brw_meta_fast_clear(struct brw_context *brw, struct gl_framebuffer *fb,
>        switch (clear_type) {
>        case FAST_CLEAR:
>           irb->mt->fast_clear_color_value =
> -            compute_fast_clear_color_bits(&ctx->Color.ClearColor);
> +            compute_fast_clear_color_bits(irb->mt->format,
> +                                          &ctx->Color.ClearColor);
>           irb->need_downsample = true;
>  
>           /* If the buffer is already in INTEL_FAST_CLEAR_STATE_CLEAR, the
> -- 
> 1.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-stable mailing list