diff --git a/3rdparty/bx/.appveyor.yml b/3rdparty/bx/.appveyor.yml index 286a3c9cc3b..db402c41b97 100644 --- a/3rdparty/bx/.appveyor.yml +++ b/3rdparty/bx/.appveyor.yml @@ -5,7 +5,6 @@ os: environment: matrix: - - TOOLSET: vs2010 - TOOLSET: vs2012 - TOOLSET: vs2013 - TOOLSET: vs2015 diff --git a/3rdparty/bx/.travis.yml b/3rdparty/bx/.travis.yml index 7b8e2d62283..cffababe8a8 100644 --- a/3rdparty/bx/.travis.yml +++ b/3rdparty/bx/.travis.yml @@ -6,8 +6,18 @@ matrix: - compiler: clang os: osx +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 + - clang + script: - make test + - if [ "$TRAVIS_OS_NAME" == "linux" ]; then make test CXX="g++-4.8" CC="gcc-4.8"; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then make test; fi branches: only: diff --git a/3rdparty/bx/LICENSE b/3rdparty/bx/LICENSE index c80afb7366a..f18446330b4 100644 --- a/3rdparty/bx/LICENSE +++ b/3rdparty/bx/LICENSE @@ -1,4 +1,4 @@ -Copyright 2010-2016 Branimir Karadzic. All rights reserved. +Copyright 2010-2017 Branimir Karadzic. All rights reserved. https://github.com/bkaradzic/bx diff --git a/3rdparty/bx/README.md b/3rdparty/bx/README.md index 0e17833a8d6..3da618f9f3d 100644 --- a/3rdparty/bx/README.md +++ b/3rdparty/bx/README.md @@ -19,7 +19,7 @@ https://github.com/bkaradzic/bx [License (BSD 2-clause)](https://github.com/bkaradzic/bx/blob/master/LICENSE) ----------------------------------------------------------------------------- - Copyright 2010-2016 Branimir Karadzic. All rights reserved. + Copyright 2010-2017 Branimir Karadzic. All rights reserved. https://github.com/bkaradzic/bx diff --git a/3rdparty/bx/include/bx/allocator.h b/3rdparty/bx/include/bx/allocator.h index 61356321134..f74b78b2c59 100644 --- a/3rdparty/bx/include/bx/allocator.h +++ b/3rdparty/bx/include/bx/allocator.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/bx.h b/3rdparty/bx/include/bx/bx.h index c9419b39357..65a50d08cb4 100644 --- a/3rdparty/bx/include/bx/bx.h +++ b/3rdparty/bx/include/bx/bx.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -81,7 +81,4 @@ namespace bx } // namespace bx -// Annoying C++0x stuff.. -//namespace std { namespace tr1 {}; using namespace tr1; } - #endif // BX_H_HEADER_GUARD diff --git a/3rdparty/bx/include/bx/cl.h b/3rdparty/bx/include/bx/cl.h index 17b7bafd403..f21aa96e734 100644 --- a/3rdparty/bx/include/bx/cl.h +++ b/3rdparty/bx/include/bx/cl.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/commandline.h b/3rdparty/bx/include/bx/commandline.h index d35843f8972..bafd48e3be2 100644 --- a/3rdparty/bx/include/bx/commandline.h +++ b/3rdparty/bx/include/bx/commandline.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/config.h b/3rdparty/bx/include/bx/config.h index 43c08ec0f24..86a81521161 100644 --- a/3rdparty/bx/include/bx/config.h +++ b/3rdparty/bx/include/bx/config.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/cpu.h b/3rdparty/bx/include/bx/cpu.h index a4d5c65f8c8..91ab437019d 100644 --- a/3rdparty/bx/include/bx/cpu.h +++ b/3rdparty/bx/include/bx/cpu.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/crtimpl.h b/3rdparty/bx/include/bx/crtimpl.h index dff0120f71c..b2b3d64c95a 100644 --- a/3rdparty/bx/include/bx/crtimpl.h +++ b/3rdparty/bx/include/bx/crtimpl.h @@ -1,11 +1,13 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ #ifndef BX_CRTIMPL_H_HEADER_GUARD #define BX_CRTIMPL_H_HEADER_GUARD +#include "bx.h" + #if BX_CONFIG_ALLOCATOR_CRT # include # include "allocator.h" @@ -115,6 +117,12 @@ namespace bx { BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); + if (NULL != m_file) + { + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "CrtFileReader: File is already open."); + return false; + } + m_file = fopen(_filePath, "rb"); if (NULL == m_file) { @@ -127,17 +135,21 @@ namespace bx virtual void close() BX_OVERRIDE { + BX_CHECK(NULL != m_file, "Reader/Writer file is not open."); fclose(m_file); + m_file = NULL; } virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE { + BX_CHECK(NULL != m_file, "Reader/Writer file is not open."); fseeko64(m_file, _offset, _whence); return ftello64(m_file); } virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE { + BX_CHECK(NULL != m_file, "Reader/Writer file is not open."); BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); int32_t size = (int32_t)fread(_data, 1, _size, m_file); @@ -145,11 +157,11 @@ namespace bx { if (0 != feof(m_file) ) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "CrtFileWriter: EOF."); + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "CrtFileReader: EOF."); } else if (0 != ferror(m_file) ) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "CrtFileWriter: read error."); + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "CrtFileReader: read error."); } return size >= 0 ? size : 0; @@ -176,6 +188,14 @@ namespace bx virtual bool open(const char* _filePath, bool _append, Error* _err) BX_OVERRIDE { + BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); + + if (NULL != m_file) + { + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "CrtFileReader: File is already open."); + return false; + } + m_file = fopen(_filePath, _append ? "ab" : "wb"); if (NULL == m_file) @@ -189,17 +209,21 @@ namespace bx virtual void close() BX_OVERRIDE { + BX_CHECK(NULL != m_file, "Reader/Writer file is not open."); fclose(m_file); + m_file = NULL; } virtual int64_t seek(int64_t _offset = 0, Whence::Enum _whence = Whence::Current) BX_OVERRIDE { + BX_CHECK(NULL != m_file, "Reader/Writer file is not open."); fseeko64(m_file, _offset, _whence); return ftello64(m_file); } virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE { + BX_CHECK(NULL != m_file, "Reader/Writer file is not open."); BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); int32_t size = (int32_t)fwrite(_data, 1, _size, m_file); @@ -241,6 +265,12 @@ namespace bx { BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); + if (NULL != m_file) + { + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "ProcessReader: File is already open."); + return false; + } + m_file = popen(_command, "r"); if (NULL == m_file) { @@ -254,7 +284,7 @@ namespace bx virtual void close() BX_OVERRIDE { BX_CHECK(NULL != m_file, "Process not open!"); - pclose(m_file); + m_exitCode = pclose(m_file); m_file = NULL; } @@ -267,11 +297,11 @@ namespace bx { if (0 != feof(m_file) ) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "CrtFileWriter: EOF."); + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "ProcessReader: EOF."); } else if (0 != ferror(m_file) ) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "CrtFileWriter: read error."); + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_READ, "ProcessReader: read error."); } return size >= 0 ? size : 0; @@ -280,8 +310,14 @@ namespace bx return size; } + int32_t getExitCode() const + { + return m_exitCode; + } + private: FILE* m_file; + int32_t m_exitCode; }; class ProcessWriter : public WriterOpenI, public CloserI, public WriterI @@ -301,6 +337,12 @@ namespace bx { BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); + if (NULL != m_file) + { + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "ProcessWriter: File is already open."); + return false; + } + m_file = popen(_command, "w"); if (NULL == m_file) { @@ -314,7 +356,7 @@ namespace bx virtual void close() BX_OVERRIDE { BX_CHECK(NULL != m_file, "Process not open!"); - pclose(m_file); + m_exitCode = pclose(m_file); m_file = NULL; } @@ -327,7 +369,7 @@ namespace bx { if (0 != ferror(m_file) ) { - BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "CrtFileWriter: write error."); + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "ProcessWriter: write error."); } return size >= 0 ? size : 0; @@ -336,8 +378,14 @@ namespace bx return size; } + int32_t getExitCode() const + { + return m_exitCode; + } + private: FILE* m_file; + int32_t m_exitCode; }; #endif // BX_CONFIG_CRT_PROCESS diff --git a/3rdparty/bx/include/bx/debug.h b/3rdparty/bx/include/bx/debug.h index 1154ab74e2c..c94f744aad2 100644 --- a/3rdparty/bx/include/bx/debug.h +++ b/3rdparty/bx/include/bx/debug.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/easing.h b/3rdparty/bx/include/bx/easing.h new file mode 100644 index 00000000000..3db6eec53a2 --- /dev/null +++ b/3rdparty/bx/include/bx/easing.h @@ -0,0 +1,315 @@ +/* + * Copyright 2011-2017 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bx#license-bsd-2-clause + */ + +#ifndef BX_EASING_H_HEADER_GUARD +#define BX_EASING_H_HEADER_GUARD + +#include "fpumath.h" + +// Reference: +// http://easings.net/ +// http://robertpenner.com/easing/ + +namespace bx +{ + struct Easing + { + enum Enum + { + Linear, + InQuad, + OutQuad, + InOutQuad, + OutInQuad, + InCubic, + OutCubic, + InOutCubic, + OutInCubic, + InQuart, + OutQuart, + InOutQuart, + OutInQuart, + InQuint, + OutQuint, + InOutQuint, + OutInQuint, + InSine, + OutSine, + InOutSine, + OutInSine, + InExpo, + OutExpo, + InOutExpo, + OutInExpo, + InCirc, + OutCirc, + InOutCirc, + OutInCirc, + InElastic, + OutElastic, + InOutElastic, + OutInElastic, + InBack, + OutBack, + InOutBack, + OutInBack, + InBounce, + OutBounce, + InOutBounce, + OutInBounce, + + Count + }; + }; + + typedef float (*EaseFn)(float _t); + + template + float easeOut(float _t) + { + return 1.0f - ease(1.0f - _t); + } + + template + float easeMix(float _t) + { + return _t < 0.5f + ? easeFrom0toH(2.0f*_t)*0.5f + : easeFromHto1(2.0f*_t - 1.0f)*0.5f + 0.5f + ; + } + + inline float easeLinear(float _t) + { + return _t; + } + + inline float easeInQuad(float _t) + { + return fsq(_t); + } + + inline float easeOutQuad(float _t) + { + return easeOut(_t); + } + + inline float easeInOutQuad(float _t) + { + return easeMix(_t); + } + + inline float easeOutInQuad(float _t) + { + return easeMix(_t); + } + + inline float easeInCubic(float _t) + { + return _t*_t*_t; + } + + inline float easeOutCubic(float _t) + { + return easeOut(_t); + } + + inline float easeInOutCubic(float _t) + { + return easeMix(_t); + } + + inline float easeOutInCubic(float _t) + { + return easeMix(_t); + } + + inline float easeInQuart(float _t) + { + return _t*_t*_t*_t; + } + + inline float easeOutQuart(float _t) + { + return easeOut(_t); + } + + inline float easeInOutQuart(float _t) + { + return easeMix(_t); + } + + inline float easeOutInQuart(float _t) + { + return easeMix(_t); + } + + inline float easeInQuint(float _t) + { + return _t*_t*_t*_t*_t; + } + + inline float easeOutQuint(float _t) + { + return easeOut(_t); + } + + inline float easeInOutQuint(float _t) + { + return easeMix(_t); + } + + inline float easeOutInQuint(float _t) + { + return easeMix(_t); + } + + inline float easeInSine(float _t) + { + return 1.0f - fcos(_t*piHalf); + } + + inline float easeOutSine(float _t) + { + return easeOut(_t); + } + + inline float easeInOutSine(float _t) + { + return easeMix(_t); + } + + inline float easeOutInSine(float _t) + { + return easeMix(_t); + } + + inline float easeInExpo(float _t) + { + return fpow(2.0f, 10.0f * (_t - 1.0f) ) - 0.001f; + } + + inline float easeOutExpo(float _t) + { + return easeOut(_t); + } + + inline float easeInOutExpo(float _t) + { + return easeMix(_t); + } + + inline float easeOutInExpo(float _t) + { + return easeMix(_t); + } + + inline float easeInCirc(float _t) + { + return -(fsqrt(1.0f - _t*_t) - 1.0f); + } + + inline float easeOutCirc(float _t) + { + return easeOut(_t); + } + + inline float easeInOutCirc(float _t) + { + return easeMix(_t); + } + + inline float easeOutInCirc(float _t) + { + return easeMix(_t); + } + + inline float easeOutElastic(float _t) + { + return fpow(2.0f, -10.0f*_t)*fsin( (_t-0.3f/4.0f)*(2.0f*pi)/0.3f) + 1.0f; + } + + inline float easeInElastic(float _t) + { + return easeOut(_t); + } + + inline float easeInOutElastic(float _t) + { + return easeMix(_t); + } + + inline float easeOutInElastic(float _t) + { + return easeMix(_t); + } + + inline float easeInBack(float _t) + { + return easeInCubic(_t) - _t*fsin(_t*pi); + } + + inline float easeOutBack(float _t) + { + return easeOut(_t); + } + + inline float easeInOutBack(float _t) + { + return easeMix(_t); + } + + inline float easeOutInBack(float _t) + { + return easeMix(_t); + } + + inline float easeOutBounce(float _t) + { + if (4.0f/11.0f > _t) + { + return 121.0f/16.0f*_t*_t; + } + + if (8.0f/11.0f > _t) + { + return 363.0f/40.0f*_t*_t + - 99.0f/10.0f*_t + + 17.0f/ 5.0f + ; + } + + if (9.0f/10.0f > _t) + { + return 4356.0f/ 361.0f*_t*_t + - 35442.0f/1805.0f*_t + + 16061.0f/1805.0f + ; + } + + return 54.0f/ 5.0f*_t*_t + - 513.0f/25.0f*_t + + 268.0f/25.0f + ; + } + + inline float easeInBounce(float _t) + { + return easeOut(_t); + } + + inline float easeInOutBounce(float _t) + { + return easeMix(_t); + } + + inline float easeOutInBounce(float _t) + { + return easeMix(_t); + } + +} // namespace bx + +#endif // BX_EASING_H_HEADER_GUARD diff --git a/3rdparty/bx/include/bx/endian.h b/3rdparty/bx/include/bx/endian.h index 0781adec589..23e9a665b63 100644 --- a/3rdparty/bx/include/bx/endian.h +++ b/3rdparty/bx/include/bx/endian.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/error.h b/3rdparty/bx/include/bx/error.h index da1b8329b6f..598d5689c6c 100644 --- a/3rdparty/bx/include/bx/error.h +++ b/3rdparty/bx/include/bx/error.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -7,6 +7,7 @@ #define BX_ERROR_H_HEADER_GUARD #include "bx.h" +#include "string.h" #define BX_ERROR_SET(_ptr, _result, _msg) \ BX_MACRO_BLOCK_BEGIN \ @@ -48,7 +49,13 @@ namespace bx { } - void setError(ErrorResult _errorResult, const char* _msg) + void reset() + { + m_code = 0; + m_msg.clear(); + } + + void setError(ErrorResult _errorResult, const StringView& _msg) { BX_CHECK(0 != _errorResult.code, "Invalid ErrorResult passed to setError!"); @@ -72,6 +79,11 @@ namespace bx return result; } + const StringView& getMessage() const + { + return m_msg; + } + bool operator==(const ErrorResult& _rhs) const { return _rhs.code == m_code; @@ -83,8 +95,8 @@ namespace bx } private: - const char* m_msg; - uint32_t m_code; + StringView m_msg; + uint32_t m_code; }; /// diff --git a/3rdparty/bx/include/bx/float4x4_t.h b/3rdparty/bx/include/bx/float4x4_t.h index 269dd633d3d..e1a5eedfa70 100644 --- a/3rdparty/bx/include/bx/float4x4_t.h +++ b/3rdparty/bx/include/bx/float4x4_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/foreach.h b/3rdparty/bx/include/bx/foreach.h index 43abf621105..53a6dde7265 100644 --- a/3rdparty/bx/include/bx/foreach.h +++ b/3rdparty/bx/include/bx/foreach.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/fpumath.h b/3rdparty/bx/include/bx/fpumath.h index 7d7a2671bb2..c7438eb3105 100644 --- a/3rdparty/bx/include/bx/fpumath.h +++ b/3rdparty/bx/include/bx/fpumath.h @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 Branimir Karadzic. All rights reserved. + * Copyright 2011-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -102,16 +102,6 @@ namespace bx return _a < 0.0f ? -1.0f : 1.0f; } - inline float fstep(float _edge, float _a) - { - return _a < _edge ? 0.0f : 1.0f; - } - - inline float fpulse(float _a, float _start, float _end) - { - return fstep(_a, _start) - fstep(_a, _end); - } - inline float fabsolute(float _a) { return fabsf(_a); @@ -127,11 +117,21 @@ namespace bx return sinf(_a); } + inline float fasin(float _a) + { + return asinf(_a); + } + inline float fcos(float _a) { return cosf(_a); } + inline float facos(float _a) + { + return acosf(_a); + } + inline float fpow(float _a, float _b) { return powf(_a, _b); @@ -197,6 +197,21 @@ namespace bx return result; } + inline float fstep(float _edge, float _a) + { + return _a < _edge ? 0.0f : 1.0f; + } + + inline float fpulse(float _a, float _start, float _end) + { + return fstep(_a, _start) - fstep(_a, _end); + } + + inline float fsmoothstep(float _a) + { + return fsq(_a)*(3.0f - 2.0f*_a); + } + // References: // - Bias And Gain Are Your Friend // http://blog.demofox.org/2012/09/24/bias-and-gain-are-your-friend/ @@ -341,6 +356,7 @@ namespace bx _result[2] = 1.0f / _a[2]; } + /// Calculate tangent frame from normal. inline void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b) { const float nx = _n[0]; @@ -365,6 +381,21 @@ namespace bx bx::vec3Cross(_b, _n, _t); } + /// Calculate tangent frame from normal and angle. + inline void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b, float _angle) + { + vec3TangentFrame(_n, _t, _b); + + const float sa = fsin(_angle); + const float ca = fcos(_angle); + + _t[0] = -sa * _b[0] + ca * _t[0]; + _t[1] = -sa * _b[1] + ca * _t[1]; + _t[2] = -sa * _b[2] + ca * _t[2]; + + bx::vec3Cross(_b, _n, _t); + } + inline void quatIdentity(float* _result) { _result[0] = 0.0f; @@ -574,6 +605,25 @@ namespace bx _result[15] = 1.0f; } + inline void mtxFromNormal(float* __restrict _result, const float* __restrict _normal, float _scale, const float* __restrict _pos, float _angle) + { + float tangent[3]; + float bitangent[3]; + vec3TangentFrame(_normal, tangent, bitangent, _angle); + + vec3Mul(&_result[ 0], bitangent, _scale); + vec3Mul(&_result[ 4], _normal, _scale); + vec3Mul(&_result[ 8], tangent, _scale); + + _result[ 3] = 0.0f; + _result[ 7] = 0.0f; + _result[11] = 0.0f; + _result[12] = _pos[0]; + _result[13] = _pos[1]; + _result[14] = _pos[2]; + _result[15] = 1.0f; + } + inline void mtxQuat(float* __restrict _result, const float* __restrict _quat) { const float x = _quat[0]; diff --git a/3rdparty/bx/include/bx/handlealloc.h b/3rdparty/bx/include/bx/handlealloc.h index bc8b42f47d4..04303f4f49c 100644 --- a/3rdparty/bx/include/bx/handlealloc.h +++ b/3rdparty/bx/include/bx/handlealloc.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/hash.h b/3rdparty/bx/include/bx/hash.h index 6e2f0849309..d037c30a3c1 100644 --- a/3rdparty/bx/include/bx/hash.h +++ b/3rdparty/bx/include/bx/hash.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -30,8 +30,7 @@ namespace bx void add(const void* _data, int _len) { - if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) - && BX_UNLIKELY(!isPtrAligned(_data, 4) ) ) + if (BX_UNLIKELY(!isPtrAligned(_data, 4) ) ) { addUnaligned(_data, _len); return; diff --git a/3rdparty/bx/include/bx/macros.h b/3rdparty/bx/include/bx/macros.h index d565fcad103..8dc35fa5865 100644 --- a/3rdparty/bx/include/bx/macros.h +++ b/3rdparty/bx/include/bx/macros.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/maputil.h b/3rdparty/bx/include/bx/maputil.h index 21e6067043d..4c7e4aa9c2d 100644 --- a/3rdparty/bx/include/bx/maputil.h +++ b/3rdparty/bx/include/bx/maputil.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/mpscqueue.h b/3rdparty/bx/include/bx/mpscqueue.h index 5a3db68641a..de4a6646db3 100644 --- a/3rdparty/bx/include/bx/mpscqueue.h +++ b/3rdparty/bx/include/bx/mpscqueue.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/mutex.h b/3rdparty/bx/include/bx/mutex.h index b01be030bf4..76a02e1a7e8 100644 --- a/3rdparty/bx/include/bx/mutex.h +++ b/3rdparty/bx/include/bx/mutex.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/os.h b/3rdparty/bx/include/bx/os.h index 58c315af7c8..78349ddab4b 100644 --- a/3rdparty/bx/include/bx/os.h +++ b/3rdparty/bx/include/bx/os.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/platform.h b/3rdparty/bx/include/bx/platform.h index d917d07df21..e976732c031 100644 --- a/3rdparty/bx/include/bx/platform.h +++ b/3rdparty/bx/include/bx/platform.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -202,7 +202,7 @@ # undef BX_PLATFORM_RPI # define BX_PLATFORM_RPI 1 #elif defined(__linux__) \ - || defined(__riscv__) + || BX_CPU_RISCV # undef BX_PLATFORM_LINUX # define BX_PLATFORM_LINUX 1 #elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) \ @@ -265,7 +265,9 @@ BX_STRINGIZE(__clang_minor__) "." \ BX_STRINGIZE(__clang_patchlevel__) #elif BX_COMPILER_MSVC -# if BX_COMPILER_MSVC >= 1900 // Visual Studio 2015 +# if BX_COMPILER_MSVC >= 1910 // Visual Studio 2017 +# define BX_COMPILER_NAME "MSVC 15.0" +# elif BX_COMPILER_MSVC >= 1900 // Visual Studio 2015 # define BX_COMPILER_NAME "MSVC 14.0" # elif BX_COMPILER_MSVC >= 1800 // Visual Studio 2013 # define BX_COMPILER_NAME "MSVC 12.0" diff --git a/3rdparty/bx/include/bx/process.h b/3rdparty/bx/include/bx/process.h index 4e4b151ee49..03c8f120624 100644 --- a/3rdparty/bx/include/bx/process.h +++ b/3rdparty/bx/include/bx/process.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/radixsort.h b/3rdparty/bx/include/bx/radixsort.h index d14398cacc8..2c4dd6a2408 100644 --- a/3rdparty/bx/include/bx/radixsort.h +++ b/3rdparty/bx/include/bx/radixsort.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/readerwriter.h b/3rdparty/bx/include/bx/readerwriter.h index ee6897b8253..d926628430d 100644 --- a/3rdparty/bx/include/bx/readerwriter.h +++ b/3rdparty/bx/include/bx/readerwriter.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -16,10 +16,11 @@ #include "error.h" #include "uint32_t.h" -BX_ERROR_RESULT(BX_ERROR_READERWRITER_OPEN, BX_MAKEFOURCC('R', 'W', 0, 1) ); -BX_ERROR_RESULT(BX_ERROR_READERWRITER_READ, BX_MAKEFOURCC('R', 'W', 0, 2) ); -BX_ERROR_RESULT(BX_ERROR_READERWRITER_WRITE, BX_MAKEFOURCC('R', 'W', 0, 3) ); -BX_ERROR_RESULT(BX_ERROR_READERWRITER_EOF, BX_MAKEFOURCC('R', 'W', 0, 4) ); +BX_ERROR_RESULT(BX_ERROR_READERWRITER_OPEN, BX_MAKEFOURCC('R', 'W', 0, 1) ); +BX_ERROR_RESULT(BX_ERROR_READERWRITER_READ, BX_MAKEFOURCC('R', 'W', 0, 2) ); +BX_ERROR_RESULT(BX_ERROR_READERWRITER_WRITE, BX_MAKEFOURCC('R', 'W', 0, 3) ); +BX_ERROR_RESULT(BX_ERROR_READERWRITER_EOF, BX_MAKEFOURCC('R', 'W', 0, 4) ); +BX_ERROR_RESULT(BX_ERROR_READERWRITER_ALREADY_OPEN, BX_MAKEFOURCC('R', 'W', 0, 5) ); namespace bx { @@ -223,6 +224,41 @@ namespace bx { }; + /// Align reader stream. + inline int32_t align(ReaderSeekerI* _reader, uint32_t _alignment, Error* _err = NULL) + { + BX_ERROR_SCOPE(_err); + const int64_t current = bx::seek(_reader); + const int64_t aligned = ( (current + _alignment-1)/_alignment) * _alignment; + const int32_t size = int32_t(aligned - current); + if (0 != size) + { + const int64_t offset = bx::seek(_reader, size); + if (offset != aligned) + { + BX_ERROR_SET(_err, BX_ERROR_READERWRITER_WRITE, "Align: read truncated."); + } + return int32_t(offset - current); + } + + return 0; + } + + /// Align writer stream (pads stream with zeros). + inline int32_t align(WriterSeekerI* _writer, uint32_t _alignment, Error* _err = NULL) + { + BX_ERROR_SCOPE(_err); + const int64_t current = bx::seek(_writer); + const int64_t aligned = ( (current + _alignment-1)/_alignment) * _alignment; + const int32_t size = int32_t(aligned - current); + if (0 != size) + { + return writeRep(_writer, 0, size, _err); + } + + return 0; + } + struct BX_NO_VTABLE ReaderOpenI { virtual ~ReaderOpenI() = 0; diff --git a/3rdparty/bx/include/bx/ringbuffer.h b/3rdparty/bx/include/bx/ringbuffer.h index f3904f4694b..28e7731e3d2 100644 --- a/3rdparty/bx/include/bx/ringbuffer.h +++ b/3rdparty/bx/include/bx/ringbuffer.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/rng.h b/3rdparty/bx/include/bx/rng.h index 0a1976d6fc8..cff323c2f95 100644 --- a/3rdparty/bx/include/bx/rng.h +++ b/3rdparty/bx/include/bx/rng.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -8,6 +8,7 @@ #include "bx.h" #include "fpumath.h" +#include "uint32_t.h" namespace bx { @@ -94,36 +95,47 @@ namespace bx }; /// Returns random number between 0.0f and 1.0f. - template - inline float frnd(Ty* _rng) + template + inline float frnd(Rng* _rng) { uint32_t rnd = _rng->gen() & UINT16_MAX; return float(rnd) * 1.0f/float(UINT16_MAX); } /// Returns random number between -1.0f and 1.0f. - template - inline float frndh(Ty* _rng) + template + inline float frndh(Rng* _rng) { return 2.0f * bx::frnd(_rng) - 1.0f; } - /// Generate random point on unit sphere. - template - static inline void randUnitSphere(float _result[3], Ty* _rng) + /// Generate random point on unit circle. + template + inline void randUnitCircle(float _result[3], Rng* _rng) { - float rand0 = frnd(_rng) * 2.0f - 1.0f; - float rand1 = frnd(_rng) * pi * 2.0f; + const float angle = frnd(_rng) * pi * 2.0f; - float sqrtf1 = sqrtf(1.0f - rand0*rand0); - _result[0] = sqrtf1 * cosf(rand1); - _result[1] = sqrtf1 * sinf(rand1); + _result[0] = fcos(angle); + _result[1] = 0.0f; + _result[2] = fsin(angle); + } + + /// Generate random point on unit sphere. + template + inline void randUnitSphere(float _result[3], Rng* _rng) + { + const float rand0 = frnd(_rng) * 2.0f - 1.0f; + const float rand1 = frnd(_rng) * pi * 2.0f; + const float sqrtf1 = fsqrt(1.0f - rand0*rand0); + + _result[0] = sqrtf1 * fcos(rand1); + _result[1] = sqrtf1 * fsin(rand1); _result[2] = rand0; } /// Generate random point on unit hemisphere. template - static inline void randUnitHemisphere(float _result[3], Ty* _rng, const float _normal[3]) + inline void randUnitHemisphere(float _result[3], Ty* _rng, const float _normal[3]) { float dir[3]; randUnitSphere(dir, _rng); @@ -148,7 +160,7 @@ namespace bx /// Sampling with Hammersley and Halton Points /// http://www.cse.cuhk.edu.hk/~ttwong/papers/udpoint/udpoints.html /// - static inline void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale = 1.0f) + inline void generateSphereHammersley(void* _data, uint32_t _stride, uint32_t _num, float _scale = 1.0f) { uint8_t* data = (uint8_t*)_data; @@ -164,19 +176,32 @@ namespace bx tt = 2.0f * tt - 1.0f; - const float phi = (ii + 0.5f) / _num; + const float phi = (ii + 0.5f) / _num; const float phirad = phi * 2.0f * pi; - const float st = sqrtf(1.0f-tt*tt) * _scale; + const float st = fsqrt(1.0f-tt*tt) * _scale; float* xyz = (float*)data; data += _stride; - xyz[0] = st * cosf(phirad); - xyz[1] = st * sinf(phirad); + xyz[0] = st * fcos(phirad); + xyz[1] = st * fsin(phirad); xyz[2] = tt * _scale; } } + /// Fisher-Yates shuffle. + template + inline void shuffle(Rng* _rng, Ty* _array, uint32_t _num) + { + BX_CHECK(_num != 0, "Number of elements can't be 0!"); + + for (uint32_t ii = 0, num = _num-1; ii < num; ++ii) + { + uint32_t jj = ii + 1 + _rng->gen() % (num - ii); + bx::xchg(_array[ii], _array[jj]); + } + } + } // namespace bx #endif // BX_RNG_H_HEADER_GUARD diff --git a/3rdparty/bx/include/bx/sem.h b/3rdparty/bx/include/bx/sem.h index 37141c53614..b33ab3721b0 100644 --- a/3rdparty/bx/include/bx/sem.h +++ b/3rdparty/bx/include/bx/sem.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/simd256_avx.inl b/3rdparty/bx/include/bx/simd256_avx.inl index 33f5af701e4..c8af735bfbf 100644 --- a/3rdparty/bx/include/bx/simd256_avx.inl +++ b/3rdparty/bx/include/bx/simd256_avx.inl @@ -10,7 +10,6 @@ namespace bx { - template<> BX_SIMD_FORCE_INLINE simd256_avx_t simd_ld(const void* _ptr) { @@ -38,6 +37,39 @@ namespace bx return result; } + template<> + BX_SIMD_FORCE_INLINE simd256_avx_t_t simd_splat(float _a) + { + return _mm256_set1_ps(_a); + } + + template<> + BX_SIMD_FORCE_INLINE simd256_avx_t_t simd_isplat(uint32_t _a) + { + const __m256i splat = _mm256_set1_epi32(_a); + const simd256_avx_t_t result = _mm256_castsi256_ps(splat); + + return result; + } + + template<> + BX_SIMD_FORCE_INLINE simd256_avx_t_t simd_itof(simd256_avx_t_t _a) + { + const __m256i itof = _mm256_castps_si256(_a); + const simd256_avx_t_t result = _mm256_cvtepi32_ps(itof); + + return result; + } + + template<> + BX_SIMD_FORCE_INLINE simd256_avx_t_t simd_ftoi(simd256_avx_t_t _a) + { + const __m256i ftoi = _mm256_cvtps_epi32(_a); + const simd256_avx_t_t result = _mm256_castsi256_ps(ftoi); + + return result; + } + typedef simd256_avx_t simd256_t; } // namespace bx diff --git a/3rdparty/bx/include/bx/simd256_ref.inl b/3rdparty/bx/include/bx/simd256_ref.inl index b1bca3f56a6..6d9a5a31ab5 100644 --- a/3rdparty/bx/include/bx/simd256_ref.inl +++ b/3rdparty/bx/include/bx/simd256_ref.inl @@ -13,27 +13,27 @@ namespace bx template<> BX_SIMD_FORCE_INLINE simd256_ref_t simd_ld(const void* _ptr) { - const simd128_t* ptr = reinterpret_cast(_ptr); + const simd256_ref_t::type* ptr = reinterpret_cast(_ptr); simd256_ref_t result; - result.simd128_0 = simd_ld(&ptr[0]); - result.simd128_1 = simd_ld(&ptr[1]); + result.simd128_0 = simd_ld(&ptr[0]); + result.simd128_1 = simd_ld(&ptr[1]); return result; } template<> BX_SIMD_FORCE_INLINE void simd_st(void* _ptr, simd256_ref_t& _a) { - simd128_t* result = reinterpret_cast(_ptr); - simd_st(&result[0], _a.simd128_0); - simd_st(&result[1], _a.simd128_1); + simd256_ref_t* result = reinterpret_cast(_ptr); + simd_st(&result[0], _a.simd128_0); + simd_st(&result[1], _a.simd128_1); } template<> BX_SIMD_FORCE_INLINE simd256_ref_t simd_ld(float _x, float _y, float _z, float _w, float _a, float _b, float _c, float _d) { simd256_ref_t result; - result.simd128_0 = simd_ld(_x, _y, _z, _w); - result.simd128_1 = simd_ld(_a, _b, _c, _d); + result.simd128_0 = simd_ld(_x, _y, _z, _w); + result.simd128_1 = simd_ld(_a, _b, _c, _d); return result; } @@ -41,8 +41,44 @@ namespace bx BX_SIMD_FORCE_INLINE simd256_ref_t simd_ild(uint32_t _x, uint32_t _y, uint32_t _z, uint32_t _w, uint32_t _a, uint32_t _b, uint32_t _c, uint32_t _d) { simd256_ref_t result; - result.simd128_0 = simd_ild(_x, _y, _z, _w); - result.simd128_1 = simd_ild(_a, _b, _c, _d); + result.simd128_0 = simd_ild(_x, _y, _z, _w); + result.simd128_1 = simd_ild(_a, _b, _c, _d); + return result; + } + + template<> + BX_SIMD_FORCE_INLINE simd256_ref_t simd_splat(float _a) + { + simd256_ref_t result; + result.simd128_0 = simd_splat(_a); + result.simd128_1 = simd_splat(_a); + return result; + } + + template<> + BX_SIMD_FORCE_INLINE simd256_ref_t simd_isplat(uint32_t _a) + { + simd256_ref_t result; + result.simd128_0 = simd_isplat(_a); + result.simd128_1 = simd_isplat(_a); + return result; + } + + template<> + BX_SIMD_FORCE_INLINE simd256_ref_t simd_itof(simd256_ref_t _a) + { + simd256_ref_t result; + result.simd128_0 = simd_itof(_a.simd128_0); + result.simd128_1 = simd_itof(_a.simd128_1); + return result; + } + + template<> + BX_SIMD_FORCE_INLINE simd256_ref_t simd_ftoi(simd256_ref_t _a) + { + simd256_ref_t result; + result.simd128_0 = simd_ftoi(_a.simd128_0); + result.simd128_1 = simd_ftoi(_a.simd128_1); return result; } diff --git a/3rdparty/bx/include/bx/simd_t.h b/3rdparty/bx/include/bx/simd_t.h index 5e1fa55d7dc..bc1fe6622f8 100644 --- a/3rdparty/bx/include/bx/simd_t.h +++ b/3rdparty/bx/include/bx/simd_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -402,8 +402,14 @@ namespace bx struct simd256_ref_t { - simd128_t simd128_0; - simd128_t simd128_1; +#if BX_COMPILER_MSVC + typedef simd128_ref_t type; +#else + typedef simd128_t type; +#endif // BX_COMPILER_MSVC + + type simd128_0; + type simd128_1; }; #if !BX_SIMD_AVX diff --git a/3rdparty/bx/include/bx/spscqueue.h b/3rdparty/bx/include/bx/spscqueue.h index 0e2ceacc362..3f75496f357 100644 --- a/3rdparty/bx/include/bx/spscqueue.h +++ b/3rdparty/bx/include/bx/spscqueue.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/string.h b/3rdparty/bx/include/bx/string.h index ea21ff37f07..44002f55250 100644 --- a/3rdparty/bx/include/bx/string.h +++ b/3rdparty/bx/include/bx/string.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -48,6 +48,23 @@ namespace bx return ptr - _str; } + /// Copy _num characters from string _src to _dst buffer of maximum _dstSize capacity + /// including zero terminator. Copy will be terminated with '\0'. + inline size_t strlncpy(char* _dst, size_t _dstSize, const char* _src, size_t _num = -1) + { + BX_CHECK(NULL != _dst, "_dst can't be NULL!"); + BX_CHECK(NULL != _src, "_src can't be NULL!"); + BX_CHECK(0 < _dstSize, "_dstSize can't be 0!"); + + const size_t len = strnlen(_src, _num); + const size_t max = _dstSize-1; + const size_t num = (len < max ? len : max); + strncpy(_dst, _src, num); + _dst[num] = '\0'; + + return num; + } + /// Find substring in string. Limit search to _size. inline const char* strnstr(const char* _str, const char* _find, size_t _size) { @@ -550,12 +567,12 @@ namespace bx return *this; } - StringView(const char* _ptr, uint32_t _len = UINT32_MAX) + StringView(const char* _ptr, uint32_t _len = UINT16_MAX) { set(_ptr, _len); } - void set(const char* _ptr, uint32_t _len = UINT32_MAX) + void set(const char* _ptr, uint32_t _len = UINT16_MAX) { clear(); @@ -619,11 +636,12 @@ namespace bx { public: StringT() - : StringView("", 0) + : StringView() { } StringT(const StringT& _rhs) + : StringView() { set(_rhs.m_ptr, _rhs.m_len); } @@ -652,15 +670,18 @@ namespace bx void set(const char* _ptr, uint32_t _len = UINT32_MAX) { clear(); + append(_ptr, _len); + } + void append(const char* _ptr, uint32_t _len = UINT32_MAX) + { if (0 != _len) { - uint32_t len = uint32_t(strnlen(_ptr, _len) ); + uint32_t old = m_len; + uint32_t len = m_len + uint32_t(strnlen(_ptr, _len) ); + char* ptr = (char*)BX_REALLOC(*AllocatorT, 0 != m_len ? const_cast(m_ptr) : NULL, len+1); m_len = len; - char* ptr = (char*)BX_ALLOC(*AllocatorT, len+1); - - memcpy(ptr, _ptr, len); - ptr[len] = '\0'; + strlncpy(ptr + old, len-old+1, _ptr, _len); *const_cast(&m_ptr) = ptr; } diff --git a/3rdparty/bx/include/bx/thread.h b/3rdparty/bx/include/bx/thread.h index 155e9f5c907..8514a704280 100644 --- a/3rdparty/bx/include/bx/thread.h +++ b/3rdparty/bx/include/bx/thread.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/timer.h b/3rdparty/bx/include/bx/timer.h index 462d9757a60..622e184e968 100644 --- a/3rdparty/bx/include/bx/timer.h +++ b/3rdparty/bx/include/bx/timer.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/tokenizecmd.h b/3rdparty/bx/include/bx/tokenizecmd.h index 5bb44de1737..0fe2e00b67a 100644 --- a/3rdparty/bx/include/bx/tokenizecmd.h +++ b/3rdparty/bx/include/bx/tokenizecmd.h @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 Branimir Karadzic. All rights reserved. + * Copyright 2012-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/include/bx/uint32_t.h b/3rdparty/bx/include/bx/uint32_t.h index 2f78ac3f34a..a7d6c45ad90 100644 --- a/3rdparty/bx/include/bx/uint32_t.h +++ b/3rdparty/bx/include/bx/uint32_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/makefile b/3rdparty/bx/makefile index 19180d4f1dc..6a6598f80b1 100644 --- a/3rdparty/bx/makefile +++ b/3rdparty/bx/makefile @@ -6,8 +6,6 @@ GENIE=../bx/tools/bin/$(OS)/genie all: - $(GENIE) vs2008 - $(GENIE) vs2010 $(GENIE) vs2012 $(GENIE) vs2013 $(GENIE) --gcc=android-arm gmake @@ -83,21 +81,6 @@ mingw-clang-release64: .build/projects/gmake-mingw-clang make -R -C .build/projects/gmake-mingw-clang config=release64 mingw-clang: mingw-clang-debug32 mingw-clang-release32 mingw-clang-debug64 mingw-clang-release64 -.build/projects/vs2008: - $(GENIE) vs2008 -vs2008-debug32: - devenv .build/projects/vs2008/bgfx.sln /Build "Debug|Win32" -vs2008-release32: - devenv .build/projects/vs2008/bgfx.sln /Build "Release|Win32" -vs2008-debug64: - devenv .build/projects/vs2008/bgfx.sln /Build "Debug|x64" -vs2008-release64: - devenv .build/projects/vs2008/bgfx.sln /Build "Release|x64" -vs2008: vs2008-debug32 vs2008-release32 vs2008-debug64 vs2008-release64 - -.build/projects/vs2010: - $(GENIE) vs2010 - .build/projects/vs2012: $(GENIE) vs2012 diff --git a/3rdparty/bx/scripts/bin2c.lua b/3rdparty/bx/scripts/bin2c.lua index 82b3a7a1771..5dbc29d7b14 100644 --- a/3rdparty/bx/scripts/bin2c.lua +++ b/3rdparty/bx/scripts/bin2c.lua @@ -1,5 +1,5 @@ -- --- Copyright 2010-2016 Branimir Karadzic. All rights reserved. +-- Copyright 2010-2017 Branimir Karadzic. All rights reserved. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause -- diff --git a/3rdparty/bx/scripts/bx.lua b/3rdparty/bx/scripts/bx.lua index 8cae8b419e8..2f1e4e57585 100644 --- a/3rdparty/bx/scripts/bx.lua +++ b/3rdparty/bx/scripts/bx.lua @@ -1,5 +1,5 @@ -- --- Copyright 2010-2016 Branimir Karadzic. All rights reserved. +-- Copyright 2010-2017 Branimir Karadzic. All rights reserved. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause -- diff --git a/3rdparty/bx/scripts/genie.lua b/3rdparty/bx/scripts/genie.lua index edc86a7823b..1e8f9028010 100644 --- a/3rdparty/bx/scripts/genie.lua +++ b/3rdparty/bx/scripts/genie.lua @@ -1,5 +1,5 @@ -- --- Copyright 2010-2016 Branimir Karadzic. All rights reserved. +-- Copyright 2010-2017 Branimir Karadzic. All rights reserved. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause -- diff --git a/3rdparty/bx/scripts/toolchain.lua b/3rdparty/bx/scripts/toolchain.lua index fced6542b9a..5d8573a690e 100644 --- a/3rdparty/bx/scripts/toolchain.lua +++ b/3rdparty/bx/scripts/toolchain.lua @@ -1,5 +1,5 @@ -- --- Copyright 2010-2016 Branimir Karadzic. All rights reserved. +-- Copyright 2010-2017 Branimir Karadzic. All rights reserved. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause -- @@ -39,6 +39,7 @@ function toolchain(_buildDir, _libDir) { "pnacl", "Native Client - PNaCl" }, { "orbis", "Orbis" }, { "qnx-arm", "QNX/Blackberry - ARM" }, + { "riscv", "RISC-V" }, { "rpi", "RaspberryPi" }, }, } @@ -51,9 +52,11 @@ function toolchain(_buildDir, _libDir) { "vs2012-clang", "Clang 3.6" }, { "vs2013-clang", "Clang 3.6" }, { "vs2015-clang", "Clang 3.9" }, + { "vs2017-clang", "Clang with MS CodeGen" }, { "vs2012-xp", "Visual Studio 2012 targeting XP" }, { "vs2013-xp", "Visual Studio 2013 targeting XP" }, { "vs2015-xp", "Visual Studio 2015 targeting XP" }, + { "vs2017-xp", "Visual Studio 2017 targeting XP" }, { "winphone8", "Windows Phone 8.0" }, { "winphone81", "Windows Phone 8.1" }, { "winstore81", "Windows Store 8.1" }, @@ -92,6 +95,12 @@ function toolchain(_buildDir, _libDir) description = "Set tvOS target version (default: 9.0).", } + newoption { + trigger = "with-windows", + value = "#", + description = "Set the Windows target platform version (default: 10.0.10240.0).", + } + newoption { trigger = "with-dynamic-runtime", description = "Dynamically link with the runtime rather than statically", @@ -118,7 +127,7 @@ function toolchain(_buildDir, _libDir) os.exit(1) end - local androidPlatform = "android-14" + local androidPlatform = "android-24" if _OPTIONS["with-android"] then androidPlatform = "android-" .. _OPTIONS["with-android"] end @@ -133,6 +142,11 @@ function toolchain(_buildDir, _libDir) tvosPlatform = _OPTIONS["with-tvos"] end + local windowsPlatform = "10.0.10240.0" + if _OPTIONS["with-windows"] then + windowsPlatform = _OPTIONS["with-windows"] + end + local compiler32bit = false if _OPTIONS["with-32bit-compiler"] then compiler32bit = true @@ -151,35 +165,41 @@ function toolchain(_buildDir, _libDir) if "android-arm" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_ARM") or not os.getenv("ANDROID_NDK_ROOT") then - print("Set ANDROID_NDK_ARM and ANDROID_NDK_ROOT envrionment variables.") + if not os.getenv("ANDROID_NDK_ARM") + or not os.getenv("ANDROID_NDK_CLANG") + or not os.getenv("ANDROID_NDK_ROOT") then + print("Set ANDROID_NDK_CLANG and ANDROID_NDK_ROOT envrionment variables.") end - premake.gcc.cc = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-gcc" - premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++" - premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar" + premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang" + premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++" + premake.gcc.llvm = true location (path.join(_buildDir, "projects", _ACTION .. "-android-arm")) elseif "android-mips" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_MIPS") or not os.getenv("ANDROID_NDK_ROOT") then + if not os.getenv("ANDROID_NDK_MIPS") + or not os.getenv("ANDROID_NDK_CLANG") + or not os.getenv("ANDROID_NDK_ROOT") then print("Set ANDROID_NDK_MIPS and ANDROID_NDK_ROOT envrionment variables.") end - premake.gcc.cc = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-gcc" - premake.gcc.cxx = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-g++" - premake.gcc.ar = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar" + premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang" + premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++" + premake.gcc.llvm = true location (path.join(_buildDir, "projects", _ACTION .. "-android-mips")) elseif "android-x86" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_X86") or not os.getenv("ANDROID_NDK_ROOT") then + if not os.getenv("ANDROID_NDK_X86") + or not os.getenv("ANDROID_NDK_CLANG") + or not os.getenv("ANDROID_NDK_ROOT") then print("Set ANDROID_NDK_X86 and ANDROID_NDK_ROOT envrionment variables.") end - premake.gcc.cc = "$(ANDROID_NDK_X86)/bin/i686-linux-android-gcc" - premake.gcc.cxx = "$(ANDROID_NDK_X86)/bin/i686-linux-android-g++" - premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar" + premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang" + premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++" + premake.gcc.llvm = true location (path.join(_buildDir, "projects", _ACTION .. "-android-x86")) elseif "asmjs" == _OPTIONS["gcc"] then @@ -387,17 +407,23 @@ function toolchain(_buildDir, _libDir) location (path.join(_buildDir, "projects", _ACTION .. "-rpi")) elseif "riscv" == _OPTIONS["gcc"] then - premake.gcc.cc = "$(RISCV_DIR)/bin/riscv64-unknown-elf-gcc" - premake.gcc.cxx = "$(RISCV_DIR)/bin/riscv64-unknown-elf-g++" - premake.gcc.ar = "$(RISCV_DIR)/bin/riscv64-unknown-elf-ar" + premake.gcc.cc = "$(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-gcc" + premake.gcc.cxx = "$(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-g++" + premake.gcc.ar = "$(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-ar" location (path.join(_buildDir, "projects", _ACTION .. "-riscv")) end - elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then + elseif _ACTION == "vs2012" + or _ACTION == "vs2013" + or _ACTION == "vs2015" + or _ACTION == "vs2017" + then if (_ACTION .. "-clang") == _OPTIONS["vs"] then - if "vs2015-clang" == _OPTIONS["vs"] then - premake.vstudio.toolset = ("LLVM-vs2014") + if "vs2017-clang" == _OPTIONS["vs"] then + premake.vstudio.toolset = "v141_clang_c2" + elseif "vs2015-clang" == _OPTIONS["vs"] then + premake.vstudio.toolset = "LLVM-vs2014" else premake.vstudio.toolset = ("LLVM-" .. _ACTION) end @@ -422,6 +448,11 @@ function toolchain(_buildDir, _libDir) elseif "winstore82" == _OPTIONS["vs"] then premake.vstudio.toolset = "v140" premake.vstudio.storeapp = "8.2" + + local action = premake.action.current() + action.vstudio.windowsTargetPlatformVersion = windowsPlatform + action.vstudio.windowsTargetPlatformMinVersion = windowsPlatform + platforms { "ARM" } location (path.join(_buildDir, "projects", _ACTION .. "-winstore82")) @@ -457,6 +488,10 @@ function toolchain(_buildDir, _libDir) premake.vstudio.toolset = ("v140_xp") location (path.join(_buildDir, "projects", _ACTION .. "-xp")) + elseif "vs2015-xp" == _OPTIONS["vs"] then + premake.vstudio.toolset = ("v141_xp") + location (path.join(_buildDir, "projects", _ACTION .. "-xp")) + elseif _ACTION == "xcode4" then if "osx" == _OPTIONS["xcode"] then @@ -557,6 +592,21 @@ function toolchain(_buildDir, _libDir) path.join(_libDir, "lib/win64_" .. _ACTION), } + configuration { "x32", "vs2017" } + targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin")) + objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj")) + libdirs { + path.join(_libDir, "lib/win32_" .. _ACTION), + } + + configuration { "x64", "vs2017" } + defines { "_WIN64" } + targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin")) + objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj")) + libdirs { + path.join(_libDir, "lib/win64_" .. _ACTION), + } + configuration { "ARM", "vs*" } targetdir (path.join(_buildDir, "arm_" .. _ACTION, "bin")) objdir (path.join(_buildDir, "arm_" .. _ACTION, "obj")) @@ -588,6 +638,9 @@ function toolchain(_buildDir, _libDir) configuration { "mingw-*" } defines { "WIN32" } includedirs { path.join(bxDir, "include/compat/mingw") } + defines { + "MINGW_HAS_SECURE_API=1", + } buildoptions { "-Wunused-value", "-fdata-sections", @@ -597,7 +650,7 @@ function toolchain(_buildDir, _libDir) "-Wundef", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } linkoptions { "-Wl,--gc-sections", @@ -679,7 +732,7 @@ function toolchain(_buildDir, _libDir) "-Wundef", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } links { "rt", @@ -687,6 +740,7 @@ function toolchain(_buildDir, _libDir) } linkoptions { "-Wl,--gc-sections", + "-Wl,--as-needed", } configuration { "linux-gcc*", "x32" } @@ -730,7 +784,7 @@ function toolchain(_buildDir, _libDir) "-Wundef", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } links { "rt", @@ -749,7 +803,7 @@ function toolchain(_buildDir, _libDir) "-Wundef", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } links { "rt", @@ -765,12 +819,11 @@ function toolchain(_buildDir, _libDir) "NoImportLib", } includedirs { - "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include", + "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include", "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue", } linkoptions { "-nostdlib", - "-static-libgcc", } links { "c", @@ -778,21 +831,20 @@ function toolchain(_buildDir, _libDir) "m", "android", "log", - "gnustl_static", + "c++", "gcc", } buildoptions { "-fPIC", "-no-canonical-prefixes", "-Wa,--noexecstack", - "-fstack-protector", + "-fstack-protector-strong", "-ffunction-sections", - "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0 "-Wunused-value", "-Wundef", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } linkoptions { "-no-canonical-prefixes", @@ -811,7 +863,7 @@ function toolchain(_buildDir, _libDir) "__STEAMLINK__=1", -- There is no special prefedined compiler symbol to detect SteamLink, faking it. } buildoptions { - "-std=c++0x", + "-std=c++11", "-Wfatal-errors", "-Wunused-value", "-Wundef", @@ -831,14 +883,16 @@ function toolchain(_buildDir, _libDir) objdir (path.join(_buildDir, "android-arm/obj")) libdirs { path.join(_libDir, "lib/android-arm"), - "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a", + "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a", } includedirs { - "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include", - "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include", + "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/include", + "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include", } buildoptions { + "-gcc-toolchain $(ANDROID_NDK_ARM)", "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"), + "-target armv7-none-linux-androideabi", "-mthumb", "-march=armv7-a", "-mfloat-abi=softfp", @@ -847,9 +901,11 @@ function toolchain(_buildDir, _libDir) "-Wundef", } linkoptions { + "-gcc-toolchain $(ANDROID_NDK_ARM)", "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"), path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"), path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"), + "-target armv7-none-linux-androideabi", "-march=armv7-a", "-Wl,--fix-cortex-a8", } @@ -859,20 +915,26 @@ function toolchain(_buildDir, _libDir) objdir (path.join(_buildDir, "android-mips/obj")) libdirs { path.join(_libDir, "lib/android-mips"), - "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips", + "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips", } includedirs { - "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/include", + "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips/include", } buildoptions { + "-gcc-toolchain $(ANDROID_NDK_MIPS)", "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"), + "-target mipsel-none-linux-android", + "-mips32", "-Wunused-value", "-Wundef", } linkoptions { + "-gcc-toolchain $(ANDROID_NDK_MIPS)", "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"), path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtbegin_so.o"), path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtend_so.o"), + "-target mipsel-none-linux-android", + "-mips32", } configuration { "android-x86" } @@ -880,13 +942,15 @@ function toolchain(_buildDir, _libDir) objdir (path.join(_buildDir, "android-x86/obj")) libdirs { path.join(_libDir, "lib/android-x86"), - "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86", + "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86", } includedirs { - "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include", + "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86/include", } buildoptions { + "-gcc-toolchain $(ANDROID_NDK_X86)", "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"), + "-target i686-none-linux-android", "-march=i686", "-mtune=atom", "-mstackrealign", @@ -896,9 +960,11 @@ function toolchain(_buildDir, _libDir) "-Wundef", } linkoptions { + "-gcc-toolchain $(ANDROID_NDK_X86)", "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"), path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"), path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtend_so.o"), + "-target i686-none-linux-android", } configuration { "asmjs" } @@ -931,7 +997,7 @@ function toolchain(_buildDir, _libDir) "-Wundef", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } includedirs { "$(NACL_SDK_ROOT)/include", @@ -1045,6 +1111,9 @@ function toolchain(_buildDir, _libDir) objdir (path.join(_buildDir, "osx_universal/bin")) configuration { "osx" } + buildoptions_cpp { + "-std=c++11", + } buildoptions { "-Wfatal-errors", "-msse2", @@ -1057,6 +1126,9 @@ function toolchain(_buildDir, _libDir) linkoptions { "-lc++", } + buildoptions_cpp { + "-std=c++11", + } buildoptions { "-Wfatal-errors", "-Wunused-value", @@ -1184,7 +1256,7 @@ function toolchain(_buildDir, _libDir) buildoptions { } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } linkoptions { } @@ -1200,7 +1272,7 @@ function toolchain(_buildDir, _libDir) "-Wundef", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } configuration { "rpi" } @@ -1219,7 +1291,7 @@ function toolchain(_buildDir, _libDir) "-Wundef", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } includedirs { "/opt/vc/include", @@ -1236,16 +1308,21 @@ function toolchain(_buildDir, _libDir) configuration { "riscv" } targetdir (path.join(_buildDir, "riscv/bin")) objdir (path.join(_buildDir, "riscv/obj")) + defines { + "__BSD_VISIBLE", + "__MISC_VISIBLE", + } includedirs { - "$(RISCV_DIR)/sysroot/usr/include", + "$(FREEDOM_E_SDK)/toolchain/riscv32-unknown-elf/include", + path.join(bxDir, "include/compat/riscv"), } buildoptions { "-Wunused-value", "-Wundef", - "--sysroot=$(RISCV_DIR)/sysroot", + "--sysroot=$(FREEDOM_E_SDK)/toolchain/riscv32-unknown-elf", } buildoptions_cpp { - "-std=c++0x", + "-std=c++11", } configuration {} -- reset configuration diff --git a/3rdparty/bx/tests/dbg.cpp b/3rdparty/bx/tests/dbg.cpp index efbfad6b6c1..58e3f034a86 100644 --- a/3rdparty/bx/tests/dbg.cpp +++ b/3rdparty/bx/tests/dbg.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 Branimir Karadzic. All rights reserved. + * Copyright 2011-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/dbg.h b/3rdparty/bx/tests/dbg.h index b1f23910b04..21f4433820b 100644 --- a/3rdparty/bx/tests/dbg.h +++ b/3rdparty/bx/tests/dbg.h @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 Branimir Karadzic. All rights reserved. + * Copyright 2011-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/fpumath_test.cpp b/3rdparty/bx/tests/fpumath_test.cpp index 8f98ea28365..f41cea8ba91 100644 --- a/3rdparty/bx/tests/fpumath_test.cpp +++ b/3rdparty/bx/tests/fpumath_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/handle_bench.cpp b/3rdparty/bx/tests/handle_bench.cpp index 1b1032bb226..a882cbe635d 100644 --- a/3rdparty/bx/tests/handle_bench.cpp +++ b/3rdparty/bx/tests/handle_bench.cpp @@ -52,7 +52,7 @@ int main() { typedef std::unordered_map StdUnorderedMap; StdUnorderedMap map; -// map.reserve(numElements); + map.reserve(numElements); for (uint32_t jj = 0; jj < numElements; ++jj) { std::pair ok = map.insert(std::make_pair(uint64_t(jj), uint16_t(jj) ) ); diff --git a/3rdparty/bx/tests/handle_test.cpp b/3rdparty/bx/tests/handle_test.cpp index 29019e318cf..5bcd6f8c89e 100644 --- a/3rdparty/bx/tests/handle_test.cpp +++ b/3rdparty/bx/tests/handle_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/macros_test.cpp b/3rdparty/bx/tests/macros_test.cpp index 321bc67e27b..37079de73a4 100644 --- a/3rdparty/bx/tests/macros_test.cpp +++ b/3rdparty/bx/tests/macros_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/main_test.cpp b/3rdparty/bx/tests/main_test.cpp index f6aaa90d538..47e9bf46155 100644 --- a/3rdparty/bx/tests/main_test.cpp +++ b/3rdparty/bx/tests/main_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/simd_test.cpp b/3rdparty/bx/tests/simd_test.cpp index f40b009388f..0a361f4f7aa 100644 --- a/3rdparty/bx/tests/simd_test.cpp +++ b/3rdparty/bx/tests/simd_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -11,11 +11,13 @@ #if 0 # define SIMD_DBG DBG #else -# define SIMD_DBG(_fmt, ...) BX_UNUSED(__VA_ARGS__); +# define SIMD_DBG unused #endif // 0 using namespace bx; +inline void unused(...) {} + union simd_cast { bx::simd256_t simd256; @@ -59,7 +61,6 @@ void simd_check_int32( REQUIRE(c.i[3] == _3); } -#if 0 void simd_check_int32( const char* _str , bx::simd256_t _a @@ -89,7 +90,6 @@ void simd_check_int32( REQUIRE(c.i[6] == _6); REQUIRE(c.i[7] == _7); } -#endif // 0 void simd_check_uint32( const char* _str @@ -114,7 +114,6 @@ void simd_check_uint32( REQUIRE(c.ui[3] == _3); } -#if 0 void simd_check_uint32( const char* _str , bx::simd256_t _a @@ -145,7 +144,6 @@ void simd_check_uint32( REQUIRE(c.ui[6] == _6); REQUIRE(c.ui[7] == _7); } -#endif // 0 void simd_check_float( const char* _str @@ -170,7 +168,6 @@ void simd_check_float( CHECK(bx::fequal(c.f[3], _3, 0.0001f) ); } -#if 0 void simd_check_float( const char* _str , bx::simd256_t _a @@ -201,7 +198,6 @@ void simd_check_float( CHECK(bx::fequal(c.f[6], _6, 0.0001f) ); CHECK(bx::fequal(c.f[7], _7, 0.0001f) ); } -#endif // 0 void simd_check_string(const char* _str, bx::simd128_t _a) { @@ -326,20 +322,20 @@ TEST_CASE("simd_load", "") , 0.0f, 1.0f, 2.0f, 3.0f ); -// simd_check_float("ld" -// , simd_ld(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f) -// , 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f -// ); + simd_check_float("ld" + , simd_ld(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f) + , 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f + ); simd_check_int32("ild" , simd_ild(uint32_t(-1), 0, 1, 2) , uint32_t(-1), 0, 1, 2 ); -// simd_check_int32("ild" -// , simd_ild(uint32_t(-1), 0, 1, 2, 3, 4, 5, 6) -// , uint32_t(-1), 0, 1, 2, 3, 4, 5, 6 -// ); + simd_check_int32("ild" + , simd_ild(uint32_t(-1), 0, 1, 2, 3, 4, 5, 6) + , uint32_t(-1), 0, 1, 2, 3, 4, 5, 6 + ); simd_check_int32("ild" , simd_ild(uint32_t(-1), uint32_t(-2), uint32_t(-3), uint32_t(-4) ) @@ -350,13 +346,21 @@ TEST_CASE("simd_load", "") , 0, 0, 0, 0 ); - simd_check_uint32("isplat", simd_isplat(0x80000001) + simd_check_uint32("isplat", simd_isplat(0x80000001) , 0x80000001, 0x80000001, 0x80000001, 0x80000001 ); - simd_check_float("isplat", simd_splat(1.0f) + simd_check_float("splat", simd_splat(1.0f) , 1.0f, 1.0f, 1.0f, 1.0f ); + + simd_check_uint32("isplat", simd_isplat(0x80000001) + , 0x80000001, 0x80000001, 0x80000001, 0x80000001, 0x80000001, 0x80000001, 0x80000001, 0x80000001 + ); + + simd_check_float("splat", simd_splat(1.0f) + , 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f + ); } TEST_CASE("simd_arithmetic", "") @@ -390,7 +394,7 @@ TEST_CASE("simd_sqrt", "") ); } -TEST_CASE("float4", "") +TEST_CASE("simd", "") { const simd128_t isplat = simd_isplat(0x80000001); simd_check_uint32("sll" diff --git a/3rdparty/bx/tests/string_test.cpp b/3rdparty/bx/tests/string_test.cpp index 3d98e38b2e8..ed83e86cc4d 100644 --- a/3rdparty/bx/tests/string_test.cpp +++ b/3rdparty/bx/tests/string_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -19,6 +19,27 @@ TEST_CASE("strnlen", "") REQUIRE(4 == bx::strnlen(test, UINT32_MAX) ); } +TEST_CASE("strlncpy", "") +{ + char dst[128]; + size_t num; + + num = bx::strlncpy(dst, 1, "blah"); + REQUIRE(num == 0); + + num = bx::strlncpy(dst, 3, "blah", 3); + REQUIRE(0 == strcmp(dst, "bl") ); + REQUIRE(num == 2); + + num = bx::strlncpy(dst, sizeof(dst), "blah", 3); + REQUIRE(0 == strcmp(dst, "bla") ); + REQUIRE(num == 3); + + num = bx::strlncpy(dst, sizeof(dst), "blah"); + REQUIRE(0 == strcmp(dst, "blah") ); + REQUIRE(num == 4); +} + TEST_CASE("StringView", "") { bx::StringView sv("test"); @@ -32,10 +53,21 @@ TEST_CASE("StringView", "") String st(sv); REQUIRE(4 == st.getLength() ); + st.append("test"); + REQUIRE(8 == st.getLength() ); + + st.append("test", 2); + REQUIRE(10 == st.getLength() ); + + REQUIRE(0 == strcmp(st.getPtr(), "testtestte") ); + st.clear(); REQUIRE(0 == st.getLength() ); REQUIRE(4 == sv.getLength() ); + st.append("test"); + REQUIRE(4 == st.getLength() ); + sv.clear(); REQUIRE(0 == sv.getLength() ); } diff --git a/3rdparty/bx/tests/test.h b/3rdparty/bx/tests/test.h index 8fb79c2c78b..33c3cf7cbc0 100644 --- a/3rdparty/bx/tests/test.h +++ b/3rdparty/bx/tests/test.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/thread_test.cpp b/3rdparty/bx/tests/thread_test.cpp index f0ee772aeba..54f24f37f20 100644 --- a/3rdparty/bx/tests/thread_test.cpp +++ b/3rdparty/bx/tests/thread_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/tokenizecmd_test.cpp b/3rdparty/bx/tests/tokenizecmd_test.cpp index 32e927bec1f..12502502a1a 100644 --- a/3rdparty/bx/tests/tokenizecmd_test.cpp +++ b/3rdparty/bx/tests/tokenizecmd_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 Branimir Karadzic. All rights reserved. + * Copyright 2012-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/uint32_test.cpp b/3rdparty/bx/tests/uint32_test.cpp index 3fe0044d67c..0c2be1e9cb7 100644 --- a/3rdparty/bx/tests/uint32_test.cpp +++ b/3rdparty/bx/tests/uint32_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 Branimir Karadzic. All rights reserved. + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tools/bin/darwin/genie b/3rdparty/bx/tools/bin/darwin/genie index 6b8fe9f8c00..842ca082bdf 100755 Binary files a/3rdparty/bx/tools/bin/darwin/genie and b/3rdparty/bx/tools/bin/darwin/genie differ diff --git a/3rdparty/bx/tools/bin/linux/genie b/3rdparty/bx/tools/bin/linux/genie index 171d83e25ec..7feeebbd006 100755 Binary files a/3rdparty/bx/tools/bin/linux/genie and b/3rdparty/bx/tools/bin/linux/genie differ diff --git a/3rdparty/bx/tools/bin/windows/genie.exe b/3rdparty/bx/tools/bin/windows/genie.exe index dd19ec0a432..ad7d65824d6 100644 Binary files a/3rdparty/bx/tools/bin/windows/genie.exe and b/3rdparty/bx/tools/bin/windows/genie.exe differ diff --git a/3rdparty/bx/tools/bin2c/bin2c.cpp b/3rdparty/bx/tools/bin2c/bin2c.cpp index 8aa1b9f9142..47fc3bc2d22 100644 --- a/3rdparty/bx/tools/bin2c/bin2c.cpp +++ b/3rdparty/bx/tools/bin2c/bin2c.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 Branimir Karadzic. All rights reserved. + * Copyright 2011-2017 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -95,7 +95,7 @@ void help(const char* _error = NULL) fprintf(stderr , "bin2c, binary to C\n" - "Copyright 2011-2016 Branimir Karadzic. All rights reserved.\n" + "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n" "License: https://github.com/bkaradzic/bx#license-bsd-2-clause\n\n" );