diff options
author | 2019-10-13 13:50:38 +0200 | |
---|---|---|
committer | 2019-10-13 07:50:38 -0400 | |
commit | 0837e7451a84f95c29dbdb9bd6b8b931fee1635d (patch) | |
tree | 626bcbd250a7fbebdf5958a288d2f438d4f9fb5a /3rdparty/bx/tests | |
parent | c913ccb59d713ce0b91135520719ac5385e54358 (diff) |
WIP: sync bgfx, bx and bimg with latest upstream (#5723)
* Sync with bgfx upstream revision b91d0b6
* Sync with bx upstream revision d60912b
* Sync with bimg upstream revision bd81f60
* Add astc-codec decoder
* Rename VertexDecl to VertexLayout
* Rename UniformType enum Int1 to Sampler.
* Add NVN stub
* Fix unused-const-variable error on macOS
* Drop redundant explicit language parameters
buildoptions_cpp are only applied to c++ files and buildoptions_objcpp are only
applied to objective c++ files. As such, hardcoding -x offers no benefit while
preventing overrides (such as one needed by 3rdparty/bgfx/src/renderer_vk.cpp on
macOS) from working.
* Re-introduce -x c++ in places where C code is compiled as C++ to prevent clang from throwing a warning
* Build bgfx as Objective-C++ on macOS
It is needed due to included headers
* Enable Direct3D12 and Vulkan bgfx rendering backends
* Enable building of spirv shaders
* Properly escape /c in cmd call
* Comment out dx12 bgfx renderer
* Honor VERBOSE setting during shaders build
* Only invert hlsl shader XYZ_TO_sRGB matrix for opengl
* Add spirv shaders
* OpenGL ES needs transposed matrix too
* Metal needs transposed matrix as well
Diffstat (limited to '3rdparty/bx/tests')
30 files changed, 210 insertions, 84 deletions
diff --git a/3rdparty/bx/tests/atomic_test.cpp b/3rdparty/bx/tests/atomic_test.cpp index 04a623686e7..219b0959d27 100644 --- a/3rdparty/bx/tests/atomic_test.cpp +++ b/3rdparty/bx/tests/atomic_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/crt_test.cpp b/3rdparty/bx/tests/crt_test.cpp index bda079036ee..bddcb2b2d76 100644 --- a/3rdparty/bx/tests/crt_test.cpp +++ b/3rdparty/bx/tests/crt_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 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 243dc234afc..2fb211862d1 100644 --- a/3rdparty/bx/tests/dbg.h +++ b/3rdparty/bx/tests/dbg.h @@ -1,5 +1,5 @@ /* - * Copyright 2011-2018 Branimir Karadzic. All rights reserved. + * Copyright 2011-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/easing_test.cpp b/3rdparty/bx/tests/easing_test.cpp index 06944547f4a..4556c3ad19c 100644 --- a/3rdparty/bx/tests/easing_test.cpp +++ b/3rdparty/bx/tests/easing_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/filepath_test.cpp b/3rdparty/bx/tests/filepath_test.cpp index 2662adeddf1..fa912105569 100644 --- a/3rdparty/bx/tests/filepath_test.cpp +++ b/3rdparty/bx/tests/filepath_test.cpp @@ -1,10 +1,10 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ #include "test.h" -#include <bx/filepath.h> +#include <bx/file.h> struct FilePathTest { @@ -96,9 +96,8 @@ TEST_CASE("FilePath", "") const FilePathTest& test = s_filePathTest[ii]; fp.set(test.filePath); - const bx::StringView result = fp.get(); - REQUIRE(0 == bx::strCmp(test.expected, result) ); + REQUIRE(0 == bx::strCmp(test.expected, fp) ); } for (uint32_t ii = 0; ii < BX_COUNTOF(s_filePathSplit); ++ii) diff --git a/3rdparty/bx/tests/handle_bench.cpp b/3rdparty/bx/tests/handle_bench.cpp index 4effb59758e..082bee0e182 100644 --- a/3rdparty/bx/tests/handle_bench.cpp +++ b/3rdparty/bx/tests/handle_bench.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/handle_test.cpp b/3rdparty/bx/tests/handle_test.cpp index eb89b1f67a9..5c367f34531 100644 --- a/3rdparty/bx/tests/handle_test.cpp +++ b/3rdparty/bx/tests/handle_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/hash_test.cpp b/3rdparty/bx/tests/hash_test.cpp index 1ec6702080e..5c2d258dcc9 100644 --- a/3rdparty/bx/tests/hash_test.cpp +++ b/3rdparty/bx/tests/hash_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 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 e0d5ffae8b4..3576b1cf2a9 100644 --- a/3rdparty/bx/tests/macros_test.cpp +++ b/3rdparty/bx/tests/macros_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 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 b9e9074a8ea..2e0fbe2b431 100644 --- a/3rdparty/bx/tests/main_test.cpp +++ b/3rdparty/bx/tests/main_test.cpp @@ -1,17 +1,17 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ #include "test.h" -static const char* s_argv[] = { "bx.test" }; - int runAllTests(int _argc, const char* _argv[]); #if BX_PLATFORM_ANDROID # include <android/native_activity.h> +static const char* s_argv[] = { "bx.test" }; + void ANativeActivity_onCreate(ANativeActivity*, void*, size_t) { exit(runAllTests(BX_COUNTOF(s_argv), s_argv) ); diff --git a/3rdparty/bx/tests/math_bench.cpp b/3rdparty/bx/tests/math_bench.cpp index 50a8b3d2301..e9e083e385c 100644 --- a/3rdparty/bx/tests/math_bench.cpp +++ b/3rdparty/bx/tests/math_bench.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -60,6 +60,10 @@ void math_bench() mathTest<bx::sin >("bx::sin"); bx::write(writer, &err, "\n"); + mathTest< ::sinhf>(" ::sinhf"); + mathTest<bx::sinh >("bx::sinh"); + + bx::write(writer, &err, "\n"); mathTest< ::asinf>(" ::asinf"); mathTest<bx::asin >("bx::asin"); @@ -68,6 +72,10 @@ void math_bench() mathTest<bx::cos >("bx::cos"); bx::write(writer, &err, "\n"); + mathTest< ::coshf>(" ::coshf"); + mathTest<bx::cosh >("bx::cosh"); + + bx::write(writer, &err, "\n"); mathTest< ::acosf>(" ::acosf"); mathTest<bx::acos >("bx::acos"); @@ -76,6 +84,26 @@ void math_bench() mathTest<bx::tan >("bx::tan"); bx::write(writer, &err, "\n"); + mathTest< ::tanhf>(" ::tanhf"); + mathTest<bx::tanh >("bx::tanh"); + + bx::write(writer, &err, "\n"); mathTest< ::atanf>(" ::atanf"); mathTest<bx::atan >("bx::atan"); + + bx::write(writer, &err, "\n"); + mathTest< ::expf>(" ::expf"); + mathTest<bx::exp >("bx::exp"); + + bx::write(writer, &err, "\n"); + mathTest< ::exp2f>(" ::exp2f"); + mathTest<bx::exp2 >("bx::exp2"); + + bx::write(writer, &err, "\n"); + mathTest< ::logf >(" ::logf"); + mathTest<bx::log >("bx::log"); + + bx::write(writer, &err, "\n"); + mathTest< ::log2f>(" ::log2f"); + mathTest<bx::log2 >("bx::log2"); } diff --git a/3rdparty/bx/tests/math_test.cpp b/3rdparty/bx/tests/math_test.cpp index 2eeac286282..84bec2c1b10 100644 --- a/3rdparty/bx/tests/math_test.cpp +++ b/3rdparty/bx/tests/math_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -203,7 +203,7 @@ TEST_CASE("quaternion", "") float mtxQ[16]; float mtx[16]; - float quat[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; + bx::Quaternion quat = { 0.0f, 0.0f, 0.0f, 1.0f }; bx::mtxQuat(mtxQ, quat); bx::mtxIdentity(mtx); mtxCheck(mtxQ, mtx); @@ -212,28 +212,27 @@ TEST_CASE("quaternion", "") float ay = bx::kPi/13.0f; float az = bx::kPi/7.0f; - bx::quatRotateX(quat, ax); + quat = bx::rotateX(ax); bx::mtxQuat(mtxQ, quat); bx::mtxRotateX(mtx, ax); mtxCheck(mtxQ, mtx); - float euler[3]; - bx::quatToEuler(euler, quat); - CHECK(bx::equal(euler[0], ax, 0.001f) ); + bx::Vec3 euler = bx::toEuler(quat); + CHECK(bx::equal(euler.x, ax, 0.001f) ); - bx::quatRotateY(quat, ay); + quat = bx::rotateY(ay); bx::mtxQuat(mtxQ, quat); bx::mtxRotateY(mtx, ay); mtxCheck(mtxQ, mtx); - bx::quatToEuler(euler, quat); - CHECK(bx::equal(euler[1], ay, 0.001f) ); + euler = bx::toEuler(quat); + CHECK(bx::equal(euler.y, ay, 0.001f) ); - bx::quatRotateZ(quat, az); + quat = bx::rotateZ(az); bx::mtxQuat(mtxQ, quat); bx::mtxRotateZ(mtx, az); mtxCheck(mtxQ, mtx); - bx::quatToEuler(euler, quat); - CHECK(bx::equal(euler[2], az, 0.001f) ); + euler = bx::toEuler(quat); + CHECK(bx::equal(euler.z, az, 0.001f) ); } diff --git a/3rdparty/bx/tests/nlalloc_test.cpp b/3rdparty/bx/tests/nlalloc_test.cpp index 91b0354926f..14c44e5f23f 100644 --- a/3rdparty/bx/tests/nlalloc_test.cpp +++ b/3rdparty/bx/tests/nlalloc_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -34,7 +34,7 @@ namespace bx { struct Blk { - static const uint64_t kInvalid = UINT64_MAX; + static constexpr uint64_t kInvalid = UINT64_MAX; Blk() : ptr(kInvalid) @@ -66,6 +66,8 @@ namespace bx class NonLocalAllocator { public: + static constexpr uint32_t kMinBlockSize = 16u; + NonLocalAllocator() { reset(); @@ -102,13 +104,13 @@ namespace bx Blk alloc(uint32_t _size) { - _size = max(_size, 16u); + _size = max(_size, kMinBlockSize); for (FreeList::iterator it = m_free.begin(), itEnd = m_free.end(); it != itEnd; ++it) { if (it->size >= _size) { - uint64_t ptr = it->ptr; + const uint64_t ptr = it->ptr; if (it->size != _size) { @@ -121,6 +123,7 @@ namespace bx } m_used += _size; + return Blk{ ptr, _size }; } } @@ -131,38 +134,32 @@ namespace bx void free(const Blk& _blk) { + BX_CHECK(isValid(_blk), "Freeing invalid block!"); + m_used -= _blk.size; - m_free.push_back(_blk); - compact(); - } - bool compact() - { - bx::quickSort( - m_free.begin() - , uint32_t(m_free.end() - m_free.begin() ) - , sizeof(Blk) - , [](const void* _a, const void* _b) -> int32_t { - const Blk& lhs = *(const Blk*)(_a); - const Blk& rhs = *(const Blk*)(_b); - return lhs < rhs ? -1 : 1; - }); - - for (FreeList::iterator it = m_free.begin(), next = it, itEnd = m_free.end(); next != itEnd;) + FreeList::iterator it = m_free.begin(); + FreeList::iterator itEnd = m_free.end(); + for (; it != itEnd; ++it) { - if ( (it->ptr + it->size) == next->ptr) + if ( (_blk.ptr + _blk.size) == it->ptr) { - it->size += next->size; - next = m_free.erase(next); + it->ptr = _blk.ptr; + it->size += _blk.size; + break; } - else + + if (_blk.ptr > it->ptr) { - it = next; - ++next; + m_free.insert(it, _blk); + break; } } - return 0 == m_used; + if (it == itEnd) + { + m_free.push_back(_blk); + } } uint32_t getUsed() const @@ -175,6 +172,9 @@ namespace bx FreeList m_free; uint32_t m_used; }; + + constexpr uint32_t NonLocalAllocator::kMinBlockSize; + } // namespace bx TEST_CASE("nlalloc") @@ -185,11 +185,45 @@ TEST_CASE("nlalloc") blk = nla.alloc(100); REQUIRE(!isValid(blk) ); - nla.add(bx::Blk{0x1000, 100}); + nla.add(bx::Blk{0x1000, 1024}); - blk = nla.alloc(100); + blk = nla.alloc(1024); REQUIRE(isValid(blk) ); + bx::Blk blk2 = nla.alloc(1); + REQUIRE(!isValid(blk2) ); + nla.free(blk); REQUIRE(0 == nla.getUsed() ); + + { + bx::Blk blk3 = nla.alloc(123); + REQUIRE(isValid(blk3) ); + + bx::Blk blk4 = nla.alloc(134); + REQUIRE(isValid(blk4) ); + + bx::Blk blk5 = nla.alloc(145); + REQUIRE(isValid(blk5) ); + + bx::Blk blk6 = nla.alloc(156); + REQUIRE(isValid(blk6) ); + + bx::Blk blk7 = nla.alloc(167); + REQUIRE(isValid(blk7) ); + + nla.free(blk3); + nla.free(blk5); + nla.free(blk7); + nla.free(blk4); + nla.free(blk6); + REQUIRE(0 == nla.getUsed() ); + } + + blk2 = nla.alloc(1); + REQUIRE(isValid(blk2) ); + REQUIRE(bx::NonLocalAllocator::kMinBlockSize == nla.getUsed() ); + + nla.free(blk2); + REQUIRE(0 == nla.getUsed() ); } diff --git a/3rdparty/bx/tests/os_test.cpp b/3rdparty/bx/tests/os_test.cpp index bf51c725e05..bd28bf51d2d 100644 --- a/3rdparty/bx/tests/os_test.cpp +++ b/3rdparty/bx/tests/os_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/queue_test.cpp b/3rdparty/bx/tests/queue_test.cpp index 4a4d5c9a325..c035dcc8db1 100644 --- a/3rdparty/bx/tests/queue_test.cpp +++ b/3rdparty/bx/tests/queue_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/readerwriter_test.cpp b/3rdparty/bx/tests/readerwriter_test.cpp new file mode 100644 index 00000000000..53fa3f80cd3 --- /dev/null +++ b/3rdparty/bx/tests/readerwriter_test.cpp @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bx#license-bsd-2-clause + */ + +#include "test.h" +#include <bx/readerwriter.h> + +TEST_CASE("writeLE", "") +{ + bx::SizerWriter writer; + + bx::Error err; + + int32_t total = bx::writeLE(&writer, 1.0f, &err); + + REQUIRE(err.isOk() ); + REQUIRE(total == 4); +} + +TEST_CASE("writeBE", "") +{ + bx::SizerWriter writer; + + bx::Error err; + + int32_t total = bx::writeBE(&writer, 1.0f, &err); + + REQUIRE(err.isOk() ); + REQUIRE(total == 4); +} diff --git a/3rdparty/bx/tests/ringbuffer_test.cpp b/3rdparty/bx/tests/ringbuffer_test.cpp index d0d2a426572..fb78b0862d7 100644 --- a/3rdparty/bx/tests/ringbuffer_test.cpp +++ b/3rdparty/bx/tests/ringbuffer_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/rng_test.cpp b/3rdparty/bx/tests/rng_test.cpp index b5161f7167e..c6586275e47 100644 --- a/3rdparty/bx/tests/rng_test.cpp +++ b/3rdparty/bx/tests/rng_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/run_test.cpp b/3rdparty/bx/tests/run_test.cpp index 090c1186c0c..1f7e0509273 100644 --- a/3rdparty/bx/tests/run_test.cpp +++ b/3rdparty/bx/tests/run_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -15,6 +15,7 @@ int runAllTests(int _argc, const char* _argv[]) ", CRT: " BX_CRT_NAME ", Date: " __DATE__ ", Time: " __TIME__ + ", C++: " BX_CPP_NAME ); return Catch::Session().run(_argc, _argv); } diff --git a/3rdparty/bx/tests/settings_test.cpp b/3rdparty/bx/tests/settings_test.cpp index 584397ad143..fbf6c9a1112 100644 --- a/3rdparty/bx/tests/settings_test.cpp +++ b/3rdparty/bx/tests/settings_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/simd_bench.cpp b/3rdparty/bx/tests/simd_bench.cpp index 66e26297aaf..5e77d4190d3 100644 --- a/3rdparty/bx/tests/simd_bench.cpp +++ b/3rdparty/bx/tests/simd_bench.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 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 3a211ca1054..8b959c8dffb 100644 --- a/3rdparty/bx/tests/simd_test.cpp +++ b/3rdparty/bx/tests/simd_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/sort_test.cpp b/3rdparty/bx/tests/sort_test.cpp index e2a5a25449d..a46a80b64f8 100644 --- a/3rdparty/bx/tests/sort_test.cpp +++ b/3rdparty/bx/tests/sort_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/string_test.cpp b/3rdparty/bx/tests/string_test.cpp index b7c4ed8ab52..c1c4b85f546 100644 --- a/3rdparty/bx/tests/string_test.cpp +++ b/3rdparty/bx/tests/string_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -91,6 +91,10 @@ TEST_CASE("strCat", "") TEST_CASE("strCmp", "") { + REQUIRE(0 < bx::strCmp("abvgd", "abv") ); + REQUIRE(0 < bx::strCmp("abvgd", "") ); + REQUIRE(0 > bx::strCmp("", "abvgd") ); + REQUIRE(0 != bx::strCmp(".tar.gz", ".") ); REQUIRE(0 != bx::strCmp("meh", "meh/") ); } @@ -184,6 +188,7 @@ TEST_CASE("strRFind", "") REQUIRE(bx::strRFind(bx::StringView(test, 0), 's').isEmpty() ); REQUIRE(bx::strRFind(bx::StringView(test, 1), 's').isEmpty() ); REQUIRE(&test[2] == bx::strRFind(test, 's').getPtr() ); + REQUIRE(&test[3] == bx::strRFind(test, 't').getPtr() ); } TEST_CASE("strFindI", "") diff --git a/3rdparty/bx/tests/test.h b/3rdparty/bx/tests/test.h index 43da95a56d2..b7654aba1e2 100644 --- a/3rdparty/bx/tests/test.h +++ b/3rdparty/bx/tests/test.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 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 80db9b5b969..a174e9f86d6 100644 --- a/3rdparty/bx/tests/thread_test.cpp +++ b/3rdparty/bx/tests/thread_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 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 e0910fef087..c453ddaf1d9 100644 --- a/3rdparty/bx/tests/tokenizecmd_test.cpp +++ b/3rdparty/bx/tests/tokenizecmd_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 Branimir Karadzic. All rights reserved. + * Copyright 2012-2019 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 bb7e0dccacd..b209219cd56 100644 --- a/3rdparty/bx/tests/uint32_test.cpp +++ b/3rdparty/bx/tests/uint32_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -14,28 +14,57 @@ TEST_CASE("StrideAlign") REQUIRE(12 == bx::strideAlign(ii+1, 12) ); } - REQUIRE(0 == bx::strideAlign16(0, 12) ); + REQUIRE(0 == bx::strideAlign<16>(0, 12) ); for (uint32_t ii = 0; ii < 12; ++ii) { - REQUIRE(48 == bx::strideAlign16(ii+1, 12) ); + REQUIRE(48 == bx::strideAlign<16>(ii+1, 12) ); } + + uint32_t offset = 11; + offset = bx::strideAlign(offset, 32); + REQUIRE(offset == 32); + + offset = bx::strideAlign(offset, 24); + REQUIRE(offset == 48); } TEST_CASE("uint32_cnt") { - REQUIRE( 0 == bx::uint32_cnttz(UINT32_C(1) ) ); - - REQUIRE(31 == bx::uint32_cntlz(UINT32_C(1) ) ); - - REQUIRE( 0 == bx::uint64_cnttz(UINT64_C(1) ) ); - - REQUIRE(63 == bx::uint64_cntlz(UINT64_C(1) ) ); - + REQUIRE( 0 == bx::uint32_cnttz<uint8_t >(1) ); + REQUIRE( 7 == bx::uint32_cnttz<uint8_t >(1<<7) ); + REQUIRE( 8 == bx::uint32_cnttz<uint8_t >(0) ); + REQUIRE( 1 == bx::uint32_cnttz<uint8_t >(0x3e) ); + REQUIRE( 0 == bx::uint32_cnttz<uint16_t>(1) ); + REQUIRE(15 == bx::uint32_cnttz<uint16_t>(1<<15) ); + REQUIRE(16 == bx::uint32_cnttz<uint16_t>(0) ); + REQUIRE( 0 == bx::uint32_cnttz<uint32_t>(1) ); + REQUIRE(32 == bx::uint32_cnttz<uint32_t>(0) ); + REQUIRE(31 == bx::uint32_cnttz<uint32_t>(1<<31) ); + REQUIRE( 0 == bx::uint32_cnttz<uint64_t>(1) ); + REQUIRE(64 == bx::uint32_cnttz<uint64_t>(0) ); + + REQUIRE( 7 == bx::uint32_cntlz<uint8_t >(1) ); + REQUIRE( 8 == bx::uint32_cntlz<uint8_t >(0) ); + REQUIRE( 2 == bx::uint32_cntlz<uint8_t >(0x3e) ); + REQUIRE(15 == bx::uint32_cntlz<uint16_t>(1) ); + REQUIRE(16 == bx::uint32_cntlz<uint16_t>(0) ); + REQUIRE(31 == bx::uint32_cntlz<uint32_t>(1) ); + REQUIRE(32 == bx::uint32_cntlz<uint32_t>(0) ); + REQUIRE(63 == bx::uint32_cntlz<uint64_t>(1) ); + REQUIRE(64 == bx::uint32_cntlz<uint64_t>(0) ); + + REQUIRE( 0 == bx::uint32_cntbits(0) ); REQUIRE( 1 == bx::uint32_cntbits(1) ); - REQUIRE(16 == bx::uint32_cntbits(UINT16_MAX) ); + REQUIRE( 4 == bx::uint32_cntbits<uint8_t>(0x55) ); + REQUIRE( 8 == bx::uint32_cntbits<uint16_t>(0x5555) ); + REQUIRE(16 == bx::uint32_cntbits<uint32_t>(0x55555555) ); + REQUIRE(32 == bx::uint32_cntbits<uint64_t>(0x5555555555555555) ); + REQUIRE( 8 == bx::uint32_cntbits(UINT8_MAX) ); + REQUIRE(16 == bx::uint32_cntbits(UINT16_MAX) ); REQUIRE(32 == bx::uint32_cntbits(UINT32_MAX) ); + REQUIRE(64 == bx::uint32_cntbits(UINT64_MAX) ); } TEST_CASE("uint32_part") diff --git a/3rdparty/bx/tests/url_test.cpp b/3rdparty/bx/tests/url_test.cpp index 50d2c3924d5..b43488c157e 100644 --- a/3rdparty/bx/tests/url_test.cpp +++ b/3rdparty/bx/tests/url_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ diff --git a/3rdparty/bx/tests/vsnprintf_test.cpp b/3rdparty/bx/tests/vsnprintf_test.cpp index 844f6363ce2..50bf5449ff7 100644 --- a/3rdparty/bx/tests/vsnprintf_test.cpp +++ b/3rdparty/bx/tests/vsnprintf_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. + * Copyright 2010-2019 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ |