From a55dc276a38fa8d146386079459cc85c8a7647ae Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 21 Sep 2020 13:02:14 -0700 Subject: [PATCH] turnip: Replace tu_log*() with mesa_log*() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This gets us logging on Android. Reviewed-by: Tapani Pälli Reviewed-by: Kristian H. Kristensen Part-of: --- src/freedreno/vulkan/tu_device.c | 2 +- src/freedreno/vulkan/tu_drm.c | 12 ++++---- src/freedreno/vulkan/tu_kgsl.c | 2 +- src/freedreno/vulkan/tu_private.h | 7 ++--- src/freedreno/vulkan/tu_util.c | 47 ++----------------------------- 5 files changed, 14 insertions(+), 56 deletions(-) diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 51b32a812d9..572b8aa030f 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -255,7 +255,7 @@ tu_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, parse_debug_string(getenv("TU_DEBUG"), tu_debug_options); if (instance->debug_flags & TU_DEBUG_STARTUP) - tu_logi("Created an instance"); + mesa_logi("Created an instance"); for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i]; diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c index 4e6206e1577..4d50ecf3410 100644 --- a/src/freedreno/vulkan/tu_drm.c +++ b/src/freedreno/vulkan/tu_drm.c @@ -347,7 +347,7 @@ tu_drm_device_init(struct tu_physical_device *device, drmFreeVersion(version); if (instance->debug_flags & TU_DEBUG_STARTUP) - tu_logi("Found compatible device '%s'.", path); + mesa_logi("Found compatible device '%s'.", path); vk_object_base_init(NULL, &device->base, VK_OBJECT_TYPE_PHYSICAL_DEVICE); device->instance = instance; @@ -365,7 +365,7 @@ tu_drm_device_init(struct tu_physical_device *device, if (tu_drm_get_gpu_id(device, &device->gpu_id)) { if (instance->debug_flags & TU_DEBUG_STARTUP) - tu_logi("Could not query the GPU ID"); + mesa_logi("Could not query the GPU ID"); result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GPU ID"); goto fail; @@ -373,7 +373,7 @@ tu_drm_device_init(struct tu_physical_device *device, if (tu_drm_get_gmem_size(device, &device->gmem_size)) { if (instance->debug_flags & TU_DEBUG_STARTUP) - tu_logi("Could not query the GMEM size"); + mesa_logi("Could not query the GMEM size"); result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GMEM size"); goto fail; @@ -381,7 +381,7 @@ tu_drm_device_init(struct tu_physical_device *device, if (tu_drm_get_gmem_base(device, &device->gmem_base)) { if (instance->debug_flags & TU_DEBUG_STARTUP) - tu_logi("Could not query the GMEM size"); + mesa_logi("Could not query the GMEM size"); result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GMEM size"); goto fail; @@ -410,9 +410,9 @@ tu_enumerate_devices(struct tu_instance *instance) if (instance->debug_flags & TU_DEBUG_STARTUP) { if (max_devices < 0) - tu_logi("drmGetDevices2 returned error: %s\n", strerror(max_devices)); + mesa_logi("drmGetDevices2 returned error: %s\n", strerror(max_devices)); else - tu_logi("Found %d drm nodes", max_devices); + mesa_logi("Found %d drm nodes", max_devices); } if (max_devices < 1) diff --git a/src/freedreno/vulkan/tu_kgsl.c b/src/freedreno/vulkan/tu_kgsl.c index db83430611b..155d7f77651 100644 --- a/src/freedreno/vulkan/tu_kgsl.c +++ b/src/freedreno/vulkan/tu_kgsl.c @@ -188,7 +188,7 @@ tu_enumerate_devices(struct tu_instance *instance) /* kgsl version check? */ if (instance->debug_flags & TU_DEBUG_STARTUP) - tu_logi("Found compatible device '%s'.", path); + mesa_logi("Found compatible device '%s'.", path); vk_object_base_init(NULL, &device->base, VK_OBJECT_TYPE_PHYSICAL_DEVICE); device->instance = instance; diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 1a78c9a7fda..3d72397483b 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -43,9 +43,12 @@ #define VG(x) ((void)0) #endif +#define MESA_LOG_TAG "TU" + #include "c11/threads.h" #include "main/macros.h" #include "util/list.h" +#include "util/log.h" #include "util/macros.h" #include "util/u_atomic.h" #include "vk_alloc.h" @@ -141,10 +144,6 @@ __vk_errorf(struct tu_instance *instance, void __tu_finishme(const char *file, int line, const char *format, ...) tu_printflike(3, 4); -void -tu_loge(const char *format, ...) tu_printflike(1, 2); -void -tu_logi(const char *format, ...) tu_printflike(1, 2); /** * Print a FINISHME message, including its source location. diff --git a/src/freedreno/vulkan/tu_util.c b/src/freedreno/vulkan/tu_util.c index ba1e4d53cd6..02fc3df163a 100644 --- a/src/freedreno/vulkan/tu_util.c +++ b/src/freedreno/vulkan/tu_util.c @@ -33,47 +33,6 @@ #include "util/u_math.h" #include "vk_enum_to_str.h" -/* TODO: Add Android support to tu_log funcs */ - -/** \see tu_loge() */ -static void -tu_loge_v(const char *format, va_list va) -{ - fprintf(stderr, "vk: error: "); - vfprintf(stderr, format, va); - fprintf(stderr, "\n"); -} - - -/** Log an error message. */ -void tu_printflike(1, 2) tu_loge(const char *format, ...) -{ - va_list va; - - va_start(va, format); - tu_loge_v(format, va); - va_end(va); -} - -/** \see tu_logi() */ -static void -tu_logi_v(const char *format, va_list va) -{ - fprintf(stderr, "tu: info: "); - vfprintf(stderr, format, va); - fprintf(stderr, "\n"); -} - -/** Log an error message. */ -void tu_printflike(1, 2) tu_logi(const char *format, ...) -{ - va_list va; - - va_start(va, format); - tu_logi_v(format, va); - va_end(va); -} - void tu_printflike(3, 4) __tu_finishme(const char *file, int line, const char *format, ...) { @@ -84,7 +43,7 @@ void tu_printflike(3, 4) vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); - fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer); + mesa_loge("%s:%d: FINISHME: %s\n", file, line, buffer); } VkResult @@ -109,9 +68,9 @@ __vk_errorf(struct tu_instance *instance, vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); - fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str); + mesa_loge("%s:%d: %s (%s)\n", file, line, buffer, error_str); } else { - fprintf(stderr, "%s:%d: %s\n", file, line, error_str); + mesa_loge("%s:%d: %s\n", file, line, error_str); } return error;