From b44a21dc5a7428d640c32af29124f26168277a05 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 22 Feb 2021 21:13:06 +0100 Subject: [PATCH] (Unix) Added a menu option to enable or disable the desktop compositor. --- USERGUIDE.md | 10 ++++++++-- es-app/src/guis/GuiMenu.cpp | 15 +++++++++++++++ es-core/src/Settings.cpp | 3 +++ es-core/src/renderers/Renderer.cpp | 10 ++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/USERGUIDE.md b/USERGUIDE.md index 0a5ab3b21..b75fef35a 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -1028,6 +1028,10 @@ If enabled, only ROMs that have metadata saved to the gamelist.xml files will be Using this option, you can place game images and videos in the ROM directory tree. The media files are searched inside the directory _\/\/images/_ and _\/\/videos/_ and the filenames must match the ROM names, followed by a dash and the media type. For example _~/ROMs/nes/images/Contra-screenshot.jpg, ~/ROMs/nes/images/Contra-marquee.jpg_ and _~/ROMs/nes/videos/Contra-video.jpg_. This option is mostly intended for legacy purposes, if you have an existing game collection with this media setup that you would like to open in ES-DE. The scraper will never save files to this directory structure and will instead use the standard media directory logic. It's recommended to keep this option disabled unless you really need it since it slows down the application somewhat. +**Disable desktop composition (requires restart)** _(Unix only)_ + +The window manager desktop composition can adversely affect the framerate of ES-DE, especially on weaker graphic cards and when running in 4K resolution. As such the desktop compositor is disabled by default, although the window manager has to be configured to allow applications to do this for the option to have any effect. Note that this setting can cause problems with some graphic drivers (notably the Nvidia proprietary drivers) so if you see strange flickering and similar after quitting ES-DE, then disable the setting. In case of such issues, make sure that the emulator is also not blocking the composition (e.g. RetroArch has a corresponding option). + **Display GPU statistics overlay** Displays the framerate and VRAM statistics as an overlay. You normally never need to use this unless you're debugging a performance problem or similar. **Note:** As of ES-DE version 1.0 the VRAM usage statistics is not accurate. This will be addressed in a future version. @@ -1413,12 +1417,14 @@ MAME emulation is a bit special as the choice of emulator or core depends on whi There are other MAME versions and derivates available as well such as MAME4ALL, AdvanceMAME, FinalBurn Alpha and FinalBurn Neo but it's beyond the scope of this document to describe those in detail. For more information, refer to the [RetroPie arcade documentation](https://retropie.org.uk/docs/Arcade) which has a good overview of the various MAME alternatives. +Running RetroArch on macOS is a bit problematic as some cores (e.g. the Nintendo 64 emulators) don't exist at all, and some cores are unusable on older macOS versions as the compilation was done without the necessary backwards compatibility support. On macOS you may therefore need to compile some cores yourself. + Consider the table below a work in progress as it's obvioulsy not fully populated yet! | Game system name | Full name | Default emulator | Recommended game setup | | :-------------------- | :--------------------------------------------- | :-------------------------------- | :----------------------------------- | | 3do | 3DO | | | -| 64dd | Nintendo 64DD | RetroArch (Mupen64Plus-Next) | | +| 64dd | Nintendo 64DD | RetroArch (Mupen64Plus-Next) [no n64 emulator available on macOS?] | | | ags | Adventure Game Studio game engine | | | | amiga | Commodore Amiga | RetroArch (P-UAE)* | WHDLoad hard disk image in .hdf or .hdz format in root folder, or diskette image in .adf format in root folder if single-disk, or in separate folder with .m3u playlist if multi-disk | | amiga600 | Commodore Amiga 600 | RetroArch (P-UAE)* | WHDLoad hard disk image in .hdf or .hdz format in root folder, or diskette image in .adf format in root folder if single-disk, or in separate folder with .m3u playlist if multi-disk | @@ -1488,7 +1494,7 @@ Consider the table below a work in progress as it's obvioulsy not fully populate | naomi | Sega NAOMI | RetroArch (Flycast) | | | naomigd | Sega NAOMI GD-ROM | RetroArch (Flycast) | | | n3ds | Nintendo 3DS | RetroArch (Citra) | | -| n64 | Nintendo 64 | RetroArch (Mupen64Plus-Next) | Single archive or ROM file in root folder | +| n64 | Nintendo 64 | RetroArch (Mupen64Plus-Next) [no n64 emulator available on macOS?] | Single archive or ROM file in root folder | | nds | Nintendo DS | | | | neogeo | SNK Neo Geo | RetroArch (FinalBurn Neo)* | Single archive file following MAME name standard in root folder | | neogeocd | SNK Neo Geo CD | RetroArch (NeoCD)* | Single archive in root folder (which includes the CD image and ripped audio) | diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 0c7788e46..46d5e7a2b 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -925,6 +925,21 @@ void GuiMenu::openOtherSettings() } }); + #if defined(__unix__) + // Whether to disable desktop composition. + auto disable_composition = std::make_shared(mWindow); + disable_composition->setState(Settings::getInstance()->getBool("DisableComposition")); + s->addWithLabel("DISABLE DESKTOP COMPOSITION (REQUIRES RESTART)", disable_composition); + s->addSaveFunc([disable_composition, s] { + if (disable_composition->getState() != + Settings::getInstance()->getBool("DisableComposition")) { + Settings::getInstance()->setBool("DisableComposition", + disable_composition->getState()); + s->setNeedsSaving(); + } + }); + #endif + // GPU statistics overlay. auto display_gpu_statistics = std::make_shared(mWindow); display_gpu_statistics->setState(Settings::getInstance()->getBool("DisplayGPUStatistics")); diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 509864894..1ce27bedc 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -230,6 +230,9 @@ void Settings::setDefaults() mBoolMap["CustomEventScripts"] = { false, false }; mBoolMap["ParseGamelistOnly"] = { false, false }; mBoolMap["ROMDirGameMedia"] = { false, false }; + #if defined(__unix__) + mBoolMap["DisableComposition"] = { true, true }; + #endif mBoolMap["DisplayGPUStatistics"] = { false, false }; // macOS requires root privileges to reboot and power off so it doesn't make much // sense to enable these settings and menu entries for this operating system. diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index 537d9baec..44c777ce1 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -145,6 +145,16 @@ namespace Renderer // games or when manually switching windows using the task switcher). SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); + #if defined(__unix__) + // Disabling desktop composition can lead to better framerates and a more fluid user + // interface, but with some drivers it can cause strange behaviours when returning to + // the desktop. + if (Settings::getInstance()->getBool("DisableComposition")) + SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "1"); + else + SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); + #endif + #if defined(__APPLE__) || defined(__unix__) bool userResolution = false; // Check if the user has changed the resolution from the command line.