aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Northrop <cnorthrop@google.com>2016-09-27 10:50:57 -0600
committerCody Northrop <cnorthrop@google.com>2016-09-28 11:41:16 -0600
commitaf28a53c67a4a3ff08d5e9b201d05379888e55a3 (patch)
tree011a241a03aedf0cbd4a6a3ac49a2ac91cf493e3
parentc5e5a8c7b716d39ccdf1fd38653317c9853cc39e (diff)
downloadusermoji-af28a53c67a4a3ff08d5e9b201d05379888e55a3.tar.xz
demos: Clean up logging for Android
-rw-r--r--demos/cube.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/demos/cube.c b/demos/cube.c
index 42a6f73d..7f12ed93 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -422,55 +422,71 @@ VKAPI_ATTR VkBool32 VKAPI_CALL
dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType,
uint64_t srcObject, size_t location, int32_t msgCode,
const char *pLayerPrefix, const char *pMsg, void *pUserData) {
+
+ // clang-format off
char *message = (char *)malloc(strlen(pMsg) + 100);
assert(message);
- if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
- sprintf(message, "ERROR: [%s] Code %d : %s", pLayerPrefix, msgCode,
- pMsg);
+ // We know we're submitting queues without fences, ignore this
+ if (strstr(pMsg, "vkQueueSubmit parameter, VkFence fence, is null pointer"))
+ return false;
+
+ if (msgFlags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
+ sprintf(message, "INFORMATION: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
validation_error = 1;
} else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
- // We know that we're submitting queues without fences, ignore this
- // warning
- if (strstr(pMsg,
- "vkQueueSubmit parameter, VkFence fence, is null pointer")) {
- return false;
- }
- sprintf(message, "WARNING: [%s] Code %d : %s", pLayerPrefix, msgCode,
- pMsg);
+ sprintf(message, "WARNING: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
+ validation_error = 1;
+ } else if (msgFlags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) {
+ sprintf(message, "PERFOERMANCE WARNING: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
+ validation_error = 1;
+ } else if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
+ sprintf(message, "ERROR: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
+ validation_error = 1;
+ } else if (msgFlags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
+ sprintf(message, "DEBUG: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
validation_error = 1;
} else {
+ sprintf(message, "INFORMATION: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
validation_error = 1;
- return false;
}
#ifdef _WIN32
+
in_callback = true;
struct demo *demo = (struct demo*) pUserData;
if (!demo->suppress_popups)
MessageBox(NULL, message, "Alert", MB_OK);
in_callback = false;
+
#elif defined(ANDROID)
+
if (msgFlags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
- __android_log_print(ANDROID_LOG_INFO, "Cube", "%s", message);
+ __android_log_print(ANDROID_LOG_INFO, APP_SHORT_NAME, "%s", message);
} else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
- __android_log_print(ANDROID_LOG_WARN, "Cube", "%s", message);
+ __android_log_print(ANDROID_LOG_WARN, APP_SHORT_NAME, "%s", message);
} else if (msgFlags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) {
- __android_log_print(ANDROID_LOG_WARN, "Cube", "%s", message);
+ __android_log_print(ANDROID_LOG_WARN, APP_SHORT_NAME, "%s", message);
} else if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
- __android_log_print(ANDROID_LOG_ERROR, "Cube", "%s", message);
+ __android_log_print(ANDROID_LOG_ERROR, APP_SHORT_NAME, "%s", message);
} else if (msgFlags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
- __android_log_print(ANDROID_LOG_DEBUG, "Cube", "%s", message);
+ __android_log_print(ANDROID_LOG_DEBUG, APP_SHORT_NAME, "%s", message);
} else {
- __android_log_print(ANDROID_LOG_INFO, "Cube", "%s", message);
+ __android_log_print(ANDROID_LOG_INFO, APP_SHORT_NAME, "%s", message);
}
+
#else
+
printf("%s\n", message);
fflush(stdout);
+
#endif
+
free(message);
+ //clang-format on
+
/*
* false indicates that layer should not bail-out of an
* API call that had validation failures. This may mean that the
@@ -3209,6 +3225,9 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
continue;
}
+#if defined(ANDROID)
+ ERR_EXIT("Usage: cube [--validate]\n", "Usage");
+#else
fprintf(stderr, "Usage:\n %s [--use_staging] [--validate] [--break] "
#if defined(VK_USE_PLATFORM_XLIB_KHR)
"[--xlib] "
@@ -3217,6 +3236,7 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
APP_SHORT_NAME);
fflush(stderr);
exit(1);
+#endif
}
if (!demo->use_xlib)
@@ -3355,7 +3375,7 @@ static void processCommand(struct android_app* app, int32_t cmd) {
// Use the following key to send arguments, i.e.
// --es args "--validate"
const char key[] = "args";
- char* appTag = (char*) "Cube";
+ char* appTag = (char*) APP_SHORT_NAME;
int argc = 0;
char** argv = get_args(app, key, appTag, &argc);