diff options
Diffstat (limited to 'video/out/vulkan/context_display.c')
-rw-r--r-- | video/out/vulkan/context_display.c | 44 |
1 files changed, 24 insertions, 20 deletions
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)); } } |