-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Surface tool is exponentially slower when threaded #56524
Comments
Is the slowdown around |
OpenGL shaders don't play nice with threads... |
SurfaceTool runs on the CPU, but the mesh needs to be uploaded to the GPU so it can be rendered. There is no shader compilation involved here. |
I went and checked the time taken for each function individually and in a funny twist of fate it was everything but the surface tool that was causing the slowdown. The 2 functions causing the slowdown are no threading:
threading:
Could someone advise me if these have been documented elsewhere or if I will open an issue for each individually |
|
@DataPlusProgram Can you use threads for mesh generation, but go back to a single thread (that waits for the multiple mesh generation threads) to generate the trimesh collision and lightmap UV2? |
Originally I made it threaded because the editor's importing functionality isn't exposed to GDScript so I have to create a thread and wait for the editor to import each file (generation of .stex, .md5, etc..) on its own time. Although it's not really a trivial fix I think I can rewrite the plugin in such way that it does a threaded pre-pass importing of resources and after that it will be free to generate meshes in a non-threaded environment. |
I've noticed that sometimes the threaded mode is [not] really threaded in my tests. I got blocked so I moved on. |
Can someone spare a minimal reproduction project? I'd like to take a look as I suspect this one is a synchronization problem just like #57148 |
You can probably use the MRP here #51311 (comment) |
@DataPlusProgram you can see my comment regarding slowdown coming from synchronization on For your case, creating mesh IMO, you should limit implementation running on the thread to creating Once this is done, you should do the remaining stuff in the main thread (without extra thread). So you'd just have to iterate over that stored |
hi all, do I understand correctly that the issue is that only I ran into the same issue and also found out that MeshDataTool's surface read/write methods are also extremely slow in a separate is there any good solution to this problem today in 3.5? edit: shouldn't this issue get the bug label instead of discussion? |
It may be an engine limitation that can't be lifted, and can only be documented, especially in 3.x. OpenGL has a lot of limitations around threading, as it's not thread-safe by design. |
thanks for the feedback @Calinou. does this mean there might be improvements regarding this issue in godot 4? |
I'd suggest trying the same code in 4.0 and see if it runs any better. |
I hope #69723 will improve the performance of that class |
amazing, so we might see improvement in 3.6 already. thanks! |
Godot version
3.4.2.stable
System information
Windows 10, GLES3, Radeon 5700xt, R7 5800
Issue description
Fast performance with no threading:
Slow performance with threading:
Steps to reproduce
I am aware of #51311 but the difference here is that
SurfaceTool.append_from()
is not being invoked.Here is how the code is laid out
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: