Skip to content

Commit

Permalink
git subrepo pull (merge) lib/astc-encoder
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "lib/astc-encoder"
  merged:   "dd816397"
upstream:
  origin:   "https://github.com/ARM-software/astc-encoder.git"
  branch:   "main"
  commit:   "97a5ff37"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/MarkCallow/git-subrepo.git"
  commit:   "c1f1132"
  • Loading branch information
MarkCallow committed Jul 21, 2021
1 parent f39b13b commit 6669245
Showing 92 changed files with 4,900 additions and 251 deletions.
2 changes: 1 addition & 1 deletion lib/astc-encoder/.gitrepo
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/ARM-software/astc-encoder.git
branch = main
commit = 2003150070c13536908714bd6eb031e678d7a2ca
commit = 97a5ff37fd7b885530c9c7b16a3397d2808eea3e
parent = 15369663a43d72972dfe0a7e3597d3ef6d90b6b9
method = merge
cmdver = 0.4.3
27 changes: 15 additions & 12 deletions lib/astc-encoder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ if(MSVC)
add_compile_options("/wd4324") # Disable structure was padded due to alignment specifier
endif()

project(astcencoder VERSION 3.0.0)
project(astcencoder VERSION 3.1.0)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -39,6 +39,7 @@ option(ISA_SSE41 "Enable builds for SSE4.1 SIMD")
option(ISA_SSE2 "Enable builds for SSE2 SIMD")
option(ISA_NEON "Enable builds for NEON SIMD")
option(ISA_NONE "Enable builds for no SIMD")
option(ISA_NATIVE "Enable builds for native SIMD")
option(DECOMPRESSOR "Enable builds for decompression only")
option(DIAGNOSTICS "Enable builds for diagnostic trace")
option(UNITTEST "Enable builds for unit tests")
@@ -175,8 +176,9 @@ else()
endif()
endif()

if(("${ARM64_ISA_COUNT}" EQUAL 0) AND ("${X64_ISA_COUNT}" EQUAL 0))
set(ISA_NONE ON)
# If nothing more specific is set then fall back on the compiler's defaults
if(("${ARM64_ISA_COUNT}" EQUAL 0) AND ("${X64_ISA_COUNT}" EQUAL 0) AND (NOT "${ISA_NONE}"))
set(ISA_NATIVE ON)
endif()

function(printopt optName optVal)
@@ -187,17 +189,18 @@ function(printopt optName optVal)
endif()
endfunction()

printopt("AVX2 backend " ${ISA_AVX2})
printopt("SSE4.1 backend" ${ISA_SSE41})
printopt("SSE2 backend " ${ISA_SSE2})
printopt("NEON backend " ${ISA_NEON})
printopt("NONE backend " ${ISA_NONE})
printopt("AVX2 backend " ${ISA_AVX2})
printopt("SSE4.1 backend " ${ISA_SSE41})
printopt("SSE2 backend " ${ISA_SSE2})
printopt("NEON backend " ${ISA_NEON})
printopt("NONE backend " ${ISA_NONE})
printopt("NATIVE backend " ${ISA_NATIVE})
if("${MACOS_BUILD}")
printopt("Universal bin " ${UNIVERSAL_BUILD})
printopt("Universal bin " ${UNIVERSAL_BUILD})
endif()
printopt("Decompressor " ${DECOMPRESSOR})
printopt("Diagnostics " ${DIAGNOSTICS})
printopt("Unit tests " ${UNITTEST})
printopt("Decompressor " ${DECOMPRESSOR})
printopt("Diagnostics " ${DIAGNOSTICS})
printopt("Unit tests " ${UNITTEST})

# Subcomponents
add_subdirectory(Source)
8 changes: 8 additions & 0 deletions lib/astc-encoder/Docs/Building.md
Original file line number Diff line number Diff line change
@@ -175,3 +175,11 @@ make package -j16

Windows packages will use the `.zip` format, other packages will use the
`.tar.gz` format.

## Integrating as a library into another project

The core codec of astcenc is built as a library, and so can be easily
integrated into other projects using CMake. An example of the CMake integration
and the codec API usage can be found in the `./Utils/Example` directory in the
repository. See the [Example Readme](../Utils/Example/README.md) for more
details.
59 changes: 59 additions & 0 deletions lib/astc-encoder/Docs/ChangeLog-3x.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,65 @@ release of the 3.x series.
All performance data on this page is measured on an Intel Core i5-9600K
clocked at 4.2 GHz, running astcenc using AVX2 and 6 threads.

<!-- ---------------------------------------------------------------------- -->
## 3.1

**Status:** July 2021

The 3.1 release is the second release in the 3.x series. This release gives
another performance boost, typically between 5 and 20% faster than the 3.0
release, as well as further incremental improvements to image quality. A number
of build system improvements make astcenc easier and faster to integrate into
other projects as a library, including support for building unversal binaries
on macOS. Full change list is shown below.

Reminder for users of the library interface - the API is not designed to be
binary compatible across versions, and this release is not compatible with
earlier releases. Please update and rebuild your client-side code using the
updated `astcenc.h` header.

* **General:**
* **Feature:** RGB color data now supports `-perceptual` operation. The
current implementation is simple, weighting color channel errors by their
contribution to perceived luminance. This mimics the behavior of the human
visual system, which is most sensitive to green, then red, then blue.
* **Feature:** Codec supports a new low weight search mode, which is a
simpler weight assignment for encodings with a low number of weights in the
weight grid. The weight threshold can be overriden using the new
`-lowweightmodelimit` commadn line option.
* **Feature:** All platform builds now support building a native binary.
Native binaries automatically select the SIMD level based on the default
configuration of the compiler in use. Native binaries built on one machine
may use different SIMD options than native binaries build on another.
* **Feature:** macOS platform builds now support building universal binaries
containing both `x86_64` and `arm64` target support.
* **Feature:** Building the command line can be disabled when using as a
library in another project. Set `-DCLI=OFF` during the CMake configure
step.
* **Feature:** A standalone minimal example of the core codec API usage has
been added in the `./Utils/Example/` directory.
* **Core API:**
* **Feature:** Config flag `ASTCENC_FLG_USE_PERCEPTUAL` works for color data.
* **Feature:** Config option `tune_low_weight_count_limit` added.
* **Feature:** New heuristic added which prunes dual weight plane searches if
they are unlikely to help. This heuristic is not user controllable.
* **Feature:** Image quality has been improved. In general we see significant
improvements (up to 0.2dB) for high bitrate encodings (4x4, 5x4), and a
smaller improvement (up to 0.1dB) for lower bitrate encodings.
* **Bug fix:** Arm "none" SIMD builds could be invariant with other builds.
This fix has also been back-ported to the 2.x LTS branch.

### Performance:

Key for charts:

* Color = block size (see legend).
* Letter = image format (N = normal map, G = greyscale, L = LDR, H = HDR).

**Relative performance vs 3.0 release:**

![Relative scores 3.1 vs 3.0](./ChangeLogImg/relative-3.0-to-3.1.png)

<!-- ---------------------------------------------------------------------- -->
## 3.0

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/astc-encoder/Source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -37,8 +37,8 @@ if(${UNIVERSAL_BUILD})
endif()
include(cmake_core.cmake)
else()
set(ARTEFACTS none neon avx2 sse4.1 sse2)
set(CONFIGS ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2})
set(ARTEFACTS native none neon avx2 sse4.1 sse2)
set(CONFIGS ${ISA_NATIVE} ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2})
list(LENGTH ARTEFACTS ARTEFACTS_LEN)
math(EXPR ARTEFACTS_LEN "${ARTEFACTS_LEN} - 1")

5 changes: 5 additions & 0 deletions lib/astc-encoder/Source/Fuzzers/build.sh
Original file line number Diff line number Diff line change
@@ -20,6 +20,11 @@

# This script is invoked by oss-fuzz from <root>/Source/

# Generate a dummy verison header (normally built by CMake variable expansion)
echo "#pragma once" > astcenccli_version.h
echo "#define VERSION_STRING \"0.0.0\"" >> astcenccli_version.h
echo "#define YEAR_STRING \"2021\"" >> astcenccli_version.h

# Build the core project for fuzz tests to link against
for source in ./*.cpp; do
BASE="${source##*/}"
4 changes: 2 additions & 2 deletions lib/astc-encoder/Source/UnitTest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@ if(${UNIVERSAL_BUILD})
endif()
include(cmake_core.cmake)
else()
set(ARTEFACTS none neon avx2 sse4.1 sse2)
set(CONFIGS ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2})
set(ARTEFACTS native none neon avx2 sse4.1 sse2)
set(CONFIGS ${ISA_NATIVE} ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2})
list(LENGTH ARTEFACTS ARTEFACTS_LEN)
math(EXPR ARTEFACTS_LEN "${ARTEFACTS_LEN} - 1")

4 changes: 2 additions & 2 deletions lib/astc-encoder/Source/UnitTest/test_simd.cpp
Original file line number Diff line number Diff line change
@@ -1082,11 +1082,11 @@ TEST(vfloat4, normalize_safe)
/** @brief Test vfloat4 float_to_int. */
TEST(vfloat4, float_to_int)
{
vfloat4 a(1.1f, 1.5f, 1.6f, 4.0f);
vfloat4 a(1.1f, 1.5f, -1.6f, 4.0f);
vint4 r = float_to_int(a);
EXPECT_EQ(r.lane<0>(), 1);
EXPECT_EQ(r.lane<1>(), 1);
EXPECT_EQ(r.lane<2>(), 1);
EXPECT_EQ(r.lane<2>(), -1);
EXPECT_EQ(r.lane<3>(), 4);
}

26 changes: 21 additions & 5 deletions lib/astc-encoder/Source/astcenc_entry.cpp
Original file line number Diff line number Diff line change
@@ -672,8 +672,7 @@ astcenc_error astcenc_config_init(
config.v_a_stdev = 50.0f;
}
}

if (flags & ASTCENC_FLG_MAP_MASK)
else if (flags & ASTCENC_FLG_MAP_MASK)
{
config.v_rgba_radius = 3;
config.v_rgba_mean_stdev_mix = 0.03f;
@@ -682,13 +681,30 @@ astcenc_error astcenc_config_init(
config.v_a_mean = 0.0f;
config.v_a_stdev = 25.0f;
}

if (flags & ASTCENC_FLG_MAP_RGBM)
else if (flags & ASTCENC_FLG_MAP_RGBM)
{
config.rgbm_m_scale = 5.0f;
config.cw_a_weight = 2.0f * config.rgbm_m_scale;
}

else // (This is color data)
{
// This is a very basic perceptual metric for RGB color data, which weights error
// significance by the perceptual luminance contribution of each color channel. For
// luminance the usual weights to compute luminance from a linear RGB value are as
// follows:
//
// l = r * 0.3 + g * 0.59 + b * 0.11
//
// ... but we scale these up to keep a better balance between color and alpha. Note
// that if the content is using alpha we'd recommend using the -a option to weight
// the color conribution by the alpha transparency.
if (flags & ASTCENC_FLG_USE_PERCEPTUAL)
{
config.cw_r_weight = 0.30f * 2.25f;
config.cw_g_weight = 0.59f * 2.25f;
config.cw_b_weight = 0.11f * 2.25f;
}
}
config.flags = flags;

return ASTCENC_SUCCESS;
10 changes: 4 additions & 6 deletions lib/astc-encoder/Source/astcenc_vecmathlib_none_4.h
Original file line number Diff line number Diff line change
@@ -936,12 +936,10 @@ ASTCENC_SIMD_INLINE void storea(vfloat4 a, float* ptr)
*/
ASTCENC_SIMD_INLINE vint4 float_to_int(vfloat4 a)
{
// Casting to unsigned buys us an extra bit of precision in cases where
// we can use the integer as nasty bit hacks.
return vint4((unsigned int)a.m[0],
(unsigned int)a.m[1],
(unsigned int)a.m[2],
(unsigned int)a.m[3]);
return vint4((int)a.m[0],
(int)a.m[1],
(int)a.m[2],
(int)a.m[3]);
}

/**f
12 changes: 9 additions & 3 deletions lib/astc-encoder/Source/astcenccli_toplevel_help.cpp
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@

/** @brief The version header. */
static const char *astcenc_copyright_string =
R"(astcenc v%s, %u-bit %s%s
R"(astcenc v%s, %u-bit %s%s%s
Copyright 2011-%s Arm Limited, all rights reserved
)";

@@ -192,7 +192,7 @@ COMPRESSION
The codec should optimize perceptual error, instead of direct
RMS error. This aims to improves perceived image quality, but
typically lowers the measured PSNR score. Perceptual methods are
currently only available for normal maps.
currently only available for normal maps and RGB color data.
-array <size>
Loads an array of <size> 2D image slices to use as a 3D image.
@@ -595,9 +595,15 @@ void astcenc_print_header()
const char* pcnttype = "";
#endif

#if (ASTCENC_F16C == 1)
const char* f16ctype = "+f16c";
#else
const char* f16ctype = "";
#endif

unsigned int bits = (int)(sizeof(void*) * 8);
printf(astcenc_copyright_string,
VERSION_STRING, bits, simdtype, pcnttype, YEAR_STRING);
VERSION_STRING, bits, simdtype, pcnttype, f16ctype, YEAR_STRING);
}

/* See header for documentation. */
3 changes: 2 additions & 1 deletion lib/astc-encoder/Source/cmake_core.cmake
Original file line number Diff line number Diff line change
@@ -54,7 +54,8 @@ add_library(${ASTC_TARGET}-static

target_include_directories(${ASTC_TARGET}-static
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR})
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:.>)

if(${CLI})
add_executable(${ASTC_TARGET}
Loading

0 comments on commit 6669245

Please sign in to comment.