diff options
Diffstat (limited to '')
-rw-r--r-- | video/out/vulkan/common.h | 1 | ||||
-rw-r--r-- | video/out/vulkan/context.c | 49 | ||||
-rw-r--r-- | video/out/vulkan/context_display.c | 44 | ||||
-rw-r--r-- | video/out/vulkan/context_mac.m | 22 | ||||
-rw-r--r-- | video/out/vulkan/context_wayland.c | 2 | ||||
-rw-r--r-- | video/out/vulkan/context_win.c | 21 |
6 files changed, 78 insertions, 61 deletions
diff --git a/video/out/vulkan/common.h b/video/out/vulkan/common.h index d006942..e75cb22 100644 --- a/video/out/vulkan/common.h +++ b/video/out/vulkan/common.h @@ -23,7 +23,6 @@ #define VK_USE_PLATFORM_WIN32_KHR #endif #if HAVE_COCOA -#define VK_USE_PLATFORM_MACOS_MVK #define VK_USE_PLATFORM_METAL_EXT #endif diff --git a/video/out/vulkan/context.c b/video/out/vulkan/context.c index 5087403..82c878a 100644 --- a/video/out/vulkan/context.c +++ b/video/out/vulkan/context.c @@ -25,6 +25,7 @@ #include "options/m_config.h" #include "video/out/placebo/ra_pl.h" +#include "video/out/placebo/utils.h" #include "context.h" #include "utils.h" @@ -37,39 +38,32 @@ struct vulkan_opts { bool async_compute; }; -static int vk_validate_dev(struct mp_log *log, const struct m_option *opt, - struct bstr name, const char **value) +static inline OPT_STRING_VALIDATE_FUNC(vk_validate_dev) { - struct bstr param = bstr0(*value); int ret = M_OPT_INVALID; - VkResult res; + void *ta_ctx = talloc_new(NULL); + pl_log pllog = mppl_log_create(ta_ctx, log); + if (!pllog) + goto done; // Create a dummy instance to validate/list the devices - VkInstanceCreateInfo info = { - .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, - .pApplicationInfo = &(VkApplicationInfo) { - .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, - .apiVersion = VK_API_VERSION_1_1, - } - }; - - VkInstance inst; - VkPhysicalDevice *devices = NULL; - uint32_t num = 0; - - res = vkCreateInstance(&info, NULL, &inst); - if (res != VK_SUCCESS) + mppl_log_set_probing(pllog, true); + pl_vk_inst inst = pl_vk_inst_create(pllog, pl_vk_inst_params()); + mppl_log_set_probing(pllog, false); + if (!inst) goto done; - res = vkEnumeratePhysicalDevices(inst, &num, NULL); + uint32_t num = 0; + VkResult res = vkEnumeratePhysicalDevices(inst->instance, &num, NULL); if (res != VK_SUCCESS) goto done; - devices = talloc_array(NULL, VkPhysicalDevice, num); - res = vkEnumeratePhysicalDevices(inst, &num, devices); + VkPhysicalDevice *devices = talloc_array(ta_ctx, VkPhysicalDevice, num); + res = vkEnumeratePhysicalDevices(inst->instance, &num, devices); if (res != VK_SUCCESS) goto done; + struct bstr param = bstr0(*value); bool help = bstr_equals0(param, "help"); if (help) { mp_info(log, "Available vulkan devices:\n"); @@ -111,7 +105,9 @@ static int vk_validate_dev(struct mp_log *log, const struct m_option *opt, BSTR_P(param)); done: - talloc_free(devices); + pl_vk_inst_destroy(&inst); + pl_log_destroy(&pllog); + talloc_free(ta_ctx); return ret; } @@ -207,8 +203,7 @@ bool ra_vk_ctx_init(struct ra_ctx *ctx, struct mpvk_ctx *vk, VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME, VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME, VK_KHR_VIDEO_QUEUE_EXTENSION_NAME, - // This is a literal string as it's not in the official headers yet. - "VK_MESA_video_decode_av1", + "VK_KHR_video_decode_av1", /* VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME */ }; VkPhysicalDeviceDescriptorBufferFeaturesEXT descriptor_buffer_feature = { @@ -310,11 +305,6 @@ char *ra_vk_ctx_get_device_name(struct ra_ctx *ctx) return device_name; } -static int color_depth(struct ra_swapchain *sw) -{ - return 0; // TODO: implement this somehow? -} - static bool start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo) { struct priv *p = sw->priv; @@ -364,7 +354,6 @@ static void get_vsync(struct ra_swapchain *sw, } static const struct ra_swapchain_fns vulkan_swapchain = { - .color_depth = color_depth, .start_frame = start_frame, .submit_frame = submit_frame, .swap_buffers = swap_buffers, diff --git a/video/out/vulkan/context_display.c b/video/out/vulkan/context_display.c index 84cef1e..72f73ad 100644 --- a/video/out/vulkan/context_display.c +++ b/video/out/vulkan/context_display.c @@ -15,9 +15,11 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +#include "common/common.h" #include "context.h" #include "options/m_config.h" #include "utils.h" +#include "video/out/placebo/utils.h" #if HAVE_DRM #include <errno.h> @@ -214,35 +216,36 @@ done: } static int print_display_info(struct mp_log *log, const struct m_option *opt, - struct bstr name) { - VkResult res; - VkPhysicalDevice *devices = NULL; + struct bstr name) +{ + void *ta_ctx = talloc_new(NULL); + pl_log pllog = mppl_log_create(ta_ctx, log); + if (!pllog) + goto done; // Create a dummy instance to list the resources - VkInstanceCreateInfo info = { - .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, - .enabledExtensionCount = 1, - .ppEnabledExtensionNames = (const char*[]) { - VK_KHR_DISPLAY_EXTENSION_NAME + mppl_log_set_probing(pllog, true); + pl_vk_inst inst = pl_vk_inst_create(pllog, pl_vk_inst_params( + .extensions = (const char *[]){ + VK_KHR_DISPLAY_EXTENSION_NAME, }, - }; - - VkInstance inst = NULL; - res = vkCreateInstance(&info, NULL, &inst); - if (res != VK_SUCCESS) { + .num_extensions = 1, + )); + mppl_log_set_probing(pllog, false); + if (!inst) { mp_warn(log, "Unable to create Vulkan instance.\n"); goto done; } uint32_t num_devices = 0; - vkEnumeratePhysicalDevices(inst, &num_devices, NULL); - if (!num_devices) { + VkResult res = vkEnumeratePhysicalDevices(inst->instance, &num_devices, NULL); + if (res != VK_SUCCESS || !num_devices) { mp_info(log, "No Vulkan devices detected.\n"); goto done; } - devices = talloc_array(NULL, VkPhysicalDevice, num_devices); - vkEnumeratePhysicalDevices(inst, &num_devices, devices); + VkPhysicalDevice *devices = talloc_array(ta_ctx, VkPhysicalDevice, num_devices); + res = vkEnumeratePhysicalDevices(inst->instance, &num_devices, devices); if (res != VK_SUCCESS) { mp_warn(log, "Failed enumerating physical devices.\n"); goto done; @@ -254,8 +257,9 @@ static int print_display_info(struct mp_log *log, const struct m_option *opt, } done: - talloc_free(devices); - vkDestroyInstance(inst, NULL); + pl_vk_inst_destroy(&inst); + pl_log_destroy(&pllog); + talloc_free(ta_ctx); return M_OPT_EXIT; } @@ -296,7 +300,7 @@ static void open_render_fd(struct ra_ctx *ctx, const char *render_path) p->drm_params.render_fd = open(render_path, O_RDWR | O_CLOEXEC); if (p->drm_params.render_fd == -1) { MP_WARN(ctx, "Failed to open render node: %s\n", - strerror(errno)); + mp_strerror(errno)); } } diff --git a/video/out/vulkan/context_mac.m b/video/out/vulkan/context_mac.m index 8ac6e16..bedd0d4 100644 --- a/video/out/vulkan/context_mac.m +++ b/video/out/vulkan/context_mac.m @@ -15,8 +15,10 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +#import <QuartzCore/QuartzCore.h> + #include "video/out/gpu/context.h" -#include "osdep/macOS_swift.h" +#include "osdep/mac/swift.h" #include "common.h" #include "context.h" @@ -42,6 +44,12 @@ static void mac_vk_swap_buffers(struct ra_ctx *ctx) [p->vo_mac swapBuffer]; } +static void mac_vk_get_vsync(struct ra_ctx *ctx, struct vo_vsync_info *info) +{ + struct priv *p = ctx->priv; + [p->vo_mac fillVsyncWithInfo:info]; +} + static bool mac_vk_init(struct ra_ctx *ctx) { struct priv *p = ctx->priv = talloc_zero(ctx, struct priv); @@ -56,7 +64,7 @@ static bool mac_vk_init(struct ra_ctx *ctx) goto error; VkMetalSurfaceCreateInfoEXT mac_info = { - .sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK, + .sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT, .pNext = NULL, .flags = 0, .pLayer = p->vo_mac.layer, @@ -64,6 +72,7 @@ static bool mac_vk_init(struct ra_ctx *ctx) struct ra_vk_ctx_params params = { .swap_buffers = mac_vk_swap_buffers, + .get_vsync = mac_vk_get_vsync, }; VkInstance inst = vk->vkinst->instance; @@ -85,7 +94,14 @@ error: static bool resize(struct ra_ctx *ctx) { - return ra_vk_ctx_resize(ctx, ctx->vo->dwidth, ctx->vo->dheight); + struct priv *p = ctx->priv; + + if (!p->vo_mac.window) { + return false; + } + CGSize size = p->vo_mac.window.framePixel.size; + + return ra_vk_ctx_resize(ctx, (int)size.width, (int)size.height); } static bool mac_vk_reconfig(struct ra_ctx *ctx) diff --git a/video/out/vulkan/context_wayland.c b/video/out/vulkan/context_wayland.c index 761ff5b..cdf1ba6 100644 --- a/video/out/vulkan/context_wayland.c +++ b/video/out/vulkan/context_wayland.c @@ -118,7 +118,7 @@ static bool resize(struct ra_ctx *ctx) const int32_t height = mp_rect_h(wl->geometry); vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha); - vo_wayland_handle_fractional_scale(wl); + vo_wayland_handle_scale(wl); return ra_vk_ctx_resize(ctx, width, height); } diff --git a/video/out/vulkan/context_win.c b/video/out/vulkan/context_win.c index a89c644..328753f 100644 --- a/video/out/vulkan/context_win.c +++ b/video/out/vulkan/context_win.c @@ -50,6 +50,9 @@ static bool win_init(struct ra_ctx *ctx) if (!vo_w32_init(ctx->vo)) goto error; + if (ctx->opts.want_alpha) + vo_w32_set_transparency(ctx->vo, ctx->opts.want_alpha); + VkWin32SurfaceCreateInfoKHR wininfo = { .sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, .hinstance = HINST_THISCOMPONENT, @@ -96,11 +99,17 @@ static int win_control(struct ra_ctx *ctx, int *events, int request, void *arg) return ret; } +static void win_update_render_opts(struct ra_ctx *ctx) +{ + vo_w32_set_transparency(ctx->vo, ctx->opts.want_alpha); +} + const struct ra_ctx_fns ra_ctx_vulkan_win = { - .type = "vulkan", - .name = "winvk", - .reconfig = win_reconfig, - .control = win_control, - .init = win_init, - .uninit = win_uninit, + .type = "vulkan", + .name = "winvk", + .reconfig = win_reconfig, + .control = win_control, + .update_render_opts = win_update_render_opts, + .init = win_init, + .uninit = win_uninit, }; |