summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software/Rasterizer.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2015-10-10 16:16:48 -0400
committerLioncash <mathew1800@gmail.com>2015-12-06 02:44:06 -0500
commit9b921c2e7c06d2c778f205d7c75e08bfc7cf42e0 (patch)
tree17d9599555e5296c9aed21d19bbdd4d12c3bafed /Source/Core/VideoBackends/Software/Rasterizer.cpp
parent7134d727bf6151d89ce7148ed2a716958334552f (diff)
Rasterizer: Get rid of a trivial pointer cast
Diffstat (limited to 'Source/Core/VideoBackends/Software/Rasterizer.cpp')
-rw-r--r--Source/Core/VideoBackends/Software/Rasterizer.cpp26
1 files changed, 14 insertions, 12 deletions
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 <algorithm>
+#include <cstring>
#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<a)?a:x
-// returns approximation of log2(f) in s28.4
-// results are close enough to use for LOD
-static inline s32 FixedLog2(float f)
-{
- u32 *x = (u32*)&f;
- s32 logInt = ((*x & 0x7F800000) >> 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;