1
mirror of https://github.com/mpv-player/mpv synced 2024-09-12 23:45:53 +02:00

vo_gpu: vulkan: Add a function to get the device UUID

We need this to do device matching for the cuda interop.
This commit is contained in:
Philip Langdale 2018-10-19 21:48:15 -07:00 committed by sfan5
parent a782197d21
commit 621389134a
2 changed files with 25 additions and 0 deletions

View File

@ -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);

View File

@ -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);