From d03dfb3dc779b0383cfc7effdfe7d8c626a7c6c6 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Tue, 14 May 2024 13:01:07 +0200 Subject: [PATCH] Allow skipping adding FSR2 shaders to Android APK. --- .../platforms/android/gradle/build.gradle | 3 ++- tools/create_android_build.py | 23 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/application/platforms/android/gradle/build.gradle b/application/platforms/android/gradle/build.gradle index d21af1f7f..9000b244b 100644 --- a/application/platforms/android/gradle/build.gradle +++ b/application/platforms/android/gradle/build.gradle @@ -67,8 +67,9 @@ android { manifest.srcFile 'AndroidManifest.xml' resources.srcDirs = ['res'] res.srcDirs = ['res'] - assets.srcDirs = ['$$ASSETS$$', '$$GRANITE_ASSETS$$', '$$GRANITE_FSR2_ASSETS$$'] + assets.srcDirs = ['$$ASSETS$$', '$$GRANITE_ASSETS$$'] jniLibs.srcDirs = ['$$EXTERNAL_JNI$$'] + $$GRANITE_AUX_ASSETS$$ } } diff --git a/tools/create_android_build.py b/tools/create_android_build.py index 6cbf2af31..a6171d6f6 100755 --- a/tools/create_android_build.py +++ b/tools/create_android_build.py @@ -66,12 +66,19 @@ def main(): help = 'The assets folder of the app', type = str, default = 'assets') + parser.add_argument('--builtin', + help = 'The builtin assets folder of the app. By default it is $GRANITE/assets.', + type = str, + default = None) parser.add_argument('--audio', help = 'Enable audio support', action = 'store_true') parser.add_argument('--physics', help = 'Enable physics support', action = 'store_true') + parser.add_argument('--fsr2', + help = 'Add FSR2 shaders to package', + action = 'store_true') args = parser.parse_args() abis = ['arm64-v8a'] if args.abis is None else args.abis @@ -131,8 +138,18 @@ def main(): cmakelists = find_relative_path(target_build_gradle, args.cmake_lists_toplevel) assets = find_relative_path(target_build_gradle, args.assets) - granite_assets = find_relative_path(target_build_gradle, os.path.join(args.granite_dir, 'assets')) - granite_fsr2_assets = find_relative_path(target_build_gradle, os.path.join(args.granite_dir, 'third_party/fsr2/src/ffx-fsr2-api/shaders')) + if args.builtin is not None: + granite_assets = find_relative_path(target_build_gradle, args.builtin) + else: + granite_assets = find_relative_path(target_build_gradle, os.path.join(args.granite_dir, 'assets')) + + if args.fsr2: + granite_fsr2_assets = find_relative_path(target_build_gradle, + os.path.join(args.granite_dir, 'third_party/fsr2/src/ffx-fsr2-api/shaders')) + granite_aux_assets = "assets.srcDirs += ['" + granite_fsr2_assets + "']" + else: + granite_aux_assets = '' + external_jni = find_relative_path(target_build_gradle, os.path.join(args.granite_dir, 'application/platforms/android/external_layers')) @@ -144,7 +161,7 @@ def main(): .replace('$$CMAKELISTS$$', cmakelists) \ .replace('$$ASSETS$$', assets) \ .replace('$$GRANITE_ASSETS$$', granite_assets) \ - .replace('$$GRANITE_FSR2_ASSETS$$', granite_fsr2_assets) \ + .replace('$$GRANITE_AUX_ASSETS$$', granite_aux_assets) \ .replace('$$EXTERNAL_JNI$$', external_jni) \ .replace('$$ABIS$$', target_abis) \ .replace('$$AUDIO$$', 'ON' if args.audio else 'OFF') \