[posila] [2.0.13] Some nuclear item glow sprites cause large draw call counts and negatively impact FPS
Posted: Thu Oct 31, 2024 5:24 pm
I decided to run Factorio under RenderDoc on a whim while discussing texture atlassing with friends, and noticed that a belt of nuclear fuel (the train kind) in my base was causing a large amount of draw calls.
I don't know the internals of the engine obviously, but it appears that the world-space “glow” effect on certain items (such as uranium fuel cells) forces the game to be unable to sprite batch, and therefore causes the game to produce tons of draw calls, which negatively affects FPS. It seems that the “glow" effect sprite is put into a different atlas than the normal item one, which forces the game to constantly flip between them.
This notably does not happen for the U-235 item, which despite glowing seems to use its normal item sprite to calculate the glow and therefore doesn't need to access a different texture. I didn't exhaustively test every item but it happens with Uranium fuel cells and Nuclear fuel at least.
I attached a test scenario that just has a ton of these items on belts. Uranium fuel cells absolutely tank FPS when a lot is in view, U-235 is fine. RenderDoc captures are gigabytes so I'll leave those out.
I don't know the internals of the engine obviously, but it appears that the world-space “glow” effect on certain items (such as uranium fuel cells) forces the game to be unable to sprite batch, and therefore causes the game to produce tons of draw calls, which negatively affects FPS. It seems that the “glow" effect sprite is put into a different atlas than the normal item one, which forces the game to constantly flip between them.
This notably does not happen for the U-235 item, which despite glowing seems to use its normal item sprite to calculate the glow and therefore doesn't need to access a different texture. I didn't exhaustively test every item but it happens with Uranium fuel cells and Nuclear fuel at least.
I attached a test scenario that just has a ton of these items on belts. Uranium fuel cells absolutely tank FPS when a lot is in view, U-235 is fine. RenderDoc captures are gigabytes so I'll leave those out.