aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-02-09 16:14:27 -0800
committerKenneth Graunke <[email protected]>2014-02-19 15:35:32 -0800
commit2ed5824a5d5400d1534139d2bda9858b95b67234 (patch)
tree7b4c70fb60701247bf80540fef6218036758311c /src/mesa
parent7700c73cf4ba780e41c351a86976aa01a995c3ce (diff)
i965: Simplify Broadwell's 3DSTATE_MULTISAMPLE sample count handling.
These enumerations are simply log2 of the number of multisamples shifted by a bit, so we can calculate them using ffs() in a lot less code. Suggested by Eric Anholt. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/gen8_multisample_state.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/src/mesa/drivers/dri/i965/gen8_multisample_state.c b/src/mesa/drivers/dri/i965/gen8_multisample_state.c
index 64c720807d2..bfe0d5b610b 100644
--- a/src/mesa/drivers/dri/i965/gen8_multisample_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_multisample_state.c
@@ -33,33 +33,13 @@
void
gen8_emit_3dstate_multisample(struct brw_context *brw, unsigned num_samples)
{
- uint32_t number_of_multisamples = 0;
+ assert(num_samples <= 16);
- switch (num_samples) {
- case 0:
- case 1:
- number_of_multisamples = MS_NUMSAMPLES_1;
- break;
- case 2:
- number_of_multisamples = MS_NUMSAMPLES_2;
- break;
- case 4:
- number_of_multisamples = MS_NUMSAMPLES_4;
- break;
- case 8:
- number_of_multisamples = MS_NUMSAMPLES_8;
- break;
- case 16:
- number_of_multisamples = MS_NUMSAMPLES_16;
- break;
- default:
- assert(!"Unrecognized num_samples in gen8_emit_3dstate_multisample");
- break;
- }
+ unsigned log2_samples = ffs(MAX2(num_samples, 1)) - 1;
BEGIN_BATCH(2);
OUT_BATCH(GEN8_3DSTATE_MULTISAMPLE << 16 | (2 - 2));
- OUT_BATCH(MS_PIXEL_LOCATION_CENTER | number_of_multisamples);
+ OUT_BATCH(MS_PIXEL_LOCATION_CENTER | log2_samples << 1);
ADVANCE_BATCH();
}