Skip to content

Optimize font related drawing

NerduMiner requested to merge nerdyminer18/srb-2:srb2p_22-fontlut into srb2p_22

Font drawing is easily the most intensive process in the game, and in low computational power situations can impact the performance of the game whenever lots of text is needed to be drawn.

There are two optimizations at play here:

  1. Realizing that font drawing already has its own lump loading procedure, we can abstract further and give font-related items their own fast cache. This allows for the game to access other elements quickly and also means the normal cache is not being constantly pumped and dumped with font graphics.

  2. Realizing that AT MOST, a given font graphic should only require a single operation to nab, we create 5 separate lumpnum_t arrays for the 5 major fonts in the game. The abstracted font loading process then uses these arrays as a fast path to acquiring their lumpnum_t. Knowing the character requested by the game is important, so the currently processed char is passed along through the functions. The function also is capable of generating the cache table at runtime, since it would be impossible to index it beforehand.

This is probably the most insane thing I have ever created, so lots of testing is needed to see if this does indeed beget a performance improvement. I have an i7-7700HQ laptop that is particularly sensitive to intensive processes and a Steam Deck where I can throttle the CPU's power usage as my testing devices. This change will not have any detectable improvements in a stock Vanilla situation. It seems that loading lots of addons(preferably large character packs) exacerbate the performance issues and is where I will be doing a majority of testing. This also may or may not change shop bug behavior.

Edited by NerduMiner

Merge request reports