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.
[posila] [2.0.13] Some nuclear item glow sprites cause large draw call counts and negatively impact FPS
[posila] [2.0.13] Some nuclear item glow sprites cause large draw call counts and negatively impact FPS
- Attachments
-
- Game screenshot with perf debug options
- factorio_Q67wzUgXB2.jpg (754.23 KiB) Viewed 845 times
-
- factorio-current.log
- log file
- (17.53 KiB) Downloaded 18 times
-
- Screenshot of RenderDoc showing that it fails to batch the item drawing.
- qrenderdoc_Yx1jHExCmk.png (292.24 KiB) Viewed 845 times
-
- the batch cruncher.zip
- Test scenario
- (1.96 MiB) Downloaded 18 times
Re: [posila] [2.0.13] Some nuclear item glow sprites cause large draw call counts and negatively impact FPS
Thanks for the report.
Good catch, fixed for 2.0.16
Good catch, fixed for 2.0.16
Re: [posila] [2.0.13] Some nuclear item glow sprites cause large draw call counts and negatively impact FPS
So this still happens with mods like https://mods.factorio.com/mod/science-pack-glow-reborn
Is there a way to fix it from the modding side?
Is there a way to fix it from the modding side?
Re: [posila] [2.0.13] Some nuclear item glow sprites cause large draw call counts and negatively impact FPS
zebez wrote: ↑Sat Nov 09, 2024 7:43 amSo this still happens with mods like https://mods.factorio.com/mod/science-pack-glow-reborn
Code: Select all
flags = { "light" }
In 1.1, draw_as_light sprites were rendered in separate queue to different render target (light map), so it was beneficial to sort them to separate atlas from regular sprites, hence "light" flag. In 2.0, both regular sprites and draw_as_light sprites are mixed in the same queue and rendered to both regular render target and the light map, and the flag just modifies how they are blended to the render targets, so layers of one thing should be ideally organized to the same atlas to allow sprite batching.
Re: [posila] [2.0.13] Some nuclear item glow sprites cause large draw call counts and negatively impact FPS
That worked wonderfully, thank you!