Merge pull request #4 from rillomas/fix-vulkan-uuid
added Vulkan API to get correct Device UUID
This commit is contained in:
commit
0db9fb4ad4
|
|
@ -41,6 +41,7 @@ void vk_init(char* vk_lib_path, vk_init_resp_t *resp) {
|
||||||
void **p;
|
void **p;
|
||||||
} l[] = {
|
} l[] = {
|
||||||
{"vkGetPhysicalDeviceProperties", (void *)&resp->ch.vkGetPhysicalDeviceProperties},
|
{"vkGetPhysicalDeviceProperties", (void *)&resp->ch.vkGetPhysicalDeviceProperties},
|
||||||
|
{"vkGetPhysicalDeviceProperties2", (void *)&resp->ch.vkGetPhysicalDeviceProperties2},
|
||||||
{"vkEnumerateDeviceExtensionProperties", (void *)&resp->ch.vkEnumerateDeviceExtensionProperties},
|
{"vkEnumerateDeviceExtensionProperties", (void *)&resp->ch.vkEnumerateDeviceExtensionProperties},
|
||||||
{"vkCreateInstance", (void *)&resp->ch.vkCreateInstance},
|
{"vkCreateInstance", (void *)&resp->ch.vkCreateInstance},
|
||||||
{"vkEnumeratePhysicalDevices", (void *)&resp->ch.vkEnumeratePhysicalDevices},
|
{"vkEnumeratePhysicalDevices", (void *)&resp->ch.vkEnumeratePhysicalDevices},
|
||||||
|
|
@ -176,6 +177,15 @@ void vk_check_vram(vk_handle_t rh, int i, mem_info_t *resp) {
|
||||||
return;
|
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;
|
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.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT;
|
||||||
physical_device_memory_budget_properties.pNext = NULL;
|
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';
|
resp->gpu_name[GPU_NAME_LEN - 1] = '\0';
|
||||||
strncpy(&resp->gpu_name[0], properties.deviceName, GPU_NAME_LEN - 1);
|
strncpy(&resp->gpu_name[0], properties.deviceName, GPU_NAME_LEN - 1);
|
||||||
resp->gpu_name[GPU_NAME_LEN - 1] = '\0';
|
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,
|
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[0], uuid[1], uuid[2], uuid[3],
|
||||||
uuid[4], uuid[5],
|
uuid[4], uuid[5],
|
||||||
uuid[6], uuid[7],
|
uuid[6], uuid[7],
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ typedef struct {
|
||||||
void (*vkGetPhysicalDeviceProperties)(
|
void (*vkGetPhysicalDeviceProperties)(
|
||||||
VkPhysicalDevice physicalDevice,
|
VkPhysicalDevice physicalDevice,
|
||||||
VkPhysicalDeviceProperties* pProperties);
|
VkPhysicalDeviceProperties* pProperties);
|
||||||
|
void (*vkGetPhysicalDeviceProperties2)(
|
||||||
|
VkPhysicalDevice physicalDevice,
|
||||||
|
VkPhysicalDeviceProperties2* pProperties);
|
||||||
VkResult (*vkEnumerateDeviceExtensionProperties)(
|
VkResult (*vkEnumerateDeviceExtensionProperties)(
|
||||||
VkPhysicalDevice physicalDevice,
|
VkPhysicalDevice physicalDevice,
|
||||||
const char* pLayerName,
|
const char* pLayerName,
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,15 @@ index 4070e248..1c8c15d5 100644
|
||||||
+
|
+
|
||||||
+ std::vector<vk::PhysicalDevice> devices = vk_instance.instance.enumeratePhysicalDevices();
|
+ std::vector<vk::PhysicalDevice> devices = vk_instance.instance.enumeratePhysicalDevices();
|
||||||
+
|
+
|
||||||
+ vk::PhysicalDeviceProperties props;
|
+ vk::PhysicalDeviceProperties2 props;
|
||||||
+ devices[device].getProperties(&props);
|
+ vk::PhysicalDeviceIDProperties deviceIDProps;
|
||||||
|
+ props.pNext = &deviceIDProps;
|
||||||
|
+ devices[device].getProperties2(&props);
|
||||||
+
|
+
|
||||||
+ const auto& uuid = props.pipelineCacheUUID;
|
+ const auto& uuid = deviceIDProps.deviceUUID;
|
||||||
+ char id[64];
|
+ char id[64];
|
||||||
+ snprintf(id, sizeof(id),
|
+ 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[0], uuid[1], uuid[2], uuid[3],
|
||||||
+ uuid[4], uuid[5],
|
+ uuid[4], uuid[5],
|
||||||
+ uuid[6], uuid[7],
|
+ uuid[6], uuid[7],
|
||||||
|
|
|
||||||
|
|
@ -10199,13 +10199,15 @@ static std::string ggml_vk_get_device_id(int device) {
|
||||||
|
|
||||||
std::vector<vk::PhysicalDevice> devices = vk_instance.instance.enumeratePhysicalDevices();
|
std::vector<vk::PhysicalDevice> devices = vk_instance.instance.enumeratePhysicalDevices();
|
||||||
|
|
||||||
vk::PhysicalDeviceProperties props;
|
vk::PhysicalDeviceProperties2 props;
|
||||||
devices[device].getProperties(&props);
|
vk::PhysicalDeviceIDProperties deviceIDProps;
|
||||||
|
props.pNext = &deviceIDProps;
|
||||||
|
devices[device].getProperties2(&props);
|
||||||
|
|
||||||
const auto& uuid = props.pipelineCacheUUID;
|
const auto& uuid = deviceIDProps.deviceUUID;
|
||||||
char id[64];
|
char id[64];
|
||||||
snprintf(id, sizeof(id),
|
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[0], uuid[1], uuid[2], uuid[3],
|
||||||
uuid[4], uuid[5],
|
uuid[4], uuid[5],
|
||||||
uuid[6], uuid[7],
|
uuid[6], uuid[7],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue