Bug 1895635 - Generate optional arguments for arm64 rtcd headers by aom_config.h r=media-playback-reviewers,alwu

This patch introduces a script to generate optional arguments for arm64
rtcd headers, utilizing the configurations specified in the associated
aom_config.h file.

Depends on D209995

Differential Revision: https://phabricator.services.mozilla.com/D210227
This commit is contained in:
Chun-Min Chang 2024-05-14 00:56:40 +00:00
parent b0e6d2539d
commit 3030e77651
2 changed files with 36 additions and 9 deletions

View File

@ -24,13 +24,6 @@ def write_aom_config(system, arch, variables, cache_variables):
# inherit this from the mozilla build config
cache_variables.remove('HAVE_PTHREAD_H')
if arch == 'arm64':
print("Please ensure the generated arm64 rtcd headers follow the feature settings here")
# The features below are copied from the "ARM64_FLAVORS" in AOM_DIR/build/cmake/cpu.cmake.
arm64_flavors = ["NEON", "ARM_CRC32", "NEON_DOTPROD", "NEON_I8MM", "SVE", "SVE2"]
for flavor in arm64_flavors:
print("ENABLE_{}: {}, HAVE_{}: {}".format(flavor, variables['ENABLE_' + flavor], flavor, variables['HAVE_' + flavor]))
outdir = os.path.join('config', system, arch, 'config')
try:
os.makedirs(outdir)

View File

@ -56,6 +56,41 @@ function gen_rtcd_header {
> $BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/aom_dsp_rtcd.h
}
# Generate arm64 optional arguments for *_rtcd.h files.
# $1 - Header file directory.
function gen_arm64_optional_args {
local file="$BASE_DIR/$LIBAOM_CONFIG_DIR/$1/config/aom_config.h"
# The features below are copied from the "ARM64_FLAVORS" in
# AOM_DIR/build/cmake/cpu.cmake.
local arm64_flavors=(
"NEON"
"ARM_CRC32"
"NEON_DOTPROD"
"NEON_I8MM"
"SVE"
"SVE2"
)
local config=""
local opt=""
local args=""
while read -r line; do
for f in "${arm64_flavors[@]}"; do
config="HAVE_$f "
if [[ $line == *"$config"* ]]; then
enabled=${line//*$config}
if [[ $enabled -eq 0 ]]; then
opt=$(echo $f | tr '[:upper:]' '[:lower:]')
args=$(echo $args; echo "--disable-$opt")
fi
fi
done
done < $file
echo $args
}
echo "Generating config files."
python3 -m venv temp
. temp/bin/activate
@ -75,8 +110,7 @@ gen_rtcd_header win/ia32 x86
gen_rtcd_header linux/arm armv7
# TODO: Parse feature settings from the generated aom_config.h
gen_rtcd_header mac/arm64 arm64 "--disable-sve --disable-sve2"
gen_rtcd_header mac/arm64 arm64 "$(gen_arm64_optional_args mac/arm64)"
gen_rtcd_header generic generic