From 91f23c7067af248846420854a0dc78c26ea6e300 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 14 Sep 2016 20:54:18 +0200 Subject: vo_gpu: vulkan: initial implementation This time based on ra/vo_gpu. 2017 is the year of the vulkan desktop! Current problems / limitations / improvement opportunities: 1. The swapchain/flipping code violates the vulkan spec, by assuming that the presentation queue will be bounded (in cases where rendering is significantly faster than vsync). But apparently, there's simply no better way to do this right now, to the point where even the stupid cube.c examples from LunarG etc. do it wrong. (cf. https://github.com/KhronosGroup/Vulkan-Docs/issues/370) 2. The memory allocator could be improved. (This is a universal constant) 3. Could explore using push descriptors instead of descriptor sets, especially since we expect to switch descriptors semi-often for some passes (like interpolation). Probably won't make a difference, but the synchronization overhead might be a factor. Who knows. 4. Parallelism across frames / async transfer is not well-defined, we either need to use a better semaphore / command buffer strategy or a resource pooling layer to safely handle cross-frame parallelism. (That said, I gave resource pooling a try and was not happy with the result at all - so I'm still exploring the semaphore strategy) 5. We aggressively use pipeline barriers where events would offer a much more fine-grained synchronization mechanism. As a result of this, we might be suffering from GPU bubbles due to too-short dependencies on objects. (That said, I'm also exploring the use of semaphores as a an ordering tactic which would allow cross-frame time slicing in theory) Some minor changes to the vo_gpu and infrastructure, but nothing consequential. NOTE: For safety, all use of asynchronous commands / multiple command pools is currently disabled completely. There are some left-over relics of this in the code (e.g. the distinction between dev_poll and pool_poll), but that is kept in place mostly because this will be re-extended in the future (vulkan rev 2). The queue count is also currently capped to 1, because of the lack of cross-frame semaphores means we need the implicit synchronization from the same-queue semantics to guarantee a correct result. --- DOCS/man/options.rst | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'DOCS') diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index b08150c6bb..80e7350292 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -4103,10 +4103,6 @@ The following video options are currently all specific to ``--vo=gpu`` and the video along the temporal axis. The filter used can be controlled using the ``--tscale`` setting. - Note that this relies on vsync to work, see ``--opengl-swapinterval`` for - more information. It should also only be used with an ``--fbo-format`` - that has at least 16 bit precision. - ``--interpolation-threshold=<0..1,-1>`` Threshold below which frame ratio interpolation gets disabled (default: ``0.0001``). This is calculated as ``abs(disphz/vfps - 1) < threshold``, @@ -4184,6 +4180,31 @@ The following video options are currently all specific to ``--vo=gpu`` and results, as can missing or incorrect display FPS information (see ``--display-fps``). +``--vulkan-swap-mode=`` + Controls the presentation mode of the vulkan swapchain. This is similar + to the ``--opengl-swapinterval`` option. + + auto + Use the preferred swapchain mode for the vulkan context. (Default) + fifo + Non-tearing, vsync blocked. Similar to "VSync on". + fifo-relaxed + Tearing, vsync blocked. Late frames will tear instead of stuttering. + mailbox + Non-tearing, not vsync blocked. Similar to "triple buffering". + immediate + Tearing, not vsync blocked. Similar to "VSync off". + +``--vulkan-queue-count=<1..8>`` + Controls the number of VkQueues used for rendering (limited by how many + your device supports). In theory, using more queues could enable some + parallelism between frames (when using a ``--swapchain-depth`` higher than + 1). (Default: 1) + + NOTE: Setting this to a value higher than 1 may cause graphical corruption, + as mpv's vulkan implementation currently does not try and protect textures + against concurrent access. + ``--glsl-shaders=`` Custom GLSL hooks. These are a flexible way to add custom fragment shaders, which can be injected at almost arbitrary points in the rendering pipeline, @@ -4590,7 +4611,7 @@ The following video options are currently all specific to ``--vo=gpu`` and on Nvidia and AMD. Newer Intel chips with the latest drivers may also work. x11 - X11/GLX + X11/GLX, VK_KHR_xlib_surface x11probe For internal autoprobing, equivalent to ``x11`` otherwise. Don't use directly, it could be removed without warning as autoprobing is changed. @@ -5020,7 +5041,10 @@ Miscellaneous Media files must use constant framerate. Section-wise VFR might work as well with some container formats (but not e.g. mkv). If the sync code detects severe A/V desync, or the framerate cannot be detected, the player - automatically reverts to ``audio`` mode for some time or permanently. + automatically reverts to ``audio`` mode for some time or permanently. These + modes also require a vsync blocked presentation mode. For OpenGL, this + translates to ``--opengl-swapinterval=1``. For Vulkan, it translates to + ``--vulkan-swap-mode=fifo`` (or ``fifo-relaxed``). The modes with ``desync`` in their names do not attempt to keep audio/video in sync. They will slowly (or quickly) desync, until e.g. the next seek -- cgit v1.2.3