Bug 90158

Summary: Make shader precompile guess MSAA layout properly
Product: Mesa Reporter: Kenneth Graunke <kenneth>
Component: Drivers/DRI/i965Assignee: Intel 3D Bugs Mailing List <intel-3d-bugs>
Status: RESOLVED MOVED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: enhancement    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 77547    

Description Kenneth Graunke 2015-04-24 06:34:16 UTC
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.
Comment 1 Kenneth Graunke 2015-05-09 00:11:34 UTC
Ilia pointed out that there is no such thing as a sampler2DMSShadow.

So you can happily ignore that :)
Comment 2 Kenneth Graunke 2016-11-05 05:50:35 UTC
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.
Comment 3 GitLab Migration User 2019-09-25 18:53:50 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/1482.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.