diff --git a/CMakeLists.txt b/CMakeLists.txt index b6eb9c5cd..11c36793d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index 1afb96fa8..dde7e94a0 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -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; }; diff --git a/renderdoc/driver/gl/gl_hooks_egl.cpp b/renderdoc/driver/gl/gl_hooks_egl.cpp index 2ae166e42..4cca52907 100644 --- a/renderdoc/driver/gl/gl_hooks_egl.cpp +++ b/renderdoc/driver/gl/gl_hooks_egl.cpp @@ -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); } diff --git a/renderdoc/driver/gl/gl_hooks_linux_shared.h b/renderdoc/driver/gl/gl_hooks_linux_shared.h index 62805565d..9feeea9c7 100644 --- a/renderdoc/driver/gl/gl_hooks_linux_shared.h +++ b/renderdoc/driver/gl/gl_hooks_linux_shared.h @@ -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 *)); diff --git a/renderdoc/driver/gl/gl_replay_egl.cpp b/renderdoc/driver/gl/gl_replay_egl.cpp index 526f0e2fd..f41d28bdb 100644 --- a/renderdoc/driver/gl/gl_replay_egl.cpp +++ b/renderdoc/driver/gl/gl_replay_egl.cpp @@ -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; }