diff --git a/thirdparty/README.md b/thirdparty/README.md index 916fb2e0a7..e3d4af737b 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -720,7 +720,7 @@ Update instructions: ## meshoptimizer - Upstream: https://github.com/zeux/meshoptimizer -- Version: 1.1 (dc9d09ed83e1004aef47a1c3c597e0ec64848a37, 2026) +- Version: 1.1.1 (b22872835dbabc56a6e4a366ea9917f62b7daf1a, 2026) - License: MIT Files extracted from upstream repository: diff --git a/thirdparty/meshoptimizer/allocator.cpp b/thirdparty/meshoptimizer/allocator.cpp index 6b6083da28..058fbf3129 100644 --- a/thirdparty/meshoptimizer/allocator.cpp +++ b/thirdparty/meshoptimizer/allocator.cpp @@ -1,6 +1,8 @@ // This file is part of meshoptimizer library; see meshoptimizer.h for version/license details #include "meshoptimizer.h" +#include + #ifdef MESHOPTIMIZER_ALLOC_EXPORT meshopt_Allocator::Storage& meshopt_Allocator::storage() { @@ -11,6 +13,8 @@ meshopt_Allocator::Storage& meshopt_Allocator::storage() void meshopt_setAllocator(void* (MESHOPTIMIZER_ALLOC_CALLCONV* allocate)(size_t), void (MESHOPTIMIZER_ALLOC_CALLCONV* deallocate)(void*)) { + assert(allocate && deallocate); + meshopt_Allocator::Storage& s = meshopt_Allocator::storage(); s.allocate = allocate; s.deallocate = deallocate; diff --git a/thirdparty/meshoptimizer/meshletutils.cpp b/thirdparty/meshoptimizer/meshletutils.cpp index e91969e58c..b92332adda 100644 --- a/thirdparty/meshoptimizer/meshletutils.cpp +++ b/thirdparty/meshoptimizer/meshletutils.cpp @@ -491,7 +491,7 @@ void meshopt_optimizeMeshletLevel(unsigned int* meshlet_vertices, size_t vertex_ // if subsequent triangles don't share edges ca or bc, we can rotate the triangle to fix this bool needab = false, needbc = false, needca = false; - for (size_t j = i + 1; j < triangle_count && j <= i + 3; ++j) + for (size_t j = i + 1; j < triangle_count && j <= i + cache_cutoff; ++j) { unsigned char oa = indices[j * 3 + 0], ob = indices[j * 3 + 1], oc = indices[j * 3 + 2]; @@ -513,6 +513,12 @@ void meshopt_optimizeMeshletLevel(unsigned int* meshlet_vertices, size_t vertex_ unsigned char t = c; c = b, b = a, a = t; } + else if (!needab && needbc && !needca) + { + // abc -> cab: put bc at most recent FIFO position + unsigned char t = c; + c = b, b = a, a = t; + } } indices[i * 3 + 0] = a, indices[i * 3 + 1] = b, indices[i * 3 + 2] = c; diff --git a/thirdparty/meshoptimizer/meshoptimizer.h b/thirdparty/meshoptimizer/meshoptimizer.h index 7d951192b8..da6acf06e1 100644 --- a/thirdparty/meshoptimizer/meshoptimizer.h +++ b/thirdparty/meshoptimizer/meshoptimizer.h @@ -1215,7 +1215,7 @@ template inline void meshopt_remapIndexBuffer(T* destination, const T* indices, size_t index_count, const unsigned int* remap) { meshopt_IndexAdapter in(NULL, indices, indices ? index_count : 0); - meshopt_IndexAdapter out(destination, 0, index_count); + meshopt_IndexAdapter out(destination, NULL, index_count); meshopt_remapIndexBuffer(out.data, indices ? in.data : NULL, index_count, remap); } @@ -1263,7 +1263,7 @@ inline size_t meshopt_generateProvokingIndexBuffer(T* destination, unsigned int* meshopt_IndexAdapter out(destination, NULL, index_count); size_t bound = vertex_count + (index_count / 3); - assert(size_t(T(bound - 1)) == bound - 1); // bound - 1 must fit in T + assert(bound == 0 || size_t(T(bound - 1)) == bound - 1); // bound - 1 must fit in T (void)bound; return meshopt_generateProvokingIndexBuffer(out.data, reorder, in.data, index_count, vertex_count); @@ -1435,7 +1435,7 @@ template inline size_t meshopt_unstripify(T* destination, const T* indices, size_t index_count, T restart_index) { meshopt_IndexAdapter in(NULL, indices, index_count); - meshopt_IndexAdapter out(destination, NULL, (index_count - 2) * 3); + meshopt_IndexAdapter out(destination, NULL, index_count == 0 ? 0 : (index_count - 2) * 3); return meshopt_unstripify(out.data, in.data, index_count, unsigned(restart_index)); } diff --git a/thirdparty/meshoptimizer/rasterizer.cpp b/thirdparty/meshoptimizer/rasterizer.cpp index bd788ffdb5..0e640bc028 100644 --- a/thirdparty/meshoptimizer/rasterizer.cpp +++ b/thirdparty/meshoptimizer/rasterizer.cpp @@ -172,7 +172,7 @@ static float transformTriangles(float* triangles, const unsigned int* indices, s extent = (maxv[1] - minv[1]) < extent ? extent : (maxv[1] - minv[1]); extent = (maxv[2] - minv[2]) < extent ? extent : (maxv[2] - minv[2]); - float scale = kViewport / extent; + float scale = extent == 0.f ? 0.f : kViewport / extent; for (size_t i = 0; i < index_count; ++i) { diff --git a/thirdparty/meshoptimizer/vertexcodec.cpp b/thirdparty/meshoptimizer/vertexcodec.cpp index 545ca90708..dabf985487 100644 --- a/thirdparty/meshoptimizer/vertexcodec.cpp +++ b/thirdparty/meshoptimizer/vertexcodec.cpp @@ -1416,7 +1416,7 @@ inline v128_t unzigzag16(v128_t v) SIMD_TARGET inline v128_t rotate32(v128_t v, int r) { - return wasm_v128_or(wasm_i32x4_shl(v, r), wasm_i32x4_shr(v, 32 - r)); + return wasm_v128_or(wasm_i32x4_shl(v, r), wasm_u32x4_shr(v, 32 - r)); } #endif