Skip to content

Commit

Permalink
PreRelease Fix
Browse files Browse the repository at this point in the history
Android Optimize
Release Script Fix
  • Loading branch information
gameknife committed Oct 1, 2024
1 parent 35253e1 commit 8a32c68
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
./build_android.sh
- name: Create zip file
run: |
zip -r gknextrenderer_android_${{ github.ref_name }}.zip ./android/app/build/outputs/apk/debug/app-debug.apk ./deploy_android.bat
zip -r gknextrenderer_android_${{ github.ref_name }}.zip ./android/app/build/outputs/apk/release/app-release.apk ./deploy_android.bat
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
- name: Create zip file
run: |
cd build/windows
copy /Y ..\..\package\*.bat %CD%
Copy-Item -Path ..\..\package\*.bat -Destination .
zip -r gknextrenderer_win64_${{ github.ref_name }}.zip ./bin ./assets/locale ./assets/fonts ./assets/models ./assets/shaders ./assets/textures ./*.bat
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
Expand Down
25 changes: 24 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@
"format": "cpp",
"ranges": "cpp",
"stop_token": "cpp",
"cfenv": "cpp"
"cfenv": "cpp",
"filesystem": "cpp",
"execution": "cpp",
"print": "cpp",
"spanstream": "cpp",
"stacktrace": "cpp",
"stdfloat": "cpp",
"syncstream": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"slist": "cpp"
},
}
9 changes: 9 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
apply plugin: 'com.android.application'

android {
signingConfigs {
release {
storeFile file('../keystore/public.jks')
storePassword 'public'
keyAlias 'public'
keyPassword 'public'
}
}
namespace = "com.gknextrenderer"
compileSdkVersion 33
//ndkVersion "25.2.9519653" on runner, ndk may differ from the vcpkg one
Expand All @@ -41,6 +49,7 @@ android {
}
}
buildTypes.release.minifyEnabled = false
buildTypes.release.signingConfig = signingConfigs.release
buildFeatures.prefab = true
}

Expand Down
Binary file added android/keystore/public.jks
Binary file not shown.
2 changes: 1 addition & 1 deletion deploy_android.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pushd android
adb install -r ./app/build/outputs/apk/debug/app-debug.apk
adb install -r ./app/build/outputs/apk/release/app-release.apk
adb shell monkey -p com.gknextrenderer 1
popd
30 changes: 12 additions & 18 deletions src/AndroidMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,18 @@ void handle_cmd(android_app* app, int32_t cmd) {
MakeExternalDirectory(app, "assets/textures");
MakeExternalDirectory(app, "assets/locale");

const char* argv[] = { "gkNextRenderer", "--renderer=4", "--scene=1", "--load-scene=simple.glb"};
const Options options(4, argv);
GOption = &options;
GApplication.reset(new NextRendererApplication(options, app->window));
__android_log_print(ANDROID_LOG_INFO, "vkdemo",
"start gknextrenderer: %d", options.RendererType);
const char* argv[] = { "gkNextRenderer", "--renderer=1" };
GOption = new Options(2, argv);
GApplication.reset(new NextRendererApplication(*GOption, app->window));
GApplication->Start();
}
break;
case APP_CMD_TERM_WINDOW:
// The window is being hidden or closed, clean it up.
{

delete GOption;
}
break;
default:
__android_log_print(ANDROID_LOG_INFO, "Vulkan Tutorials",
"event not handled: %d", cmd);
}
}

Expand All @@ -69,14 +63,14 @@ static int32_t engine_handle_input(struct android_app* app) {
case AMOTION_EVENT_ACTION_UP:
io.AddMouseSourceEvent(ImGuiMouseSource_Mouse);
io.AddMousePosEvent(GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_X) * 0.75, GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_Y) * 0.75);
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_X) * 0.5, GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_Y) * 0.5);
io.AddMouseButtonEvent(0, event->action == AMOTION_EVENT_ACTION_DOWN);

GApplication->OnTouch(event->action == AMOTION_EVENT_ACTION_DOWN, GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_Y) * 0.75,
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_Y) * 0.5,
GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_X) * 0.75);
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_X) * 0.5);

break;
case AMOTION_EVENT_ACTION_MOVE:
Expand All @@ -88,14 +82,14 @@ static int32_t engine_handle_input(struct android_app* app) {
//...
io.AddMouseSourceEvent(ImGuiMouseSource_Mouse);
io.AddMousePosEvent(GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_X) * 0.75,
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_X) * 0.5,
GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_Y) * 0.75);
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_Y) * 0.5);

GApplication->OnTouchMove(GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_Y) * 0.75,
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_Y) * 0.5,
GameActivityPointerAxes_getAxisValue(
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_X) * 0.75);
&event->pointers[ptrIdx], AMOTION_EVENT_AXIS_X) * 0.5);
break;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/Runtime/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ UserSettings CreateUserSettings(const Options& options)

userSettings.IsRayTraced = true;
userSettings.AccumulateRays = false;

userSettings.NumberOfSamples = options.Benchmark ? 1 : options.Samples;
userSettings.NumberOfBounces = options.Benchmark ? 4 : options.Bounces;
userSettings.MaxNumberOfBounces = options.MaxBounces;
Expand Down Expand Up @@ -148,6 +149,11 @@ UserSettings CreateUserSettings(const Options& options)
userSettings.DenoiseSigmaNormal = 0.005f;
userSettings.DenoiseSize = 5;

#if ANDROID
userSettings.NumberOfSamples = 1;
userSettings.Denoiser = false;
#endif

return userSettings;
}

Expand Down
8 changes: 6 additions & 2 deletions src/Runtime/UserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ UserInterface::UserInterface(

// Window scaling and style.
#if ANDROID
const auto scaleFactor = 1.5;
const auto scaleFactor = 1.0;
#elif __APPLE__
const auto scaleFactor = 1.0;
#else
Expand Down Expand Up @@ -477,7 +477,11 @@ void UserInterface::DrawSettings()
const ImVec2 pos = ImVec2(distance, distance);
const ImVec2 posPivot = ImVec2(0.0f, 0.0f);
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, posPivot);
#if ANDROID
ImGui::SetNextWindowSize(ImVec2(300,-1));
#else
ImGui::SetNextWindowSize(ImVec2(400,-1));
#endif
ImGui::SetNextWindowBgAlpha(0.9f);

const auto flags =
Expand Down Expand Up @@ -601,7 +605,7 @@ void UserInterface::DrawOverlay(const Statistics& statistics, Vulkan::VulkanGpuT
const auto& io = ImGui::GetIO();
const float distance = 10.0f;
#if ANDROID
const ImVec2 pos = ImVec2(io.DisplaySize.x * 0.75 - distance, distance);
const ImVec2 pos = ImVec2(io.DisplaySize.x * 0.5 - distance, distance);
const ImVec2 posPivot = ImVec2(1.0f, 0.0f);
#else
const ImVec2 pos = ImVec2(io.DisplaySize.x - distance, distance);
Expand Down
10 changes: 2 additions & 8 deletions src/Vulkan/SwapChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ SwapChain::SwapChain(const class Device& device, const VkPresentModeKHR presentM

#if ANDROID
float aspect = extent.width / static_cast<float>(extent.height);
extent.height = 1920;
extent.width = floorf(1920 * aspect);
extent.height = 1280;
extent.width = floorf(1280 * aspect);
#endif

VkSwapchainCreateInfoKHR createInfo = {};
Expand Down Expand Up @@ -233,12 +233,6 @@ VkPresentModeKHR SwapChain::ChooseSwapPresentMode(const std::vector<VkPresentMod

VkExtent2D SwapChain::ChooseSwapExtent(const Window& window, const VkSurfaceCapabilitiesKHR& capabilities)
{
#if ANDROID
__android_log_print(ANDROID_LOG_INFO, "vkdemo",
"curr capabilities res: %d x %d", capabilities.currentExtent.width, capabilities.currentExtent.height);
__android_log_print(ANDROID_LOG_INFO, "vkdemo",
"max capabilities res: %d x %d", capabilities.maxImageExtent.width, capabilities.maxImageExtent.height);
#endif
// Vulkan tells us to match the resolution of the window by setting the width and height in the currentExtent member.
// However, some window managers do allow us to differ here and this is indicated by setting the width and height in
// currentExtent to a special value: the maximum value of uint32_t. In that case we'll pick the resolution that best
Expand Down

0 comments on commit 8a32c68

Please sign in to comment.