You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I found someone trying to use TileMap to represent a cubic region. While this is an edge case, I looked a bit into why they were having trouble with switching which layer of the map to display. To test the effect I created a very large (256x256x256) TileMap and flipped the top layer each frame, clearly showing a slowdown that was not present with less layers. I also disabled every other layer to make sure it wasn't calculation on used layers. Even with all the other layers disabled it still slows down.
So I found set_layer_enabled causes one, and only one call to this loop which attempts to update every extant layer. I figured out this is necessary to do what needs to be done when switching the enabled boolean. While no update is issued when a layer's enabled is set to what it was set before, it only takes one layer actually switching to trigger the update of every layer.
I am not sure why this is so slow when all the layers are disabled. It should only attempt to free quadrants the first time and then there shouldn't be that much overhead from trying to do it again since there's nothing to loop on, but I only looked at rendering code, may be the other branches.
In any case, I am definitely way over my head trying to pinpoint this performance drop. The only thing I can think about is having a flag that tells the layer if it was disabled last frame and skip over it completely if it was disabled and is to remain disabled (within the loop I linked above, not in the set method). But I do not know if this would interfere with the other systems if they are supposed to work even if a layer is staying disabled. Also, I think maybe the flags that already are there can be used for this, but I am not sure. Thus I ask of you what would be a reasonable course of action.
Attached is the Godot Project I used to test. Made with the 4.2 version from the repo compiled on my own for linux (loving how easy that is).
In conclusion, this may be an extreme test case, but if it can be made to run smoothly I think everyone may benefit from it as layer disabling could be very useful if it works as fast as it should in all circumstances.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Today I found someone trying to use TileMap to represent a cubic region. While this is an edge case, I looked a bit into why they were having trouble with switching which layer of the map to display. To test the effect I created a very large (256x256x256) TileMap and flipped the top layer each frame, clearly showing a slowdown that was not present with less layers. I also disabled every other layer to make sure it wasn't calculation on used layers. Even with all the other layers disabled it still slows down.
So I found set_layer_enabled causes one, and only one call to this loop which attempts to update every extant layer. I figured out this is necessary to do what needs to be done when switching the enabled boolean. While no update is issued when a layer's enabled is set to what it was set before, it only takes one layer actually switching to trigger the update of every layer.
I am not sure why this is so slow when all the layers are disabled. It should only attempt to free quadrants the first time and then there shouldn't be that much overhead from trying to do it again since there's nothing to loop on, but I only looked at rendering code, may be the other branches.
In any case, I am definitely way over my head trying to pinpoint this performance drop. The only thing I can think about is having a flag that tells the layer if it was disabled last frame and skip over it completely if it was disabled and is to remain disabled (within the loop I linked above, not in the set method). But I do not know if this would interfere with the other systems if they are supposed to work even if a layer is staying disabled. Also, I think maybe the flags that already are there can be used for this, but I am not sure. Thus I ask of you what would be a reasonable course of action.
Attached is the Godot Project I used to test. Made with the 4.2 version from the repo compiled on my own for linux (loving how easy that is).
TileMapEnableSwitchTest.zip
In conclusion, this may be an extreme test case, but if it can be made to run smoothly I think everyone may benefit from it as layer disabling could be very useful if it works as fast as it should in all circumstances.
Beta Was this translation helpful? Give feedback.
All reactions