The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

c/util: Query GPU LUID when possible

authored by

Ryan Pavlik and committed by
Jakob Bornecrantz
63fdadae 3691d881

+43
+37
src/xrt/compositor/util/comp_vulkan.c
··· 64 64 return true; 65 65 } 66 66 67 + static bool 68 + get_device_luid(struct vk_bundle *vk, int gpu_index, xrt_uuid_t *uuid) 69 + { 70 + VkPhysicalDeviceIDProperties pdidp = { 71 + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES, 72 + }; 73 + 74 + VkPhysicalDeviceProperties2 pdp2 = { 75 + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, 76 + .pNext = &pdidp, 77 + }; 78 + 79 + VkPhysicalDevice phys[16]; 80 + uint32_t gpu_count = ARRAY_SIZE(phys); 81 + VkResult ret; 82 + 83 + ret = vk->vkEnumeratePhysicalDevices(vk->instance, &gpu_count, phys); 84 + if (ret != VK_SUCCESS) { 85 + VK_ERROR_RET(vk, "vkEnumeratePhysicalDevices", "Failed to enumerate physical devices.", ret); 86 + return false; 87 + } 88 + 89 + vk->vkGetPhysicalDeviceProperties2(phys[gpu_index], &pdp2); 90 + if (pdidp.deviceLUIDValid != VK_TRUE) { 91 + return false; 92 + } 93 + memcpy(uuid->data, pdidp.deviceLUID, ARRAY_SIZE(uuid->data)); 94 + 95 + return true; 96 + } 97 + 67 98 VkResult 68 99 fill_in_results(struct vk_bundle *vk, const struct comp_vulkan_arguments *vk_args, struct comp_vulkan_results *vk_res) 69 100 { ··· 98 129 99 130 // Trailing space above, means 'to' should be right next to '%s'. 100 131 VK_DEBUG(vk, "Suggest %d with uuid: %sto clients", vk_res->client_gpu_index, uuid_str); 132 + 133 + if (get_device_luid(vk, vk_res->client_gpu_index, &vk_res->client_gpu_deviceLUID)) { 134 + vk_res->client_gpu_deviceLUID_valid = true; 135 + snprint_uuid(uuid_str, ARRAY_SIZE(uuid_str), &vk_res->client_gpu_deviceLUID); 136 + VK_DEBUG(vk, " Device LUID: %s", uuid_str); 137 + } 101 138 } else { 102 139 VK_ERROR(vk, "Failed to get device %d uuid", vk_res->client_gpu_index); 103 140 }
+6
src/xrt/compositor/util/comp_vulkan.h
··· 75 75 76 76 //! Selected Vulkan device UUID to suggest to clients. 77 77 xrt_uuid_t client_gpu_deviceUUID; 78 + 79 + //! The (Windows) LUID for the GPU device suggested for clients. 80 + xrt_uuid_t client_gpu_deviceLUID; 81 + 82 + //! Whether @ref client_gpu_deviceLUID is valid (probably only on Windows) 83 + bool client_gpu_deviceLUID_valid; 78 84 }; 79 85 80 86 /*!