-
-
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
Fix threading bug in Vulkan rendering device #78794
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. From reviewing related code, it seems like everything called during a draw list needs to be made thread safe.
The Incidentally I don't think holding this lock is a major issue, because it's vulkan, everything is deferred, the actual draw_list calls are super fast. The only downside of it is that it means if people call draw_list_begin without a matching draw_list_end, or try to add things to the same draw_list across multiple threads, bad things will happen. But really there isn't any non-stupid use case for that until or unless we add support for multiple draw lists on one renderingdevice. This bug was the only thing I caught when I went through it, I think I was quite thorough - I stepped through things in debugger also. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this fixes threading bugs, it's fine I guess. In any case, we have to reassess the whole thread safety topic in RD to determine and enforce specific design goals.
Thanks! And congrats for your first merged Godot contribution 🎉 |
Cherry-picked for 4.1.1. |
This is a fix for the following bug:
#78786
The bug was that:
draw_list_switch_to_next_pass
was not holding the lock, and was calling_draw_list_free(&viewport);
and
draw_list_allocate
with stuff in between, all mid a single multiple pass draw-list.The free and allocate functions release and acquire the lock. So in between the two calls, other stuff was happening (other draw lists being started and ended), which meant bad things happened because the vulkan state goes bad (segfaults in graphics drivers on my machine).
This is I think a pretty trivial bugfix - deffo for 4.2, would be great for 4.1 if poss?