summaryrefslogtreecommitdiffstats
path: root/video/out/vulkan/common.h
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2018-11-10 12:53:33 +0100
committerJan Ekström <jeebjp@gmail.com>2019-04-21 23:55:22 +0300
commit7006d6752d7da21870dfdb2b0d7640a3734f748c (patch)
tree035ca58d22de438e834d212e97b73d03a4248d98 /video/out/vulkan/common.h
parent9f7dcc0726ab635fb34fb7310e54b1aec9467f14 (diff)
downloadmpv-7006d6752d7da21870dfdb2b0d7640a3734f748c.tar.bz2
mpv-7006d6752d7da21870dfdb2b0d7640a3734f748c.tar.xz
vo_gpu: vulkan: use libplacebo instead
This commit rips out the entire mpv vulkan implementation in favor of exposing lightweight wrappers on top of libplacebo instead, which provides much of the same except in a more up-to-date and polished form. This (finally) unifies the code base between mpv and libplacebo, which is something I've been hoping to do for a long time. Note: The ra_pl wrappers are abstract enough from the actual libplacebo device type that we can in theory re-use them for other devices like d3d11 or even opengl in the future, so I moved them to a separate directory for the time being. However, the rest of the code is still vulkan-specific, so I've kept the "vulkan" naming and file paths, rather than introducing a new `--gpu-api` type. (Which would have been ended up with significantly more code duplicaiton) Plus, the code and functionality is similar enough that for most users this should just be a straight-up drop-in replacement. Note: This commit excludes some changes; specifically, the updates to context_win and hwdec_cuda are deferred to separate commits for authorship reasons.
Diffstat (limited to 'video/out/vulkan/common.h')
-rw-r--r--video/out/vulkan/common.h58
1 files changed, 7 insertions, 51 deletions
diff --git a/video/out/vulkan/common.h b/video/out/vulkan/common.h
index a4284f9055..b085fb462c 100644
--- a/video/out/vulkan/common.h
+++ b/video/out/vulkan/common.h
@@ -23,58 +23,14 @@
#define VK_USE_PLATFORM_WIN32_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
+#include <libplacebo/vulkan.h>
// 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 spirv_compiler *spirv; // GLSL -> SPIR-V compiler
- struct vk_cmdpool **pools; // command pools (one per queue family)
- int num_pools;
- struct vk_cmd *last_cmd; // most recently submitted command
-
- // Queued/pending commands. These are shared for the entire mpvk_ctx to
- // ensure submission and callbacks are FIFO
- struct vk_cmd **cmds_queued; // recorded but not yet submitted
- struct vk_cmd **cmds_pending; // submitted but not completed
- int num_cmds_queued;
- int num_cmds_pending;
-
- // Pointers into *pools
- struct vk_cmdpool *pool_graphics; // required
- struct vk_cmdpool *pool_compute; // optional
- struct vk_cmdpool *pool_transfer; // optional
-
- // Common pool of signals, to avoid having to re-create these objects often
- struct vk_signal **signals;
- int num_signals;
-
- // Cached capabilities
- VkPhysicalDeviceLimits limits;
- VkPhysicalDeviceFeatures features;
-
- // Extension availability
- bool has_ext_external_memory;
- bool has_ext_external_memory_export;
+ struct mp_log *pl_log;
+ struct pl_context *ctx;
+ const struct pl_vk_inst *vkinst;
+ const struct pl_vulkan *vulkan;
+ const struct pl_gpu *gpu; // points to vulkan->gpu for convenience
+ VkSurfaceKHR surface;
};