-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
GPU: Make SDL_SetGPUBufferName and SDL_SetGPUTextureName thread safe #11929
GPU: Make SDL_SetGPUBufferName and SDL_SetGPUTextureName thread safe #11929
Conversation
For consistency with how these naming APIs work in some other places you probably want to strdup the name, since it could be a temporary stack buffer being passed in. Or document that it needs to stay alive indefinitely, but that seems worse. You should be able to free the name once you actually pass it through to vulkan though. |
Good call. |
This code looks fine, but are we guaranteed that the main thread is a safe thread to call this on? Is there a possibility of interacting with other graphics calls being made off the main thread? |
Skimmed the Vulkan spec again and saw:
This might be more problematic than I thought. I'm not sure that we have any way to guarantee this for the client. |
What does externally synchronized mean? Just that it can only be done by one thread at a time? |
@danginsburg, do you have any insight here? |
Is the thread safety of these mainly hard to reason about because they can be called at any point after creating the resource? Would making resource names be part of buffer and texture creation SDL_Properties instead solve that? Although I suppose it might be too late to do that now.. |
It means the handle should only be accessed by one thread at a time. |
Yeah I think that would be a good solution. As long as the thread safety issue on the existing functions is clearly documented (which it currently is) we could just add this as a creation property and sidestep the safety issues that way. |
Agreed. Having the name as a creation property makes a lot of sense. |
It should, because if we call the Vulkan debug name function before returning from the creation function there's no way for the client to even have a handle that they would need to synchronize. |
In my repro case the texture wasn't externally visible yet or being used. The synchronization hazard is on the device I think. |
Closing this in favor of #11946 |
Resolves #11927