summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2018-10-19 21:48:15 -0700
committersfan5 <sfan5@live.de>2018-10-22 21:35:48 +0200
commit621389134afd3026b7e3508dba070442c4eeefa0 (patch)
treee4ff5e5aa1e95032ba30dbf6243a52ef81200608 /video
parenta782197d216b2343abe04045b9bb3076864aca80 (diff)
downloadmpv-621389134afd3026b7e3508dba070442c4eeefa0.tar.bz2
mpv-621389134afd3026b7e3508dba070442c4eeefa0.tar.xz
vo_gpu: vulkan: Add a function to get the device UUID
We need this to do device matching for the cuda interop.
Diffstat (limited to 'video')
-rw-r--r--video/out/vulkan/utils.c22
-rw-r--r--video/out/vulkan/utils.h3
2 files changed, 25 insertions, 0 deletions
diff --git a/video/out/vulkan/utils.c b/video/out/vulkan/utils.c
index 4413fe70b1..1ad55d1275 100644
--- a/video/out/vulkan/utils.c
+++ b/video/out/vulkan/utils.c
@@ -192,6 +192,7 @@ bool mpvk_instance_init(struct mpvk_ctx *vk, struct mp_log *log,
// Enable whatever extensions were compiled in.
const char *extensions[] = {
+ VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
VK_KHR_SURFACE_EXTENSION_NAME,
surf_ext_name,
@@ -328,6 +329,27 @@ error:
return false;
}
+bool mpvk_get_phys_device_uuid(struct mpvk_ctx *vk, uint8_t uuid_out[VK_UUID_SIZE])
+{
+ assert(vk->physd);
+
+ VkPhysicalDeviceIDProperties idprops = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES,
+ };
+
+ VkPhysicalDeviceProperties2 props = {
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
+ .pNext = &idprops,
+ };
+
+ VK_LOAD_PFN(vkGetPhysicalDeviceProperties2KHR);
+ pfn_vkGetPhysicalDeviceProperties2KHR(vk->physd, &props);
+
+ memcpy(uuid_out, idprops.deviceUUID, VK_UUID_SIZE);
+
+ return true;
+}
+
bool mpvk_pick_surface_format(struct mpvk_ctx *vk)
{
assert(vk->physd);
diff --git a/video/out/vulkan/utils.h b/video/out/vulkan/utils.h
index 97d1c24489..9af59e4b50 100644
--- a/video/out/vulkan/utils.h
+++ b/video/out/vulkan/utils.h
@@ -56,6 +56,9 @@ bool mpvk_surface_init(struct vo *vo, struct mpvk_ctx *vk);
// sw: also allow software/virtual devices
bool mpvk_find_phys_device(struct mpvk_ctx *vk, const char *name, bool sw);
+// Get the UUID for the selected physical device
+bool mpvk_get_phys_device_uuid(struct mpvk_ctx *vk, uint8_t uuid_out[VK_UUID_SIZE]);
+
// Pick a suitable surface format that's supported by this physical device.
bool mpvk_pick_surface_format(struct mpvk_ctx *vk);