diff options
Diffstat (limited to 'thirdparty')
-rw-r--r-- | thirdparty/README.md | 8 | ||||
-rw-r--r-- | thirdparty/squish/Add-Decompress-Bc5-to-Squish.patch | 143 | ||||
-rw-r--r-- | thirdparty/squish/colourblock.cpp | 85 | ||||
-rw-r--r-- | thirdparty/squish/colourblock.h | 3 | ||||
-rw-r--r-- | thirdparty/squish/squish.cpp | 8 | ||||
-rw-r--r-- | thirdparty/thekla_atlas/nvcore/Debug.cpp | 9 | ||||
-rw-r--r-- | thirdparty/thekla_atlas/nvmath/ftoi.h | 5 | ||||
-rw-r--r-- | thirdparty/thekla_atlas/nvmath/nvmath.h | 17 | ||||
-rw-r--r-- | thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp | 30 | ||||
-rw-r--r-- | thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h | 4 | ||||
-rw-r--r-- | thirdparty/thekla_atlas/thekla/thekla_atlas.cpp | 23 |
11 files changed, 315 insertions, 20 deletions
diff --git a/thirdparty/README.md b/thirdparty/README.md index 8c50081782..62690e21c7 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -365,6 +365,7 @@ Files extracted from upstream source: - celt/ and silk/ subfolders - COPYING + ## pcre2 - Upstream: http://www.pcre.org/ @@ -378,6 +379,7 @@ Files extracted from upstream source: - src/pcre2_jit_*.c and src/sljit/* - AUTHORS and COPYING + ## pvrtccompressor - Upstream: https://bitbucket.org/jthlim/pvrtccompressor @@ -389,12 +391,14 @@ Files extracted from upstream source: - all .cpp and .h files apart from `main.cpp` - LICENSE.TXT + ## recastnavigation - Upstream: https://github.com/recastnavigation/recastnavigation - version: git commit ef3ea40f - 2016-02-06 - License: zlib + ## rtaudio - Upstream: http://www.music.mcgill.ca/~gary/rtaudio/ @@ -416,6 +420,10 @@ Files extracted from upstream source: - all .cpp, .h and .inl files +Important: Some files have Godot-made changes. +They are marked with `// -- GODOT start --` and `// -- GODOT end --` +comments and a patch is provided in the squish/ folder. + ## tinyexr diff --git a/thirdparty/squish/Add-Decompress-Bc5-to-Squish.patch b/thirdparty/squish/Add-Decompress-Bc5-to-Squish.patch new file mode 100644 index 0000000000..1e06a8d318 --- /dev/null +++ b/thirdparty/squish/Add-Decompress-Bc5-to-Squish.patch @@ -0,0 +1,143 @@ +From 7b64cc4c8b0be0443741483bf65909f5140179c0 Mon Sep 17 00:00:00 2001 +From: Orkun <orkuntezerm@gmail.com> +Date: Sun, 19 Nov 2017 02:24:31 +0300 +Subject: [PATCH] Fix #12220: Add Decompress Bc5 to Squish + +This Commit fixes the corrupted file preview described in #12220. +Added DecompressColourBc5 function to squish. +--- + thirdparty/squish/colourblock.cpp | 85 +++++++++++++++++++++++++++++++++++++++ + thirdparty/squish/colourblock.h | 3 ++ + thirdparty/squish/squish.cpp | 8 +++- + 3 files changed, 95 insertions(+), 1 deletion(-) + +diff --git a/thirdparty/squish/colourblock.cpp b/thirdparty/squish/colourblock.cpp +index af8b98036..3de46382c 100644 +--- a/thirdparty/squish/colourblock.cpp ++++ b/thirdparty/squish/colourblock.cpp +@@ -211,4 +211,89 @@ void DecompressColour( u8* rgba, void const* block, bool isDxt1 ) + } + } + ++// -- Godot start -- ++void DecompressColourBc5( u8* rgba, void const* block) ++{ ++ // get the block bytes ++ u8 const* bytes = reinterpret_cast< u8 const* >( block ); ++ ++ // unpack the endpoints ++ u8 codes[16]; ++ int red_0 = bytes[0]; ++ int red_1 = bytes[1]; ++ ++ codes[0] = red_0; ++ codes[1] = red_1; ++ codes[6] = 0.0f; ++ codes[7] = 1.0f; ++ // generate the midpoints ++ if(red_0 > red_1) ++ { ++ for( int i = 2; i < 8; ++i ) ++ { ++ codes[i] = ((8-i)*red_0 + (i-1)*red_1)/7; ++ } ++ } ++ else ++ { ++ for( int i = 2; i < 6; ++i ) ++ { ++ codes[i] = ((6-i)*red_0 + (i-1)*red_1)/5; ++ } ++ } ++ ++ int green_0 = bytes[8]; ++ int green_1 = bytes[9]; ++ ++ codes[0 + 8] = green_0; ++ codes[1 + 8] = green_1; ++ codes[6 + 8] = 0.0f; ++ codes[7 + 8] = 1.0f; ++ // generate the midpoints ++ if(green_0 > green_1) ++ { ++ for( int i = 2; i < 8; ++i ) ++ { ++ codes[i + 8] = ((8-i)*green_0 + (i-1)*green_1)/7; ++ } ++ } ++ else ++ { ++ for( int i = 2; i < 6; ++i ) ++ { ++ codes[i + 8] = ((6-i)*green_0 + (i-1)*green_1)/5; ++ } ++ } ++ ++ u8 indices[32]; ++ for( int i = 0; i < 4; ++i ) ++ { ++ u8 packed = bytes[2 + i]; ++ u8* red_ind = indices + 4*i; ++ ++ red_ind[0] = packed & 0x3; ++ red_ind[1] = ( packed >> 2 ) & 0x3; ++ red_ind[2] = ( packed >> 4 ) & 0x3; ++ red_ind[3] = ( packed >> 6 ) & 0x3; ++ ++ packed = bytes[8 + i]; ++ u8* green_ind = indices + 4*i + 16; ++ green_ind[0] = packed & 0x3; ++ green_ind[1] = ( packed >> 2 ) & 0x3; ++ green_ind[2] = ( packed >> 4 ) & 0x3; ++ green_ind[3] = ( packed >> 6 ) & 0x3; ++ } ++ ++ // store out the colours ++ for( int i = 0; i < 16; ++i ) ++ { ++ rgba[4*i] = codes[indices[i]]; ++ rgba[4*i +1] = codes[indices[i + 16] + 8]; ++ rgba[4*i +2] = 0; ++ rgba[4*i +3] = 255; ++ } ++} ++// -- GODOT end -- ++ ++ + } // namespace squish +diff --git a/thirdparty/squish/colourblock.h b/thirdparty/squish/colourblock.h +index fee2cd7c5..3cb9b7e3b 100644 +--- a/thirdparty/squish/colourblock.h ++++ b/thirdparty/squish/colourblock.h +@@ -35,6 +35,9 @@ void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* + void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); + + void DecompressColour( u8* rgba, void const* block, bool isDxt1 ); ++// -- GODOT start -- ++void DecompressColourBc5( u8* rgba, void const* block ); ++// -- GODOT end -- + + } // namespace squish + +diff --git a/thirdparty/squish/squish.cpp b/thirdparty/squish/squish.cpp +index 1d22a64ad..fd11a147d 100644 +--- a/thirdparty/squish/squish.cpp ++++ b/thirdparty/squish/squish.cpp +@@ -135,7 +135,13 @@ void Decompress( u8* rgba, void const* block, int flags ) + colourBlock = reinterpret_cast< u8 const* >( block ) + 8; + + // decompress colour +- DecompressColour( rgba, colourBlock, ( flags & kDxt1 ) != 0 ); ++ // -- GODOT start -- ++ //DecompressColour( rgba, colourBlock, ( flags & kDxt1 ) != 0 ); ++ if(( flags & ( kBc5 ) ) != 0) ++ DecompressColourBc5( rgba, colourBlock); ++ else ++ DecompressColour( rgba, colourBlock, ( flags & kDxt1 ) != 0 ); ++ // -- GODOT end -- + + // decompress alpha separately if necessary + if( ( flags & kDxt3 ) != 0 ) +-- +2.13.6 + diff --git a/thirdparty/squish/colourblock.cpp b/thirdparty/squish/colourblock.cpp index af8b980365..3de46382c0 100644 --- a/thirdparty/squish/colourblock.cpp +++ b/thirdparty/squish/colourblock.cpp @@ -211,4 +211,89 @@ void DecompressColour( u8* rgba, void const* block, bool isDxt1 ) } } +// -- Godot start -- +void DecompressColourBc5( u8* rgba, void const* block) +{ + // get the block bytes + u8 const* bytes = reinterpret_cast< u8 const* >( block ); + + // unpack the endpoints + u8 codes[16]; + int red_0 = bytes[0]; + int red_1 = bytes[1]; + + codes[0] = red_0; + codes[1] = red_1; + codes[6] = 0.0f; + codes[7] = 1.0f; + // generate the midpoints + if(red_0 > red_1) + { + for( int i = 2; i < 8; ++i ) + { + codes[i] = ((8-i)*red_0 + (i-1)*red_1)/7; + } + } + else + { + for( int i = 2; i < 6; ++i ) + { + codes[i] = ((6-i)*red_0 + (i-1)*red_1)/5; + } + } + + int green_0 = bytes[8]; + int green_1 = bytes[9]; + + codes[0 + 8] = green_0; + codes[1 + 8] = green_1; + codes[6 + 8] = 0.0f; + codes[7 + 8] = 1.0f; + // generate the midpoints + if(green_0 > green_1) + { + for( int i = 2; i < 8; ++i ) + { + codes[i + 8] = ((8-i)*green_0 + (i-1)*green_1)/7; + } + } + else + { + for( int i = 2; i < 6; ++i ) + { + codes[i + 8] = ((6-i)*green_0 + (i-1)*green_1)/5; + } + } + + u8 indices[32]; + for( int i = 0; i < 4; ++i ) + { + u8 packed = bytes[2 + i]; + u8* red_ind = indices + 4*i; + + red_ind[0] = packed & 0x3; + red_ind[1] = ( packed >> 2 ) & 0x3; + red_ind[2] = ( packed >> 4 ) & 0x3; + red_ind[3] = ( packed >> 6 ) & 0x3; + + packed = bytes[8 + i]; + u8* green_ind = indices + 4*i + 16; + green_ind[0] = packed & 0x3; + green_ind[1] = ( packed >> 2 ) & 0x3; + green_ind[2] = ( packed >> 4 ) & 0x3; + green_ind[3] = ( packed >> 6 ) & 0x3; + } + + // store out the colours + for( int i = 0; i < 16; ++i ) + { + rgba[4*i] = codes[indices[i]]; + rgba[4*i +1] = codes[indices[i + 16] + 8]; + rgba[4*i +2] = 0; + rgba[4*i +3] = 255; + } +} +// -- GODOT end -- + + } // namespace squish diff --git a/thirdparty/squish/colourblock.h b/thirdparty/squish/colourblock.h index fee2cd7c5d..3cb9b7e3b9 100644 --- a/thirdparty/squish/colourblock.h +++ b/thirdparty/squish/colourblock.h @@ -35,6 +35,9 @@ void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); void DecompressColour( u8* rgba, void const* block, bool isDxt1 ); +// -- GODOT start -- +void DecompressColourBc5( u8* rgba, void const* block ); +// -- GODOT end -- } // namespace squish diff --git a/thirdparty/squish/squish.cpp b/thirdparty/squish/squish.cpp index 1d22a64ad6..fd11a147de 100644 --- a/thirdparty/squish/squish.cpp +++ b/thirdparty/squish/squish.cpp @@ -135,7 +135,13 @@ void Decompress( u8* rgba, void const* block, int flags ) colourBlock = reinterpret_cast< u8 const* >( block ) + 8; // decompress colour - DecompressColour( rgba, colourBlock, ( flags & kDxt1 ) != 0 ); + // -- GODOT start -- + //DecompressColour( rgba, colourBlock, ( flags & kDxt1 ) != 0 ); + if(( flags & ( kBc5 ) ) != 0) + DecompressColourBc5( rgba, colourBlock); + else + DecompressColour( rgba, colourBlock, ( flags & kDxt1 ) != 0 ); + // -- GODOT end -- // decompress alpha separately if necessary if( ( flags & kDxt3 ) != 0 ) diff --git a/thirdparty/thekla_atlas/nvcore/Debug.cpp b/thirdparty/thekla_atlas/nvcore/Debug.cpp index 81498c219e..4980ffa916 100644 --- a/thirdparty/thekla_atlas/nvcore/Debug.cpp +++ b/thirdparty/thekla_atlas/nvcore/Debug.cpp @@ -394,8 +394,10 @@ namespace #pragma warning(disable:4748) static NV_NOINLINE int backtrace(void * trace[], int maxcount) { CONTEXT ctx = { 0 }; +// -- GODOT start -- #if NV_CPU_X86 && !NV_CPU_X86_64 ctx.ContextFlags = CONTEXT_CONTROL; +#if NV_CC_MSVC _asm { call x x: pop eax @@ -404,6 +406,13 @@ namespace mov ctx.Esp, esp } #else + register long unsigned int ebp asm("ebp"); + ctx.Eip = (DWORD) __builtin_return_address(0); + ctx.Ebp = ebp; + ctx.Esp = (DWORD) __builtin_frame_address(0); +#endif +// -- GODOT end -- +#else RtlCaptureContext(&ctx); // Not implemented correctly in x86. #endif diff --git a/thirdparty/thekla_atlas/nvmath/ftoi.h b/thirdparty/thekla_atlas/nvmath/ftoi.h index bee15c0908..182c56d1c3 100644 --- a/thirdparty/thekla_atlas/nvmath/ftoi.h +++ b/thirdparty/thekla_atlas/nvmath/ftoi.h @@ -53,7 +53,10 @@ namespace nv return (val<0) ? ftoi_ceil_xs(val) : ftoi_floor_xs(val); } -#if NV_CPU_X86 || NV_CPU_X86_64 +// -- GODOT start -- +//#if NV_CPU_X86 || NV_CPU_X86_64 +#if NV_USE_SSE +// -- GODOT end -- NV_FORCEINLINE int ftoi_round_sse(float f) { return _mm_cvt_ss2si(_mm_set_ss(f)); diff --git a/thirdparty/thekla_atlas/nvmath/nvmath.h b/thirdparty/thekla_atlas/nvmath/nvmath.h index 695f452c1d..f2b69426e1 100644 --- a/thirdparty/thekla_atlas/nvmath/nvmath.h +++ b/thirdparty/thekla_atlas/nvmath/nvmath.h @@ -14,10 +14,12 @@ #include <float.h> // finite, isnan #endif -#if NV_CPU_X86 || NV_CPU_X86_64 - //#include <intrin.h> - #include <xmmintrin.h> -#endif +// -- GODOT start -- +//#if NV_CPU_X86 || NV_CPU_X86_64 +// //#include <intrin.h> +// #include <xmmintrin.h> +//#endif +// -- GODOT end -- @@ -65,6 +67,13 @@ #endif +// -- GODOT start -- +#if NV_USE_SSE + //#include <intrin.h> + #include <xmmintrin.h> +#endif +// -- GODOT end -- + #ifndef PI #define PI float(3.1415926535897932384626433833) diff --git a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp index 5ce452cb9e..fd37b8c59c 100644 --- a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp +++ b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp @@ -142,9 +142,11 @@ AtlasPacker::AtlasPacker(Atlas * atlas) : m_atlas(atlas), m_bitmap(256, 256) { m_width = 0; m_height = 0; - - m_debug_bitmap.allocate(256, 256); - m_debug_bitmap.fill(Color32(0,0,0,0)); + + // -- GODOT start -- + //m_debug_bitmap.allocate(256, 256); + //m_debug_bitmap.fill(Color32(0,0,0,0)); + // -- GODOT end -- } AtlasPacker::~AtlasPacker() @@ -597,8 +599,10 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned m_bitmap.clearAll(); if (approximateExtent > m_bitmap.width()) { m_bitmap.resize(approximateExtent, approximateExtent, false); - m_debug_bitmap.resize(approximateExtent, approximateExtent); - m_debug_bitmap.fill(Color32(0,0,0,0)); + // -- GODOT start -- + //m_debug_bitmap.resize(approximateExtent, approximateExtent); + //m_debug_bitmap.fill(Color32(0,0,0,0)); + // -- GODOT end -- } @@ -680,20 +684,24 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned { //nvDebug("Resize bitmap (%d, %d).\n", nextPowerOfTwo(w), nextPowerOfTwo(h)); m_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h)), false); - m_debug_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h))); + // -- GODOT start -- + //m_debug_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h))); + // -- GODOT end -- } //nvDebug("Add chart at (%d, %d).\n", best_x, best_y); addChart(&chart_bitmap, w, h, best_x, best_y, best_r, /*debugOutput=*/NULL); + // -- GODOT start -- // IC: Output chart again to debug bitmap. - if (chart->isVertexMapped()) { + /*if (chart->isVertexMapped()) { addChart(&chart_bitmap, w, h, best_x, best_y, best_r, &m_debug_bitmap); } else { addChart(chart, w, h, best_x, best_y, best_r, &m_debug_bitmap); - } + }*/ + // -- GODOT end -- //float best_angle = 2 * PI * best_r; @@ -842,8 +850,10 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned nvCheck(isAligned(m_width, 4)); nvCheck(isAligned(m_height, 4)); - m_debug_bitmap.resize(m_width, m_height); - m_debug_bitmap.setFormat(Image::Format_ARGB); + // -- GODOT start -- + //m_debug_bitmap.resize(m_width, m_height); + //m_debug_bitmap.setFormat(Image::Format_ARGB); + // -- GODOT end -- #if DEBUG_OUTPUT //outputDebugBitmap("debug_packer_final.tga", m_bitmap, w, h); diff --git a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h index 2d305f38cd..845dbfb6f3 100644 --- a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h +++ b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h @@ -48,7 +48,9 @@ namespace nv Atlas * m_atlas; BitMap m_bitmap; - Image m_debug_bitmap; + // -- GODOT start -- + //Image m_debug_bitmap; + // -- GODOT end -- RadixSort m_radix; uint m_width; diff --git a/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp b/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp index d6f0accf54..de1953db8a 100644 --- a/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp +++ b/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp @@ -2,6 +2,9 @@ #include "thekla_atlas.h" #include <cfloat> +// -- GODOT start -- +#include <stdio.h> +// -- GODOT end -- #include "nvmesh/halfedge/Edge.h" #include "nvmesh/halfedge/Mesh.h" @@ -112,6 +115,8 @@ static Atlas_Output_Mesh * mesh_atlas_to_output(const HalfEdge::Mesh * mesh, con output->index_count = face_count * 3; output->index_array = new int[face_count * 3]; + // -- GODOT start -- + int face_ofs = 0; // Set face indices. for (int f = 0; f < face_count; f++) { uint c = charts->faceChartAt(f); @@ -121,14 +126,26 @@ static Atlas_Output_Mesh * mesh_atlas_to_output(const HalfEdge::Mesh * mesh, con const Chart * chart = charts->chartAt(c); nvDebugCheck(chart->faceAt(i) == f); + if (i >= chart->chartMesh()->faceCount()) { + printf("WARNING: Faces may be missing in the final vertex, which could not be packed\n"); + continue; + } + const HalfEdge::Face * face = chart->chartMesh()->faceAt(i); const HalfEdge::Edge * edge = face->edge; - output->index_array[3*f+0] = vertexOffset + edge->vertex->id; - output->index_array[3*f+1] = vertexOffset + edge->next->vertex->id; - output->index_array[3*f+2] = vertexOffset + edge->next->next->vertex->id; + //output->index_array[3*f+0] = vertexOffset + edge->vertex->id; + //output->index_array[3*f+1] = vertexOffset + edge->next->vertex->id; + //output->index_array[3*f+2] = vertexOffset + edge->next->next->vertex->id; + output->index_array[3 * face_ofs + 0] = vertexOffset + edge->vertex->id; + output->index_array[3 * face_ofs + 1] = vertexOffset + edge->next->vertex->id; + output->index_array[3 * face_ofs + 2] = vertexOffset + edge->next->next->vertex->id; + face_ofs++; } + output->index_count = face_ofs * 3; + // -- GODOT end -- + *error = Atlas_Error_Success; output->atlas_width = w; output->atlas_height = h; |