mesa: Promote Intel's simple logging façade for Android to util/
I'm bringing up freedreno Vulkan on an Android phone, and my pains are
exactly what Chad said when working on Intel's vulkan for Android in
aa716db0f6
("intel: Add simple logging façade for Android (v2)"):
On Android, stdio goes to /dev/null. On Android, remote gdb is even
more painful than the usual remote gdb. On Android, nothing works like
you expect and debugging is hell. I need logging.
This patch introduces a small, simple logging API that can easily wrap
Android's API. On non-Android platforms, this logger does nothing
fancy. It follows the time-honored Unix tradition of spewing
everything to stderr with minimal fuss.
My goal here is not perfection. My goal is to make a minimal, clean API,
that people hate merely a little instead of a lot, and that's good
enough to let me bring up Android Vulkan. And it needs to be fast,
which means it must be small. No one wants to their game to miss frames
while aiming a flaming bow into the jaws of an angry robot t-rex, and
thus become t-rex breakfast, because some fool had too much fun desiging
a bloated, ideal logging API.
Compared to trusty fprintf, _mesa_log[ewi]() is actually usable on
Android. Compared to os_log_message(), this has different error levels
and supports format arguments.
The only code change in the move is wrapping flockfile/funlockfile in
!DETECT_OS_WINDOWS, since mingw32 doesn't have it. Windows likely wants
different logging code, anyway.
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6806>
This commit is contained in:
@@ -92,7 +92,8 @@ struct gen_perf_query_result;
|
||||
#include "isl/isl.h"
|
||||
|
||||
#include "dev/gen_debug.h"
|
||||
#include "common/intel_log.h"
|
||||
#define MESA_LOG_TAG "MESA-INTEL"
|
||||
#include "util/log.h"
|
||||
#include "wsi_common.h"
|
||||
|
||||
#define NSEC_PER_SEC 1000000000ull
|
||||
@@ -507,7 +508,7 @@ VkResult __vk_errorf(struct anv_instance *instance, const void *object,
|
||||
* defined by extensions supported by that component.
|
||||
*/
|
||||
#define anv_debug_ignored_stype(sType) \
|
||||
intel_logd("%s: ignored VkStructureType %u\n", __func__, (sType))
|
||||
mesa_logd("%s: ignored VkStructureType %u\n", __func__, (sType))
|
||||
|
||||
void __anv_perf_warn(struct anv_device *device, const void *object,
|
||||
VkDebugReportObjectTypeEXT type, const char *file,
|
||||
@@ -523,7 +524,7 @@ void anv_loge_v(const char *format, va_list va);
|
||||
do { \
|
||||
static bool reported = false; \
|
||||
if (!reported) { \
|
||||
intel_logw("%s:%d: FINISHME: " format, __FILE__, __LINE__, \
|
||||
mesa_logw("%s:%d: FINISHME: " format, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
reported = true; \
|
||||
} \
|
||||
@@ -546,7 +547,7 @@ void anv_loge_v(const char *format, va_list va);
|
||||
#ifdef DEBUG
|
||||
#define anv_assert(x) ({ \
|
||||
if (unlikely(!(x))) \
|
||||
intel_loge("%s:%d ASSERT: %s", __FILE__, __LINE__, #x); \
|
||||
mesa_loge("%s:%d ASSERT: %s", __FILE__, __LINE__, #x); \
|
||||
})
|
||||
#else
|
||||
#define anv_assert(x)
|
||||
|
Reference in New Issue
Block a user