summaryrefslogtreecommitdiffstats
path: root/video/out/vulkan/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/vulkan/utils.c')
-rw-r--r--video/out/vulkan/utils.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/video/out/vulkan/utils.c b/video/out/vulkan/utils.c
index cfe97377c0..4413fe70b1 100644
--- a/video/out/vulkan/utils.c
+++ b/video/out/vulkan/utils.c
@@ -438,6 +438,38 @@ static void add_qinfo(void *tactx, VkDeviceQueueCreateInfo **qinfos,
MP_TARRAY_APPEND(tactx, *qinfos, *num_qinfos, qinfo);
}
+static bool detect_device_extensions(struct mpvk_ctx *vk)
+{
+ bool ret = false;
+ VkExtensionProperties *props = NULL;
+
+ uint32_t num_exts;
+ VK(vkEnumerateDeviceExtensionProperties(vk->physd, NULL,
+ &num_exts, NULL));
+
+ props = talloc_array(NULL, VkExtensionProperties, num_exts);
+ VK(vkEnumerateDeviceExtensionProperties(vk->physd,
+ NULL, &num_exts, props));
+
+ for (uint32_t i = 0; i < num_exts; i++) {
+ if (!strcmp(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME,
+ props[i].extensionName)) {
+ vk->has_ext_external_memory = true;
+ continue;
+ }
+ if (!strcmp(MP_VK_EXTERNAL_MEMORY_EXPORT_EXTENSION_NAME,
+ props[i].extensionName)) {
+ vk->has_ext_external_memory_export = true;
+ continue;
+ }
+ }
+
+ ret = true;
+error:
+ talloc_free(props);
+ return ret;
+}
+
bool mpvk_device_init(struct mpvk_ctx *vk, struct mpvk_device_opts opts)
{
assert(vk->physd);
@@ -493,9 +525,18 @@ bool mpvk_device_init(struct mpvk_ctx *vk, struct mpvk_device_opts opts)
add_qinfo(tmp, &qinfos, &num_qinfos, qfs, idx_comp, opts.queue_count);
add_qinfo(tmp, &qinfos, &num_qinfos, qfs, idx_tf, opts.queue_count);
+ if (!detect_device_extensions(vk)) {
+ MP_WARN(vk, "Failed to enumerate device extensions. "
+ "Some features may be disabled.\n");
+ }
+
const char **exts = NULL;
int num_exts = 0;
MP_TARRAY_APPEND(tmp, exts, num_exts, VK_KHR_SWAPCHAIN_EXTENSION_NAME);
+ if (vk->has_ext_external_memory)
+ MP_TARRAY_APPEND(tmp, exts, num_exts, VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
+ if (vk->has_ext_external_memory_export)
+ MP_TARRAY_APPEND(tmp, exts, num_exts, MP_VK_EXTERNAL_MEMORY_EXPORT_EXTENSION_NAME);
if (vk->spirv->required_ext)
MP_TARRAY_APPEND(tmp, exts, num_exts, vk->spirv->required_ext);