Courtney Goeltzenleuchter | e06e72d | 2014-08-01 12:44:23 -0600 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan 3-D graphics library |
Courtney Goeltzenleuchter | e06e72d | 2014-08-01 12:44:23 -0600 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 25 | * Courtney Goeltzenleuchter <courtney@lunarg.com> |
| 26 | * Chia-I Wu <olv@lunarg.com> |
Courtney Goeltzenleuchter | e06e72d | 2014-08-01 12:44:23 -0600 | [diff] [blame] | 27 | */ |
| 28 | |
Chia-I Wu | 023ef68 | 2014-09-15 11:06:50 +0800 | [diff] [blame] | 29 | #include "icd-enumerate-drm.h" |
Chia-I Wu | a6e3349 | 2014-08-05 13:35:08 +0800 | [diff] [blame] | 30 | #include "gpu.h" |
Chia-I Wu | 94ae71a | 2015-02-20 12:26:08 -0700 | [diff] [blame] | 31 | #include "instance.h" |
Courtney Goeltzenleuchter | e06e72d | 2014-08-01 12:44:23 -0600 | [diff] [blame] | 32 | |
Chia-I Wu | 73019ad | 2014-08-29 12:01:13 +0800 | [diff] [blame] | 33 | static int intel_devid_override; |
Chia-I Wu | 1c52701 | 2014-08-23 14:57:35 +0800 | [diff] [blame] | 34 | int intel_debug = -1; |
| 35 | |
Courtney Goeltzenleuchter | 33a54d5 | 2015-06-09 07:50:24 -0600 | [diff] [blame] | 36 | void *intel_alloc(const void *handle, |
| 37 | size_t size, size_t alignment, |
| 38 | VkSystemAllocType type) |
| 39 | { |
| 40 | assert(intel_handle_validate(handle)); |
| 41 | return icd_instance_alloc(((const struct intel_handle *) handle)->instance->icd, |
| 42 | size, alignment, type); |
| 43 | } |
| 44 | |
| 45 | void intel_free(const void *handle, void *ptr) |
| 46 | { |
| 47 | assert(intel_handle_validate(handle)); |
| 48 | icd_instance_free(((const struct intel_handle *) handle)->instance->icd, ptr); |
| 49 | } |
| 50 | |
| 51 | void intel_logv(const void *handle, |
| 52 | VkFlags msg_flags, |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 53 | VkDbgObjectType obj_type, uint64_t src_object, |
Courtney Goeltzenleuchter | 33a54d5 | 2015-06-09 07:50:24 -0600 | [diff] [blame] | 54 | size_t location, int32_t msg_code, |
| 55 | const char *format, va_list ap) |
| 56 | { |
| 57 | char msg[256]; |
| 58 | int ret; |
| 59 | |
| 60 | ret = vsnprintf(msg, sizeof(msg), format, ap); |
| 61 | if (ret >= sizeof(msg) || ret < 0) |
| 62 | msg[sizeof(msg) - 1] = '\0'; |
| 63 | |
| 64 | assert(intel_handle_validate(handle)); |
| 65 | icd_instance_log(((const struct intel_handle *) handle)->instance->icd, |
| 66 | msg_flags, |
| 67 | obj_type, src_object, /* obj_type, object */ |
| 68 | location, msg_code, /* location, msg_code */ |
| 69 | msg); |
| 70 | } |
| 71 | |
Chia-I Wu | 1c52701 | 2014-08-23 14:57:35 +0800 | [diff] [blame] | 72 | static void intel_debug_init(void) |
| 73 | { |
| 74 | const char *env; |
| 75 | |
| 76 | if (intel_debug >= 0) |
| 77 | return; |
| 78 | |
| 79 | intel_debug = 0; |
| 80 | |
| 81 | /* parse comma-separated debug options */ |
Courtney Goeltzenleuchter | 893f287 | 2015-07-29 09:08:22 -0600 | [diff] [blame] | 82 | env = getenv("VK_INTEL_DEBUG"); |
Chia-I Wu | 1c52701 | 2014-08-23 14:57:35 +0800 | [diff] [blame] | 83 | while (env) { |
| 84 | const char *p = strchr(env, ','); |
| 85 | size_t len; |
| 86 | |
| 87 | if (p) |
| 88 | len = p - env; |
| 89 | else |
| 90 | len = strlen(env); |
| 91 | |
Courtney Goeltzenleuchter | d9fc984 | 2014-10-13 12:58:25 -0600 | [diff] [blame] | 92 | if (len > 0) { |
| 93 | if (strncmp(env, "batch", len) == 0) { |
| 94 | intel_debug |= INTEL_DEBUG_BATCH; |
| 95 | } else if (strncmp(env, "nohw", len) == 0) { |
| 96 | intel_debug |= INTEL_DEBUG_NOHW; |
Chia-I Wu | 3fb47ce | 2014-10-28 11:19:36 +0800 | [diff] [blame] | 97 | } else if (strncmp(env, "nocache", len) == 0) { |
| 98 | intel_debug |= INTEL_DEBUG_NOCACHE; |
Chia-I Wu | c45db53 | 2015-02-19 11:20:38 -0700 | [diff] [blame] | 99 | } else if (strncmp(env, "nohiz", len) == 0) { |
| 100 | intel_debug |= INTEL_DEBUG_NOHIZ; |
Chia-I Wu | 465fe21 | 2015-02-11 11:27:06 -0700 | [diff] [blame] | 101 | } else if (strncmp(env, "hang", len) == 0) { |
| 102 | intel_debug |= INTEL_DEBUG_HANG; |
Courtney Goeltzenleuchter | d9fc984 | 2014-10-13 12:58:25 -0600 | [diff] [blame] | 103 | } else if (strncmp(env, "0x", 2) == 0) { |
| 104 | intel_debug |= INTEL_DEBUG_NOHW; |
| 105 | intel_devid_override = strtol(env, NULL, 16); |
| 106 | } |
Chia-I Wu | 73019ad | 2014-08-29 12:01:13 +0800 | [diff] [blame] | 107 | } |
Chia-I Wu | 1c52701 | 2014-08-23 14:57:35 +0800 | [diff] [blame] | 108 | |
| 109 | if (!p) |
| 110 | break; |
| 111 | |
| 112 | env = p + 1; |
| 113 | } |
| 114 | } |
Jon Ashburn | 815bddd | 2014-10-16 15:48:50 -0600 | [diff] [blame] | 115 | |
Chia-I Wu | d71ff55 | 2015-02-20 12:50:12 -0700 | [diff] [blame] | 116 | static void intel_instance_add_gpu(struct intel_instance *instance, |
| 117 | struct intel_gpu *gpu) |
| 118 | { |
| 119 | gpu->next = instance->gpus; |
| 120 | instance->gpus = gpu; |
| 121 | } |
| 122 | |
| 123 | static void intel_instance_remove_gpus(struct intel_instance *instance) |
| 124 | { |
| 125 | struct intel_gpu *gpu = instance->gpus; |
| 126 | |
| 127 | while (gpu) { |
| 128 | struct intel_gpu *next = gpu->next; |
| 129 | |
| 130 | intel_gpu_destroy(gpu); |
| 131 | gpu = next; |
| 132 | } |
| 133 | |
| 134 | instance->gpus = NULL; |
| 135 | } |
| 136 | |
Chia-I Wu | 94ae71a | 2015-02-20 12:26:08 -0700 | [diff] [blame] | 137 | static void intel_instance_destroy(struct intel_instance *instance) |
Jon Ashburn | fa836e0 | 2015-01-28 18:26:16 -0700 | [diff] [blame] | 138 | { |
Chia-I Wu | 96a41bc | 2015-02-21 14:19:23 +0800 | [diff] [blame] | 139 | struct icd_instance *icd = instance->icd; |
| 140 | |
Chia-I Wu | d71ff55 | 2015-02-20 12:50:12 -0700 | [diff] [blame] | 141 | intel_instance_remove_gpus(instance); |
Chia-I Wu | 96a41bc | 2015-02-21 14:19:23 +0800 | [diff] [blame] | 142 | icd_instance_free(icd, instance); |
| 143 | |
| 144 | icd_instance_destroy(icd); |
Jon Ashburn | fa836e0 | 2015-01-28 18:26:16 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 147 | static VkResult intel_instance_create( |
| 148 | const VkInstanceCreateInfo* info, |
| 149 | struct intel_instance **pInstance) |
Jon Ashburn | fa836e0 | 2015-01-28 18:26:16 -0700 | [diff] [blame] | 150 | { |
Chia-I Wu | 94ae71a | 2015-02-20 12:26:08 -0700 | [diff] [blame] | 151 | struct intel_instance *instance; |
Chia-I Wu | 96a41bc | 2015-02-21 14:19:23 +0800 | [diff] [blame] | 152 | struct icd_instance *icd; |
Jon Ashburn | 29669a4 | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 153 | uint32_t i; |
Jon Ashburn | fa836e0 | 2015-01-28 18:26:16 -0700 | [diff] [blame] | 154 | |
| 155 | intel_debug_init(); |
| 156 | |
Jon Ashburn | 29669a4 | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 157 | icd = icd_instance_create(info->pAppInfo, info->pAllocCb); |
Chia-I Wu | 96a41bc | 2015-02-21 14:19:23 +0800 | [diff] [blame] | 158 | if (!icd) |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 159 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
Chia-I Wu | 94ae71a | 2015-02-20 12:26:08 -0700 | [diff] [blame] | 160 | |
Chia-I Wu | 96a41bc | 2015-02-21 14:19:23 +0800 | [diff] [blame] | 161 | instance = icd_instance_alloc(icd, sizeof(*instance), 0, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 162 | VK_SYSTEM_ALLOC_TYPE_API_OBJECT); |
Chia-I Wu | 96a41bc | 2015-02-21 14:19:23 +0800 | [diff] [blame] | 163 | if (!instance) { |
| 164 | icd_instance_destroy(icd); |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 165 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
Chia-I Wu | 96a41bc | 2015-02-21 14:19:23 +0800 | [diff] [blame] | 166 | } |
| 167 | |
Chia-I Wu | 94ae71a | 2015-02-20 12:26:08 -0700 | [diff] [blame] | 168 | memset(instance, 0, sizeof(*instance)); |
Courtney Goeltzenleuchter | 9ecf685 | 2015-06-09 08:22:48 -0600 | [diff] [blame] | 169 | intel_handle_init(&instance->handle, VK_OBJECT_TYPE_INSTANCE, instance); |
Chia-I Wu | 94ae71a | 2015-02-20 12:26:08 -0700 | [diff] [blame] | 170 | |
Chia-I Wu | 96a41bc | 2015-02-21 14:19:23 +0800 | [diff] [blame] | 171 | instance->icd = icd; |
| 172 | |
Jon Ashburn | 29669a4 | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 173 | for (i = 0; i < info->extensionCount; i++) { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 174 | const enum intel_global_ext_type ext = intel_gpu_lookup_global_extension(info->ppEnabledExtensionNames[i]); |
Jon Ashburn | 29669a4 | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 175 | |
Courtney Goeltzenleuchter | 9ecf685 | 2015-06-09 08:22:48 -0600 | [diff] [blame] | 176 | if (ext != INTEL_GLOBAL_EXT_INVALID) { |
| 177 | instance->global_exts[ext] = true; |
| 178 | } else { |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 179 | /* Fail create if extensions are specified that |
| 180 | * ICD cannot satisfy. Loader will filter out extensions / layers |
| 181 | * not meant by the ICD. |
Courtney Goeltzenleuchter | 9ecf685 | 2015-06-09 08:22:48 -0600 | [diff] [blame] | 182 | */ |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 183 | icd_instance_destroy(icd); |
| 184 | intel_instance_destroy(instance); |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 185 | return VK_ERROR_EXTENSION_NOT_PRESENT; |
Courtney Goeltzenleuchter | 9ecf685 | 2015-06-09 08:22:48 -0600 | [diff] [blame] | 186 | } |
Jon Ashburn | 29669a4 | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 187 | } |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 188 | |
| 189 | /* |
| 190 | * This ICD does not support any layers. |
| 191 | */ |
| 192 | if (info->layerCount > 0) { |
| 193 | icd_instance_destroy(icd); |
| 194 | intel_instance_destroy(instance); |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 195 | return VK_ERROR_LAYER_NOT_PRESENT; |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | *pInstance = instance; |
| 199 | |
| 200 | return VK_SUCCESS; |
Jon Ashburn | fa836e0 | 2015-01-28 18:26:16 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Courtney Goeltzenleuchter | 95b7372 | 2015-06-08 18:08:35 -0600 | [diff] [blame] | 203 | enum intel_global_ext_type intel_gpu_lookup_global_extension( |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 204 | const char *extName) |
Courtney Goeltzenleuchter | 95b7372 | 2015-06-08 18:08:35 -0600 | [diff] [blame] | 205 | { |
| 206 | enum intel_global_ext_type type; |
| 207 | |
| 208 | for (type = 0; type < ARRAY_SIZE(intel_global_exts); type++) { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 209 | if (compare_vk_extension_properties(&intel_global_exts[type], extName)) |
Courtney Goeltzenleuchter | 95b7372 | 2015-06-08 18:08:35 -0600 | [diff] [blame] | 210 | break; |
| 211 | } |
| 212 | |
| 213 | assert(type < INTEL_GLOBAL_EXT_COUNT || type == INTEL_GLOBAL_EXT_INVALID); |
| 214 | |
| 215 | return type; |
| 216 | } |
| 217 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 218 | ICD_EXPORT VkResult VKAPI vkCreateInstance( |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 219 | const VkInstanceCreateInfo* pCreateInfo, |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 220 | VkInstance* pInstance) |
Jon Ashburn | 349508d | 2015-01-26 14:51:40 -0700 | [diff] [blame] | 221 | { |
Courtney Goeltzenleuchter | b44d6f2 | 2015-07-05 22:09:41 -0600 | [diff] [blame] | 222 | return intel_instance_create(pCreateInfo, (struct intel_instance **) pInstance); |
Jon Ashburn | 349508d | 2015-01-26 14:51:40 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Mark Lobodzinski | 67b42b7 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 225 | ICD_EXPORT void VKAPI vkDestroyInstance( |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 226 | VkInstance pInstance) |
Jon Ashburn | 349508d | 2015-01-26 14:51:40 -0700 | [diff] [blame] | 227 | { |
Chia-I Wu | 94ae71a | 2015-02-20 12:26:08 -0700 | [diff] [blame] | 228 | struct intel_instance *instance = intel_instance(pInstance); |
| 229 | |
| 230 | intel_instance_destroy(instance); |
Jon Ashburn | 349508d | 2015-01-26 14:51:40 -0700 | [diff] [blame] | 231 | } |
| 232 | |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 233 | ICD_EXPORT VkResult VKAPI vkEnumerateInstanceExtensionProperties( |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 234 | const char* pLayerName, |
| 235 | uint32_t* pCount, |
| 236 | VkExtensionProperties* pProperties) |
Courtney Goeltzenleuchter | f0441e6 | 2015-06-09 08:20:20 -0600 | [diff] [blame] | 237 | { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 238 | uint32_t copy_size; |
| 239 | |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 240 | if (pProperties == NULL) { |
| 241 | *pCount = INTEL_GLOBAL_EXT_COUNT; |
| 242 | return VK_SUCCESS; |
| 243 | } |
| 244 | |
| 245 | copy_size = *pCount < INTEL_GLOBAL_EXT_COUNT ? *pCount : INTEL_GLOBAL_EXT_COUNT; |
| 246 | memcpy(pProperties, intel_global_exts, copy_size * sizeof(VkExtensionProperties)); |
| 247 | *pCount = copy_size; |
| 248 | if (copy_size < INTEL_GLOBAL_EXT_COUNT) { |
| 249 | return VK_INCOMPLETE; |
| 250 | } |
| 251 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 252 | return VK_SUCCESS; |
| 253 | } |
Courtney Goeltzenleuchter | f0441e6 | 2015-06-09 08:20:20 -0600 | [diff] [blame] | 254 | |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 255 | ICD_EXPORT VkResult VKAPI vkEnumerateInstanceLayerProperties( |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 256 | uint32_t* pCount, |
| 257 | VkLayerProperties* pProperties) |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 258 | { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 259 | *pCount = 0; |
Courtney Goeltzenleuchter | f0441e6 | 2015-06-09 08:20:20 -0600 | [diff] [blame] | 260 | return VK_SUCCESS; |
| 261 | } |
| 262 | |
Jon Ashburn | 07b309a | 2015-04-15 11:31:12 -0600 | [diff] [blame] | 263 | ICD_EXPORT VkResult VKAPI vkEnumeratePhysicalDevices( |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 264 | VkInstance instance_, |
| 265 | uint32_t* pPhysicalDeviceCount, |
| 266 | VkPhysicalDevice* pPhysicalDevices) |
Jon Ashburn | 349508d | 2015-01-26 14:51:40 -0700 | [diff] [blame] | 267 | { |
Chia-I Wu | d71ff55 | 2015-02-20 12:50:12 -0700 | [diff] [blame] | 268 | struct intel_instance *instance = intel_instance(instance_); |
Jon Ashburn | 5f078e9 | 2015-01-28 19:15:45 -0700 | [diff] [blame] | 269 | struct icd_drm_device *devices, *dev; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 270 | VkResult ret; |
Jon Ashburn | 92e8013 | 2015-01-29 15:47:01 -0700 | [diff] [blame] | 271 | uint32_t count; |
Jon Ashburn | 5f078e9 | 2015-01-28 19:15:45 -0700 | [diff] [blame] | 272 | |
Jon Ashburn | 07b309a | 2015-04-15 11:31:12 -0600 | [diff] [blame] | 273 | if (pPhysicalDevices == NULL) { |
| 274 | *pPhysicalDeviceCount = 1; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 275 | return VK_SUCCESS; |
Jon Ashburn | 5f078e9 | 2015-01-28 19:15:45 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Jon Ashburn | 07b309a | 2015-04-15 11:31:12 -0600 | [diff] [blame] | 278 | intel_instance_remove_gpus(instance); |
| 279 | |
Chia-I Wu | 15517d8 | 2015-02-20 13:41:57 -0700 | [diff] [blame] | 280 | devices = icd_drm_enumerate(instance->icd, 0x8086); |
Jon Ashburn | 5f078e9 | 2015-01-28 19:15:45 -0700 | [diff] [blame] | 281 | |
| 282 | count = 0; |
| 283 | dev = devices; |
| 284 | while (dev) { |
| 285 | const char *primary_node, *render_node; |
| 286 | int devid; |
| 287 | struct intel_gpu *gpu; |
| 288 | |
| 289 | primary_node = icd_drm_get_devnode(dev, ICD_DRM_MINOR_LEGACY); |
| 290 | if (!primary_node) |
| 291 | continue; |
| 292 | |
| 293 | render_node = icd_drm_get_devnode(dev, ICD_DRM_MINOR_RENDER); |
| 294 | |
| 295 | devid = (intel_devid_override) ? intel_devid_override : dev->devid; |
Chia-I Wu | d71ff55 | 2015-02-20 12:50:12 -0700 | [diff] [blame] | 296 | ret = intel_gpu_create(instance, devid, |
| 297 | primary_node, render_node, &gpu); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 298 | if (ret == VK_SUCCESS) { |
Chia-I Wu | d71ff55 | 2015-02-20 12:50:12 -0700 | [diff] [blame] | 299 | intel_instance_add_gpu(instance, gpu); |
| 300 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 301 | pPhysicalDevices[count++] = (VkPhysicalDevice) gpu; |
Jon Ashburn | 07b309a | 2015-04-15 11:31:12 -0600 | [diff] [blame] | 302 | if (count >= *pPhysicalDeviceCount) |
Jon Ashburn | 5f078e9 | 2015-01-28 19:15:45 -0700 | [diff] [blame] | 303 | break; |
| 304 | } |
| 305 | |
| 306 | dev = dev->next; |
| 307 | } |
| 308 | |
Chia-I Wu | 15517d8 | 2015-02-20 13:41:57 -0700 | [diff] [blame] | 309 | icd_drm_release(instance->icd, devices); |
Jon Ashburn | 5f078e9 | 2015-01-28 19:15:45 -0700 | [diff] [blame] | 310 | |
Jon Ashburn | 07b309a | 2015-04-15 11:31:12 -0600 | [diff] [blame] | 311 | *pPhysicalDeviceCount = count; |
Jon Ashburn | 5f078e9 | 2015-01-28 19:15:45 -0700 | [diff] [blame] | 312 | |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 313 | return VK_SUCCESS; |
Jon Ashburn | 349508d | 2015-01-26 14:51:40 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 316 | ICD_EXPORT VkResult VKAPI vkDbgCreateMsgCallback( |
| 317 | VkInstance instance, |
| 318 | VkFlags msgFlags, |
| 319 | PFN_vkDbgMsgCallback pfnMsgCallback, |
| 320 | void* pUserData, |
| 321 | VkDbgMsgCallback* pMsgCallback) |
Chia-I Wu | b02558c | 2015-01-03 15:21:51 +0800 | [diff] [blame] | 322 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 323 | struct intel_instance *inst = intel_instance(instance); |
Courtney Goeltzenleuchter | 0629efa | 2015-04-13 14:59:19 -0600 | [diff] [blame] | 324 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 325 | return icd_instance_create_logger(inst->icd, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
Chia-I Wu | b02558c | 2015-01-03 15:21:51 +0800 | [diff] [blame] | 326 | } |
| 327 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 328 | ICD_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( |
| 329 | VkInstance instance, |
| 330 | VkDbgMsgCallback msgCallback) |
Chia-I Wu | b02558c | 2015-01-03 15:21:51 +0800 | [diff] [blame] | 331 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 332 | struct intel_instance *inst = intel_instance(instance); |
Courtney Goeltzenleuchter | 0629efa | 2015-04-13 14:59:19 -0600 | [diff] [blame] | 333 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 334 | return icd_instance_destroy_logger(inst->icd, msgCallback); |
Chia-I Wu | b02558c | 2015-01-03 15:21:51 +0800 | [diff] [blame] | 335 | } |