Currently, brw_fs_precompile doesn't set compressed_multisample_layout_mask, leaving it at the default value of 0 (non-CMS).
This is dumb. Virtually all multisampled color buffers on Gen7+ use the CMS layout, not UMS or IMS. So, basically every shader that uses a sampler2DMS type (including most of WebGL) will require a recompile.
A better guess would be:
- 1 for sampler2DMS on Gen7+ (0 on Gen6)
- 0 for sampler2DMSShadow
- 0 for non-MS sampler types.
This should eliminate almost all recompiles due to compressed_multisample_layout_mask.
To accomplish this, we may want to create a bitfield similar to SamplersUsed or ShadowSamplers...SamplerIsMSAA or such. Then the precompile could easily check it. Alternatively, we could stop using bitfields and walk a list of NIR uniforms. It should be pretty simple.
Ilia pointed out that there is no such thing as a sampler2DMSShadow.
So you can happily ignore that :)
Assuming it works, here's a better idea: kill the field altogether. Just treat all surfaces like CMS.
According to the docs:
"If ld_mcs is issued on a surface with MCS disabled, this message returns zeros in all channels."
I'm pretty sure it'll work for UMS and maybe even IMS. It's a bit of extra work in the shader for the non-CMS case, but most things are CMS anyway.