I am drawing some simple tiles to form a map, but when scrolling around the map with a Camera2D I noticed that the motion was not at all smooth so I added a label with a framerate counter. The label says the FPS (Engine.get_frames_per_second()) is capped at 40 but why?
I am running CachyOS Linux, KDE Wayland with a 144hz monitor and a Radeon 9070XT
Things I have tried:
Project FPS cap (0)
All the 4 vsync options in project settings
Desktop refresh rate (set to 144)
Power profile (set to max performance)
Can’t find an answer anywhere online and AI didn’t know either.
After tearing my hair out about 100 different settings trying to get the cap up, including trying x11 and OpenGL instead of Vulkan I have answered my own question.
I discovered this was actually a performance issue. For some reason if you use draw_texture in Godot it does not just simply draw on the canvas and reuse it, it repeats that draw call every single frame even if you don’t call _draw() explicitly at all. It also does not batch these draw calls at all so it just kills performance even on a high end GPU
I had an entire map of 256x256 tiles with multiple layers and Godot was re-rendering that every single frame, redrawing every single quad. Seems like I am forced to use TileMapLayer even though I wanted to make my own custom one that can draw partial tiles and do other things.
You’ll need to give more information because draw calls get batched correctly as long as they can be batched. If you use different textures then they won’t be able to be batched and a tilemap won’t change that (unless you merge the tiles with the atlas merging tool).
I was using AtlasTextures to draw parts of a loaded png, seems like this is not a very efficient way to do things, but anyway I didn’t quite realise how powerful the built in tileset tools are. After switching to the built in TileSetLayer my fps jumped from 40 to 4000 so just slightly more efficient!