}
if (!device->ws) {
- result = vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
- goto fail;
+ result = vk_error(instance, VK_ERROR_INITIALIZATION_FAILED);
+ goto fail_fd;
}
if (drm_device && instance->enabled_extensions.KHR_display) {
device->rad_info.name);
if (radv_device_get_cache_uuid(device->rad_info.family, device->cache_uuid)) {
- device->ws->destroy(device->ws);
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
"cannot generate UUID");
- goto fail;
+ goto fail_wsi;
}
/* These flags affect shader compilation. */
*/
result = radv_init_wsi(device);
if (result != VK_SUCCESS) {
- device->ws->destroy(device->ws);
vk_error(instance, result);
- goto fail;
+ goto fail_disk_cache;
}
return VK_SUCCESS;
-fail:
+fail_disk_cache:
+ disk_cache_destroy(device->disk_cache);
+fail_wsi:
+ device->ws->destroy(device->ws);
+fail_fd:
close(fd);
if (master_fd != -1)
close(master_fd);
}
}
-static int radv_get_instance_extension_index(const char *name)
-{
- for (unsigned i = 0; i < RADV_INSTANCE_EXTENSION_COUNT; ++i) {
- if (strcmp(name, radv_instance_extensions[i].extensionName) == 0)
- return i;
- }
- return -1;
-}
-
static const char radv_dri_options_xml[] =
DRI_CONF_BEGIN
DRI_CONF_SECTION_PERFORMANCE
struct radv_instance *instance;
VkResult result;
- assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
-
- uint32_t client_version;
- if (pCreateInfo->pApplicationInfo &&
- pCreateInfo->pApplicationInfo->apiVersion != 0) {
- client_version = pCreateInfo->pApplicationInfo->apiVersion;
- } else {
- client_version = VK_API_VERSION_1_0;
- }
-
- const char *engine_name = NULL;
- uint32_t engine_version = 0;
- if (pCreateInfo->pApplicationInfo) {
- engine_name = pCreateInfo->pApplicationInfo->pEngineName;
- engine_version = pCreateInfo->pApplicationInfo->engineVersion;
- }
-
instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
if (!instance)
else
instance->alloc = default_alloc;
- instance->apiVersion = client_version;
+ if (pCreateInfo->pApplicationInfo) {
+ const VkApplicationInfo *app = pCreateInfo->pApplicationInfo;
+
+ instance->engineName =
+ vk_strdup(&instance->alloc, app->pEngineName,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ instance->engineVersion = app->engineVersion;
+ instance->apiVersion = app->apiVersion;
+ }
+
+ if (instance->apiVersion == 0)
+ instance->apiVersion = VK_API_VERSION_1_0;
+
instance->physicalDeviceCount = -1;
/* Get secure compile thread count. NOTE: We cap this at 32 */
radv_logi("Created an instance");
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
- const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
- int index = radv_get_instance_extension_index(ext_name);
+ int idx;
+ for (idx = 0; idx < RADV_INSTANCE_EXTENSION_COUNT; idx++) {
+ if (!strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+ radv_instance_extensions[idx].extensionName))
+ break;
+ }
- if (index < 0 || !radv_supported_instance_extensions.extensions[index]) {
+ if (idx >= RADV_INSTANCE_EXTENSION_COUNT ||
+ !radv_supported_instance_extensions.extensions[idx]) {
vk_free2(&default_alloc, pAllocator, instance);
return vk_error(instance, VK_ERROR_EXTENSION_NOT_PRESENT);
}
- instance->enabled_extensions.extensions[index] = true;
+ instance->enabled_extensions.extensions[idx] = true;
}
bool unchecked = instance->debug_flags & RADV_DEBUG_ALL_ENTRYPOINTS;
return vk_error(instance, result);
}
- instance->engineName = vk_strdup(&instance->alloc, engine_name,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- instance->engineVersion = engine_version;
-
glsl_type_singleton_init_or_ref();
VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false));
}
static VkResult
-radv_enumerate_devices(struct radv_instance *instance)
+radv_enumerate_physical_devices(struct radv_instance *instance)
{
/* TODO: Check for more devices ? */
drmDevicePtr devices[8];
VkResult result;
if (instance->physicalDeviceCount < 0) {
- result = radv_enumerate_devices(instance);
+ result = radv_enumerate_physical_devices(instance);
if (result != VK_SUCCESS &&
result != VK_ERROR_INCOMPATIBLE_DRIVER)
return result;
VkResult result;
if (instance->physicalDeviceCount < 0) {
- result = radv_enumerate_devices(instance);
+ result = radv_enumerate_physical_devices(instance);
if (result != VK_SUCCESS &&
result != VK_ERROR_INCOMPATIBLE_DRIVER)
return result;