[Android] Add support for GLES3 HW render.

This commit is contained in:
Themaister 2014-04-14 13:17:05 +02:00
parent 30cb130184
commit f2c78c36e3
11 changed files with 43 additions and 74 deletions

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.retroarch.retroarch"
android:versionCode="1"
android:versionName="1.0">
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="9" />
<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label="@string/app_name" android:hasCode="false">
<!-- 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="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name"
android:value="retroarch" />
<meta-data android:name="android.app.func_name"
android:value="ANativeActivity_onCreate" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->

View File

@ -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

View File

@ -1,2 +0,0 @@
APP_PLATFORM := android-9
APP_ABI := all

View File

@ -1,2 +1,6 @@
APP_PLATFORM := android-9
ifeq ($(GLES),3)
APP_PLATFORM := android-18
else
APP_PLATFORM := android-9
endif
APP_ABI := all

View File

@ -15,7 +15,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <GLES2/gl2.h>
#include "../gfx/glsym/glsym.h"
#include "../driver.h"
#include "../android/native/jni/jni_macros.h"

View File

@ -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;
}

View File

@ -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)

View File

@ -27,29 +27,7 @@
#include "../config.h"
#endif
#if defined(IOS)
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#elif defined(__APPLE__) // Because they like to be "oh, so, special".
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#elif defined(HAVE_PSGL)
#include <PSGL/psgl.h>
#include <GLES/glext.h>
#elif defined(HAVE_OPENGL_MODERN)
#include <EGL/egl.h>
#include <GL3/gl3.h>
#include <GL3/gl3ext.h>
#elif defined(HAVE_OPENGLES2)
#include <GLES2/gl2.h>
#elif defined(HAVE_OPENGLES1)
#include <GLES/gl.h>
#include <GLES/glext.h>
#else
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#endif
#include "glsym/glsym.h"
#include "gfx_context.h"
#include <stdlib.h>

View File

@ -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)

View File

@ -1,3 +1,7 @@
APP_ABI := all
APP_PLATFORM := android-9
ifeq ($(GLES), 3)
APP_PLATFORM := android-18
else
APP_PLATFORM := android-9
endif

View File

@ -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)