[Mesa-dev] [PATCH 06/12] i965/fs: Add a sampler program key for whether the texture is 16x MSAA

Ben Widawsky ben at bwidawsk.net
Tue Sep 22 12:22:27 PDT 2015


On Thu, Sep 17, 2015 at 05:00:08PM +0100, Neil Roberts wrote:
> When 16x MSAA is used for sampling with texelFetch the compiler needs
> to use a different instruction which passes more arguments for the MCS
> data. Previously on skl+ it was unconditionally using this new
> instruction. However since 16x MSAA is probably going to be pretty
> rare, it is probably worthwhile to avoid using this instruction for
> the other sample counts. In order to do that this patch adds a new
> member to brw_sampler_prog_key_data to track when a sampler refers to
> a buffer with 16 samples.
> 
> Note that this isn't done for the vec4 backend because it wouldn't
> change how many registers it uses.

Hmm. I was of the other opinion actually, I'd prefer to always use the
new instruction to limit the variability between tests. I suppose if we're often
passing the LOD parameter that is problematic, but we don't do that either,
right?

> ---
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 +-
>  src/mesa/drivers/dri/i965/brw_program.h      | 7 +++++++
>  src/mesa/drivers/dri/i965/brw_wm.c           | 8 ++++++++
>  3 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> index ea7b3eb..7937c48 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -287,7 +287,7 @@ fs_visitor::emit_texture(ir_texture_opcode op,
>        opcode = SHADER_OPCODE_TXF_LOGICAL;
>        break;
>     case ir_txf_ms:
> -      if (devinfo->gen >= 9)
> +      if ((key_tex->msaa_16 & (1 << sampler)))
>           opcode = SHADER_OPCODE_TXF_CMS_W_LOGICAL;
>        else
>           opcode = SHADER_OPCODE_TXF_CMS_LOGICAL;
> diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
> index 00e8f3f..b27ab7f 100644
> --- a/src/mesa/drivers/dri/i965/brw_program.h
> +++ b/src/mesa/drivers/dri/i965/brw_program.h
> @@ -72,6 +72,13 @@ struct brw_sampler_prog_key_data {
>     uint32_t compressed_multisample_layout_mask;
>  
>     /**
> +    * Whether this sampler is using 16x multisampling. If so fetching from
> +    * this sampler will be handled with a different instruction, ld2ms_w
> +    * instead of ld2ms.
> +    */
> +   uint32_t msaa_16;
> +
> +   /**
>      * For Sandybridge, which shader w/a we need for gather quirks.
>      */
>     enum gen6_gather_sampler_wa gen6_gather_wa[MAX_SAMPLERS];
> diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
> index 35c0908..2d6f10d 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm.c
> @@ -292,6 +292,9 @@ brw_debug_recompile_sampler_key(struct brw_context *brw,
>     found |= key_debug(brw, "compressed multisample layout",
>                        old_key->compressed_multisample_layout_mask,
>                        key->compressed_multisample_layout_mask);
> +   found |= key_debug(brw, "16x msaa",
> +                      old_key->msaa_16,
> +                      key->msaa_16);
>  
>     for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
>        found |= key_debug(brw, "textureGather workarounds",
> @@ -451,6 +454,11 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
>           if (brw->gen >= 7 &&
>               intel_tex->mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
>              key->compressed_multisample_layout_mask |= 1 << s;
> +
> +            if (intel_tex->mt->num_samples >= 16) {
> +               assert(brw->gen >= 9);
> +               key->msaa_16 |= 1 << s;
> +            }
>           }
>        }
>     }
> -- 
> 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-dev mailing list