diff --git a/Source/Core/VideoBackends/Software/Rasterizer.cpp b/Source/Core/VideoBackends/Software/Rasterizer.cpp index 440572e45a..d4977f7671 100644 --- a/Source/Core/VideoBackends/Software/Rasterizer.cpp +++ b/Source/Core/VideoBackends/Software/Rasterizer.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include "Common/CommonTypes.h" #include "VideoBackends/Software/BPMemLoader.h" @@ -15,22 +16,10 @@ #include "VideoBackends/Software/XFMemLoader.h" #include "VideoCommon/BoundingBox.h" - #define BLOCK_SIZE 2 #define CLAMP(x, a, b) (x>b)?b:(x> 19) - 2032; // integer part - s32 logFract = (*x & 0x007fffff) >> 19; // approximate fractional part - - return logInt + logFract; -} - namespace Rasterizer { static Slope ZSlope; @@ -83,6 +72,19 @@ void Init() ZSlope.f0 = 1.f; } +// Returns approximation of log2(f) in s28.4 +// results are close enough to use for LOD +static s32 FixedLog2(float f) +{ + u32 x; + std::memcpy(&x, &f, sizeof(u32)); + + s32 logInt = ((x & 0x7F800000) >> 19) - 2032; // integer part + s32 logFract = (x & 0x007fffff) >> 19; // approximate fractional part + + return logInt + logFract; +} + static inline int iround(float x) { int t = (int)x;