From b343d0f7309914a335dc1a6ce26f983637f8f045 Mon Sep 17 00:00:00 2001 From: Steve M Date: Mon, 22 Apr 2024 13:15:14 -0700 Subject: [PATCH] Fix failing build on armeabi-v7a via android NDK --- contrib/tinyusdz/README.md | 36 +++++++++++++++++++ .../src/external/stb_image_resize2.h | 32 +++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/contrib/tinyusdz/README.md b/contrib/tinyusdz/README.md index 60cfe9f40..0c5a7d226 100644 --- a/contrib/tinyusdz/README.md +++ b/contrib/tinyusdz/README.md @@ -1,5 +1,41 @@ # tinyusdz +## MODIFICATIONS REQUIRED + +### Need to patch `contrib/tinyusdz/tinyusdz_repo/src/external/stb_image_resize2.h` to allow build on +armeabi-v7a via android NDK + +Add `#elif` block as indicated below around line `2407` +``` +#elif defined(STBIR_WASM) || (defined(STBIR_NEON) && defined(_MSC_VER) && defined(_M_ARM)) // WASM or 32-bit ARM on MSVC/clang +... +#elif defined(STBIR_NEON) && (defined(__ANDROID__) && defined(__arm__)) // 32-bit ARM on android NDK + + static stbir__inline void stbir__half_to_float_SIMD(float * output, stbir__FP16 const * input) + { + // TODO: this stub is just to allow build on armeabi-v7a via android NDK + } + + static stbir__inline void stbir__float_to_half_SIMD(stbir__FP16 * output, float const * input) + { + // TODO: this stub is just to allow build on armeabi-v7a via android NDK + } + + static stbir__inline float stbir__half_to_float( stbir__FP16 h ) + { + // TODO: this stub is just to allow build on armeabi-v7a via android NDK + return 0; + } + + static stbir__inline stbir__FP16 stbir__float_to_half( float f ) + { + // TODO: this stub is just to allow build on armeabi-v7a via android NDK + return 0; + } + +#elif defined(STBIR_NEON) && defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__) // 64-bit ARM on MSVC (not clang) +``` + ## Notes Couldn't leverage tinyusdz CMakeLists.txt. Fell back to compiling source files specified in "android" example. diff --git a/contrib/tinyusdz/tinyusdz_repo/src/external/stb_image_resize2.h b/contrib/tinyusdz/tinyusdz_repo/src/external/stb_image_resize2.h index 1cd379a72..c2f767a3a 100644 --- a/contrib/tinyusdz/tinyusdz_repo/src/external/stb_image_resize2.h +++ b/contrib/tinyusdz/tinyusdz_repo/src/external/stb_image_resize2.h @@ -2404,6 +2404,38 @@ static stbir__inline stbir_uint8 stbir__linear_to_srgb_uchar(float in) } } +#elif defined(STBIR_NEON) && (defined(__ANDROID__) && defined(__arm__)) // 32-bit ARM on android NDK + + // TODO As of Apr 2024, tinyusdz doesn't support building on armeabi-v7a (32 bit arm) for android + // (falls through to arm64 block and build fails) + // + // For assimp integration, the image processing utilities aren't used at all, so it's safe to + // essentially replace the functions with dummy no-ops. + // + // This will need to be done manually whenever the tinyusdz source files are updated in assimp, + // as it seems unlikely this will be fixed in the tinyusdz project + static stbir__inline void stbir__half_to_float_SIMD(float * output, stbir__FP16 const * input) + { + // TODO: this stub is just to allow build on armeabi-v7a via android NDK + } + + static stbir__inline void stbir__float_to_half_SIMD(stbir__FP16 * output, float const * input) + { + // TODO: this stub is just to allow build on armeabi-v7a via android NDK + } + + static stbir__inline float stbir__half_to_float( stbir__FP16 h ) + { + // TODO: this stub is just to allow build on armeabi-v7a via android NDK + return 0; + } + + static stbir__inline stbir__FP16 stbir__float_to_half( float f ) + { + // TODO: this stub is just to allow build on armeabi-v7a via android NDK + return 0; + } + #elif defined(STBIR_NEON) && defined(_MSC_VER) && defined(_M_ARM64) && !defined(__clang__) // 64-bit ARM on MSVC (not clang) static stbir__inline void stbir__half_to_float_SIMD(float * output, stbir__FP16 const * input)