i965: Use ffs() for sample counting in gen7_surface_msaa_bits().

The enumerations are just log2(num_samples) shifted by 3, which we can
easily compute via ffs().

This also makes it reusable for Broadwell, which has 2x MSAA.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
This commit is contained in:
Kenneth Graunke 2014-02-10 11:06:03 -08:00
parent 2ed5824a5d
commit 6eeae17c02
1 changed files with 4 additions and 6 deletions

View File

@ -82,12 +82,10 @@ gen7_surface_msaa_bits(unsigned num_samples, enum intel_msaa_layout layout)
{
uint32_t ss4 = 0;
if (num_samples > 4)
ss4 |= GEN7_SURFACE_MULTISAMPLECOUNT_8;
else if (num_samples > 1)
ss4 |= GEN7_SURFACE_MULTISAMPLECOUNT_4;
else
ss4 |= GEN7_SURFACE_MULTISAMPLECOUNT_1;
assert(num_samples <= 8);
/* The SURFACE_MULTISAMPLECOUNT_X enums are simply log2(num_samples) << 3. */
ss4 |= (ffs(MAX2(num_samples, 1)) - 1) << 3;
if (layout == INTEL_MSAA_LAYOUT_IMS)
ss4 |= GEN7_SURFACE_MSFMT_DEPTH_STENCIL;