From f2c78c36e3eadc57a421dcde26586d05bcc06474 Mon Sep 17 00:00:00 2001 From: Themaister Date: Mon, 14 Apr 2014 13:17:05 +0200 Subject: [PATCH] [Android] Add support for GLES3 HW render. --- android/native/AndroidManifest.xml | 32 ----------------------------- android/native/jni/Android.mk | 9 +++++++- android/native/jni/Application.mk | 2 -- android/phoenix/jni/Application.mk | 6 +++++- camera/android.c | 2 +- gfx/context/androidegl_ctx.c | 21 +++++++++++-------- gfx/context/bbqnx_ctx.c | 2 -- gfx/shader_glsl.c | 24 +--------------------- libretro-test-gl/jni/Android.mk | 11 ++++++++-- libretro-test-gl/jni/Application.mk | 6 +++++- libretro-test-gl/libretro-test.c | 2 +- 11 files changed, 43 insertions(+), 74 deletions(-) delete mode 100644 android/native/AndroidManifest.xml delete mode 100644 android/native/jni/Application.mk diff --git a/android/native/AndroidManifest.xml b/android/native/AndroidManifest.xml deleted file mode 100644 index cf9fb0071b..0000000000 --- a/android/native/AndroidManifest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/native/jni/Android.mk b/android/native/jni/Android.mk index 0224c7efa2..e9fd7a21fa 100644 --- a/android/native/jni/Android.mk +++ b/android/native/jni/Android.mk @@ -47,9 +47,16 @@ ifeq ($(PERF_TEST), 1) LOCAL_CFLAGS += -DPERF_TEST endif +ifeq ($(GLES),3) + GLES_LIB := -lGLESv3 + LOCAL_CFLAGS += -DHAVE_OPENGLES3 +else + GLES_LIB := -lGLESv2 +endif + LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_SCREENSHOTS -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -I../../../deps/miniz -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_CAMERA -DRARCH_INTERNAL -DHAVE_LOCATION -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL -lGLESv2 $(LOGGER_LDLIBS) -ldl +LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL $(GLES_LIB) $(LOGGER_LDLIBS) -ldl LOCAL_CFLAGS += -DHAVE_SL LOCAL_LDLIBS += -lOpenSLES -lz diff --git a/android/native/jni/Application.mk b/android/native/jni/Application.mk deleted file mode 100644 index 492004a45f..0000000000 --- a/android/native/jni/Application.mk +++ /dev/null @@ -1,2 +0,0 @@ -APP_PLATFORM := android-9 -APP_ABI := all diff --git a/android/phoenix/jni/Application.mk b/android/phoenix/jni/Application.mk index 492004a45f..e5fb02e9b5 100644 --- a/android/phoenix/jni/Application.mk +++ b/android/phoenix/jni/Application.mk @@ -1,2 +1,6 @@ -APP_PLATFORM := android-9 +ifeq ($(GLES),3) + APP_PLATFORM := android-18 +else + APP_PLATFORM := android-9 +endif APP_ABI := all diff --git a/camera/android.c b/camera/android.c index 94d1972cdf..eaa147e0e9 100644 --- a/camera/android.c +++ b/camera/android.c @@ -15,7 +15,7 @@ * If not, see . */ -#include +#include "../gfx/glsym/glsym.h" #include "../driver.h" #include "../android/native/jni/jni_macros.h" diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index 3e08e5f2c8..8ce5e86b97 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -36,10 +36,7 @@ static EGLSurface g_egl_surf; static EGLDisplay g_egl_dpy; static EGLConfig g_config; static bool g_resize; - -GLfloat _angle; - -static enum gfx_ctx_api g_api; +static bool g_es3; static void gfx_ctx_set_swap_interval(void *data, unsigned interval) { @@ -98,8 +95,9 @@ static bool gfx_ctx_init(void *data) EGLint egl_version_major, egl_version_minor; EGLint format; + RARCH_LOG("Android EGL: GLES version = %d.\n", g_es3 ? 3 : 2); EGLint context_attributes[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_CLIENT_VERSION, g_es3 ? 3 : 2, EGL_NONE }; @@ -239,9 +237,16 @@ static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol) static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; - (void)major; - (void)minor; - g_api = api; + + unsigned version = major * 100 + minor; + if (version > 300) + return false; +#ifdef HAVE_OPENGLES3 + if (version < 300) + g_es3 = false; + else if (version == 300) + g_es3 = true; +#endif return api == GFX_CTX_OPENGL_ES_API; } diff --git a/gfx/context/bbqnx_ctx.c b/gfx/context/bbqnx_ctx.c index cf466e04bf..12d0cdd1f2 100644 --- a/gfx/context/bbqnx_ctx.c +++ b/gfx/context/bbqnx_ctx.c @@ -48,8 +48,6 @@ screen_context_t screen_ctx; screen_window_t screen_win; static screen_display_t screen_disp; -GLfloat _angle; - static enum gfx_ctx_api g_api; static void gfx_ctx_set_swap_interval(void *data, unsigned interval) diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index 3013745500..6d9e745c1a 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -27,29 +27,7 @@ #include "../config.h" #endif -#if defined(IOS) -#include -#include -#elif defined(__APPLE__) // Because they like to be "oh, so, special". -#include -#include -#elif defined(HAVE_PSGL) -#include -#include -#elif defined(HAVE_OPENGL_MODERN) -#include -#include -#include -#elif defined(HAVE_OPENGLES2) -#include -#elif defined(HAVE_OPENGLES1) -#include -#include -#else -#define GL_GLEXT_PROTOTYPES -#include -#include -#endif +#include "glsym/glsym.h" #include "gfx_context.h" #include diff --git a/libretro-test-gl/jni/Android.mk b/libretro-test-gl/jni/Android.mk index b240874d3c..c3bcbe0791 100644 --- a/libretro-test-gl/jni/Android.mk +++ b/libretro-test-gl/jni/Android.mk @@ -17,9 +17,16 @@ ifeq ($(TARGET_ARCH),mips) LOCAL_CFLAGS += -DANDROID_MIPS endif -LOCAL_SRC_FILES += $(wildcard ../*.c) ../glsym/rglgen.c ../glsym/glsym_es2.c +ifeq ($(GLES), 3) + LOCAL_CFLAGS += -DHAVE_OPENGLES3 -DGLES3 + GLES_LIB := -lGLESv3 +else + GLES_LIB := -lGLESv2 +endif + +LOCAL_SRC_FILES += $(addprefix ../,$(wildcard *.c) ../gfx/glsym/rglgen.c ../gfx/glsym/glsym_es2.c) LOCAL_CFLAGS += -O2 -Wall -std=gnu99 -ffast-math -DGLES -DHAVE_OPENGLES2 -LOCAL_LDLIBS += -lGLESv2 +LOCAL_LDLIBS += $(GLES_LIB) include $(BUILD_SHARED_LIBRARY) diff --git a/libretro-test-gl/jni/Application.mk b/libretro-test-gl/jni/Application.mk index 2b3a608fa0..a6c92889cc 100644 --- a/libretro-test-gl/jni/Application.mk +++ b/libretro-test-gl/jni/Application.mk @@ -1,3 +1,7 @@ APP_ABI := all -APP_PLATFORM := android-9 +ifeq ($(GLES), 3) + APP_PLATFORM := android-18 +else + APP_PLATFORM := android-9 +endif diff --git a/libretro-test-gl/libretro-test.c b/libretro-test-gl/libretro-test.c index f2c9c6d9bc..5128ae33d0 100644 --- a/libretro-test-gl/libretro-test.c +++ b/libretro-test-gl/libretro-test.c @@ -290,7 +290,7 @@ static void update_variables(void) { char *pch; char str[100]; - snprintf(str, sizeof(str), var.value); + snprintf(str, sizeof(str), "%s", var.value); pch = strtok(str, "x"); if (pch)