diff options
Diffstat (limited to '3rdparty/bgfx/tools')
-rw-r--r-- | 3rdparty/bgfx/tools/geometryc/geometryc.cpp | 32 | ||||
-rw-r--r-- | 3rdparty/bgfx/tools/shaderc/shaderc.h | 2 | ||||
-rw-r--r-- | 3rdparty/bgfx/tools/texturec/texturec.cpp | 8 |
3 files changed, 37 insertions, 5 deletions
diff --git a/3rdparty/bgfx/tools/geometryc/geometryc.cpp b/3rdparty/bgfx/tools/geometryc/geometryc.cpp index 7687f3c5e38..fe4de46ada8 100644 --- a/3rdparty/bgfx/tools/geometryc/geometryc.cpp +++ b/3rdparty/bgfx/tools/geometryc/geometryc.cpp @@ -58,11 +58,11 @@ namespace stl = tinystl; #include <bx/debug.h> #include <bx/commandline.h> #include <bx/timer.h> -#include <bx/readerwriter.h> #include <bx/hash.h> #include <bx/uint32_t.h> #include <bx/fpumath.h> #include <bx/tokenizecmd.h> +#include <bx/crtimpl.h> #include "bounds.h" @@ -81,6 +81,7 @@ struct Index3 int32_t m_texcoord; int32_t m_normal; int32_t m_vertexIndex; + int32_t m_vbc; // Barycentric ID. Holds eigher 0, 1 or 2. }; typedef stl::unordered_map<uint64_t, Index3> Index3Map; @@ -387,6 +388,7 @@ void help(const char* _error = NULL) " 0 - unpacked 8 bytes (default).\n" " 1 - packed 4 bytes.\n" " --tangent Calculate tangent vectors (packing mode is the same as normal).\n" + " --barycentric Adds barycentric vertex attribute (packed in bgfx::Attrib::Color1).\n" " -c, --compress Compress indices.\n" "\n" @@ -450,6 +452,7 @@ int main(int _argc, const char* _argv[]) bool ccw = cmdLine.hasArg("ccw"); bool flipV = cmdLine.hasArg("flipv"); bool hasTangent = cmdLine.hasArg("tangent"); + bool hasBc = cmdLine.hasArg("barycentric"); FILE* file = fopen(filePath, "r"); if (NULL == file) @@ -513,6 +516,14 @@ int main(int _argc, const char* _argv[]) index.m_texcoord = -1; index.m_normal = -1; index.m_vertexIndex = -1; + if (hasBc) + { + index.m_vbc = edge < 3 ? edge : (1+(edge+1) )&1; + } + else + { + index.m_vbc = 0; + } char* vertex = argv[edge+1]; char* texcoord = strchr(vertex, '/'); @@ -542,7 +553,8 @@ int main(int _argc, const char* _argv[]) uint64_t hash0 = index.m_position; uint64_t hash1 = uint64_t(index.m_texcoord)<<20; uint64_t hash2 = uint64_t(index.m_normal)<<40; - uint64_t hash = hash0^hash1^hash2; + uint64_t hash3 = uint64_t(index.m_vbc)<<60; + uint64_t hash = hash0^hash1^hash2^hash3; stl::pair<Index3Map::iterator, bool> result = indexMap.insert(stl::make_pair(hash, index) ); if (!result.second) @@ -755,6 +767,11 @@ int main(int _argc, const char* _argv[]) decl.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true); } + if (hasBc) + { + decl.add(bgfx::Attrib::Color1, 4, bgfx::AttribType::Uint8, true); + } + if (hasTexcoord) { switch (packUv) @@ -914,6 +931,17 @@ int main(int _argc, const char* _argv[]) *color0 = rgbaToAbgr(numVertices%255, numIndices%255, 0, 0xff); } + if (hasBc) + { + const float bc[3] = + { + (index.m_vbc == 0) ? 1.0f : 0.0f, + (index.m_vbc == 1) ? 1.0f : 0.0f, + (index.m_vbc == 2) ? 1.0f : 0.0f, + }; + bgfx::vertexPack(bc, true, bgfx::Attrib::Color1, decl, vertices); + } + if (hasTexcoord) { float uv[2]; diff --git a/3rdparty/bgfx/tools/shaderc/shaderc.h b/3rdparty/bgfx/tools/shaderc/shaderc.h index 29bf450e474..47bae98c3aa 100644 --- a/3rdparty/bgfx/tools/shaderc/shaderc.h +++ b/3rdparty/bgfx/tools/shaderc/shaderc.h @@ -59,9 +59,9 @@ namespace bgfx #include <bx/commandline.h> #include <bx/endian.h> #include <bx/uint32_t.h> -#include <bx/readerwriter.h> #include <bx/string.h> #include <bx/hash.h> +#include <bx/crtimpl.h> #include "../../src/vertexdecl.h" namespace bgfx diff --git a/3rdparty/bgfx/tools/texturec/texturec.cpp b/3rdparty/bgfx/tools/texturec/texturec.cpp index 81bccfeb6f6..35983dc9849 100644 --- a/3rdparty/bgfx/tools/texturec/texturec.cpp +++ b/3rdparty/bgfx/tools/texturec/texturec.cpp @@ -27,8 +27,8 @@ #endif // DEBUG #include <bx/bx.h> -#include <bx/allocator.h> #include <bx/commandline.h> +#include <bx/crtimpl.h> #include <bx/uint32_t.h> namespace bgfx @@ -117,7 +117,7 @@ namespace bgfx case TextureFormat::PTC14: { using namespace Javelin; - RgbBitmap bmp; + RgbaBitmap bmp; bmp.width = _width; bmp.height = _height; bmp.data = (uint8_t*)const_cast<void*>(_src); @@ -511,6 +511,8 @@ int main(int _argc, const char* _argv[]) { imageRgba32fDownsample2x2NormalMap(mip.m_width, mip.m_height, mip.m_width*16, rgba, rgba); imageRgba32f11to01(rgbaDst, mip.m_width, mip.m_height, mip.m_width*16, rgba); + mip.m_width = bx::uint32_max(1, mip.m_width >> 1); + mip.m_height = bx::uint32_max(1, mip.m_height >> 1); ImageMip dstMip; imageGetRawData(imageContainer, 0, lod, output->data, output->size, dstMip); @@ -541,6 +543,8 @@ int main(int _argc, const char* _argv[]) for (uint8_t lod = 1; lod < numMips; ++lod) { imageRgba8Downsample2x2(mip.m_width, mip.m_height, mip.m_width*4, rgba, rgba); + mip.m_width = bx::uint32_max(1, mip.m_width >> 1); + mip.m_height = bx::uint32_max(1, mip.m_height >> 1); ImageMip dstMip; imageGetRawData(imageContainer, 0, lod, output->data, output->size, dstMip); |