diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index e331a7ead42..1999862a838 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -2701,8 +2701,8 @@ VkResult radv_CreateDevice( &radv_device_entrypoints, true); } - result = vk_device_init(&device->vk, &physical_device->vk, &dispatch_table, pCreateInfo, - &physical_device->instance->vk.alloc, pAllocator); + result = vk_device_init(&device->vk, &physical_device->vk, + &dispatch_table, pCreateInfo, pAllocator); if (result != VK_SUCCESS) { vk_free(&device->vk.alloc, device); return result; diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 4b4f53c258c..9cc5b190454 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -1394,8 +1394,7 @@ v3dv_CreateDevice(VkPhysicalDevice physicalDevice, vk_device_dispatch_table_from_entrypoints(&dispatch_table, &v3dv_device_entrypoints, true); result = vk_device_init(&device->vk, &physical_device->vk, - &dispatch_table, pCreateInfo, - &physical_device->vk.instance->alloc, pAllocator); + &dispatch_table, pCreateInfo, pAllocator); if (result != VK_SUCCESS) { vk_free(&device->vk.alloc, device); return vk_error(instance, result); diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index a248c1d9a03..41c2fd75ac4 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -1018,9 +1018,7 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice, &dispatch_table, &tu_device_entrypoints, true); result = vk_device_init(&device->vk, &physical_device->vk, - &dispatch_table, pCreateInfo, - &physical_device->instance->vk.alloc, - pAllocator); + &dispatch_table, pCreateInfo, pAllocator); if (result != VK_SUCCESS) { vk_free(&device->vk.alloc, device); return vk_startup_errorf(physical_device->instance, result, diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index 0193fbfe067..09f3cded595 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -810,7 +810,6 @@ VkResult lvp_CreateDevice( VkResult result = vk_device_init(&device->vk, &physical_device->vk, &dispatch_table, pCreateInfo, - &physical_device->vk.instance->alloc, pAllocator); if (result != VK_SUCCESS) { vk_free(&device->vk.alloc, device); diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index a4bd3012671..bb8513b82ab 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -2660,8 +2660,7 @@ VkResult anv_CreateDevice( &anv_device_entrypoints, false); result = vk_device_init(&device->vk, &physical_device->vk, - &dispatch_table, pCreateInfo, - &physical_device->instance->vk.alloc, pAllocator); + &dispatch_table, pCreateInfo, pAllocator); if (result != VK_SUCCESS) { vk_error(result); goto fail_alloc; diff --git a/src/vulkan/util/vk_device.c b/src/vulkan/util/vk_device.c index d3c953b5f7f..6f58dc4c9b4 100644 --- a/src/vulkan/util/vk_device.c +++ b/src/vulkan/util/vk_device.c @@ -34,43 +34,38 @@ vk_device_init(struct vk_device *device, struct vk_physical_device *physical_device, const struct vk_device_dispatch_table *dispatch_table, const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *instance_alloc, - const VkAllocationCallbacks *device_alloc) + const VkAllocationCallbacks *alloc) { memset(device, 0, sizeof(*device)); vk_object_base_init(device, &device->base, VK_OBJECT_TYPE_DEVICE); - if (device_alloc) - device->alloc = *device_alloc; + if (alloc != NULL) + device->alloc = *alloc; else - device->alloc = *instance_alloc; + device->alloc = physical_device->instance->alloc; device->physical = physical_device; - if (dispatch_table != NULL) { - device->dispatch_table = *dispatch_table; + device->dispatch_table = *dispatch_table; - /* Add common entrypoints without overwriting driver-provided ones. */ - vk_device_dispatch_table_from_entrypoints( - &device->dispatch_table, &vk_common_device_entrypoints, false); - } + /* Add common entrypoints without overwriting driver-provided ones. */ + vk_device_dispatch_table_from_entrypoints( + &device->dispatch_table, &vk_common_device_entrypoints, false); - if (physical_device != NULL) { - for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - int idx; - for (idx = 0; idx < VK_DEVICE_EXTENSION_COUNT; idx++) { - if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], - vk_device_extensions[idx].extensionName) == 0) - break; - } - - if (idx >= VK_DEVICE_EXTENSION_COUNT) - return VK_ERROR_EXTENSION_NOT_PRESENT; - - if (!physical_device->supported_extensions.extensions[idx]) - return VK_ERROR_EXTENSION_NOT_PRESENT; - - device->enabled_extensions.extensions[idx] = true; + for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { + int idx; + for (idx = 0; idx < VK_DEVICE_EXTENSION_COUNT; idx++) { + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], + vk_device_extensions[idx].extensionName) == 0) + break; } + + if (idx >= VK_DEVICE_EXTENSION_COUNT) + return VK_ERROR_EXTENSION_NOT_PRESENT; + + if (!physical_device->supported_extensions.extensions[idx]) + return VK_ERROR_EXTENSION_NOT_PRESENT; + + device->enabled_extensions.extensions[idx] = true; } p_atomic_set(&device->private_data_next_index, 0); diff --git a/src/vulkan/util/vk_device.h b/src/vulkan/util/vk_device.h index b0b3883b4a5..e31688475c8 100644 --- a/src/vulkan/util/vk_device.h +++ b/src/vulkan/util/vk_device.h @@ -57,8 +57,7 @@ vk_device_init(struct vk_device *device, struct vk_physical_device *physical_device, const struct vk_device_dispatch_table *dispatch_table, const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *instance_alloc, - const VkAllocationCallbacks *device_alloc); + const VkAllocationCallbacks *alloc); void vk_device_finish(struct vk_device *device); diff --git a/src/vulkan/util/vk_instance.c b/src/vulkan/util/vk_instance.c index 7d6b83cc271..952deed5156 100644 --- a/src/vulkan/util/vk_instance.c +++ b/src/vulkan/util/vk_instance.c @@ -57,32 +57,28 @@ vk_instance_init(struct vk_instance *instance, if (instance->app_info.api_version == 0) instance->app_info.api_version = VK_API_VERSION_1_0; - if (supported_extensions != NULL) { - for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { - int idx; - for (idx = 0; idx < VK_INSTANCE_EXTENSION_COUNT; idx++) { - if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], - vk_instance_extensions[idx].extensionName) == 0) - break; - } - - if (idx >= VK_INSTANCE_EXTENSION_COUNT) - return VK_ERROR_EXTENSION_NOT_PRESENT; - - if (!supported_extensions->extensions[idx]) - return VK_ERROR_EXTENSION_NOT_PRESENT; - - instance->enabled_extensions.extensions[idx] = true; + for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { + int idx; + for (idx = 0; idx < VK_INSTANCE_EXTENSION_COUNT; idx++) { + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], + vk_instance_extensions[idx].extensionName) == 0) + break; } + + if (idx >= VK_INSTANCE_EXTENSION_COUNT) + return VK_ERROR_EXTENSION_NOT_PRESENT; + + if (!supported_extensions->extensions[idx]) + return VK_ERROR_EXTENSION_NOT_PRESENT; + + instance->enabled_extensions.extensions[idx] = true; } - if (dispatch_table != NULL) { - instance->dispatch_table = *dispatch_table; + instance->dispatch_table = *dispatch_table; - /* Add common entrypoints without overwriting driver-provided ones. */ - vk_instance_dispatch_table_from_entrypoints( - &instance->dispatch_table, &vk_common_instance_entrypoints, false); - } + /* Add common entrypoints without overwriting driver-provided ones. */ + vk_instance_dispatch_table_from_entrypoints( + &instance->dispatch_table, &vk_common_instance_entrypoints, false); if (mtx_init(&instance->debug_report.callbacks_mutex, mtx_plain) != 0) return VK_ERROR_INITIALIZATION_FAILED; diff --git a/src/vulkan/util/vk_physical_device.c b/src/vulkan/util/vk_physical_device.c index 320b7460c12..d544685a4b5 100644 --- a/src/vulkan/util/vk_physical_device.c +++ b/src/vulkan/util/vk_physical_device.c @@ -39,13 +39,11 @@ vk_physical_device_init(struct vk_physical_device *pdevice, if (supported_extensions != NULL) pdevice->supported_extensions = *supported_extensions; - if (dispatch_table != NULL) { - pdevice->dispatch_table = *dispatch_table; + pdevice->dispatch_table = *dispatch_table; - /* Add common entrypoints without overwriting driver-provided ones. */ - vk_physical_device_dispatch_table_from_entrypoints( - &pdevice->dispatch_table, &vk_common_physical_device_entrypoints, false); - } + /* Add common entrypoints without overwriting driver-provided ones. */ + vk_physical_device_dispatch_table_from_entrypoints( + &pdevice->dispatch_table, &vk_common_physical_device_entrypoints, false); return VK_SUCCESS; }