mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 17:19:44 -06:00
Big commit. Fix running the APK, I had missed a view in the manifest. Clean up the Android EGL context creation to fit more in line with how Dolphin works. This breaks input at the moment as well. Change the memarena from 768MB to 64MB to allow 1GB phones to potentially run it. Rename EGL_X11 back to EGL since this merge brings in some of soreau's changes to more easily allow different platforms like Wayland and Android. Not quite all of the code because some needs to be cleaned up still.
This commit is contained in:
@ -153,7 +153,12 @@ u8* MemArena::Find4GBBase()
|
||||
}
|
||||
return base;
|
||||
#else
|
||||
void* base = mmap(0, 0x31000000, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
#ifdef ANDROID
|
||||
const u32 MemSize = 0x04000000;
|
||||
#else
|
||||
const u32 MemSize = 0x31000000;
|
||||
#endif
|
||||
void* base = mmap(0, MemSize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
if (base == MAP_FAILED) {
|
||||
PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno));
|
||||
return 0;
|
||||
|
@ -7,10 +7,19 @@ set(LIBS core
|
||||
audiocommon
|
||||
z
|
||||
sfml-network
|
||||
${GTK2_LIBRARIES}
|
||||
${XRANDR_LIBRARIES}
|
||||
${X11_LIBRARIES})
|
||||
${GTK2_LIBRARIES})
|
||||
if(NOT ANDROID)
|
||||
if(USE_X11)
|
||||
set(LIBS ${LIBS} ${X11_LIBRARIES}
|
||||
${XRANDR_LIBRARIES})
|
||||
endif()
|
||||
if(USE_WAYLAND)
|
||||
set(LIBS ${LIBS} ${WAYLAND_LIBRARIES}
|
||||
${XKBCOMMON_LIBRARIES})
|
||||
endif()
|
||||
|
||||
link_directories(${CMAKE_PREFIX_PATH}/lib)
|
||||
|
||||
if(SDL2_FOUND)
|
||||
# Using shared SDL2
|
||||
set(LIBS ${LIBS} ${SDL2_LIBRARY})
|
||||
@ -87,13 +96,17 @@ else()
|
||||
endif()
|
||||
|
||||
if(USE_EGL)
|
||||
if(NOT ANDROID)
|
||||
set(SRCS ${SRCS} Src/GLInterface/EGL_X11.cpp
|
||||
Src/GLInterface/X11_Util.cpp)
|
||||
set(SRCS ${SRCS} Src/GLInterface/Platform.cpp
|
||||
Src/GLInterface/EGL.cpp)
|
||||
if(USE_WAYLAND)
|
||||
set(SRCS ${SRCS} Src/GLInterface/Wayland_Util.cpp)
|
||||
endif()
|
||||
if(USE_X11)
|
||||
set(SRCS ${SRCS} Src/GLInterface/X11_Util.cpp)
|
||||
endif()
|
||||
else()
|
||||
if(WIN32)
|
||||
set(SRCS ${SRCS} Src/GLInterface/GLW.cpp)
|
||||
set(SRCS ${SRCS} Src/GLInterface/WGL.cpp)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(SRCS ${SRCS} Src/GLInterface/AGL.cpp)
|
||||
else()
|
||||
@ -127,10 +140,8 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
list(APPEND SRCS ${RESOURCES})
|
||||
set_source_files_properties(${RESOURCES} PROPERTIES
|
||||
MACOSX_PACKAGE_LOCATION Resources)
|
||||
else()
|
||||
if(NOT ANDROID)
|
||||
set(SRCS ${SRCS} Src/X11Utils.cpp)
|
||||
endif()
|
||||
elseif(USE_X11)
|
||||
set(SRCS ${SRCS} Src/X11Utils.cpp)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
|
||||
|
@ -17,14 +17,18 @@
|
||||
#ifndef _GLINTERFACE_H_
|
||||
#define _GLINTERFACE_H_
|
||||
|
||||
#if USE_EGL
|
||||
#include "GLInterface/Platform.h"
|
||||
#else
|
||||
|
||||
#include "Thread.h"
|
||||
#ifdef ANDROID
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GLInterface/InterfaceBase.h>
|
||||
#include "GLInterface/EGL.h"
|
||||
#elif defined(USE_EGL) && USE_EGL
|
||||
#include "GLInterface/EGL_X11.h"
|
||||
#include "GLInterface/EGL.h"
|
||||
#elif defined(__APPLE__)
|
||||
#include "GLInterface/AGL.h"
|
||||
#elif defined(_WIN32)
|
||||
@ -36,19 +40,11 @@
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
#ifdef ANDROID
|
||||
#elif defined(USE_EGL) && USE_EGL // This is currently a X11/EGL implementation for desktop
|
||||
#if defined(USE_EGL) && USE_EGL // This is currently a X11/EGL implementation for desktop
|
||||
int screen;
|
||||
Display *dpy;
|
||||
Display *evdpy;
|
||||
Window win;
|
||||
Window parent;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
XVisualInfo *vi;
|
||||
XSetWindowAttributes attr;
|
||||
std::thread xEventThread;
|
||||
int x, y;
|
||||
unsigned int width, height;
|
||||
#elif defined(__APPLE__)
|
||||
@ -74,3 +70,4 @@ extern cInterfaceBase *GLInterface;
|
||||
extern GLWindow GLWin;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -19,59 +19,30 @@
|
||||
#include "RenderBase.h"
|
||||
|
||||
#include "../GLInterface.h"
|
||||
#include "EGL_X11.h"
|
||||
#include "EGL.h"
|
||||
|
||||
// Show the current FPS
|
||||
void cInterfaceEGL::UpdateFPSDisplay(const char *text)
|
||||
{
|
||||
XStoreName(GLWin.dpy, GLWin.win, text);
|
||||
Platform.UpdateFPSDisplay(text);
|
||||
}
|
||||
|
||||
void cInterfaceEGL::SwapInterval(int Interval)
|
||||
{
|
||||
eglSwapInterval(GLWin.egl_dpy, Interval);
|
||||
}
|
||||
|
||||
void cInterfaceEGL::Swap()
|
||||
{
|
||||
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
|
||||
}
|
||||
void cInterfaceEGL::SwapInterval(int Interval)
|
||||
{
|
||||
eglSwapInterval(GLWin.egl_dpy, Interval);
|
||||
}
|
||||
|
||||
// Create rendering window.
|
||||
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
|
||||
bool cInterfaceEGL::Create(void *&window_handle)
|
||||
{
|
||||
int _tx, _ty, _twidth, _theight;
|
||||
Host_GetRenderWindowSize(_tx, _ty, _twidth, _theight);
|
||||
|
||||
// Control window size and picture scaling
|
||||
s_backbuffer_width = _twidth;
|
||||
s_backbuffer_height = _theight;
|
||||
|
||||
const char *s;
|
||||
EGLint egl_major, egl_minor;
|
||||
|
||||
GLWin.dpy = XOpenDisplay(NULL);
|
||||
|
||||
if (!GLWin.dpy) {
|
||||
ERROR_LOG(VIDEO, "Error: couldn't open display\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
GLWin.egl_dpy = eglGetDisplay(GLWin.dpy);
|
||||
if (!GLWin.egl_dpy) {
|
||||
ERROR_LOG(VIDEO, "Error: eglGetDisplay() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) {
|
||||
ERROR_LOG(VIDEO, "Error: eglInitialize() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(VIDEO, "EGL_VERSION = %s\n", eglQueryString(GLWin.egl_dpy, EGL_VERSION));
|
||||
INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", eglQueryString(GLWin.egl_dpy, EGL_VENDOR));
|
||||
INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS));
|
||||
INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS));
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
|
||||
// attributes for a visual in RGBA format with at least
|
||||
// 8 bits per color and a 24 bit depth buffer
|
||||
@ -93,70 +64,79 @@ bool cInterfaceEGL::Create(void *&window_handle)
|
||||
#endif
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
GLWin.evdpy = XOpenDisplay(NULL);
|
||||
GLWin.parent = (Window)window_handle;
|
||||
GLWin.screen = DefaultScreen(GLWin.dpy);
|
||||
if (GLWin.parent == 0)
|
||||
GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
|
||||
|
||||
XVisualInfo visTemplate;
|
||||
int num_visuals;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
if(!Platform.SelectDisplay())
|
||||
return false;
|
||||
|
||||
if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
ERROR_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
|
||||
GLWin.egl_dpy = Platform.EGLGetDisplay();
|
||||
|
||||
if (!GLWin.egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(GLWin.egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
ERROR_LOG(VIDEO, "Error: eglGetConfigAttrib() failed\n");
|
||||
GLWin.platform = Platform.platform;
|
||||
|
||||
if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
GLWin.vi = XGetVisualInfo(GLWin.dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!GLWin.vi) {
|
||||
ERROR_LOG(VIDEO, "Error: couldn't get X visual\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
GLWin.x = _tx;
|
||||
GLWin.y = _ty;
|
||||
GLWin.width = _twidth;
|
||||
GLWin.height = _theight;
|
||||
|
||||
XWindow.CreateXWindow();
|
||||
#ifdef USE_GLES
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#else
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
#endif
|
||||
GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
|
||||
if (!GLWin.egl_ctx) {
|
||||
ERROR_LOG(VIDEO, "Error: eglCreateContext failed\n");
|
||||
return false;
|
||||
|
||||
if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config, (NativeWindowType)GLWin.win, NULL);
|
||||
if (!GLWin.egl_surf) {
|
||||
ERROR_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n");
|
||||
if (!Platform.Init(config))
|
||||
return false;
|
||||
|
||||
s = eglQueryString(GLWin.egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(GLWin.egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
|
||||
if (!GLWin.egl_ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
GLWin.native_window = Platform.CreateWindow();
|
||||
|
||||
GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config,
|
||||
GLWin.native_window, NULL);
|
||||
if (!GLWin.egl_surf) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx)) {
|
||||
ERROR_LOG(VIDEO, "Error: eglMakeCurrent() failed\n");
|
||||
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(VIDEO, "GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
||||
INFO_LOG(VIDEO, "GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
||||
INFO_LOG(VIDEO, "GL_VERSION: %s\n", glGetString(GL_VERSION));
|
||||
INFO_LOG(VIDEO, "GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
|
||||
window_handle = (void *)GLWin.win;
|
||||
|
||||
printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
||||
printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION: %s\n", glGetString(GL_VERSION));
|
||||
printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
|
||||
|
||||
Platform.ToggleFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
|
||||
|
||||
window_handle = (void *)GLWin.native_window;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -167,7 +147,7 @@ bool cInterfaceEGL::MakeCurrent()
|
||||
// Close backend
|
||||
void cInterfaceEGL::Shutdown()
|
||||
{
|
||||
XWindow.DestroyXWindow();
|
||||
Platform.DestroyWindow();
|
||||
if (GLWin.egl_ctx && !eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx))
|
||||
NOTICE_LOG(VIDEO, "Could not release drawing context.");
|
||||
if (GLWin.egl_ctx)
|
||||
@ -178,4 +158,3 @@ void cInterfaceEGL::Shutdown()
|
||||
GLWin.egl_ctx = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -17,24 +17,23 @@
|
||||
#ifndef _INTERFACEEGL_H_
|
||||
#define _INTERFACEEGL_H_
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#ifdef USE_GLES
|
||||
#if USE_GLES
|
||||
#include <GLES2/gl2.h>
|
||||
#include <X11/Xutil.h>
|
||||
#else
|
||||
#include <GL/glxew.h>
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include "X11_Util.h"
|
||||
#include "InterfaceBase.h"
|
||||
|
||||
class cPlatform;
|
||||
|
||||
class cInterfaceEGL : public cInterfaceBase
|
||||
{
|
||||
private:
|
||||
cX11Window XWindow;
|
||||
cPlatform Platform;
|
||||
public:
|
||||
friend class cX11Window;
|
||||
friend class cPlatform;
|
||||
void SwapInterval(int Interval);
|
||||
void Swap();
|
||||
void UpdateFPSDisplay(const char *Text);
|
@ -39,6 +39,7 @@
|
||||
#include <android/native_window_jni.h>
|
||||
JNIEnv *g_env = NULL;
|
||||
ANativeWindow* surf;
|
||||
int g_width, g_height;
|
||||
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Dolphinemu", __VA_ARGS__))
|
||||
|
||||
bool rendererHasFocus = true;
|
||||
@ -83,8 +84,8 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
|
||||
{
|
||||
x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos;
|
||||
y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos;
|
||||
width = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth;
|
||||
height = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight;
|
||||
width = g_width;
|
||||
height = g_height;
|
||||
}
|
||||
|
||||
void Host_RequestRenderWindowSize(int width, int height) {}
|
||||
@ -122,18 +123,12 @@ void Host_SysMessage(const char *fmt, ...)
|
||||
|
||||
void Host_SetWiiMoteConnectionState(int _State) {}
|
||||
|
||||
extern void DrawReal();
|
||||
extern void PrepareShit();
|
||||
extern void DrawButton(int tex, int ID);
|
||||
extern void SetButtonCoords(float *Coords);
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_PrepareME(JNIEnv *env, jobject obj)
|
||||
{
|
||||
PrepareShit();
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_SetButtonCoords(JNIEnv *env, jobject obj, jfloatArray Coords)
|
||||
{
|
||||
jfloat* flt1 = env->GetFloatArrayElements(Coords, 0);
|
||||
@ -148,33 +143,30 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawButton(
|
||||
DrawButton((int)GLTex, (int)ID);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_UnPauseEmulation(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_UnPauseEmulation(JNIEnv *env, jobject obj)
|
||||
{
|
||||
PowerPC::Start();
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_PauseEmulation(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_PauseEmulation(JNIEnv *env, jobject obj)
|
||||
{
|
||||
PowerPC::Pause();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_StopEmulation(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_StopEmulation(JNIEnv *env, jobject obj)
|
||||
{
|
||||
PowerPC::Stop();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeRenderer_DrawME(JNIEnv *env, jobject obj)
|
||||
{
|
||||
DrawReal();
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_SetKey(JNIEnv *env, jobject obj, jint Value, jint Key)
|
||||
{
|
||||
WARN_LOG(COMMON, "Key %d with action %d\n", (int)Key, (int)Value);
|
||||
KeyStates[(int)Key] = (int)Value == 0 ? true : false;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf, jint _width, jint _height)
|
||||
{
|
||||
surf = ANativeWindow_fromSurface(env, _surf);
|
||||
g_width = (int)_width;
|
||||
g_height = (int)_height;
|
||||
g_env = env;
|
||||
|
||||
LogManager::Init();
|
||||
|
Reference in New Issue
Block a user