Skip to content

Commit

Permalink
Vulkan: Allow C++ to determine use of JavaGL.
Browse files Browse the repository at this point in the history
Based on config - this way we can enable Vulkan more easily even before we
determine why some devices don't like C++ EGL for GLES.
  • Loading branch information
unknownbrackets committed Jul 1, 2016
1 parent 935568a commit b94d4c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
7 changes: 7 additions & 0 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ std::string NativeQueryConfig(std::string query) {
return std::string(temp);
} else if (query == "force44khz") {
return std::string("0");
} else if (query == "androidJavaGL") {
// If we're using Vulkan, we say no... need C++ to use Vulkan.
if (GetGPUBackend() == GPUBackend::VULKAN) {
return "false";
}
// Otherwise, some devices prefer the Java init so play it safe.
return "true";
} else {
return "";
}
Expand Down
7 changes: 5 additions & 2 deletions android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ InputState input_state;

static bool renderer_inited = false;
static bool first_lost = true;
// See NativeQueryConfig("androidJavaGL") to change this value.
static bool javaGL = true;

static std::string library_path;
Expand Down Expand Up @@ -477,9 +478,8 @@ extern "C" jstring Java_org_ppsspp_ppsspp_NativeApp_queryConfig
extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
(JNIEnv *env, jclass, jstring jmodel, jint jdeviceType, jstring jlangRegion, jstring japkpath,
jstring jdataDir, jstring jexternalDir, jstring jlibraryDir, jstring jcacheDir, jstring jshortcutParam,
jint jAndroidVersion, jstring jboard, jboolean jjavaGL) {
jint jAndroidVersion, jstring jboard) {
jniEnvUI = env;
javaGL = jjavaGL;
setCurrentThreadName("androidInit");

ILOG("NativeApp.init() -- begin");
Expand Down Expand Up @@ -544,6 +544,9 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
NativeInit(2, argv, user_data_path.c_str(), externalDir.c_str(), cacheDir.c_str());
}

// Now that we've loaded config, set javaGL.
javaGL = NativeQueryConfig("androidJavaGL") == "true";

ILOG("NativeApp.init() -- end");
}

Expand Down
7 changes: 5 additions & 2 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
// Allows us to skip a lot of initialization on secondary calls to onCreate.
private static boolean initialized = false;

// Change this to false to switch to C++ EGL.
// False to use C++ EGL, queried from C++ after NativeApp.init.
private static boolean javaGL = true;

// Graphics and audio interfaces for EGL (javaGL = false)
Expand Down Expand Up @@ -266,7 +266,10 @@ public void Initialize() {
String languageRegion = Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();

NativeApp.audioConfig(optimalFramesPerBuffer, optimalSampleRate);
NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, externalStorageDir, libraryDir, cacheDir, shortcutParam, Build.VERSION.SDK_INT, Build.BOARD, javaGL);
NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, externalStorageDir, libraryDir, cacheDir, shortcutParam, Build.VERSION.SDK_INT, Build.BOARD);

// Allow C++ to tell us to use JavaGL or not.
javaGL = NativeApp.queryConfig("androidJavaGL") == "true";

sendInitialGrants();

Expand Down
2 changes: 1 addition & 1 deletion android/src/org/ppsspp/ppsspp/NativeApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class NativeApp {
public final static int DEVICE_TYPE_TV = 1;
public final static int DEVICE_TYPE_DESKTOP = 2;

public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String cacheDir, String shortcutParam, int androidVersion, String board, boolean javaGL);
public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String cacheDir, String shortcutParam, int androidVersion, String board);
public static native void audioInit();
public static native void audioShutdown();
public static native void audioConfig(int optimalFramesPerBuffer, int optimalSampleRate);
Expand Down

0 comments on commit b94d4c3

Please sign in to comment.