-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Enforce calling RenderingDevice code from rendering thread in TextureRD classes #87721
Enforce calling RenderingDevice code from rendering thread in TextureRD classes #87721
Conversation
Good catch. I would change this slightly because this means the property doesn't change at all until the rendering thread can process this. Which means that I can call The same with the texture object, it will now be created late, while we likely need it earlier when it is being assigned to materials etc. This is why So I think we should assign the |
We can't call That being said, I'm not too worried about creating the texture object. We create a placeholder if the user calls This has made me realize that godot/servers/rendering/rendering_server_default.h Lines 159 to 168 in 4577dfd
Which will create the texture on whatever thread it is called from. But it has to be called from the rendering thread because it immediately calls godot/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp Lines 1469 to 1474 in 4577dfd
So I think the correct solution here is going to be a mix of things Let's assign Then, we need to also stop using |
@clayjohn it only calls
does? |
Or is it the |
Ya, in the RD renderers |
Thanks! |
Needed for #87590
This fixes an unreported bug in the TextureRD classes where RenderingDevice functions could get called from any thread. Currently we allow doing this as we guard every RD function that cares about threads behind a mutex. However in #87590 we are moving to a much more efficient approach which is to have thread guards on single-threaded functions and to have nothing on the functions that can be called from any thread.
Accordingly, certain functions will need to be called from the rendering thread using
call_on_render_thread()
. The overall impact of this change is minimal.