-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Threaded function is unusual slow under some conditions #86796
Comments
Creating new textures or changing and receiving image data stalls the RenderingServer as data need to be received from or updated on the GPU. You are basically pulling the handbrake on the rendering loop at that point that needs to lock when you query the server api like that randomly from a thread so bad performance is expected. |
What is the alternative? If there is any. |
Try enabling threaded rendering, though it has its drawbacks and instabilities, otherwise don't do it on a thread but on the main thread on request, just generate the data on the thread, you're not going to be able to pass the data to the rendering device at the same time anyway due to communication channels AFAIK, so set up the data and request it to be updated on the main thread, as a producer/consumer setup |
This wont be possible, it is used in a plugin.
The consumer/producer could work, but would increase the complexity a lot, especially when loading 10k or 20k of textures. |
Tested versions
v4.2.1.stable.official [b09f793]
System information
Godot v4.2.1.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 Ti (NVIDIA; 31.0.15.4633) - AMD Ryzen 9 7900X 12-Core Processor (24 Threads)
Issue description
I tried to use
ImageTexture.create_from_image
in a thread and was surprised that the performance is around 10x slower than when being used in the main thread.If the line
self._load_progress = float(idx) / 2000.0 * 100.0
is removed or commented out, the threaded performance drops to 30x slower.Might be related to #36793.
Steps to reproduce
Just run the attached project.
Results are printed to log.
Minimal reproduction project (MRP)
MTSlow.zip
The text was updated successfully, but these errors were encountered: