Skip to content

Commit

Permalink
Not using a GL config chooser seems to be the way to go, really, and …
Browse files Browse the repository at this point in the history
…was the way we used before the EGL attempt.
  • Loading branch information
hrydgard committed Mar 17, 2016
1 parent 4c0e6d0 commit 92c6810
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static int DefaultAndroidHwScale() {
int xres = System_GetPropertyInt(SYSPROP_DISPLAY_XRES);
int yres = System_GetPropertyInt(SYSPROP_DISPLAY_YRES);

if (xres < 960) {
if (xres <= 960) {
// Smaller than the PSP*2, let's go native.
return 0;
} else if (xres <= 480 * 3) { // 720p xres
Expand Down
2 changes: 2 additions & 0 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ void GameSettingsScreen::CreateViews() {
#ifdef ANDROID
static const char *deviceResolutions[] = { "Native device resolution", "Auto (same as Rendering)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
int max_res_temp = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)) / 480 + 2;
if (max_res_temp == 3)
max_res_temp = 4; // At least allow 2x
int max_res = std::min(max_res_temp, (int)ARRAY_SIZE(deviceResolutions));
UI::PopupMultiChoice *hwscale = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iAndroidHwScale, gr->T("Display Resolution (HW scaler)"), deviceResolutions, 0, max_res, gr->GetName(), screenManager()));
hwscale->OnChoice.Handle(this, &GameSettingsScreen::OnHwScaleChange); // To refresh the display mode
Expand Down
10 changes: 3 additions & 7 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ public void getDesiredBackbufferSize(Point sz) {
sz.y = NativeApp.getDesiredBackbufferHeight();
}

@Override
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
shuttingDown = false;
Expand Down Expand Up @@ -452,13 +453,8 @@ public void onCreate(Bundle savedInstanceState) {
if (Build.MANUFACTURER == "OUYA") {
mGLSurfaceView.getHolder().setFormat(PixelFormat.RGBX_8888);
mGLSurfaceView.setEGLConfigChooser(new NativeEGLConfigChooser());
} else {
// Many devices require that we set a config chooser, despite the documentation
// explicitly stating: "If no setEGLConfigChooser method is called, then by default the view will choose an RGB_888 surface with a depth buffer depth of at least 16 bits."
// On these devices, I get these crashes: http://stackoverflow.com/questions/14167319/android-opengl-demo-no-config-chosen
// So let's try it...
mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 8);
}
// Tried to mess around with config choosers here but fail completely on Xperia Play.

mGLSurfaceView.setRenderer(nativeRenderer);
setContentView(mGLSurfaceView);
Expand Down
8 changes: 8 additions & 0 deletions android/src/org/ppsspp/ppsspp/NativeEGLConfigChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;

import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView.EGLConfigChooser;
import android.util.Log;

Expand All @@ -12,6 +13,9 @@ public class NativeEGLConfigChooser implements EGLConfigChooser {

private static final int EGL_OPENGL_ES2_BIT = 4;

NativeEGLConfigChooser() {
}

private class ConfigAttribs {
EGLConfig config;
public int red;
Expand Down Expand Up @@ -60,6 +64,7 @@ ConfigAttribs[] getConfigAttribs(EGL10 egl, EGLDisplay display, EGLConfig[] conf
return attr;
}

@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
// The absolute minimum. We will do our best to choose a better config though.
int[] configSpec = {
Expand All @@ -70,6 +75,7 @@ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
EGL10.EGL_STENCIL_SIZE, 0,
EGL10.EGL_SURFACE_TYPE, EGL10.EGL_WINDOW_BIT,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
// EGL10.EGL_TRANSPARENT_TYPE, EGL10.EGL_NONE
EGL10.EGL_NONE
};

Expand Down Expand Up @@ -98,8 +104,10 @@ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
configs[i].Log();
}


// We now ignore destination alpha as a workaround for the Mali issue
// where we get badly composited if we use it.
// Though, that may be possible to fix by using EGL10.EGL_TRANSPARENT_TYPE, EGL10.EGL_NONE.

// First, find our ideal configuration. Prefer depth.
for (int i = 0; i < configs.length; i++) {
Expand Down

0 comments on commit 92c6810

Please sign in to comment.