From 0837e7451a84f95c29dbdb9bd6b8b931fee1635d Mon Sep 17 00:00:00 2001 From: Julian Sikorski Date: Sun, 13 Oct 2019 13:50:38 +0200 Subject: 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 --- 3rdparty/bx/src/string.cpp | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to '3rdparty/bx/src/string.cpp') diff --git a/3rdparty/bx/src/string.cpp b/3rdparty/bx/src/string.cpp index 7710028ae6d..678af6664ce 100644 --- a/3rdparty/bx/src/string.cpp +++ b/3rdparty/bx/src/string.cpp @@ -1,12 +1,12 @@ /* - * 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 "bx_p.h" #include +#include #include -#include #include namespace bx @@ -188,7 +188,12 @@ namespace bx } } - return 0 == max && _lhsMax == _rhsMax ? 0 : fn(*_lhs) - fn(*_rhs); + if (0 == max) + { + return _lhsMax == _rhsMax ? 0 : _lhsMax > _rhsMax ? 1 : -1; + } + + return fn(*_lhs) - fn(*_rhs); } int32_t strCmp(const StringView& _lhs, const StringView& _rhs, int32_t _max) @@ -370,7 +375,7 @@ namespace bx inline const char* strRFindUnsafe(const char* _str, int32_t _len, char _ch) { - for (int32_t ii = _len; 0 <= ii; --ii) + for (int32_t ii = _len-1; 0 <= ii; --ii) { if (_str[ii] == _ch) { @@ -687,9 +692,10 @@ namespace bx return StringView(_str.getTerm(), _str.getTerm() ); } - StringView findIdentifierMatch(const StringView& _str, const char** _words) + StringView findIdentifierMatch(const StringView& _str, const char** _words, int32_t _num) { - for (StringView word = *_words; !word.isEmpty(); ++_words, word = *_words) + int32_t ii = 0; + for (StringView word = *_words; ii < _num && !word.isEmpty(); ++ii, ++_words, word = *_words) { StringView match = findIdentifierMatch(_str, word); if (!match.isEmpty() ) @@ -1147,10 +1153,10 @@ namespace bx SizerWriter sizer; va_list argListCopy; va_copy(argListCopy, _argList); - int32_t size = write(&sizer, _format, argListCopy, &err); + int32_t total = write(&sizer, _format, argListCopy, &err); va_end(argListCopy); - return size; + return total; } int32_t snprintf(char* _out, int32_t _max, const char* _format, ...) @@ -1159,6 +1165,28 @@ namespace bx va_start(argList, _format); int32_t total = vsnprintf(_out, _max, _format, argList); va_end(argList); + + return total; + } + + int32_t vprintf(const char* _format, va_list _argList) + { + Error err; + va_list argListCopy; + va_copy(argListCopy, _argList); + int32_t total = write(getStdOut(), _format, argListCopy, &err); + va_end(argListCopy); + + return total; + } + + int32_t printf(const char* _format, ...) + { + va_list argList; + va_start(argList, _format); + int32_t total = vprintf(_format, argList); + va_end(argList); + return total; } -- cgit v1.2.3-70-g09d2