Skip to content

Commit

Permalink
Pull upstream ASTC for fixes building with GCC 11 for arm64, (#700)
Browse files Browse the repository at this point in the history
fixes for changes to floating point option defaults in MSVC >= 19.30 (VS2022) and addition of ASTC namespace on all CMake cache variables.

* git subrepo pull (merge) lib/astc-encoder

subrepo:
  subdir:   "lib/astc-encoder"
  merged:   "f4cacf25"
upstream:
  origin:   "https://github.com/ARM-software/astc-encoder.git"
  branch:   "main"
  commit:   "f744ab45"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/MarkCallow/git-subrepo.git"
  commit:   "c1f1132"

* Regenerate golden files with latest ASTC encoder.

* Remove non-cp932 characters in tools/imageio/formatdesc.h.
  • Loading branch information
MarkCallow authored May 24, 2023
1 parent b493276 commit 514051c
Show file tree
Hide file tree
Showing 261 changed files with 15,807 additions and 4,571 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ jobs:
env:
ANDROID_ABI: arm64-v8a
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
ASTC_ISA: "ISA_NEON=ON"
ASTCENC_ISA: "ASTCENC_ISA_NEON=ON"
CONFIGURATION: Debug

- name: android_arm64-v8a
run: ./ci_scripts/build_android.sh
env:
ANDROID_ABI: arm64-v8a
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
ASTC_ISA: "ISA_NEON=ON"
ASTCENC_ISA: "ASTCENC_ISA_NEON=ON"

# Android ABI x86 is obsolete
# and not supported by ARM ASTC encoder
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ jobs:
if: matrix.arch == 'x64' && matrix.options.tests == 'ON'
run: ctest --test-dir $env:BUILD_DIR -C Release

- name: Upload test log
if: ${{ failure() }}
run: ci_scripts/on_failure.ps1

- name: Get KTX version
if: matrix.options.package == 'YES'
id: ktx-version
Expand Down
54 changes: 27 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -863,64 +863,64 @@ endif()
add_subdirectory(interface/basisu_c_binding)

# Only one architecture is supported at once, if neither of
# ISA_SSE41 and ISA_SSE2 are defined ISA_AVX2 is chosen.
# If ISA_AVX2 fails to compile user must chose other x86 options.
# On arm based systems ISA_NEON is default
# ASTC_SSE41 and ASTC_SSE2 are defined ASTC_AVX2 is chosen.
# If ASTC_AVX2 fails to compile user must chose other x86 options.
# On arm based systems ASTC_NEON is default

list(FIND CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)" ASTC_BUILD_UNIVERSAL)
list(LENGTH CMAKE_OSX_ARCHITECTURES ARCHITECTURE_COUNT)

if(${ASTC_BUILD_UNIVERSAL} EQUAL -1 AND ARCHITECTURE_COUNT LESS_EQUAL 1)
if (${ISA_NONE})
set(ASTC_LIB_TARGET astcenc-none-static)
if (${ASTCENC_ISA_NONE})
set(ASTCENC_LIB_TARGET astcenc-none-static)
else()
if(CPU_ARCHITECTURE STREQUAL x86_64 OR CPU_ARCHITECTURE STREQUAL x86)
if (${ISA_SSE41})
set(ASTC_LIB_TARGET astcenc-sse4.1-static)
elseif (${ISA_SSE2})
set(ASTC_LIB_TARGET astcenc-sse2-static)
if (${ASTCENC_ISA_SSE41})
set(ASTCENC_LIB_TARGET astcenc-sse4.1-static)
elseif (${ASTCENC_ISA_SSE2})
set(ASTCENC_LIB_TARGET astcenc-sse2-static)
else()
set(ISA_AVX2 ON)
set(ASTC_LIB_TARGET astcenc-avx2-static)
set(ASTCENC_ISA_AVX2 ON)
set(ASTCENC_LIB_TARGET astcenc-avx2-static)
endif()
if(CPU_ARCHITECTURE STREQUAL x86)
set(ISA_NONE ON)
set(ISA_AVX2 OFF)
set(ASTCENC_ISA_NONE ON)
set(ASTCENC_ISA_AVX2 OFF)
set(ASTCENC_POPCNT 0)
set(ASTC_LIB_TARGET astcenc-none-static)
set(ASTCENC_LIB_TARGET astcenc-none-static)
endif()
elseif(CPU_ARCHITECTURE STREQUAL armv8 OR CPU_ARCHITECTURE STREQUAL arm64)
set(ASTC_LIB_TARGET astcenc-neon-static)
set(ISA_NEON ON)
set(ASTCENC_LIB_TARGET astcenc-neon-static)
set(ASTCENC_ISA_NEON ON)
else()
message(STATUS "Unsupported ISA for ${CPU_ARCHITECTURE} arch, using ISA_NONE.")
set(ASTC_LIB_TARGET astcenc-none-static)
set(ISA_NONE ON)
message(STATUS "Unsupported ISA for ASTC on ${CPU_ARCHITECTURE} arch, using ASTCENC_ISA_NONE.")
set(ASTCENC_LIB_TARGET astcenc-none-static)
set(ASTCENC_ISA_NONE ON)
endif()
endif()
else()
set(ASTC_LIB_TARGET astcenc-static)
set(ASTCENC_LIB_TARGET astcenc-static)
endif()

# astcenc
set(CLI OFF) # Only build as library not the CLI astcencoder
set(ASTCENC_CLI OFF) # Only build as library not the CLI astcencoder
add_subdirectory(lib/astc-encoder)
set_property(TARGET ${ASTC_LIB_TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET ${ASTCENC_LIB_TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON)

if(KTX_FEATURE_STATIC_LIBRARY AND APPLE)
# Make a single static library to simplify linking.
add_dependencies(ktx ${ASTC_LIB_TARGET})
add_dependencies(ktx ${ASTCENC_LIB_TARGET})
add_custom_command( TARGET ktx
POST_BUILD
COMMAND libtool -static -o $<TARGET_FILE:ktx> $<TARGET_FILE:ktx> $<TARGET_FILE:${ASTC_LIB_TARGET}>
COMMAND libtool -static -o $<TARGET_FILE:ktx> $<TARGET_FILE:ktx> $<TARGET_FILE:${ASTCENC_LIB_TARGET}>
)

# Don't know libtool equivalent on Windows or Emscripten. Applications
# will have to link with both ktx and ${ASTC_LIB_TARGET}. Static libs
# will have to link with both ktx and ${ASTCENC_LIB_TARGET}. Static libs
# are unlikely to be used on Windows so not a problem there. For Emscripten
# everything is built into the JS module so not an issue there either.
else()
target_link_libraries(ktx PRIVATE ${ASTC_LIB_TARGET})
target_link_libraries(ktx PRIVATE ${ASTCENC_LIB_TARGET})
endif()

# FMT
Expand All @@ -941,7 +941,7 @@ endif()

set(KTX_INSTALL_TARGETS ktx)
if(KTX_FEATURE_STATIC_LIBRARY AND NOT APPLE)
list(APPEND KTX_INSTALL_TARGETS ${ASTC_LIB_TARGET})
list(APPEND KTX_INSTALL_TARGETS ${ASTCENC_LIB_TARGET})
endif()

# Install
Expand Down
4 changes: 2 additions & 2 deletions ci_scripts/build_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e

# Fallback to arm64-v8a
ANDROID_ABI=${ANDROID_ABI:-'arm64-v8a'}
ASTC_ISA=${ASTC_ISA:-'ISA_NONE=ON'}
ASTCENC_ISA=${ASTCENC_ISA:-'ASTCENC_ISA_NONE=ON'}
CONFIGURATION=${CONFIGURATION:-Release}

BUILD_DIR="build-android-$ANDROID_ABI"
Expand All @@ -22,7 +22,7 @@ cmake_args=("-G" "Ninja" \
"-D" "CMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
"-D" "CMAKE_BUILD_TYPE=$CONFIGURATION" \
"-D" "BASISU_SUPPORT_SSE=OFF" \
"-D" "${ASTC_ISA}"
"-D" "${ASTCENC_ISA}"
)

config_display="Configure KTX-Software (Android $ANDROID_ABI $CONFIGURATION): "
Expand Down
4 changes: 2 additions & 2 deletions ci_scripts/build_android_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e

# Fallback to arm64-v8a
ANDROID_ABI=${ANDROID_ABI:-'arm64-v8a'}
ASTC_ISA=${ASTC_ISA:-'ISA_NONE=ON'}
ASTCENC_ISA=${ASTCENC_ISA:-'ASTCENC_ISA_NONE=ON'}

BUILD_DIR="build-android-$ANDROID_ABI-debug"

Expand All @@ -21,7 +21,7 @@ cmake_args=("-G" "Ninja" \
"-D" "CMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
"-D" "CMAKE_BUILD_TYPE=Debug" \
"-D" "BASISU_SUPPORT_SSE=OFF" \
"-D" "${ASTC_ISA}"
"-D" "${ASTCENC_ISA}"
)

config_display="Configure KTX-Software (Android $ANDROID_ABI Debug): "
Expand Down
2 changes: 1 addition & 1 deletion ci_scripts/build_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ set -o pipefail
cmake_args=("-G" "Xcode" \
"-B" $BUILD_DIR \
"-D" "CMAKE_SYSTEM_NAME=iOS" \
"-D" "ISA_NEON=ON" \
"-D" "ASTCENC_ISA_NEON=ON" \
"-D" "KTX_FEATURE_DOC=$FEATURE_DOC" \
"-D" "KTX_FEATURE_JNI=$FEATURE_JNI" \
"-D" "KTX_FEATURE_LOADTEST_APPS=$FEATURE_LOADTESTS" \
Expand Down
2 changes: 1 addition & 1 deletion ci_scripts/build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cmake_args=("-G" "Xcode" \
"-D" "BASISU_SUPPORT_OPENCL=$SUPPORT_OPENCL" \
"-D" "BASISU_SUPPORT_SSE=$SUPPORT_SSE"
)
if [ "$ARCHS" = "x86_64" ]; then cmake_args+=("-D" "ISA_SSE41=ON"); fi
if [ "$ARCHS" = "x86_64" ]; then cmake_args+=("-D" "ASTCENC_ISA_SSE41=ON"); fi
if [ -n "$MACOS_CERTIFICATES_P12" ]; then
cmake_args+=( \
"-D" "XCODE_CODE_SIGN_IDENTITY=${CODE_SIGN_IDENTITY}" \
Expand Down
5 changes: 3 additions & 2 deletions lib/astc-encoder/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
*.log
*.diff
*.user
*.o
*.o
*.a
__pycache__
Scratch
Proto

# Precompiled reference binaries for comparison tests
bin
lib
Binaries

# Build artifacts
Expand All @@ -22,7 +24,6 @@ build*
Test/DocOut

# Test images we download from other sources
Test/Images/Frymire
Test/Images/Kodak*/**/*.png
Test/Images/Scratch*

Expand Down
4 changes: 2 additions & 2 deletions lib/astc-encoder/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/ARM-software/astc-encoder.git
branch = main
commit = c9424dcfc5c9684717a3f18166be64ab7baed3fa
parent = ed9e7253e5481ecb73b471f9860fb2dc9369725a
commit = 8377e52e57c1fb5bcf159aa981f3b25b7bad1cb3
parent = 1646c4d06408b3b8f00e316169381239b51acf8c
method = merge
cmdver = 0.4.3
Loading

0 comments on commit 514051c

Please sign in to comment.