-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathghost_intrinsics.h
89 lines (77 loc) · 1.48 KB
/
ghost_intrinsics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#if !defined(GHOST_INTRINSICS_H)
// TODO(): Convert all of these to platform-efficient versions
// and remove math.h
//m
#include "math.h"
inline int32
RoundReal32ToInt32(real32 Real32)
{
int32 Result = (int32)roundf(Real32);
return(Result);
}
inline uint32
RoundReal32ToUInt32(real32 Real32)
{
uint32 Result = (uint32)roundf(Real32);
return(Result);
}
inline int32
FloorReal32ToInt32(real32 Real32)
{
int32 Result = (int32)floorf(Real32);
return(Result);
}
inline int32
TruncateReal32ToInt32(real32 Real32)
{
int32 Result = (int32)Real32;
return(Result);
}
inline real32
Sin(real32 Angle)
{
real32 Result = sinf(Angle);
return(Result);
}
inline real32
Cos(real32 Angle)
{
real32 Result = cosf(Angle);
return(Result);
}
inline real32
ATan2(real32 Y, real32 X)
{
real32 Result = atan2f(Y, X);
return(Result);
}
/*
struct bit_scan_result
{
bool32 Found;
uint32 Index;
};
inline bit_scan_result
FindLeastSignificantSetBit(uint32 Value)
{
bit_scan_result Result = {};
#if COMPILER_MSVC
Result.Found = _BitScanForward((unsigned long *)&Result.Index, Value);
#else
for(uint32 Test = 0;
Test < 32;
++Test)
{
if(Value & (1 << Test))
{
Result.Index = Test;
Result.Found = true;
break;
}
}
#endif
return(Result);
}
*/
#define GHOST_INTRINSICS_H
#endif