diff options
author | Eric Anholt <eric@anholt.net> | 2008-12-23 16:08:40 -0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2009-01-05 15:11:48 +0800 |
commit | 37f489edd217f7a92998b7ca9207d43e2860b357 (patch) | |
tree | ae404803bc453161b2c7fb7d507b111bf1f1fd96 | |
parent | fe3eef8ef262af56d8dcd9b2565a1a5e8a8a00f1 (diff) | |
download | mesa-37f489edd217f7a92998b7ca9207d43e2860b357.tar.gz |
dri: Fix driWaitForMSC32 when divisor >= 2 and msc < 0.
We'd come up with a negative remainder, while we were looking for the positive
version of it in the loop conditional. And, since the "did we hit our target"
break was disabled for the target_msc == 0 ("Just make the divisor/remainder
work") path, we'd never exit.
Simplify the code by just using int64_t all over instead of trying to do it
in a u32 space.
(cherry picked from commit 6c01500228014a6cfa133b5dbba8c6d024833e84)
-rw-r--r-- | src/mesa/drivers/dri/common/vblank.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/mesa/drivers/dri/common/vblank.c b/src/mesa/drivers/dri/common/vblank.c index d610253fe6f..12aeaa108f7 100644 --- a/src/mesa/drivers/dri/common/vblank.c +++ b/src/mesa/drivers/dri/common/vblank.c @@ -130,9 +130,8 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv, if ( divisor != 0 ) { - unsigned int target = (unsigned int)target_msc; - unsigned int next = target; - unsigned int r; + int64_t next = target_msc; + int64_t r; int dont_wait = (target_msc == 0); do { @@ -154,9 +153,9 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv, *msc = vblank_to_msc(priv, vbl.reply.sequence); - dont_wait = 0; - if (target_msc != 0 && *msc == target) + if (!dont_wait && *msc == next) break; + dont_wait = 0; /* Assuming the wait-done test fails, the next refresh to wait for * will be one that satisfies (MSC % divisor) == remainder. The @@ -165,11 +164,12 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv, * If this refresh has already happened, we add divisor to obtain * the next refresh after the current one that will satisfy it. */ - r = (*msc % (unsigned int)divisor); - next = (*msc - r + (unsigned int)remainder); - if (next <= *msc) next += (unsigned int)divisor; + r = ((uint64_t)*msc % divisor); + next = (*msc - r + remainder); + if (next <= *msc) + next += divisor; - } while ( r != (unsigned int)remainder ); + } while (r != remainder); } else { /* If the \c divisor is zero, just wait until the MSC is greater |