Fixes a memory leak as explained in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30014.
Even if drivers fix all the leaks, we should still memoize, since it's still a dumb memory allocation that should not be necessary, and our existing code to do format query was quite awkward in hindsight.
Some games tend to spam CheckColorSpaceSupport every frame, which we should optimize for.
Also fixes a bug with cleanup should swapchain creation fail for whatever reason. It would be possible for uninitialized mutexes to be destroyed, and the wait thread join might deadlock or segfault.
Fixes a memory leak as explained in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30014. Even if drivers fix all the leaks, we should still memoize, since it's still a dumb memory allocation that should not be necessary, and our existing code to do format query was quite awkward in hindsight. Some games tend to spam CheckColorSpaceSupport every frame, which we should optimize for.
Also fixes a bug with cleanup should swapchain creation fail for whatever reason. It would be possible for uninitialized mutexes to be destroyed, and the wait thread join might deadlock or segfault.