Merge pull request #4 from rillomas/fix-vulkan-uuid

added Vulkan API to get correct Device UUID
This commit is contained in:
Thomas Stocker 2025-09-11 16:24:15 +02:00 committed by GitHub
commit 0db9fb4ad4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 10 deletions

View File

@ -41,6 +41,7 @@ void vk_init(char* vk_lib_path, vk_init_resp_t *resp) {
void **p;
} l[] = {
{"vkGetPhysicalDeviceProperties", (void *)&resp->ch.vkGetPhysicalDeviceProperties},
{"vkGetPhysicalDeviceProperties2", (void *)&resp->ch.vkGetPhysicalDeviceProperties2},
{"vkEnumerateDeviceExtensionProperties", (void *)&resp->ch.vkEnumerateDeviceExtensionProperties},
{"vkCreateInstance", (void *)&resp->ch.vkCreateInstance},
{"vkEnumeratePhysicalDevices", (void *)&resp->ch.vkEnumeratePhysicalDevices},
@ -176,6 +177,15 @@ void vk_check_vram(vk_handle_t rh, int i, mem_info_t *resp) {
return;
}
VkPhysicalDeviceProperties2 device_props2 = {};
device_props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
VkPhysicalDeviceIDProperties id_props = {};
id_props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES;
device_props2.pNext = &id_props;
(*rh.vkGetPhysicalDeviceProperties2)(devices[i], &device_props2);
VkPhysicalDeviceMemoryBudgetPropertiesEXT physical_device_memory_budget_properties;
physical_device_memory_budget_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT;
physical_device_memory_budget_properties.pNext = NULL;
@ -204,9 +214,9 @@ void vk_check_vram(vk_handle_t rh, int i, mem_info_t *resp) {
resp->gpu_name[GPU_NAME_LEN - 1] = '\0';
strncpy(&resp->gpu_name[0], properties.deviceName, GPU_NAME_LEN - 1);
resp->gpu_name[GPU_NAME_LEN - 1] = '\0';
const uint8_t *uuid = properties.pipelineCacheUUID;
const uint8_t *uuid = id_props.deviceUUID;
snprintf(&resp->gpu_id[0], GPU_ID_LEN,
"GPU-%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
"GPU-%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5],
uuid[6], uuid[7],

View File

@ -16,6 +16,9 @@ typedef struct {
void (*vkGetPhysicalDeviceProperties)(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties* pProperties);
void (*vkGetPhysicalDeviceProperties2)(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties2* pProperties);
VkResult (*vkEnumerateDeviceExtensionProperties)(
VkPhysicalDevice physicalDevice,
const char* pLayerName,

View File

@ -21,13 +21,15 @@ index 4070e248..1c8c15d5 100644
+
+ std::vector<vk::PhysicalDevice> devices = vk_instance.instance.enumeratePhysicalDevices();
+
+ vk::PhysicalDeviceProperties props;
+ devices[device].getProperties(&props);
+ vk::PhysicalDeviceProperties2 props;
+ vk::PhysicalDeviceIDProperties deviceIDProps;
+ props.pNext = &deviceIDProps;
+ devices[device].getProperties2(&props);
+
+ const auto& uuid = props.pipelineCacheUUID;
+ const auto& uuid = deviceIDProps.deviceUUID;
+ char id[64];
+ snprintf(id, sizeof(id),
+ "GPU-%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+ "GPU-%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uuid[0], uuid[1], uuid[2], uuid[3],
+ uuid[4], uuid[5],
+ uuid[6], uuid[7],

View File

@ -10199,13 +10199,15 @@ static std::string ggml_vk_get_device_id(int device) {
std::vector<vk::PhysicalDevice> devices = vk_instance.instance.enumeratePhysicalDevices();
vk::PhysicalDeviceProperties props;
devices[device].getProperties(&props);
vk::PhysicalDeviceProperties2 props;
vk::PhysicalDeviceIDProperties deviceIDProps;
props.pNext = &deviceIDProps;
devices[device].getProperties2(&props);
const auto& uuid = props.pipelineCacheUUID;
const auto& uuid = deviceIDProps.deviceUUID;
char id[64];
snprintf(id, sizeof(id),
"GPU-%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
"GPU-%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5],
uuid[6], uuid[7],