forked from mpv-player/mpv
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. KhronosGroup/Vulkan-Docs#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.
- Loading branch information
Showing
19 changed files
with
3,748 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
#include <assert.h> | ||
|
||
#include "config.h" | ||
|
||
#include "common/common.h" | ||
#include "common/msg.h" | ||
|
||
// We need to define all platforms we want to support. Since we have | ||
// our own mechanism for checking this, we re-define the right symbols | ||
#if HAVE_X11 | ||
#define VK_USE_PLATFORM_XLIB_KHR | ||
#endif | ||
|
||
#include <vulkan/vulkan.h> | ||
|
||
// Vulkan allows the optional use of a custom allocator. We don't need one but | ||
// mark this parameter with a better name in case we ever decide to change this | ||
// in the future. (And to make the code more readable) | ||
#define MPVK_ALLOCATOR NULL | ||
|
||
// A lot of things depend on streaming resources across frames. Depending on | ||
// how many frames we render ahead of time, we need to pick enough to avoid | ||
// any conflicts, so make all of these tunable relative to this constant in | ||
// order to centralize them. | ||
#define MPVK_MAX_STREAMING_DEPTH 8 | ||
|
||
// Shared struct used to hold vulkan context information | ||
struct mpvk_ctx { | ||
struct mp_log *log; | ||
VkInstance inst; | ||
VkPhysicalDevice physd; | ||
VkDebugReportCallbackEXT dbg; | ||
VkDevice dev; | ||
|
||
// Surface, must be initialized fter the context itself | ||
VkSurfaceKHR surf; | ||
VkSurfaceFormatKHR surf_format; // picked at surface initialization time | ||
|
||
struct vk_malloc *alloc; // memory allocator for this device | ||
struct vk_cmdpool *pool; // primary command pool for this device | ||
struct vk_cmdpool *pool_transfer; // pool for async transfers (optional) | ||
struct vk_cmd *last_cmd; // most recently submitted command | ||
|
||
// Cached capabilities | ||
VkPhysicalDeviceLimits limits; | ||
}; |
Oops, something went wrong.