summaryrefslogtreecommitdiffstats
path: root/video/out/vulkan/context_display.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/vulkan/context_display.c')
-rw-r--r--video/out/vulkan/context_display.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/video/out/vulkan/context_display.c b/video/out/vulkan/context_display.c
index 4568f1dc46..7e3bc8ea2f 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;
}
@@ -274,11 +278,7 @@ const struct m_sub_options vulkan_display_conf = {
{0}
},
.size = sizeof(struct vulkan_display_opts),
- .defaults = &(struct vulkan_display_opts) {
- .display = 0,
- .mode = 0,
- .plane = 0,
- },
+ .defaults = &(struct vulkan_display_opts) {0},
};
struct priv {
@@ -300,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));
}
}
@@ -478,7 +478,7 @@ static void display_wakeup(struct ra_ctx *ctx)
// TODO
}
-static void display_wait_events(struct ra_ctx *ctx, int64_t until_time_us)
+static void display_wait_events(struct ra_ctx *ctx, int64_t until_time_ns)
{
// TODO
}
@@ -486,6 +486,7 @@ static void display_wait_events(struct ra_ctx *ctx, int64_t until_time_us)
const struct ra_ctx_fns ra_ctx_vulkan_display = {
.type = "vulkan",
.name = "displayvk",
+ .description = "VK_KHR_display",
.reconfig = display_reconfig,
.control = display_control,
.wakeup = display_wakeup,