Grid Sage Forums

Grid Sage Forums

  • November 21, 2024, 11:04:05 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

LINKS: Website | Steam | Wiki

Author Topic: Performance Mods for Cogmind [STABLE] OpenGL, modern CPUs (2007-2013+) (4k res)  (Read 13600 times)

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile

EDIT: Loading time also improved with separate mod
EDIT 2: You must register for the forum to see attachments on posts (and download them)


The CPU mod can be downloaded here https://github.com/aronson/SDL-1.2/releases

The "GPU" mod can be downloaded here https://github.com/aronson/sdl12-compat/releases

Hello fellow Cogminders, would you like to get anywhere between 20-400+% measurable FPS speedups on your machine?

I can make Cogmind draw on your screen faster (FPS++)!

I have found the source code to and made numerous modifications to the SDL.dll file powering the graphics for the game.

Are you running on an older/slower machine, Wine on Linux, or macOS?
Or might you be streaming Cogmind on Twitch.tv or recording it with a program like OBS or even the built-in Windows recording feature for games?

Do you have a computer that chugs a little bit now and then when you pan the map with shift and mouse aggressively? If it lags in this situation, it probably lags in other situations too. One that comes to mind is those beautiful win animations -- you rarely see them, but on WINE on regular ol' Linux you might have a 15 FPS experience as you hit that lovely high note if you have a computer from around 2014, not 2022, and you have your own reasons for not running Windows.

One can display an FPS counter with Ctrl+F3 in the titlebar and above your core to track FPS as you play, if you feel it's lagging a little bit compared to other video games on your machine.

If any of these situations apply to you, I highly suggest you try out my experimental builds of the Simple DirectMedia Library (SDL) attached to these posts with your copy of Cogmind. You can unzip these files and drop the DLLs contained within next to Cogmind. Note, this will overwrite your original files! Please either rename them to something like SDL.dll.bak first so you can restore them later, or you can click "validate local files" in Steam through the game's properties to return to the official Cogmind CPU renderer.

Please do not run random DLLs off the internet
After half a decade working as a cybersecurity engineer in network forensic analysis for a US department of defense contractor, I urge you, do not run binary files like DLL's and EXE's from sources you don't trust.


Source code is linked here ;)
CPU mod: https://github.com/aronson/SDL-1.2
"GPU" mod: https://github.com/aronson/sdl12-compat https://github.com/aronson/SDL/tree/cog-sdl2
Original sources provided by Kyzrati: https://www.gridsagegames.com/forums/index.php?topic=1566

Don't report new bugs to Kyz if you use this
I'm very interested in new bugs, but if you use this who knows what will happen. I have a pretty good idea -- massive speedups for a lot of use-cases that are outside of Cogmind but make sense in 2022 when we are running operating systems with multi-tasking. If something weird happens, restore the old DLLs and try it again first. If you see a difference, great, feel free to let me know and I'll see what I can do :) If you don't see a difference and it's buggy, well, nothing to do with me!
There is a memory leak of like a few bytes, that's why it's in the archive name. It doesn't compound unless you change the window size or borderless fullscreen/etc. setting as far as I understand, but I have not yet fixed it.
« Last Edit: November 27, 2023, 05:23:23 AM by Luigi »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind
Re: Unofficial GPU support for Cogmind [ALPHA]
« Reply #1 on: January 09, 2022, 01:45:12 AM »

Extremely impressive work, Luigi :)

Was amazing to see how fast you hacked this out despite being totally unfamiliar with the relevant tech.

Note that Cogmind doesn't feel much different beyond 60 FPS (there are minor differences in a few animations), and it's capped there by default, so anyone wanting to take advantage of extra FPS offered here would also need to uncap theirs in the advanced options, unless you're not actually reaching that cap to begin with, which only really happens on systems over 10 years old.

As Luigi mentions, one exception might be those using non-Windows systems, who are more likely to get something out of this since those systems can often benefit from Cogmind using a hardware-based graphics solution as opposed to the software approach it's built with (although hardware-based solutions tend to run into more issues that need troubleshooting). Also this can be useful if you're streaming with a web cam and green screen etc, depending on your software.

There is a memory leak of like a few bytes, that's why it's in the archive name. It doesn't compound unless you change the window size or borderless fullscreen/etc. setting as far as I understand, but I have not yet fixed it.
Yeah this and a few other tiny memory leaks are present in Cogmind, but since they don't compound and are part of the library rather than stuff that I wrote myself, I never bothered with them. (Dynamically resizing the window isn't something you can do while running the game anyway, so that particular function is only called when switching fullscreen modes, which isn't something people are repeatedly doing while playing anyway :P)
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile
Re: Unofficial GPU support for Cogmind [BETAv2] DirectX and OpenGL
« Reply #2 on: January 27, 2022, 03:51:17 PM »

Keyboard fix for GPU mod on macOS

One can "just do it in the OS" with Karabiner-Elements, formerly known as KeyRemap4MacBook -- a free, open-source application that allows for complex scripting.

It can be obtained here
https://karabiner-elements.pqrs.org/

For a simple fix, press the "Add Item" button, choose "right_shift" and set it to "left_shift". Easy peasy! Included is a screenshot of how it should look when you're done.
Spoiler (click to show/hide)

Works great on my machine! I will learn how to apply it to only CrossOver, and hopefully only COGMIND.EXE at some point. This works for me for now, I hope it helps others!
« Last Edit: July 07, 2023, 05:34:57 PM by Luigi »
Logged

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile

Cogmind with Software (CPU) Blitting using SSE4.1 and AVX2 is now available!
Fastest option out there on Windows! No hacks needed, drag and drop
Note: it's also attached to the first post

What does that mean? If you have a CPU from 2013 or later this will get you free performance under load and at idle. If your CPU is older than that... you still get free performance! Isn't that great?

JellySquid and a number of other talented programmers worked with me to create this build of SDL. I have gone from 15 FPS under stress at 4k on my Ryzen 7 5800X to 77 FPS. Yeah. Crazy.

YMMV, have fun! Sources are on my github.
https://github.com/aronson/SDL-1.2

Note: This new stable release also includes debug symbols
« Last Edit: March 01, 2022, 05:48:43 AM by Luigi »
Logged

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile
Re: Performance Mods for Cogmind [STABLE] OpenGL, modern CPUs (2013+)
« Reply #4 on: February 18, 2022, 05:07:59 AM »

Faster loading times are here!

[EDIT]: Below info is outdated, but the new DLL attached here is what you want

Try the later AVX build if your machine was made after 2013 or is not Apple Silicon.


The game ships a real old libvorbis-0.dll that doesn't have modern optimizations enabled.

I'm down from 7 minutes on my M1 MacBook to 30 seconds. It's ~100% faster now on older Intel-compat PCs (<2013).

Drag and drop and overwrite per usual.

Sources can be obtained from Xiph. I compiled with -O3 -msse4.1 -ffast-math
Note: The original release was accidentally empty, sorry about that! This new release also includes debug symbols.
« Last Edit: August 01, 2023, 03:44:25 PM by Luigi »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind
Re: Performance Mods for Cogmind [STABLE] OpenGL, modern CPUs (2013+)
« Reply #5 on: February 19, 2022, 05:30:12 PM »

Brilliant work, Luigi :)
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind
Re: Performance Mods for Cogmind [STABLE] OpenGL, modern CPUs (2013+)
« Reply #6 on: February 19, 2022, 05:41:38 PM »

So I was testing this out of curiosity, specifically the new alternative libvorbis build, and was wondering what systems do you reckon these enhancements apply to? I tried swapping in those DLLs to replace the default ones and there was no real difference in startup time for me on Windows 10.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile
Re: Performance Mods for Cogmind [STABLE] OpenGL, modern CPUs (2013+)
« Reply #7 on: February 19, 2022, 06:08:32 PM »

what systems do you reckon these enhancements apply to? [...] there was no real difference in startup time for me


TL;DR: It's for old machines, try the builds below for speedups on modern machines


Now that I test it more, I think this is for emulated systems under Wine, though there are benefits to be had on machines from 2013+ that are less and less obvious on machines more modern. There's overhead when doing some of the basic decoding math that only uses i686-compatible instructions when under so-called "transpiled environments". In addition, think of older processors like an Intel Core Duo, they're going to be chugging doing basic floating point decoding with the old vorbis DLLs.


A modern Ryzen 7? It eats floating point math for breakfast. But if you use intrinsic SSE4.1 support to extend how much data that Intel Core Duo can process to 2 or even 4-wide floating point matrix operations, it's suddenly loading the game much faster. I had a unique case under Rosetta 2 on my Mac where I got the 7 minutes down by ~1300%, but that was because the unaligned memory access of basic decoding incurred massive overhead on every random file load.


The only difference between these DLLs and the ones shipped by Xiph is they won't run on something like a Pentium 4 anymore -- they're using a more expressive/efficient set of assembly instructions that has been evolving for the last few decades. On my Intel Atom Cherry Trail ASUS T100-HA laptop, a little 10" powerhouse from 2013 that runs Cogmind like a dream with the SSE4.1 CPU blitting mod, I went from 60 seconds of loading time to 30 seconds.
« Last Edit: February 21, 2022, 07:48:59 AM by Luigi »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind
Re: Performance Mods for Cogmind [STABLE] OpenGL, modern CPUs (2013+)
« Reply #8 on: February 19, 2022, 06:19:01 PM »

Thanks for the rundown, makes sense.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile
Re: Performance Mods for Cogmind [STABLE] OpenGL, modern CPUs (2007-2013+)
« Reply #9 on: February 20, 2022, 05:19:44 PM »

For those interested in the loading time mod, I offer a new build (this time with debug symbols included!)

AVX is for most modern CPUs (2013+). If your CPU does not support it (rare!) the game will harmlessly crash a few seconds into load.

I went from 20 seconds to 10 seconds load time on my Ryzen 7 5800X. Significant! It's an AVX2 processor.
Similarly, an Intel i7 from 2017 got down to 8 seconds, as did my 2020 i7 MacBook Pro.

Note: I previously offered an AVX2 build but it wasn't any faster than normal old AVX so there's only one release to keep it simple.
Edit: download removed as no longer relevant
« Last Edit: August 01, 2023, 03:45:43 PM by Luigi »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind

Interesting you got such a speed-up. The change for me in that most recent build is less than 1 second faster. Intel i7 10750H.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile

I recently made a lot of progress on figuring out the "loading time" situation. For anyone interested, the fastest possible solution is quite simple and attached to this post. These DLLs are the latest libvorbis and libvorbisfile as of 2021 compiled with Visual Studio 2022 and MinGW respectively, and a number of stable optimizations. They'll work on any machine, and save a few seconds on most machines a few members of the community tested on:

Cracklepappy's i7-4790k reduced load time from 12.5s->8s
My Windows i7 1068NG7 2020 laptop goes from 10.5s->7.5s
aoemica's i7-9700k was a less significant 11.5->11s, could be typical variance but not worse
Kyzrati saved around 2 seconds on his development machine

Cogmind will soon ship with minimal DLLs that work on everyone's machine and solves the Apple Silicon 10 minute load time by default, making the old load-time mods above irrelevant. You only want these DLLs if you want to potentially save a few seconds.
« Last Edit: August 01, 2023, 07:42:00 PM by Luigi »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind

Definitely some great work by Luigi, and yep Beta 13 will release with these enhancements built in, but if you want them before then, get the files from his post!
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile

I found another SDL project that allows Cogmind to render under SDL3.


Apple Silicon users will see at least 10% performance gains under stress, if not more.


Users who use my mod for ReShade support will also gain performance.


Untested compared to the others, YMMV!


Sources are on the libSDL project on github, sdl2-compat and SDL3, release-2.28.x and main tags respectively. Built with MSVC and heavy optimizations.
I have further improvements to make. When they're ready I'll publish a fork and put it in the main post as a replacement to sdl12-compat.


EDIT: New build with the improvements out.
sources: https://github.com/aronson/SDL/tree/blitters-sdl3


EDIT 2: Wow it has massive bugs. Backported my enhancements to SDL2, wrote even more optimizations, and integrated it into the old "GPU" mod -- which by the way only uses GPU at the very final step, who knew! Releasing a new version of the GPU mod that is much faster.
sources: https://github.com/aronson/SDL/tree/cog-sdl2

Use the zip attached or the in the main post for the best experience! It's way faster oh wow. Sometimes it's 1300% faster. This applies to all machines.
« Last Edit: September 04, 2023, 05:37:02 AM by Luigi »
Logged

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile

It's come to my attention that some users are trying to run my mods on systems so old they aren't supported and experiencing a blank screen.


If you seek performance improvements on, say, a 2006 Core2Duo I suggest you use this optimized build of vanilla SDL 1.2 I've made.


My mods assume a minimum processor version, but this mod doesn't. One user has reported it fixed issues they experienced perf-wise.


The sources are from upstream libSDL/SDL-1.2 on github and built off the release-1.12.15 tag.
Logged

Dixius99

  • Unaware
  • *
  • Posts: 1
    • View Profile

Thanks so much for these. I've gotten used to the 5+ minute wait time to get the game started, though I have to tell you I much prefer the ~30-second load time with the updated libvorbis dll.
Logged

Luigi

  • Derelict
  • **
  • Kyzrati Patron
  • Posts: 25
  • Numba one numba two
    • View Profile

Thanks so much for these. I've gotten used to the 5+ minute wait time to get the game started, though I have to tell you I much prefer the ~30-second load time with the updated libvorbis dll.
No problem! 5+ minutes is way too much. I've added the second loading time DLL, libvorbisfile-3.dll, to the main post. It should improve the loading from 30 seconds on macOS to even less.
Logged