Skip to content

Commit

Permalink
Merge pull request #28 from rokuz/lvk_android_fix
Browse files Browse the repository at this point in the history
Fix Android samples
  • Loading branch information
corporateshark authored Apr 22, 2024
2 parents 78f8866 + c71326a commit ded9d02
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 50 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
submodules: recursive

- name: Set up NDK
uses: nttld/setup-ndk@v1
uses: nttld/setup-ndk@v1.4.2
with:
ndk-version: r26b

Expand Down Expand Up @@ -60,6 +60,12 @@ jobs:
chmod +x ./gradlew
./gradlew assembleDebug
- name: Assemble 003_RenderToCubeMapSinglePass APK
run: |
cd build/android/003_RenderToCubeMapSinglePass
chmod +x ./gradlew
./gradlew assembleDebug
cmake-build:
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ option(LVK_WITH_ANDROID_VALIDATION "Enable validation layers on Android" ON)

cmake_dependent_option(LVK_WITH_VULKAN_PORTABILITY "Enable portability extension" ON "APPLE" OFF)

set(LVK_ANDROID_ABI "\'arm64-v8a\'" CACHE STRING "Enabled ABI on Android")
set(LVK_ANDROID_ABI "arm64-v8a" CACHE STRING "Enabled ABI on Android")
set(LVK_CUSTOM_MOLTENVK_PATH "" CACHE STRING "Path to custom MoltenVK")
# cmake-format: on

Expand Down
2 changes: 1 addition & 1 deletion android/app/AndroidManifest.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:label="@APP_NAME@">
android:label="lvk_@APP_NAME@">
<activity
android:exported="true"
android:name="org.lvk.samples.MainActivity"
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
compileSdk 34

defaultConfig {
applicationId "org.lvk.samples.@APP_NAME@"
applicationId "org.lvk.samples.lvk_@APP_NAME@"
minSdk 24
targetSdk 34
versionCode 1
Expand Down
2 changes: 1 addition & 1 deletion samples/001_HelloTriangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void android_main(android_app* app) {
if (ctx_) {
render();
}
if (ALooper_pollAll(0, nullptr, &events, (void**)&source) >= 0) {
if (ALooper_pollOnce(0, nullptr, &events, (void**)&source) >= 0) {
if (source) {
source->process(app, source);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/002_RenderToCubeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void android_main(android_app* app) {
if (ctx_) {
render((float)newTimeSec);
}
if (ALooper_pollAll(0, nullptr, &events, (void**)&source) >= 0) {
if (ALooper_pollOnce(0, nullptr, &events, (void**)&source) >= 0) {
if (source) {
source->process(app, source);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/003_RenderToCubeMapSinglePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void android_main(android_app* app) {
if (ctx_) {
render((float)newTimeSec);
}
if (ALooper_pollAll(0, nullptr, &events, (void**)&source) >= 0) {
if (ALooper_pollOnce(0, nullptr, &events, (void**)&source) >= 0) {
if (source) {
source->process(app, source);
}
Expand Down
13 changes: 11 additions & 2 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ macro(ADD_DEMO app)
DESTINATION "${CMAKE_BINARY_DIR}/android/${app}/gradle/wrapper")

set(APP_NAME ${app})
set(ANDROID_ABI_FILTERS ${LVK_ANDROID_ABI})

set(ABI_STRING "")
foreach(str ${LVK_ANDROID_ABI})
if(NOT ${ABI_STRING} STRLESS "")
set(ABI_STRING "${ABI_STRING}, ")
endif()
set(ABI_STRING "${ABI_STRING}'${str}'")
endforeach()
set(ANDROID_ABI_FILTERS ${ABI_STRING})

configure_file("${LVK_ROOT_DIR}/android/settings.gradle.in"
"${CMAKE_BINARY_DIR}/android/${app}/settings.gradle")
configure_file("${LVK_ROOT_DIR}/android/app/build.gradle.in"
Expand All @@ -70,7 +79,7 @@ macro(ADD_DEMO app)
if(LVK_WITH_ANDROID_VALIDATION)
list(APPEND abdroid_abi arm64-v8a armeabi-v7a x86 x86_64)
foreach(abi ${abdroid_abi})
string(FIND ${LVK_ANDROID_ABI} "${abi}" abi_substr_index)
string(FIND ${ABI_STRING} "${abi}" abi_substr_index)
if(abi_substr_index GREATER -1)
file(COPY "${LVK_ROOT_DIR}/third-party/deps/src/android-validation-layers/${abi}/libVkLayer_khronos_validation.so"
DESTINATION "${CMAKE_BINARY_DIR}/android/${app}/app/src/main/jniLibs/${abi}")
Expand Down
2 changes: 1 addition & 1 deletion samples/Tiny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void android_main(android_app* app) {
if (ctx_) {
vk.render();
}
if (ALooper_pollAll(0, nullptr, &events, (void**)&source) >= 0) {
if (ALooper_pollOnce(0, nullptr, &events, (void**)&source) >= 0) {
if (source) {
source->process(app, source);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/Tiny_Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ void android_main(android_app* app) {
if (ctx_) {
render(frameIndex, (float)newTimeSec);
}
if (ALooper_pollAll(0, nullptr, &events, (void**)&source) >= 0) {
if (ALooper_pollOnce(0, nullptr, &events, (void**)&source) >= 0) {
if (source) {
source->process(app, source);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/Tiny_MeshLarge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ void android_main(android_app* app) {
render(delta, frameIndex);
processLoadedMaterials();
}
if (ALooper_pollAll(0, nullptr, &events, (void**)&source) >= 0) {
if (ALooper_pollOnce(0, nullptr, &events, (void**)&source) >= 0) {
if (source) {
source->process(app, source);
}
Expand Down
4 changes: 0 additions & 4 deletions third-party/bootstrap-deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
"type": "git",
"url": "https://github.com/KhronosGroup/glslang.git",
"revision": "14.1.0"
},
"postprocess": {
"type": "script",
"file": "glslang.py"
}
},
{
Expand Down
18 changes: 0 additions & 18 deletions third-party/deps/patches/glslang.py

This file was deleted.

16 changes: 0 additions & 16 deletions third-party/deps/patches/glslang_crash_arm64_v8a.patch

This file was deleted.

0 comments on commit ded9d02

Please sign in to comment.