libmpv: add D3D11 render API backend - #17764
Open
kasper93 wants to merge 1 commit into
Open
Conversation
Adds a new render API backend that lets libmpv embedders render directly into an application-owned ID3D11Texture2D. The backend is selected with MPV_RENDER_API_TYPE_D3D11. The embedder supplies the ID3D11Device via MPV_RENDER_PARAM_D3D11_INIT_PARAMS at context creation, and the target texture via MPV_RENDER_PARAM_D3D11_FBO on each mpv_render_context_render() call. Swapchain creation and presentation stay entirely on the caller side. Bumps MPV_CLIENT_API_VERSION to 2.6 and adds the public render_d3d11.h header. Co-authored-by: dragonflylee <dragonflylee@outlook.com>
This was referenced Apr 17, 2026
Member
Author
|
Also for d3d11 on Windows, window embedding may be better solution. Render api is limited. |
Contributor
Member
Author
|
@ikas-mc Thank you for testing. What if you add a |
kasper93
commented
Apr 18, 2026
| :: | ||
|
|
||
| --- mpv 0.40.0 --- | ||
| 2.6 - add MPV_RENDER_API_TYPE_D3D11 render API backend, along with |
Contributor
StageGuard
pushed a commit
to open-ani/mediamp
that referenced
this pull request
Jul 10, 2026
…S and Windows (#37) This PR supersedes #36 and delivers a production-ready mpv playback backend for desktop — macOS and Windows, hardware-accelerated and zero-copy into the Compose scene graph. ## Rendering **macOS (Metal).** A native render thread drives mpv (hwdec=videotoolbox) over an offscreen CGL context into a triple-buffered IOSurface ring, each surface wrapped as an MTLTexture on Skia's device. **Windows (D3D11).** Via the libmpv D3D11 render API (upstream mpv-player/mpv#17764, vendored as a patch on the 0.41.0 submodule; drop it once that PR lands in 0.42). A native render thread drives mpv (hwdec=d3d11va) on its own `ID3D11Device` into a triple-buffered ring of NT-handle shared textures, each opened as an `ID3D12Resource` on Skia's D3D12 device (Compose's default Windows backend). Replaces the legacy synchronous OpenGL path (which required forcing `SKIKO_RENDER_API=OPENGL`). Both platforms draw the frame **zero-copy GPU→GPU** onto the Compose canvas via `nativeCanvas.drawImageRect` — no per-frame GPU→CPU readback — reaching ~240fps at 4K under a full-screen danmaku overlay, with no resize crash. **HDR.** PQ/bt2020 content is tone-mapped down to the 8-bit SDR render target (`gpu-dumb-mode=no` + SDR target primaries/transfer), so 10-bit HDR clips play correctly instead of near-black. ## Runtime & packaging - **Zero-config consumption:** automatic runtime extraction via `LibraryLoader` on first use; a single fat JVM runtime artifact works on all platforms. - **Self-contained artifacts:** macOS bundles the external dylib closure with `@loader_path` rewrites; Windows collects DLL dependencies + a TLS CA bundle; Linux sets `RUNPATH=$ORIGIN` (system libraries otherwise). - FFmpeg is built with exactly the decoders/parsers/hwaccels mediamp needs, including **d3d11va** on Windows. ## Build system - buildSrc: each module's per-platform build configuration (meson/configure flags, toolchain, JNI compile/link, runtime layout) is centralized into one `*Targets.kt`; task implementations are platform-agnostic data consumers. Verified end to end on Windows x64 and Android arm64-v8a. ## Testing - Integration smoke test with pixel-level screenshot verification; playback state-machine unit tests; in-repo zero-config runtime-loading test. ## CI - Multi-platform runtime-jar build + release workflow (windows-x64, linux-x64, macos-arm64). ## Known limitations - Android cross-compilation for mpv is not yet wired into CI. - No windows-arm64 (upstream mpv has no D3D11 render path there). - The Linux runtime still relies on system libraries (libplacebo/libass/…). --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
|
Any progress on it? I have tested the branch and it works well! |
abcming
added a commit
to abcming/mpv
that referenced
this pull request
Aug 11, 2026
Enables mpv to render directly into an application-provided ID3D11Texture2D via the render API, matching the existing OpenGL render API pattern. Changes: - video/out/gpu_next/context.c: D3D11 render context implementation - video/out/vo_libmpv.c: D3D11 FBO setup in done_frame - video/out/gpu/libmpv_gpu.c: D3D11 render API type registration - include/mpv/render.h: D3D11 render param types - meson.build: D3D11 dependency for libmpv Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adds a new render API backend that lets libmpv embedders render directly into an application-owned ID3D11Texture2D.
The backend is selected with MPV_RENDER_API_TYPE_D3D11. The embedder supplies the ID3D11Device via MPV_RENDER_PARAM_D3D11_INIT_PARAMS at context creation, and the target texture via MPV_RENDER_PARAM_D3D11_FBO on each mpv_render_context_render() call. Swapchain creation and presentation stay entirely on the caller side.
Bumps MPV_CLIENT_API_VERSION to 2.6 and adds the public render_d3d11.h header.