Switch port fixes (#251)

* switch: fix es-shaders being packed before transpilation

* switch: build fixes and glsl debug logs

* switch: fix crash on shutdown

shutdown is now done before __libc_fini_array is called, which avoids
freeing the gl context resources twice (in __libc_fini_array, and in SDL_GL_DeleteContext)
This commit is contained in:
Samuel P 2020-09-01 15:31:35 +02:00 committed by GitHub
parent 4326d6a6f1
commit 5238f4080d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View file

@ -112,6 +112,7 @@ if host_machine.system() == 'nx'
'--exclude', '**/meson.build',
],
output : shader_pkg_zip,
depends : essl_targets,
depfile : '@0@.d'.format(shader_pkg_zip),
install : true,
install_dir : data_path,

View file

@ -9,15 +9,18 @@
#include "arch_switch.h"
#include <switch/runtime/devices/socket.h>
#include <switch/runtime/nxlink.h>
#include <switch/services/applet.h>
#include <switch/services/fs.h>
#include <switch/services/ssl.h>
#include <switch/runtime/devices/socket.h>
#include <switch/runtime/nxlink.h>
#define NX_LOG_FMT(fmt, ...) tsfprintf(stdout, "[NX] " fmt "\n", ##__VA_ARGS__)
#define NX_LOG(str) NX_LOG_FMT("%s", str)
#define NX_SETENV(name, val) NX_LOG_FMT("Setting env var %s to %s", name, val);env_set_string(name, val, true)
uint32_t __nx_fs_num_sessions = 1;
static nxAtExitFn g_nxAtExitFn = NULL;
static char g_programDir[FS_MAX_PATH] = {0};
static AppletHookCookie g_hookCookie;
@ -58,7 +61,10 @@ void userAppInit(void) {
NX_SETENV("EGL_LOG_LEVEL", "debug");
NX_SETENV("MESA_VERBOSE", "all");
NX_SETENV("MESA_DEBUG", "1");
NX_SETENV("MESA_INFO", "1");
NX_SETENV("MESA_GLSL", "errors");
NX_SETENV("NOUVEAU_MESA_DEBUG", "1");
NX_SETENV("LIBGL_DEBUG", "verbose");
// enable shader debugging in Nouveau:
NX_SETENV("NV50_PROG_OPTIMIZE", "0");
@ -72,11 +78,6 @@ void userAppInit(void) {
attr_used
void userAppExit(void) {
if(g_nxAtExitFn != NULL) {
NX_LOG("calling exit callback");
g_nxAtExitFn();
g_nxAtExitFn = NULL;
}
socketExit();
appletUnlockExit();
}
@ -93,6 +94,12 @@ int nxAtExit(nxAtExitFn fn) {
void __attribute__((weak)) noreturn __libnx_exit(int rc);
void noreturn nxExit(int rc) {
if(g_nxAtExitFn != NULL) {
NX_LOG("calling exit callback");
g_nxAtExitFn();
g_nxAtExitFn = NULL;
}
__libnx_exit(rc);
}