Author: ArcRiley
Date: 2007-07-03 18:26:43 -0400 (Tue, 03 Jul 2007)
New Revision: 330
Modified:
trunk/pysoy/src/textures/Texture.pxi
Log:
_squareup is now much faster
Modified: trunk/pysoy/src/textures/Texture.pxi
===================================================================
--- trunk/pysoy/src/textures/Texture.pxi 2007-07-03 22:17:42 UTC (rev
329)
+++ trunk/pysoy/src/textures/Texture.pxi 2007-07-03 22:26:43 UTC (rev
330)
@@ -146,11 +146,16 @@
self._depth = z
- cdef int _squareup(self, int size) :
- cdef int e
- for e from 0 <= e <= 12 :
- if size <= 1 << e :
- return 1 << e
+ cdef int _squareup(self, int _v) :
+ # This handy hack courtesy Sean Anderson, see:
+ # http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
+ _v = _v - 1
+ _v = _v | _v >> 1
+ _v = _v | _v >> 2
+ _v = _v | _v >> 4
+ _v = _v | _v >> 8
+ _v = _v | _v >> 16
+ return _v + 1
def __dealloc__(self) :
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn