-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polygon2D is extremely slow compared to Sprite rendering #19943
Comments
Note: draw_polygon might require to recompute triangulation everytime, unless the polygon is retained and doesn't change (while sprites are trivial and dont require generic triangulation) |
Every time update() is called or every frame? |
I also think for a few 2D sprites this is kind of slow in general. Though, I don't know the specs of OP's device. |
It's not caused by triangulation in this case. A quick profiling shows that the multiple glBufferSubData and glDrawElements calls (from RasterizerCanvasGLES3::_draw_polygon) cause the FPS drop here. |
I'm working on a PR that reduces the number of glBufferSubData calls by splitting canvas_render_items implementation into the following parts:
Currently there is a per-polygon glBufferSubData call made and that hurts performance. Some preliminary tests for the new approach seem to be promising (with ~4x FPS increase -> 240 vs 60 FPS). |
did batching PR get merged in the end? |
I am having a big problem with this now. What I need to do is to be able to submit triangles as vertices with uvs using However doing so with less than 100 calls on iOS results in less than 20 fps. (It goes down to less than 10 fps when I do it in my game, compared to 60fps with out those calls.) It is disappointing to see that Godot 3 does not do any automatic batching. I would actually want to try and fix this .. or maybe at least write a new add_triangle_array call that would batch them, or maybe use something else that doesn't get impacted by the multiple However, I would like to ask first ... why is iOS using only GLES3? I would like to implement this in only GLES2 which I thought was the recommended mobile renderer, however iOS is hardcoded to use GLES3? |
Just looking at #20077 speedup results:
That is the difference between 2D polygons being actually useful or not. EDIT And looking at the code, it was a very well architected solution which would have been a great framework to later add batching. This and the other batching pull request, if combined into one would be perfect. (Then could optimize to reduce the number of flush calls to allow batching across canvas items.) I don't know why there is such an all or nothing mindset though. reduz wants full batching so doesn't allow this PR even though it would be a good stepping stone. Then the batching PR gets completely reverted because of 9 patch rendering on Android instead of maybe just going back to old rendering for 9 patches? |
is the dragonbones runtime outperforming godot's polygon2d node? |
I can confirm that this is still an issue; adding just 20 polygons was enough to tank my android performance. I managed to work around this problem by rendering the polygons in a viewport once, and using the resulting texture to draw the polygon with a sprite node instead. This entirely solved the problem for me, but wouldn't work if your polygon geometry changed every frame. |
I'm not using |
This should be vastly improved with the new Vulkan backend. |
@kjav can you share a bit more details? something like this?: |
I am not quite shure, whether this is part of the same issue... But using Custom StyleBoxFlat Ressources on Control Elements also impacts performance really bad. Just three elements drop the performance to 30-40fps on my S7 Edge. So this is basically unusable on mobile. |
@dekaravanhoc Can you take screenshots of the StyleBoxFlat properties you've used? If using rounded corners, you may want to decrease their detail level. (Also, StyleBoxFlat doesn't rely on Polygon2D under the hood. It uses |
Shure. But I also changed the settings to test, whether transparency or anti-aliasing might be the reason, and neither of it is. Also the Label does not use rounded corners and just hits the performance as bad as the ProgressBar.
|
I think I'm facing the same problem. I wrote some code which instantiates about 100 Polygon2D objects from a Polygon2D object scripted to mutate geometry in reaction to mouse movement and it's running incredibly slow... |
@jjgh have you tried with 3.2? There was a PR merged that vastly improved polygon rendering. Also try reducing rendering/limits/buffers/canvas_polygon_buffer_size_kb and rendering/limits/buffers/canvas_polygon_index_buffer_size_kb in the project settings |
Thanks for your advice @clayjohn but unfortunately using 3.2 beta 3 did not make things better. |
@clayjohn changed the code to only draw triangles so that bad polygons aren't possible anymore and it now works really fast so I think I can confirm that in my case the slowness was only caused by the debugger activity. |
@clayjohn This worked very well for me! I'm using 3.2 to make a a polygon-heavy game and was stuck at ~25FPS with the default of 128Kb buffer for both values: Switching both buffers to 32Kb moved this number up to ~40FPS! FYI, this is the public 3.2 release running on a Moto X4 android device. Thank you for all the work you and the other Godot developers have done. It's great to see such an active community. |
For my use case, I was still seeing fairly bad performance after 3.2— I am rendering a large number of complex Here's a gist that renders an arbitrary polygon as a |
This will be fixed by #42119. Running the example project at 1x, polygon 2D was about 75% of the speed of sprites, but at 2x or higher the speed was the exact same (likely because at that range it becomes fill-rate limited). |
Fixed by #42119. |
Godot version:
3.04
OS/device including version:
Windows 10 / Surface Pro 4
Issue description:
Polygon2D seems alarmingly slow when compared to Sprite or draw_rect().
Here are some results from a small test scene I made:
![godot3_poly2d_performance](https://user-images.githubusercontent.com/8040820/42241241-8ced0604-7f12-11e8-9051-cced1068b495.jpg)
I've had the same results in a game project where I've attempted to create levels from Polygon2D objects. Usually optimized meshes would be very useful for optimizing fillrate, but this performance seems to make it impossible to utilize. I feel like this is going to hurt many graphically demanding 2D-projects.
Steps to reproduce:
Comparing between Sprite / Polygon2D and draw_rect() / draw_polygon() seems to give similiar results.
Minimal reproduction project:
polygon2d_performance.zip
The text was updated successfully, but these errors were encountered: