libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
194 stars 40 forks source link

idTech 4 Games - 40-50 FPS Bug #167

Closed d10sfan closed 2 years ago

d10sfan commented 2 years ago

With id Tech 4 games (tested with Quake 4 and Prey (2006), using sdl12-compat (this also happened with sdlcl as well), will cause the game to launch with the fps stuck at 40-50 fps. After launching the game a few times, usually three or 4 times, the game will launch normally at 60 fps. Running without sdl12-compat makes the game not have this issue.

I have some log files from launching the game with SDL12COMPAT_DEBUG_LOGGING=1 set.

quake4-40fps.log quake4-60fps.log

parkerlreed commented 2 years ago

Log file for 45-50 FPS Prey 2006 with sdl12-compat

https://gist.github.com/parkerlreed/09c437bcdd7fa2ed3022d0110224052c

As mentioned launching a few times in a row can make it go to 60. Starting a game and just pausing it can (and usually does) drop it back down to the 45-50 error state.

60 FPS launch https://gist.github.com/parkerlreed/ca77613e0677b600187a46c4adbd5ad7

sulix commented 2 years ago

Wow: this looks like a nasty issue.

I was able to reproduce it, but I also was able to reproduce it under the real SDL 1.2, so I don't think this is an sdl12-compat bug.

I can get a smooth 60fps by setting com_fixedTic 1 and SDL12COMPAT_SYNC_TO_VBLANK=1, though that's obviously dependent on the system refresh rate, and apparently can cause problems with the game physics (which are supposed to run at ~62 Hz?)

(A quick look over the Doom 3 source and general complaints online suggests the timing code in the game is pretty dodgy anyway. It looks like it's using some combination of gettimeofday() (in its 32-bit variety which will break in 2038), and rdtsc for time-related stuff, and doesn't use SDL at all.)

d10sfan commented 2 years ago

Interesting, it may be because it's a bit sporadic not seeing it on the real sdl 1.2.

I was able to use that as well to get a nice smooth 60 fps when it works, although it'll still launch at 40-50 fps randomly as well.

Source ports like dhewm3 and rbdoom-3-bfg seemed to have fixed these issues, since I haven't seen anything like that with those, although that's easier with the source code.

arrowgent commented 2 years ago

linux quake4 could not find sdl12-compat is it just me or are the SDLCL patches specific to id

this will just be a note here, if anyone searches quake4


normal quake4

~/quake4 $ cat quake4

#!/bin/sh
# Needed to make symlinks/shortcuts work.
# the binaries must run with correct working directory
cd "/home/games/quake4/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/games/quake4/:."
exec ./quake4.x86 +disconnect "$@"

~/quake4 $ ldd quake4.x86|grep SDL libSDL-1.2.so.0 => /usr/lib/i386-linux-gnu/libSDL-1.2.so.0 (0xf7e3a000)

quake4-smp with sdlcl patch

~/quake4 $ cat quake4-smp

#!/bin/sh
# Needed to make symlinks/shortcuts work.
# the binaries must run with correct working directory
cd "/home/games/quake4/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/games/quake4:."
exec ./quake4smp.x86 +disconnect "$@"

~/quake4 $ ldd quake4smp.x86|grep SDL libSDL-1.2.id.so.0 => not found

~/quake4 $ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/games/quake4:." ~/quake4 $ ldd quake4smp.x86|grep SDL libSDL-1.2.id.so.0 (0xf7d4d000)


SDL Compatibility Library (SDLCL) Enables native Alt+Tab ↹ and additional screen resolutions by translating SDL 1.2's calls into modern SDL 2.0 on Linux. Replace libSDL library of the game[6] Install libsdl2-2.0-0, libsdl2-2.0-0:i386, libsdl1.2debian, libsdl1.2debian:i386, libudev1, libudev1:i386 packages with your distro's software manager. Backup and remove libSDL-1.2.id.so.0 library in . Download sdlcl-1.0-i686.tar.gz; extract libSDL-1.2.so.0 into . Rename libSDL-1.2.so.0 as libSDL-1.2.id.so.0


copy and rename sdl12-compat to folder = libSDL-1.2.id.so.0 sudo ldconfig ~/quake4 $ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/games/quake4:." ldd quake4smp.x86|grep SDL libSDL-1.2.id.so.0 => not found

fails to find the sdl12-compat library

-rwxrwxr-x 1 games games  221936 Mar 17 08:05 libSDL-1.2.id.so.0*
-rwxrwxr-x 1 games games  363252 May 14  2018 libSDL-1.2.id.so.0_GOOD*
-rwxr-x--- 1 games games 3368297 Apr 23  2019 OLD_libSDL-1.2.id.so.0*

ah. i see

its i386, it wont find it unless compiled :i386 library

ldd quake4.x86|grep SDL libSDL-1.2.so.0 => /usr/lib/i386-linux-gnu/libSDL-1.2.so.0 (0xf7e7d000)