turnip: Extend the coverage of TU_DEBUG=startup.
I found while debugging KGSL that we were missing failure output for a bunch of the error paths. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7014>
This commit is contained in:
parent
80869f0bc3
commit
a4d9a9d11c
|
@ -99,13 +99,13 @@ tu_physical_device_init(struct tu_physical_device *device,
|
|||
device->supports_multiview_mask = true;
|
||||
break;
|
||||
default:
|
||||
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"device %s is unsupported", device->name);
|
||||
result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"device %s is unsupported", device->name);
|
||||
goto fail;
|
||||
}
|
||||
if (tu_device_get_cache_uuid(device->gpu_id, device->cache_uuid)) {
|
||||
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"cannot generate UUID");
|
||||
result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"cannot generate UUID");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ tu_physical_device_init(struct tu_physical_device *device,
|
|||
|
||||
result = tu_wsi_init(device);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_error(instance, result);
|
||||
vk_startup_errorf(instance, result, "WSI init failure");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,8 @@ tu_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
if (index < 0 || !tu_instance_extensions_supported.extensions[index]) {
|
||||
vk_object_base_finish(&instance->base);
|
||||
vk_free2(&default_alloc, pAllocator, instance);
|
||||
return vk_error(instance, VK_ERROR_EXTENSION_NOT_PRESENT);
|
||||
return vk_startup_errorf(instance, VK_ERROR_EXTENSION_NOT_PRESENT,
|
||||
"Missing %s", ext_name);
|
||||
}
|
||||
|
||||
instance->enabled_extensions.extensions[index] = true;
|
||||
|
@ -276,7 +277,7 @@ tu_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
if (result != VK_SUCCESS) {
|
||||
vk_object_base_finish(&instance->base);
|
||||
vk_free2(&default_alloc, pAllocator, instance);
|
||||
return vk_error(instance, result);
|
||||
return vk_startup_errorf(instance, result, "debug_report setup failure");
|
||||
}
|
||||
|
||||
glsl_type_singleton_init_or_ref();
|
||||
|
@ -945,7 +946,8 @@ tu_queue_init(struct tu_device *device,
|
|||
|
||||
int ret = tu_drm_submitqueue_new(device, 0, &queue->msm_queue_id);
|
||||
if (ret)
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
return vk_startup_errorf(device->instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"submitqueue create failed");
|
||||
|
||||
queue->fence = -1;
|
||||
|
||||
|
@ -991,8 +993,9 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32);
|
||||
for (uint32_t i = 0; i < num_features; i++) {
|
||||
if (enabled_feature[i] && !supported_feature[i])
|
||||
return vk_error(physical_device->instance,
|
||||
VK_ERROR_FEATURE_NOT_PRESENT);
|
||||
return vk_startup_errorf(physical_device->instance,
|
||||
VK_ERROR_FEATURE_NOT_PRESENT,
|
||||
"Missing feature bit %d\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1011,7 +1014,7 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
device = vk_zalloc2(&physical_device->instance->alloc, pAllocator,
|
||||
sizeof(*device), 8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
||||
if (!device)
|
||||
return vk_error(physical_device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_startup_errorf(physical_device->instance, VK_ERROR_OUT_OF_HOST_MEMORY, "OOM");
|
||||
|
||||
vk_device_init(&device->vk, pCreateInfo,
|
||||
&physical_device->instance->alloc, pAllocator);
|
||||
|
@ -1029,8 +1032,9 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
if (index < 0 ||
|
||||
!physical_device->supported_extensions.extensions[index]) {
|
||||
vk_free(&device->vk.alloc, device);
|
||||
return vk_error(physical_device->instance,
|
||||
VK_ERROR_EXTENSION_NOT_PRESENT);
|
||||
return vk_startup_errorf(physical_device->instance,
|
||||
VK_ERROR_EXTENSION_NOT_PRESENT,
|
||||
"Missing device extension '%s'", ext_name);
|
||||
}
|
||||
|
||||
device->enabled_extensions.extensions[index] = true;
|
||||
|
@ -1044,7 +1048,9 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
&device->vk.alloc, queue_create->queueCount * sizeof(struct tu_queue),
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
|
||||
if (!device->queues[qfi]) {
|
||||
result = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
result = vk_startup_errorf(physical_device->instance,
|
||||
VK_ERROR_OUT_OF_HOST_MEMORY,
|
||||
"OOM");
|
||||
goto fail_queues;
|
||||
}
|
||||
|
||||
|
@ -1062,8 +1068,12 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
}
|
||||
|
||||
device->compiler = ir3_compiler_create(NULL, physical_device->gpu_id);
|
||||
if (!device->compiler)
|
||||
if (!device->compiler) {
|
||||
result = vk_startup_errorf(physical_device->instance,
|
||||
VK_ERROR_INITIALIZATION_FAILED,
|
||||
"failed to initialize ir3 compiler");
|
||||
goto fail_queues;
|
||||
}
|
||||
|
||||
/* initial sizes, these will increase if there is overflow */
|
||||
device->vsc_draw_strm_pitch = 0x1000 + VSC_PAD;
|
||||
|
@ -1074,12 +1084,16 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
global_size += TU_BORDER_COLOR_COUNT * sizeof(struct bcolor_entry);
|
||||
|
||||
result = tu_bo_init_new(device, &device->global_bo, global_size, false);
|
||||
if (result != VK_SUCCESS)
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_startup_errorf(device->instance, result, "BO init");
|
||||
goto fail_global_bo;
|
||||
}
|
||||
|
||||
result = tu_bo_map(device, &device->global_bo);
|
||||
if (result != VK_SUCCESS)
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_startup_errorf(device->instance, result, "BO map");
|
||||
goto fail_global_bo_map;
|
||||
}
|
||||
|
||||
struct tu6_global *global = device->global_bo.map;
|
||||
tu_init_clear_blit_shaders(device->global_bo.map);
|
||||
|
@ -1109,8 +1123,10 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
VkPipelineCache pc;
|
||||
result =
|
||||
tu_CreatePipelineCache(tu_device_to_handle(device), &ci, NULL, &pc);
|
||||
if (result != VK_SUCCESS)
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_startup_errorf(device->instance, result, "create pipeline cache failed");
|
||||
goto fail_pipeline_cache;
|
||||
}
|
||||
|
||||
device->mem_cache = tu_pipeline_cache_from_handle(pc);
|
||||
|
||||
|
|
|
@ -311,8 +311,8 @@ tu_drm_device_init(struct tu_physical_device *device,
|
|||
|
||||
fd = open(path, O_RDWR | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"failed to open device %s", path);
|
||||
return vk_startup_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"failed to open device %s", path);
|
||||
}
|
||||
|
||||
/* Version 1.6 added SYNCOBJ support. */
|
||||
|
@ -322,25 +322,27 @@ tu_drm_device_init(struct tu_physical_device *device,
|
|||
version = drmGetVersion(fd);
|
||||
if (!version) {
|
||||
close(fd);
|
||||
return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"failed to query kernel driver version for device %s",
|
||||
path);
|
||||
return vk_startup_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"failed to query kernel driver version for device %s",
|
||||
path);
|
||||
}
|
||||
|
||||
if (strcmp(version->name, "msm")) {
|
||||
drmFreeVersion(version);
|
||||
close(fd);
|
||||
return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"device %s does not use the msm kernel driver", path);
|
||||
return vk_startup_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"device %s does not use the msm kernel driver",
|
||||
path);
|
||||
}
|
||||
|
||||
if (version->version_major != min_version_major ||
|
||||
version->version_minor < min_version_minor) {
|
||||
result = vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"kernel driver for device %s has version %d.%d, "
|
||||
"but Vulkan requires version >= %d.%d",
|
||||
path, version->version_major, version->version_minor,
|
||||
min_version_major, min_version_minor);
|
||||
result = vk_startup_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"kernel driver for device %s has version %d.%d, "
|
||||
"but Vulkan requires version >= %d.%d",
|
||||
path,
|
||||
version->version_major, version->version_minor,
|
||||
min_version_major, min_version_minor);
|
||||
drmFreeVersion(version);
|
||||
close(fd);
|
||||
return result;
|
||||
|
@ -421,7 +423,8 @@ tu_enumerate_devices(struct tu_instance *instance)
|
|||
}
|
||||
|
||||
if (max_devices < 1)
|
||||
return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
|
||||
return vk_startup_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||
"No DRM devices found");
|
||||
|
||||
for (unsigned i = 0; i < (unsigned) max_devices; i++) {
|
||||
if (devices[i]->available_nodes & 1 << DRM_NODE_RENDER &&
|
||||
|
|
|
@ -129,15 +129,22 @@ struct tu_instance;
|
|||
VkResult
|
||||
__vk_errorf(struct tu_instance *instance,
|
||||
VkResult error,
|
||||
bool force_print,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *format,
|
||||
...) PRINTFLIKE(5, 6);
|
||||
...) PRINTFLIKE(6, 7);
|
||||
|
||||
#define vk_error(instance, error) \
|
||||
__vk_errorf(instance, error, __FILE__, __LINE__, NULL);
|
||||
__vk_errorf(instance, error, false, __FILE__, __LINE__, NULL);
|
||||
#define vk_errorf(instance, error, format, ...) \
|
||||
__vk_errorf(instance, error, __FILE__, __LINE__, format, ##__VA_ARGS__);
|
||||
__vk_errorf(instance, error, false, __FILE__, __LINE__, format, ##__VA_ARGS__);
|
||||
|
||||
/* Prints startup errors if TU_DEBUG=startup is set.
|
||||
*/
|
||||
#define vk_startup_errorf(instance, error, format, ...) \
|
||||
__vk_errorf(instance, error, instance->debug_flags & TU_DEBUG_STARTUP, \
|
||||
__FILE__, __LINE__, format, ##__VA_ARGS__)
|
||||
|
||||
void
|
||||
__tu_finishme(const char *file, int line, const char *format, ...)
|
||||
|
|
|
@ -49,6 +49,7 @@ void PRINTFLIKE(3, 4)
|
|||
VkResult
|
||||
__vk_errorf(struct tu_instance *instance,
|
||||
VkResult error,
|
||||
bool always_print,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *format,
|
||||
|
@ -60,7 +61,8 @@ __vk_errorf(struct tu_instance *instance,
|
|||
const char *error_str = vk_Result_to_str(error);
|
||||
|
||||
#ifndef DEBUG
|
||||
return error;
|
||||
if (!always_print)
|
||||
return error;
|
||||
#endif
|
||||
|
||||
if (format) {
|
||||
|
|
Loading…
Reference in New Issue