Emulator crash after eglCreateWindowSurface()
Posted: Tue Oct 19, 2021 1:38 am
I am new to Switch homebrewing and I'm about to port my existing mini engine (originally written in C++ using SDL2 + OpenGL 4.3) to the Switch. It seems that I can not go with SDL2 + OpenGL (using my own OpenGL code), so I am following the existing examples using EGL + OpenGL. I am testing the builds *.nro file) in the yuzu and ryujinx emulators.
Depending on how far I got into my code, I am no longer able to do "consoleInit(nullptr);" + printing some debug or error messages. The exact point after which I am not able anymore is after I called eglCreateWindowSurface(). The yuzu emulator for example keeps haning on the emulator's "loading" screen. I'm unsure if anything until then went wrong, or if everything until then is just fine and something later doesn't work.
As for the EGL initialization part of my code, it looks like this:
I added a throw/catch expression in a different file, so in case of error my program will do "consoleInit(nullptr);" and print the error message, which works perfectly fine before "eglCreateWindowSurface" has been executed.
The only relevant code, I run before initializing EGL, is creating some small classes, doing nothing really in their constructors, and optionally "romfsInit()" (I also tried without romfs).
Does anyone have any clue what is possibly going wrong or how I can debug the Switch ROM better?
Depending on how far I got into my code, I am no longer able to do "consoleInit(nullptr);" + printing some debug or error messages. The exact point after which I am not able anymore is after I called eglCreateWindowSurface(). The yuzu emulator for example keeps haning on the emulator's "loading" screen. I'm unsure if anything until then went wrong, or if everything until then is just fine and something later doesn't work.
As for the EGL initialization part of my code, it looks like this:
Code: Select all
auto window = nwindowGetDefault();
nwindowSetDimensions(window, DISPLAY_WIDTH, DISPLAY_HEIGHT);
static const EGLint framebufferAttributeList[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 24,
EGL_STENCIL_SIZE, 8,
EGL_NONE
};
static const EGLint contextAttributeList[] = {
EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
EGL_CONTEXT_MAJOR_VERSION, 4,
EGL_CONTEXT_MINOR_VERSION, 3,
EGL_NONE
};
mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if(!mEglDisplay) {
throw new std::runtime_error(eglErrorToString(eglGetError()));
}
if(eglInitialize(mEglDisplay, nullptr, nullptr) == EGL_FALSE) {
throw new std::runtime_error(eglErrorToString(eglGetError()));
}
if(eglBindAPI(EGL_OPENGL_API) == EGL_FALSE) {
throw new std::runtime_error(eglErrorToString(eglGetError()));
}
EGLConfig config;
EGLint numConfigs;
eglChooseConfig(mEglDisplay, framebufferAttributeList, &config, 1, &numConfigs);
if(numConfigs == 0) {
throw new std::runtime_error(eglErrorToString(eglGetError()));
}
mEglSurface = eglCreateWindowSurface(mEglDisplay, config, window, nullptr); // <- emulator seems to hang here (?)
if(!mEglSurface) {
throw new std::runtime_error(eglErrorToString(eglGetError()));
}
mEglContext = eglCreateContext(mEglDisplay, config, EGL_NO_CONTEXT, contextAttributeList);
if(!mEglContext) {
throw new std::runtime_error(eglErrorToString(eglGetError()));
}
eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext);
The only relevant code, I run before initializing EGL, is creating some small classes, doing nothing really in their constructors, and optionally "romfsInit()" (I also tried without romfs).
Does anyone have any clue what is possibly going wrong or how I can debug the Switch ROM better?