mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Makefiles to build apk for RenderDocCmd on Android & More replay fixes.
This commit is contained in:
@@ -23,6 +23,7 @@ elseif(APPLE)
|
||||
list(APPEND RDOC_LIBRARIES
|
||||
PRIVATE m
|
||||
PRIVATE dl
|
||||
PRIVATE log
|
||||
PRIVATE ${CMAKE_THREAD_LIBS_INIT})
|
||||
elseif(UNIX)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
@@ -45,4 +45,7 @@ void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst)
|
||||
|
||||
void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h)
|
||||
{
|
||||
w = 500;
|
||||
h = 500; // FIXME
|
||||
RDCLOG("VulkanReplay::GetOutputWindowDimensions: %i, %i", w, h);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ void library_loaded()
|
||||
FileIO::GetExecutableFilename(curfile);
|
||||
|
||||
if(curfile.find("/renderdoccmd") != string::npos ||
|
||||
curfile.find("/renderdocui") != string::npos || curfile.find("/qrenderdoc") != string::npos)
|
||||
curfile.find("/renderdocui") != string::npos || curfile.find("/qrenderdoc") != string::npos ||
|
||||
curfile.find("/system/bin/app_process") != string::npos)
|
||||
{
|
||||
RDCDEBUG("Not creating hooks - in replay app");
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ set(libraries PRIVATE renderdoc)
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND sources renderdoccmd_apple.cpp)
|
||||
elseif(ANDROID)
|
||||
list(APPEND sources renderdoccmd_android.cpp)
|
||||
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
|
||||
list(APPEND libraries PRIVATE -llog -landroid)
|
||||
elseif(UNIX)
|
||||
list(APPEND sources renderdoccmd_linux.cpp)
|
||||
|
||||
@@ -14,6 +18,10 @@ elseif(UNIX)
|
||||
list(APPEND libraries PRIVATE -lxcb)
|
||||
endif()
|
||||
|
||||
add_executable(renderdoccmd ${sources})
|
||||
if(ANDROID)
|
||||
add_library(renderdoccmd SHARED ${sources})
|
||||
else()
|
||||
add_executable(renderdoccmd ${sources})
|
||||
endif()
|
||||
target_include_directories(renderdoccmd ${includes})
|
||||
target_link_libraries(renderdoccmd ${libraries})
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.renderdoc.renderdoccmd" android:versionCode="1" android:versionName="1.0">
|
||||
|
||||
<!-- This is the platform API where NativeActivity was introduced. -->
|
||||
<uses-sdk android:minSdkVersion="9"/>
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application android:label="RenderDocCmd" android:hasCode="true">
|
||||
|
||||
<activity android:name=".Loader" android:label="RenderDocCmdLoader" android:configChanges="orientation|keyboardHidden">
|
||||
<meta-data android:name="android.app.lib_name" android:value="renderdoccmd"/>
|
||||
</activity>
|
||||
|
||||
<!-- Our activity is the built-in NativeActivity framework class.
|
||||
This will take care of integrating with our NDK code. -->
|
||||
<activity android:name="android.app.NativeActivity" android:label="RenderDocCmd" android:configChanges="orientation|keyboardHidden">
|
||||
<!-- Tell NativeActivity the name of or .so -->
|
||||
<meta-data android:name="android.app.lib_name" android:value="renderdoccmd"/>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
<!-- END_INCLUDE(manifest) -->
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.renderdoc.renderdoccmd;
|
||||
import android.app.Activity;
|
||||
|
||||
public class Loader extends android.app.NativeActivity
|
||||
{
|
||||
/* load our native library */
|
||||
static {
|
||||
System.loadLibrary("renderdoc");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <replay/renderdoc_replay.h>
|
||||
|
||||
#include <android_native_app_glue.h>
|
||||
#define ANativeActivity_onCreate __attribute__((visibility("default"))) ANativeActivity_onCreate
|
||||
extern "C" {
|
||||
#include <android_native_app_glue.c>
|
||||
}
|
||||
|
||||
#include <android/log.h>
|
||||
#define LOGCAT_TAG "renderdoc"
|
||||
|
||||
using std::string;
|
||||
|
||||
struct android_app *android_state;
|
||||
|
||||
string GetUsername()
|
||||
{
|
||||
return string("Username");
|
||||
}
|
||||
|
||||
void DisplayRendererPreview(ReplayRenderer *renderer, TextureDisplay displayCfg)
|
||||
{
|
||||
ANativeWindow *connectionScreenWindow = android_state->window;
|
||||
|
||||
ReplayOutput *out =
|
||||
ReplayRenderer_CreateOutput(renderer, connectionScreenWindow, eOutputType_TexDisplay);
|
||||
|
||||
OutputConfig c = {eOutputType_TexDisplay};
|
||||
|
||||
ReplayOutput_SetOutputConfig(out, c);
|
||||
ReplayOutput_SetTextureDisplay(out, displayCfg);
|
||||
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
ReplayRenderer_SetFrameEvent(renderer, 10000000 + rand() % 1000, true);
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, LOGCAT_TAG, "Frame %i", i);
|
||||
ReplayOutput_Display(out);
|
||||
|
||||
usleep(100000);
|
||||
}
|
||||
}
|
||||
|
||||
int renderdoccmd(int argc, char **argv);
|
||||
void handle_cmd(android_app *app, int32_t cmd)
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case APP_CMD_INIT_WINDOW:
|
||||
{
|
||||
// The window is being shown, get it ready.
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, LOGCAT_TAG,
|
||||
"APP_CMD_INIT_WINDOW: android_state->window: %p", android_state->window);
|
||||
|
||||
char *argv[] = {
|
||||
"renderdoccmd", "/sdcard/capture.rdc",
|
||||
};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
renderdoccmd(argc, argv);
|
||||
break;
|
||||
}
|
||||
case APP_CMD_TERM_WINDOW:
|
||||
// The window is being hidden or closed, clean it up.
|
||||
// DeleteVulkan();
|
||||
break;
|
||||
default: __android_log_print(ANDROID_LOG_INFO, LOGCAT_TAG, "event not handled: %d", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void android_main(struct android_app *state)
|
||||
{
|
||||
android_state = state;
|
||||
android_state->onAppCmd = handle_cmd;
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, LOGCAT_TAG, "android_main android_state->window: %p",
|
||||
android_state->window);
|
||||
|
||||
// Used to poll the events in the main loop
|
||||
int events;
|
||||
android_poll_source *source;
|
||||
do
|
||||
{
|
||||
if(ALooper_pollAll(1, nullptr, &events, (void **)&source) >= 0)
|
||||
{
|
||||
if(source != NULL)
|
||||
source->process(android_state, source);
|
||||
}
|
||||
} while(android_state->destroyRequested == 0);
|
||||
}
|
||||
Reference in New Issue
Block a user