Add Android build support for GL ES

Allow building GL ES for Android.
Minimal guards are added to avoid using X11 calls
in case of Android and added support for Android
windowing system.
This commit is contained in:
Peter Gal
2017-03-28 03:47:57 -07:00
committed by Baldur Karlsson
parent a73c456a80
commit bb8ae3fb12
5 changed files with 62 additions and 25 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ if(ANDROID)
message(STATUS "Disabling GL driver on android and enabling GLES")
endif()
set(ENABLE_GL OFF CACHE BOOL "" FORCE)
set(ENABLE_GLES OFF CACHE BOOL "" FORCE)
set(ENABLE_GLES ON CACHE BOOL "" FORCE)
# Android doesn't support the Qt UI for obvious reasons
message(STATUS "Disabling qrenderdoc for android build")
+19 -5
View File
@@ -141,19 +141,33 @@ struct GLWindowingData
#elif ENABLED(RDOC_ANDROID)
#include "EGL/egl.h"
#include "EGL/eglext.h"
// force include the eglplatform.h, as we want to use
// our own because the system one could be a bit older and
// propably not suitable for the given egl.h
#include "official/eglplatform.h"
#include "official/egl.h"
#include "official/eglext.h"
struct GLWindowingData
{
GLWindowingData()
{
ctx = NULL;
egl_ctx = 0;
egl_dpy = 0;
egl_wnd = 0;
wnd = 0;
}
void SetCtx(void *c) { ctx = (void *)c; }
EGLContext ctx;
void SetCtx(void *c) { egl_ctx = (void *)c; }
union
{
// currently required to allow compatiblity with the driver parts
void *ctx;
EGLContext egl_ctx;
};
EGLDisplay egl_dpy;
EGLSurface egl_wnd;
ANativeWindow *wnd;
};
+30 -19
View File
@@ -149,14 +149,14 @@ public:
{
EGLConfig config;
EGLint numConfigs;
EGLBoolean configFound = eglChooseConfig(share.dpy, attribs, &config, 1, &numConfigs);
EGLBoolean configFound = eglChooseConfig(share.egl_dpy, attribs, &config, 1, &numConfigs);
if(configFound)
{
const EGLint pbAttribs[] = {EGL_WIDTH, 32, EGL_HEIGHT, 32, EGL_NONE};
ret.egl_wnd = eglCreatePbufferSurface(share.dpy, config, pbAttribs);
ret.egl_dpy = share.dpy;
ret.egl_ctx = eglCreateContext_real(share.dpy, config, share.ctx, ctxAttribs);
ret.egl_wnd = eglCreatePbufferSurface(share.egl_dpy, config, pbAttribs);
ret.egl_dpy = share.egl_dpy;
ret.egl_ctx = eglCreateContext_real(share.egl_dpy, config, share.ctx, ctxAttribs);
}
}
}
@@ -203,22 +203,28 @@ public:
GLWindowingData ret;
EGLNativeWindowType window = 0;
if(system == eWindowingSystem_Xlib)
switch(system)
{
XlibWindowData *xlib = (XlibWindowData *)data;
window = (EGLNativeWindowType)xlib->window;
}
else if(system == eWindowingSystem_Unknown)
{
// allow undefined so that internally we can create a window-less context
Display *dpy = XOpenDisplay(NULL);
if(dpy == NULL)
return ret;
}
else
{
RDCERR("Unexpected window system %u", system);
#if ENABLED(RDOC_ANDROID)
case eWindowingSystem_Android: window = (EGLNativeWindowType)data; break;
#elif ENABLED(RDOC_LINUX)
case eWindowingSystem_Xlib:
{
XlibWindowData *xlib = (XlibWindowData *)data;
window = (EGLNativeWindowType)xlib->window;
break;
}
#endif
case eWindowingSystem_Unknown: {
#if ENABLED(RDOC_LINUX)
// allow undefined so that internally we can create a window-less context
Display *dpy = XOpenDisplay(NULL);
if(dpy == NULL)
return ret;
break;
#endif
}
default: RDCERR("Unexpected window system %u", system); break;
}
EGLDisplay eglDisplay = eglGetDisplay_real(EGL_DEFAULT_DISPLAY);
@@ -276,6 +282,9 @@ public:
ret.egl_dpy = eglDisplay;
ret.egl_ctx = ctx;
ret.egl_wnd = surface;
#if ENABLED(RDOC_ANDROID)
ret.wnd = (ANativeWindow *)window;
#endif
return ret;
}
@@ -351,7 +360,9 @@ __attribute__((visibility("default"))) EGLDisplay eglGetDisplay(EGLNativeDisplay
if(eglhooks.eglGetDisplay_real == NULL)
eglhooks.SetupExportedFunctions();
#if DISABLED(RDOC_ANDROID)
Keyboard::CloneDisplay(display);
#endif
return eglhooks.eglGetDisplay_real(display);
}
@@ -23,10 +23,12 @@
******************************************************************************/
// bit of a hack
#if DISABLED(RDOC_ANDROID)
namespace Keyboard
{
void CloneDisplay(Display *dpy);
}
#endif
void *SharedLookupFuncPtr(const char *func, void *realFunc);
bool SharedPopulateHooks(void *(*lookupFunc)(const char *));
+10
View File
@@ -113,6 +113,7 @@ ReplayCreateStatus GLES_CreateReplayDevice(const char *logfile, IReplayDriver **
return status;
}
#if DISABLED(RDOC_ANDROID)
Display *dpy = XOpenDisplay(NULL);
if(dpy == NULL)
@@ -120,6 +121,7 @@ ReplayCreateStatus GLES_CreateReplayDevice(const char *logfile, IReplayDriver **
RDCERR("Couldn't open default X display");
return eReplayCreate_APIInitFailed;
}
#endif
eglBindAPIProc(EGL_OPENGL_ES_API);
@@ -161,7 +163,9 @@ ReplayCreateStatus GLES_CreateReplayDevice(const char *logfile, IReplayDriver **
EGLContext ctx = eglCreateContextProc(eglDisplay, config, EGL_NO_CONTEXT, ctxAttribs);
if(ctx == NULL)
{
#if DISABLED(RDOC_ANDROID)
XCloseDisplay(dpy);
#endif
GLReplay::PostContextShutdownCounters();
RDCERR("Couldn't create GL ES 3.x context - RenderDoc requires OpenGL ES 3.x availability");
return eReplayCreate_APIHardwareUnsupported;
@@ -174,7 +178,9 @@ ReplayCreateStatus GLES_CreateReplayDevice(const char *logfile, IReplayDriver **
{
RDCERR("Couldn't create a suitable PBuffer");
eglDestroySurfaceProc(eglDisplay, pbuffer);
#if DISABLED(RDOC_ANDROID)
XCloseDisplay(dpy);
#endif
GLReplay::PostContextShutdownCounters();
return eReplayCreate_APIInitFailed;
}
@@ -185,7 +191,9 @@ ReplayCreateStatus GLES_CreateReplayDevice(const char *logfile, IReplayDriver **
RDCERR("Couldn't active the created GL ES context");
eglDestroySurfaceProc(eglDisplay, pbuffer);
eglDestroyContextProc(eglDisplay, ctx);
#if DISABLED(RDOC_ANDROID)
XCloseDisplay(dpy);
#endif
GLReplay::PostContextShutdownCounters();
return eReplayCreate_APIInitFailed;
}
@@ -198,7 +206,9 @@ ReplayCreateStatus GLES_CreateReplayDevice(const char *logfile, IReplayDriver **
{
eglDestroySurfaceProc(eglDisplay, pbuffer);
eglDestroyContextProc(eglDisplay, ctx);
#if DISABLED(RDOC_ANDROID)
XCloseDisplay(dpy);
#endif
GLReplay::PostContextShutdownCounters();
return eReplayCreate_APIHardwareUnsupported;
}