viti95 / FastDoom

Doom port for DOS, optimized to be as fast as possible!
378 stars 26 forks source link

[Question] Why is FastDoom way faster using fdoom13h.exe than using fdoom.exe? #151

Closed vanfanel closed 11 months ago

vanfanel commented 11 months ago

Hello there,

I won't say FastDoom is incredible, because you already know... but it is!

I use FastDoom in many different machines, one of them is the TinyLlamaV2 (https://github.com/eivindbohler/tinyllama2)

The TinyLlama v2 uses the Vortex86VGA chip: https://www.vortex86.com/products/Vortex86VGA This chip seems way enough for DOS games, but the original DOOM.EXE/DOOM2.EXE runs at ~20-25FPS on it, which is a mistery to me (according to the TinyLlama author, it's simply "too slow", but I am not sure on what that means).

However, FASTDOOM using the FDOOM13H.EXE executable, runs at 34-35 FPS on it, more in line with what I would expect from such a machine.

Why/on what circumstances is FDOOM13H.EXE faster than FDOOM.EXE? Maybe that could shed some light on why original Doom is so slow on the Tinyllama.

Thanks!

viti95 commented 11 months ago

In FastDoom there are two possible ways to render the scene, one is directly on the video card VRAM, and the other is render everything on a RAM based framebuffer and then copy the framebuffer to the VRAM.

Fdoom13h.exe uses the second idea (on mode 13h), while fdoom.exe uses the original direct render to VRAM on mode Y.

The framebuffer method is really fast with powerful CPUs (a 500MHz 486 based CPU is way more than Doom requires for high detail 35fps). It also reduces the number of writes to the video card bus (the Vortex86VGA seems slow as it uses 16bit PSRAM). Also there are some video cards that are really slow on Mode Y, such as the Cyrix MediaGX or the Rendition Verite.

vanfanel commented 11 months ago

Ah! So if I understand you correctly, the problem comes from slow writing to video card bus (because of the 16bit PSRAM), so using FASTDOOM13H.EXE uses RAM framebuffer, which reduces the number of writes but uses more CPU, thus resulting on good performance on fast CPUs with slow graphics, am I right?

And... I guess there's no generic way to use a framebuffer in every VGA game, right? Like a TSR or something that makes mode Y into mode 13H.

viti95 commented 11 months ago

I guess that's it. As for other VGA games, you need to either recompile the game (if source code is available) or patch the executable directly. Also some games use some advantages Mode Y have over Mode 13h (for example writing multiple planes at the same time in a single write), so those will require extra work to make it work.

vanfanel commented 11 months ago

Ok, now everything is clear. Thanks @viti95 !