-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Support creating GPU textures shared with other APIs #14157
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
base: main
Are you sure you want to change the base?
Conversation
2c8b9a0
to
1164ac6
Compare
Don't have time to get into too many details here, but I wonder - is it unreasonable to try using the native video API extensions in Vulkan/D3D/Metal instead of doing all this mess with passing handles between an ffmpeg application? I'd have to imagine that's just what ffmpeg is doing anyway. |
Yeah, there’s a lot of work going on in ffmpeg to support different codecs and in some cases do bitstream parsing that it doesn’t make sense to shove into SDL. In addition, this is a generally useful way to do interop with other projects without having to expose internals. |
(this also supports cross-process interop which is interesting for a number of applications) |
I'm not sure about the shape of the other APIs but Vulkan video can handle bitstream parsing and decoding, as seen in this post: I think it would be reasonable to limit video support to formats that native hardware decode can handle. I'm mostly just very trepidatious about allowing external contexts. I've done a lot of work to put guard rails on the GPU API but as soon as you expose contexts that's all gone. Modern graphics APIs are very sensitive to synchronization and layout issues and we cannot control that with external contexts at all. When we added external texture support to FNA3D it was a technical mess that I regretted immediately. I would like to exhaust all possible designs and options before resorting to this. |
I’m fine with that. My immediate motivation is to have the GPU renderer replace the metal, D3D12 and Vulkan renderers, but the metal renderer is used on iOS and macOS for playback of video. We support h264 and HEVC, and on macOS videotoolbox does require some basic parsing of the bitstream to set up the decode context. If video decode were built into the GPU API, that would certainly reduce the number of external interop use cases. In the meantime I’ll check in the first commit which is just about interop between the GPU API and the GPU renderer and we can come back to the rest of this later. |
This allows sharing textures from other APIs with the GPU API
@thatcosmonaut, another use case was mentioned in #12617, where they're trying to integrate CEF for web based rendering. This is actually a pretty common use case for games that have React based UI and web authoring flows. |
I currently have several issues with the proposed API:
I have not used shared textures with Vulkan so I unfortunately cannot provide any guidance for backend. |
I still have to implement Vulkan texture import, but D3D12 and Metal work great!
Fixes #14077