summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2014-02-10 11:06:03 -0800
committerKenneth Graunke <kenneth@whitecape.org>2014-02-19 15:35:53 -0800
commit6eeae17c02267c57ba3f9f2ace6252fb50dbc9ec (patch)
tree470309866edbe57c0054c78975327fdff5ce0869 /src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
parent2ed5824a5d5400d1534139d2bda9858b95b67234 (diff)
downloadexternal_mesa3d-6eeae17c02267c57ba3f9f2ace6252fb50dbc9ec.zip
external_mesa3d-6eeae17c02267c57ba3f9f2ace6252fb50dbc9ec.tar.gz
external_mesa3d-6eeae17c02267c57ba3f9f2ace6252fb50dbc9ec.tar.bz2
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>
Diffstat (limited to 'src/mesa/drivers/dri/i965/gen7_wm_surface_state.c')
-rw-r--r--src/mesa/drivers/dri/i965/gen7_wm_surface_state.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 12d0fa9..154a0fd 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -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;