exult / exult

Exult is a project to recreate Ultima 7 for modern operating systems, using the game's original plot, data, and graphics files.
http://exult.info
GNU General Public License v2.0
502 stars 80 forks source link

For performance reasons, would you consider externalizing some of the scalers #331

Open i30817 opened 1 year ago

i30817 commented 1 year ago

So they can use hardware rendering 'under the hood'? It's a bit... annoying, to see 30%+ of the processing time spend on hqx or xbr if you try to use it, when it could be offloaded to GPUs in most devices.

Something like this https://snowflakepowe.red/blog/announcing-librashader-0.1.0/

A externalized/standalone version of the shader pipeline in retroarch where i suppose you can just pass a render surface which it then transforms for you to display.

Although i'm not sure if that project has software fallbacks, which would be necessary for devices without a compatible cpu/standard, so maybe keeping the old versions around would be a necessity.

DominusExult commented 1 year ago

Personally I'm just hoping that https://github.com/libsdl-org/SDL_shader_tools/blob/main/docs/README-SDL_gpu.md gets somewhere :) But generally it would make sense to switch to any shadersystem.

i30817 commented 1 year ago

That's cool, but the very link says it will be part of SDL3 and not backported. Even if SDL came out tomorrow i'm not sure exult could switch quickly.

On the other hand, i'm not quite sure if the library i linked wouldn't be a pain in the ass to actually support in multiple platforms. I suspect i'd need to do another launchpad ppa just to build it to link it to my current exult ppa.

As i mentioned in the first post, i don't think it's possible to remove the current scaler code either, because of devices where software rendering is the only option (either because they have no GPU, a weak GPU, or the case where they have a GPU but it's overheating and they don't want to use it - and don't have a iGPU).

Failing shouldn't crash of course, but the exult menu is already kind of ... bad at telling when a option is not working (audio drivers fallback automatically but still show the wrong option iirc - without fixing this it would be yet another trap). Also timidity driver can't tell when the timidity.cfg/freepaths is not installed either so it outputs 'silence' instead of falling back to FMOPL. Maybe fluidsynth too. Since there is no way to show a message to the user in exult (yet), in reaction to the closing/application of the settings, at least the correct option could be shown next time the menu is open.

i30817 commented 1 year ago

Also i forgot. A year ago or so, dosbox gained upstream shader support and I used the shaders in this repository for my ppa build, which might be a 'lighter' option that the whole libretro nonsense, with some already done and tested glsl shaders.

It has a equivalent of xbr (xbr_lv2_3d, xbr_lv2_noblend, xbr_lv2, xbr_lv3), but a lot of other stuff i mostly don't know what it is, except some curved screen nonsense and pixelating shimmer things.

https://github.com/tyrells/dosbox-svn-shaders

DominusExult commented 1 year ago

Just a note about SDL3, AFAIU at the moment switching would be fast as most functions just uses new names with old stuff being cut. I don't think that would affect us.

The DOSBox approach is interesting, would need some restructuring of how we render.

And of course disabling current scaler engine, as you wrote.

i30817 commented 1 year ago

On that repo the guy says you 'have' to choose a path to the shader and it doesn't have simple names, but this is just a question of minimal amounts of code since the shaders are self contained.

Dosbox by default stops looking if it can't find the shader either in the given path, or in dosbox config .dosbox/glshaders/nameofshader, or the current dir. I simply added a 'default' linux path for my build and allowed the user to use the 'simple' shader name to get them, with the files installed by the packaging. I also remember changing the names of the files slightly so they're less cryptic, with 'ctr_' prefixes for shaders that alter the curvature of the screen.

I also kind of remember the pixel perfect one was good for not distorting the image in fullscreen, which i guess is not a problem for exult, since it can adapt the viewport.

like so:

--- a/src/dosbox.cpp
+++ b/src/dosbox.cpp
@@ -478,7 +478,12 @@ void DOSBOX_Init(void) {
                      "Can be either an absolute path, a file in the \"glshaders\" subdirectory\n"
                      "of the DOSBox configuration directory, or one of the built-in shaders:\n"
                      "advinterp2x, advinterp3x, advmame2x, advmame3x, rgb2x, rgb3x, scan2x,\n"
-                     "scan3x, tv2x, tv3x, sharp.");
+                     "scan3x, tv2x, tv3x, sharp, pixel_perfect, pixel_perfect_scanlines, pixellate,\n"
+                     "crt_aperture, crt_caligari, crt_easymode, crt_easymode_tweaked, crt_fakelottes,\n"
+                     "crt_fakelottes_tweaked, crt_geom, crt_geom_tweaked, crt_hyllian,\n"
+                     "crt_lottes, crt_lottes_fast, crt_lottes_fast_tweaked, crt_lottes_tweaked,\n"
+                     "crt_nes_mini, crt_pi, crt_scanline, crt_yee64, crt_yeetron, crt_zfast,\n"
+                     "xbr_lv2_3d, xbr_lv2_noblend, xbr_lv2, xbr_lv3.");
 #endif

    secprop=control->AddSection_prop("cpu",&CPU_Init,true);//done
--- a/src/gui/render.cpp
+++ b/src/gui/render.cpp
@@ -708,9 +708,11 @@ void RENDER_Init(Section * sec) {
    if (f.empty() || f=="none") render.shader_src = NULL;
    else if (!RENDER_GetShader(sh->realpath,shader_src)) {
        std::string path;
+       std::string path2;
        Cross::GetPlatformConfigDir(path);
        path = path + "glshaders" + CROSS_FILESPLIT + f;
-       if (!RENDER_GetShader(path,shader_src) && (sh->realpath==f || !RENDER_GetShader(f,shader_src))) {
+       path2 = "/usr/share/dosbox/glshaders/" + f;
+       if (!RENDER_GetShader(path,shader_src) && !RENDER_GetShader(path2,shader_src) && !RENDER_GetShader(f,shader_src)) {
            sh->SetValue("none");
            LOG_MSG("Shader file \"%s\" not found", f.c_str());
        }