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
I made a test of my own in GDScript (v4.2.rc1.mono.official [ad72de508]). The test creates 10000 sprites. Then I tested 4 different cases, where the sprites do different things in _process.
debug fps
release fps
sprite doesn't do anything
73
105
flip_h = true in every frame
35
48
frame = 0 in every frame
50
95
flip_h = true and frame = 0 in every frame
31
47
The cost of setting properties even without actually changing them seems to be huge.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
My proposal is to add change guards to Sprite2D's properties. I am not very familiar to Godot's source code, but at least some Control use change guards extensively.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this proposal is approved, I can implement this.
If this enhancement will not be used often, can it be worked around with a few lines of script?
This can be worked around with a few lines of code, but it will not. Just watch any Godot 2D tutorial video from YouTube and there will be some variation of this:
sprite.flip_h=velocity.x>0
I'm also assuming that the performance cost of guarding a property change is higher when made with GDScript than when made in Sprite2D's setter.
So this enhancement would be beneficial in very many 2D games. Also, in my opinion it should be Node's responsibility to not to do unnecessary work if properties do not actually change.
Is there a reason why this should be core and not an add-on in the asset library?
Cannot be done with an add-on.
The text was updated successfully, but these errors were encountered:
My opinion is that if nothing is changed, there is no need to pay the performance price of ERR_FAIL_INDEX, no matter how small it is. So I would like to put change guards before ERR_FAIL_*s whenever suitable.
Describe the project you are working on
My projects are 2D games.
Describe the problem or limitation you are having in your project
A game developer told in a reddit thread (https://www.reddit.com/r/godot/comments/182gdgi/checking_equality_before_assignment_optimization/) how the frame rate increased considerably when a property change guards for Sprite2D were added to the games C# code.
I made a test of my own in GDScript (v4.2.rc1.mono.official [ad72de508]). The test creates 10000 sprites. Then I tested 4 different cases, where the sprites do different things in
_process
.flip_h = true
in every frameframe = 0
in every frameflip_h = true
andframe = 0
in every frameThe cost of setting properties even without actually changing them seems to be huge.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
My proposal is to add change guards to Sprite2D's properties. I am not very familiar to Godot's source code, but at least some Control use change guards extensively.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
For example:
would be changed to
Some properties, like region and frame, already check if the property actually changed, but they still do things like emitting signals:
This would be changed to
If this proposal is approved, I can implement this.
If this enhancement will not be used often, can it be worked around with a few lines of script?
This can be worked around with a few lines of code, but it will not. Just watch any Godot 2D tutorial video from YouTube and there will be some variation of this:
I'm also assuming that the performance cost of guarding a property change is higher when made with GDScript than when made in Sprite2D's setter.
So this enhancement would be beneficial in very many 2D games. Also, in my opinion it should be Node's responsibility to not to do unnecessary work if properties do not actually change.
Is there a reason why this should be core and not an add-on in the asset library?
Cannot be done with an add-on.
The text was updated successfully, but these errors were encountered: