This commit is contained in:
Branimir Karadžić
2017-02-06 16:22:22 -08:00
parent 17e0713b7b
commit bb15438be4
9 changed files with 34 additions and 46 deletions

View File

@@ -10,7 +10,6 @@
#include "bx.h"
#include <math.h>
#include <string.h>
namespace bx
{

View File

@@ -9,10 +9,6 @@
# error "Must be included from bx/fpumath.h!"
#endif // BX_FPU_MATH_H_HEADER_GUARD
#include "bx.h"
#include <math.h>
#include <string.h>
namespace bx
{
inline float toRad(float _deg)
@@ -597,7 +593,7 @@ namespace bx
inline void mtxIdentity(float* _result)
{
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[0] = _result[5] = _result[10] = _result[15] = 1.0f;
}
@@ -611,7 +607,7 @@ namespace bx
inline void mtxScale(float* _result, float _sx, float _sy, float _sz)
{
memset(_result, 0, sizeof(float) * 16);
memSet(_result, 0, sizeof(float) * 16);
_result[0] = _sx;
_result[5] = _sy;
_result[10] = _sz;
@@ -738,7 +734,7 @@ namespace bx
vec3Cross(up, _view, right);
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = right[0];
_result[ 1] = up[0];
_result[ 2] = _view[0];
@@ -791,7 +787,7 @@ namespace bx
const float aa = _oglNdc ? (_far+_near)/diff : _far/diff;
const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa;
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = _width;
_result[ 5] = _height;
_result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
@@ -888,7 +884,7 @@ namespace bx
bb = _oglNdc ? 2.0f*_near : _near;
}
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = _width;
_result[ 5] = _height;
_result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
@@ -1009,7 +1005,7 @@ namespace bx
const float ee = (_top + _bottom)/(_bottom - _top);
const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = aa;
_result[ 5] = bb;
_result[10] = (Handness::Right == HandnessT) ? -cc : cc;
@@ -1039,7 +1035,7 @@ namespace bx
const float sx = fsin(_ax);
const float cx = fcos(_ax);
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = 1.0f;
_result[ 5] = cx;
_result[ 6] = -sx;
@@ -1053,7 +1049,7 @@ namespace bx
const float sy = fsin(_ay);
const float cy = fcos(_ay);
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = cy;
_result[ 2] = sy;
_result[ 5] = 1.0f;
@@ -1067,7 +1063,7 @@ namespace bx
const float sz = fsin(_az);
const float cz = fcos(_az);
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = cz;
_result[ 1] = -sz;
_result[ 4] = sz;
@@ -1083,7 +1079,7 @@ namespace bx
const float sy = fsin(_ay);
const float cy = fcos(_ay);
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = cy;
_result[ 2] = sy;
_result[ 4] = sx*sy;
@@ -1104,7 +1100,7 @@ namespace bx
const float sz = fsin(_az);
const float cz = fcos(_az);
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = cy*cz;
_result[ 1] = -cy*sz;
_result[ 2] = sy;
@@ -1126,7 +1122,7 @@ namespace bx
const float sz = fsin(_az);
const float cz = fcos(_az);
memset(_result, 0, sizeof(float)*16);
memSet(_result, 0, sizeof(float)*16);
_result[ 0] = cy*cz;
_result[ 1] = cz*sx*sy-cx*sz;
_result[ 2] = cx*cz*sy+sx*sz;

View File

@@ -23,7 +23,7 @@ namespace bx
uint32_t pass = 0;
for (; pass < 3; ++pass)
{
memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
memSet(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
bool sorted = true;
{
@@ -87,7 +87,7 @@ done:
uint32_t pass = 0;
for (; pass < 3; ++pass)
{
memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
memSet(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
bool sorted = true;
{
@@ -157,7 +157,7 @@ done:
uint32_t pass = 0;
for (; pass < 6; ++pass)
{
memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
memSet(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
bool sorted = true;
{
@@ -221,7 +221,7 @@ done:
uint32_t pass = 0;
for (; pass < 6; ++pass)
{
memset(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
memSet(histogram, 0, sizeof(uint32_t)*BX_RADIXSORT_HISTOGRAM_SIZE);
bool sorted = true;
{

View File

@@ -6,8 +6,6 @@
#ifndef BX_SIMD128_REF_H_HEADER_GUARD
#define BX_SIMD128_REF_H_HEADER_GUARD
#include <math.h> // sqrtf
#define simd_shuf_xAzC simd_shuf_xAzC_ni
#define simd_shuf_yBwD simd_shuf_yBwD_ni
#define simd_rcp simd_rcp_ni
@@ -396,10 +394,10 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw , 0xf);
BX_SIMD_FORCE_INLINE simd128_ref_t simd_sqrt(simd128_ref_t _a)
{
simd128_ref_t result;
result.fxyzw[0] = sqrtf(_a.fxyzw[0]);
result.fxyzw[1] = sqrtf(_a.fxyzw[1]);
result.fxyzw[2] = sqrtf(_a.fxyzw[2]);
result.fxyzw[3] = sqrtf(_a.fxyzw[3]);
result.fxyzw[0] = fsqrt(_a.fxyzw[0]);
result.fxyzw[1] = fsqrt(_a.fxyzw[1]);
result.fxyzw[2] = fsqrt(_a.fxyzw[2]);
result.fxyzw[3] = fsqrt(_a.fxyzw[3]);
return result;
}
@@ -407,10 +405,10 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw , 0xf);
BX_SIMD_FORCE_INLINE simd128_ref_t simd_rsqrt_est(simd128_ref_t _a)
{
simd128_ref_t result;
result.fxyzw[0] = 1.0f / sqrtf(_a.fxyzw[0]);
result.fxyzw[1] = 1.0f / sqrtf(_a.fxyzw[1]);
result.fxyzw[2] = 1.0f / sqrtf(_a.fxyzw[2]);
result.fxyzw[3] = 1.0f / sqrtf(_a.fxyzw[3]);
result.fxyzw[0] = 1.0f / fsqrt(_a.fxyzw[0]);
result.fxyzw[1] = 1.0f / fsqrt(_a.fxyzw[1]);
result.fxyzw[2] = 1.0f / fsqrt(_a.fxyzw[2]);
result.fxyzw[3] = 1.0f / fsqrt(_a.fxyzw[3]);
return result;
}

View File

@@ -7,6 +7,7 @@
#define BX_SIMD_T_H_HEADER_GUARD
#include "bx.h"
#include "fpumath.h"
#define BX_SIMD_FORCE_INLINE BX_FORCE_INLINE
#define BX_SIMD_INLINE inline

View File

@@ -18,6 +18,4 @@ namespace bx
} // namespace bx
#include "timer.inl"
#endif // BX_TIMER_H_HEADER_GUARD

View File

@@ -1,61 +0,0 @@
/*
* Copyright 2010-2017 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
*/
#ifndef BX_TIMER_H_HEADER_GUARD
# error "Must be included from bx/timer.h!"
#endif // BX_TIMER_H_HEADER_GUARD
#include "bx.h"
#if BX_PLATFORM_ANDROID
# include <time.h> // clock, clock_gettime
#elif BX_PLATFORM_EMSCRIPTEN
# include <emscripten.h>
#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
# include <windows.h>
#else
# include <sys/time.h> // gettimeofday
#endif // BX_PLATFORM_
namespace bx
{
inline int64_t getHPCounter()
{
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
LARGE_INTEGER li;
// Performance counter value may unexpectedly leap forward
// http://support.microsoft.com/kb/274323
QueryPerformanceCounter(&li);
int64_t i64 = li.QuadPart;
#elif BX_PLATFORM_ANDROID
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
int64_t i64 = now.tv_sec*INT64_C(1000000000) + now.tv_nsec;
#elif BX_PLATFORM_EMSCRIPTEN
int64_t i64 = int64_t(1000.0f * emscripten_get_now() );
#else
struct timeval now;
gettimeofday(&now, 0);
int64_t i64 = now.tv_sec*INT64_C(1000000) + now.tv_usec;
#endif // BX_PLATFORM_
return i64;
}
inline int64_t getHPFrequency()
{
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT
LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
return li.QuadPart;
#elif BX_PLATFORM_ANDROID
return INT64_C(1000000000);
#elif BX_PLATFORM_EMSCRIPTEN
return INT64_C(1000000);
#else
return INT64_C(1000000);
#endif // BX_PLATFORM_
}
} // namespace bx