Skip to content

Add experimental Vulkan render backend - #133

Closed
Superborec22 wants to merge 1 commit into
GhostNaN:masterfrom
Superborec22:feat/vulkan-implementation
Closed

Add experimental Vulkan render backend#133
Superborec22 wants to merge 1 commit into
GhostNaN:masterfrom
Superborec22:feat/vulkan-implementation

Conversation

@Superborec22

@Superborec22 Superborec22 commented Jul 13, 2026

Copy link
Copy Markdown

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 -o parser. 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.mp4

New options:

--gpu-api=opengl|vulkan
--vulkan-device=<physical device name>

Implementation

The Vulkan backend:

  • selects a physical device by name
  • creates a Wayland Vulkan surface and swapchain for each output
  • renders libmpv directly into swapchain images
  • uses per-image semaphores for asynchronous presentation
  • transitions images to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
  • recreates the swapchain after resize or an out-of-date result

The -o parser 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-smi confirmed that mpvpaper was running on the selected GTX 1660 SUPER.

The OpenGL backend remains the default and is unchanged unless Vulkan is explicitly selected.

image

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant