aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorCorbin Simpson <[email protected]>2009-11-20 14:10:59 -0800
committerCorbin Simpson <[email protected]>2009-11-20 14:10:59 -0800
commit06ec216d191e160494dd0a922ab0395418a78402 (patch)
tree1b5fa641db254c95b36510c3b6f7a699326596ca /src/gallium/drivers
parent6a3eb1f91b4ccd4ee7ac6b91505e0dfa476922d4 (diff)
r300g: Clean up bitcounting function.
I didn't see this in u_math; surely somebody else has this wheel reinvented elsewhere.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/r300/r300_emit.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 4cd5074379f..c50c989f01a 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -690,14 +690,19 @@ void r300_emit_vertex_format_state(struct r300_context* r300)
END_CS;
}
-/* XXX This should probably go to util ... */
+/* XXX This should go to util ... */
/* Return the number of bits set in the given number. */
static unsigned bitcount(unsigned n)
{
- unsigned bits;
- for (bits = 0; n > 0; n = n >> 1) {
- bits += n & 1;
+ unsigned bits = 0;
+
+ while (n) {
+ if (n & 1) {
+ bits++;
+ }
+ n >>= 1;
}
+
return bits;
}
@@ -714,7 +719,7 @@ void r300_emit_vertex_program_code(struct r300_context* r300,
int temp_count = MAX2(code->num_temporaries, 1);
int pvs_num_slots = MIN3(vtx_mem_size / input_count,
vtx_mem_size / output_count, 10);
- int pvs_num_controllers = MIN2(6, vtx_mem_size / temp_count);
+ int pvs_num_controllers = MIN2(vtx_mem_size / temp_count, 6);
CS_LOCALS(r300);