Add experimental Vulkan render backend - #133
Closed
Superborec22 wants to merge 1 commit into
Closed
Conversation
Add an optional Vulkan backend using the experimental libmpv Vulkan Render API. The OpenGL backend remains the default. Vulkan rendering supports physical-device selection, Wayland swapchains, and asynchronous presentation using per-image semaphores.
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.
Summary
This adds Vulkan rendering backend to mpvpaper.
mpvpaper now creates its own Vulkan instance, device, Wayland surface, swapchain and presentation loop, and passes Vulkan image targets to a Vulkan-capable libmpv render API.
The existing EGL/OpenGL backend remains the default.
Relation to #123
I originally opened #123 while investigating high VRAM usage and GPU selection in a dual-GPU setup.
That PR was written quickly as a narrow workaround. Project activity appeared low enough that I was unsure whether a larger rendering refactor would be reviewed, and I also did not want to first track down the quoting problem in the generic
-oparser. I therefore exposed the relevant options directly.That was useful for settings such as
hwdec=vulkan, which reduced VRAM usage on my system, but it was never intended to claim that mpvpaper itself was rendering through Vulkan. The final render context was still OpenGL.The review correctly noted that real Vulkan support required changes to mpvpaper's initialization and rendering pipeline. This PR implements those changes.
Usage
mpvpaper \ --gpu-api=vulkan \ --vulkan-device="NVIDIA GeForce GTX 1660 SUPER" \ -o "no-audio loop-file=inf hwdec=vulkan" \ '*' \ wallpaper.mp4New options:
Implementation
The Vulkan backend:
VK_IMAGE_LAYOUT_PRESENT_SRC_KHRThe
-oparser was also updated to preserve quoted and escaped values containing spaces.Dependency
This branch depends on the proposed Vulkan libmpv Render API
Until that API is available in a normal mpv release, this backend requires a custom mpv build and should be considered experimental.
Testing
Tested on Garuda Linux with Wayland/Hyprland, NVIDIA driver 610.43.02, an RTX 4070 driving the compositor and a GTX 1660 SUPER selected for mpvpaper rendering.
4K H.264 videos played and looped correctly with Vulkan hardware decoding.
nvidia-smiconfirmed that mpvpaper was running on the selected GTX 1660 SUPER.The OpenGL backend remains the default and is unchanged unless Vulkan is explicitly selected.