[Mesa-dev] [PATCH 2/2] i965/borp: Don't blend integer values during MSAA resolves

Matt Turner mattst88 at gmail.com
Thu May 5 17:21:16 UTC 2016


Typo in subject: s/borp/blorp/

On Wed, May 4, 2016 at 4:22 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 30 ++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> index 882f9ed..dc68eab 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> @@ -2160,6 +2160,8 @@ brw_blorp_blit_program::manual_blend_average(unsigned num_samples)
>     if (key->tex_layout == INTEL_MSAA_LAYOUT_CMS)
>        mcs_fetch();
>
> +   assert(key->texture_data_type == BRW_REGISTER_TYPE_F);
> +
>     /* We add together samples using a binary tree structure, e.g. for 4x MSAA:
>      *
>      *   result = ((sample[0] + sample[1]) + (sample[2] + sample[3])) / 4
> @@ -2228,8 +2230,7 @@ brw_blorp_blit_program::manual_blend_average(unsigned num_samples)
>
>           /* TODO: should use a smaller loop bound for non_RGBA formats */
>           for (int k = 0; k < 4; ++k) {
> -            emit_combine(key->texture_data_type == BRW_REGISTER_TYPE_F ?
> -                            BRW_OPCODE_ADD : BRW_OPCODE_AVG,
> +            emit_combine(BRW_OPCODE_ADD,
>                           offset(texture_data[stack_depth - 1], 2*k),
>                           offset(vec8(texture_data[stack_depth - 1]), 2*k),
>                           offset(vec8(texture_data[stack_depth]), 2*k));
> @@ -2240,14 +2241,12 @@ brw_blorp_blit_program::manual_blend_average(unsigned num_samples)
>     /* We should have just 1 sample on the stack now. */
>     assert(stack_depth == 1);
>
> -   if (key->texture_data_type == BRW_REGISTER_TYPE_F) {
> -      /* Scale the result down by a factor of num_samples */
> -      /* TODO: should use a smaller loop bound for non-RGBA formats */
> -      for (int j = 0; j < 4; ++j) {
> -         emit_mul(offset(texture_data[0], 2*j),
> -                 offset(vec8(texture_data[0]), 2*j),
> -                 brw_imm_f(1.0f / num_samples));
> -      }
> +   /* Scale the result down by a factor of num_samples */
> +   /* TODO: should use a smaller loop bound for non-RGBA formats */
> +   for (int j = 0; j < 4; ++j) {
> +      emit_mul(offset(texture_data[0], 2*j),
> +              offset(vec8(texture_data[0]), 2*j),
> +              brw_imm_f(1.0f / num_samples));
>     }
>
>     if (key->tex_layout == INTEL_MSAA_LAYOUT_CMS)
> @@ -2869,8 +2868,17 @@ brw_blorp_blit_miptrees(struct brw_context *brw,
>     GLenum base_format = _mesa_get_format_base_format(src_mt->format);
>     if (base_format != GL_DEPTH_COMPONENT && /* TODO: what about depth/stencil? */
>         base_format != GL_STENCIL_INDEX &&
> +       !_mesa_is_format_integer(src_mt->format) &&
>         src_mt->num_samples > 1 && dst_mt->num_samples <= 1) {
> -      /* We are downsampling a color buffer, so blend. */
> +      /* We are downsampling a non-integer color buffer, so blend.
> +       *
> +       * Regarding integer color buffers, the OpenGL ES 3.2 spec says:
> +       *
> +       *    "If the source formats are integer types or stencil values, a
> +       *    single sample’s value is selected for each pixel."

Smart quote -> single quote.

With those couple of things fixed, these two are

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-dev mailing list