mpv-player / mpv-player/mpv

Slow startup when using `gpu-api = vulkan` with NVIDIA

Open
#13,019 11 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core:video down-upstream:nvidia
Dominant language
C
Stars
37k
Forks
3.5k
Avg merge
1d 10h
Merged PRs (30d)
22

Description

Important Information
Reproduction steps

Run on Windows with NVIDIA and setup mpv to use Vulkan as GPU API. This is my config file:

vo = gpu-next
hwdec = nvdec or vulkan
gpu-api = vulkan
Expected behavior

The player starts without a delay.

Actual behavior

The player takes about 2 seconds to start and there are reports of delays when creating Vulkan instance and device:

[vo/gpu-next/libplacebo] Spent 1037.710 ms creating vulkan instance (slow!)
[vo/gpu-next/libplacebo] Spent 350.304 ms creating vulkan device (slow!)
When does it NOT happen

Tested on multiple machines and OS. This does NOT happen in the following situations:

  • When running on Linux with AMD using Wayland with the config above
  • When running on Windows with AMD with the config above
  • When running on Linux with NVIDIA using X11 with the config above
  • When running on Windows with NVIDIA (same setup as with the issue) but NOT using Vulkan, for example:
vo = gpu-next
hwdec = nvdec
gpu-api = opengl
gpu-context = win
Log file

The relevant part of the log file (also attached as output.txt):

[vo/gpu-next/vulkan] Initializing GPU context 'winvk'
[vo/gpu-next/libplacebo] Initialized libplacebo v6.338.0-60-g795600a-dirty (API v342)
[vo/gpu-next/libplacebo] Spent 93.897 ms enumerating instance extensions
[vo/gpu-next/libplacebo] Creating vulkan instance with extensions:
[vo/gpu-next/libplacebo]     VK_KHR_get_physical_device_properties2
[vo/gpu-next/libplacebo]     VK_KHR_surface
[vo/gpu-next/libplacebo]     VK_EXT_swapchain_colorspace
[vo/gpu-next/libplacebo]     VK_KHR_external_memory_capabilities
[vo/gpu-next/libplacebo]     VK_KHR_external_semaphore_capabilities
[vo/gpu-next/libplacebo]     VK_KHR_get_surface_capabilities2
[vo/gpu-next/libplacebo]     VK_KHR_portability_enumeration
[vo/gpu-next/libplacebo]     VK_KHR_surface
[vo/gpu-next/libplacebo]     VK_KHR_win32_surface
[vo/gpu-next/libplacebo] Spent 1037.710 ms creating vulkan instance (slow!)
[vo/gpu-next/libplacebo] Probing for vulkan devices:
[vo/gpu-next/libplacebo]     GPU 0: NVIDIA GeForce RTX 3080 v1.3.260 (discrete)
[vo/gpu-next/libplacebo]            uuid: F7:9C:C7:F0:2E:57:EB:B3:87:B4:E8:95:88:06:06:BF
[vo/gpu-next/libplacebo] Vulkan device properties:
[vo/gpu-next/libplacebo]     Device Name: NVIDIA GeForce RTX 3080
[vo/gpu-next/libplacebo]     Device ID: 10de:2206
[vo/gpu-next/libplacebo]     Device UUID: F7:9C:C7:F0:2E:57:EB:B3:87:B4:E8:95:88:06:06:BF
[vo/gpu-next/libplacebo]     Driver version: 88844000
[vo/gpu-next/libplacebo]     API version: 1.3.260
[vo/gpu-next/libplacebo] Using async transfer (queue 1)
[vo/gpu-next/libplacebo] Using async compute (queue 2)
[vo/gpu-next/libplacebo] Creating vulkan device with extensions:
[vo/gpu-next/libplacebo]     VK_KHR_swapchain
[vo/gpu-next/libplacebo]     VK_KHR_swapchain
[vo/gpu-next/libplacebo]     VK_KHR_push_descriptor
[vo/gpu-next/libplacebo]     VK_KHR_external_memory_win32
[vo/gpu-next/libplacebo]     VK_EXT_external_memory_host
[vo/gpu-next/libplacebo]     VK_KHR_external_semaphore_win32
[vo/gpu-next/libplacebo]     VK_EXT_pci_bus_info
[vo/gpu-next/libplacebo]     VK_EXT_hdr_metadata
[vo/gpu-next/libplacebo]     VK_EXT_full_screen_exclusive
[vo/gpu-next/libplacebo]     VK_EXT_descriptor_buffer
[vo/gpu-next/libplacebo]     VK_EXT_shader_atomic_float
[vo/gpu-next/libplacebo]     VK_KHR_video_decode_queue
[vo/gpu-next/libplacebo]     VK_KHR_video_decode_h264
[vo/gpu-next/libplacebo]     VK_KHR_video_decode_h265
[vo/gpu-next/libplacebo]     VK_KHR_video_queue
[vo/gpu-next/libplacebo] Spent 350.304 ms creating vulkan device (slow!)
Sample files

This issue is irrelevant of the media file used.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the gpu-next/libplacebo Vulkan initialization path, especially the winvk context, and compare the instance and device creation timings in the supplied log across the listed Windows and Linux configurations. Done means identifying the cause of the NVIDIA Windows delay and verifying that startup no longer incurs the reported multi-second Vulkan initialization cost.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
desktop-dev, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.