aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlenny-lunarg <lenny@lunarg.com>2016-06-06 11:07:53 -0600
committerlenny-lunarg <lenny@lunarg.com>2016-06-06 13:35:01 -0600
commitfbe2239345caa6f3d8882b961ac875c6af310fbe (patch)
treea0cd57edb0aac8607da853755826bc6b5811a176
parentb07287d835f207646a852192ecda79a356e33872 (diff)
downloadusermoji-fbe2239345caa6f3d8882b961ac875c6af310fbe.tar.xz
demos: Added --suppress_popups flag
Added a command line option to cube and tri to suppress windows message boxes to facilitate Windows testing. Change-Id: I069f9b199c9740e1e21c42100ceec42d5fb8f0e2
-rw-r--r--demos/cube.c106
-rw-r--r--demos/tri.c90
2 files changed, 106 insertions, 90 deletions
diff --git a/demos/cube.c b/demos/cube.c
index 082ed613..dc160131 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -61,7 +61,8 @@
#ifdef _WIN32
#define ERR_EXIT(err_msg, err_class) \
do { \
- MessageBox(NULL, err_msg, err_class, MB_OK); \
+ if (!demo->suppress_popups) \
+ MessageBox(NULL, err_msg, err_class, MB_OK); \
exit(1); \
} while (0)
@@ -266,51 +267,6 @@ void dumpVec4(const char *note, vec4 vector) {
}
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) {
- 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);
- 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);
- validation_error = 1;
- } else {
- validation_error = 1;
- return false;
- }
-
-#ifdef _WIN32
- MessageBox(NULL, message, "Alert", MB_OK);
-#else
- printf("%s\n", message);
- fflush(stdout);
-#endif
- free(message);
-
- /*
- * false indicates that layer should not bail-out of an
- * API call that had validation failures. This may mean that the
- * app dies inside the driver due to invalid parameter(s).
- * That's what would happen without validation layers, so we'll
- * keep that behavior here.
- */
- return false;
-}
-
-VKAPI_ATTR VkBool32 VKAPI_CALL
BreakCallback(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType,
uint64_t srcObject, size_t location, int32_t msgCode,
const char *pLayerPrefix, const char *pMsg,
@@ -436,6 +392,7 @@ struct demo {
int32_t frameCount;
bool validate;
bool use_break;
+ bool suppress_popups;
PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallback;
PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallback;
VkDebugReportCallbackEXT msg_callback;
@@ -445,6 +402,53 @@ struct demo {
uint32_t queue_count;
};
+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) {
+ 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);
+ 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);
+ validation_error = 1;
+ } else {
+ validation_error = 1;
+ return false;
+ }
+
+#ifdef _WIN32
+ struct demo *demo = (struct demo*) pUserData;
+ if (!demo->suppress_popups)
+ MessageBox(NULL, message, "Alert", MB_OK);
+#else
+ printf("%s\n", message);
+ fflush(stdout);
+#endif
+ free(message);
+
+ /*
+ * false indicates that layer should not bail-out of an
+ * API call that had validation failures. This may mean that the
+ * app dies inside the driver due to invalid parameter(s).
+ * That's what would happen without validation layers, so we'll
+ * keep that behavior here.
+ */
+ return false;
+}
+
// Forward declaration:
static void demo_resize(struct demo *demo);
@@ -2540,7 +2544,7 @@ static void demo_init_vk(struct demo *demo) {
dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
dbgCreateInfo.pNext = NULL;
dbgCreateInfo.pfnCallback = demo->use_break ? BreakCallback : dbgFunc;
- dbgCreateInfo.pUserData = NULL;
+ dbgCreateInfo.pUserData = demo;
dbgCreateInfo.flags =
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
inst_info.pNext = &dbgCreateInfo;
@@ -2689,7 +2693,7 @@ static void demo_init_vk(struct demo *demo) {
dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
dbgCreateInfo.pNext = NULL;
dbgCreateInfo.pfnCallback = callback;
- dbgCreateInfo.pUserData = NULL;
+ dbgCreateInfo.pUserData = demo;
dbgCreateInfo.flags =
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
err = demo->CreateDebugReportCallback(demo->inst, &dbgCreateInfo, NULL,
@@ -2969,9 +2973,13 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
i++;
continue;
}
+ if (strcmp(argv[i], "--suppress_popups") == 0) {
+ demo->suppress_popups = true;
+ continue;
+ }
fprintf(stderr, "Usage:\n %s [--use_staging] [--validate] [--break] "
- "[--c <framecount>]\n",
+ "[--c <framecount>] [--suppress_popups]\n",
APP_SHORT_NAME);
fflush(stderr);
exit(1);
diff --git a/demos/tri.c b/demos/tri.c
index 441eddcb..318291bc 100644
--- a/demos/tri.c
+++ b/demos/tri.c
@@ -66,7 +66,8 @@
#ifdef _WIN32
#define ERR_EXIT(err_msg, err_class) \
do { \
- MessageBox(NULL, err_msg, err_class, MB_OK); \
+ if (!demo->suppress_popups) \
+ MessageBox(NULL, err_msg, err_class, MB_OK); \
exit(1); \
} while (0)
#elif defined __ANDROID__
@@ -119,44 +120,6 @@ struct texture_object {
static int validation_error = 0;
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) {
- char *message = (char *)malloc(strlen(pMsg) + 100);
-
- assert(message);
-
- validation_error = 1;
-
- if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
- sprintf(message, "ERROR: [%s] Code %d : %s", pLayerPrefix, msgCode,
- pMsg);
- } else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
- sprintf(message, "WARNING: [%s] Code %d : %s", pLayerPrefix, msgCode,
- pMsg);
- } else {
- return false;
- }
-
-#ifdef _WIN32
- MessageBox(NULL, message, "Alert", MB_OK);
-#else
- printf("%s\n", message);
- fflush(stdout);
-#endif
- free(message);
-
- /*
- * false indicates that layer should not bail-out of an
- * API call that had validation failures. This may mean that the
- * app dies inside the driver due to invalid parameter(s).
- * That's what would happen without validation layers, so we'll
- * keep that behavior here.
- */
- return false;
-}
-
-VKAPI_ATTR VkBool32 VKAPI_CALL
BreakCallback(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType,
uint64_t srcObject, size_t location, int32_t msgCode,
const char *pLayerPrefix, const char *pMsg,
@@ -193,6 +156,7 @@ struct demo {
VkSurfaceKHR surface;
bool prepared;
bool use_staging_buffer;
+ bool suppress_popups;
VkInstance inst;
VkPhysicalDevice gpu;
@@ -285,6 +249,46 @@ struct demo {
uint32_t queue_count;
};
+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) {
+ char *message = (char *)malloc(strlen(pMsg) + 100);
+
+ assert(message);
+
+ validation_error = 1;
+
+ if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
+ sprintf(message, "ERROR: [%s] Code %d : %s", pLayerPrefix, msgCode,
+ pMsg);
+ } else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
+ sprintf(message, "WARNING: [%s] Code %d : %s", pLayerPrefix, msgCode,
+ pMsg);
+ } else {
+ return false;
+ }
+
+#ifdef _WIN32
+ struct demo *demo = (struct demo*) pUserData;
+ if (!demo->suppress_popups)
+ MessageBox(NULL, message, "Alert", MB_OK);
+#else
+ printf("%s\n", message);
+ fflush(stdout);
+#endif
+ free(message);
+
+ /*
+ * false indicates that layer should not bail-out of an
+ * API call that had validation failures. This may mean that the
+ * app dies inside the driver due to invalid parameter(s).
+ * That's what would happen without validation layers, so we'll
+ * keep that behavior here.
+ */
+ return false;
+}
+
// Forward declaration:
static void demo_resize(struct demo *demo);
@@ -2120,7 +2124,7 @@ static void demo_init_vk(struct demo *demo) {
dbgCreateInfo.flags =
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
dbgCreateInfo.pfnCallback = demo->use_break ? BreakCallback : dbgFunc;
- dbgCreateInfo.pUserData = NULL;
+ dbgCreateInfo.pUserData = demo;
dbgCreateInfo.pNext = NULL;
err = demo->CreateDebugReportCallback(demo->inst, &dbgCreateInfo, NULL,
&demo->msg_callback);
@@ -2376,9 +2380,13 @@ static void demo_init(struct demo *demo, const int argc, const char *argv[])
i++;
continue;
}
+ if (strcmp(argv[i], "--suppress_popups") == 0) {
+ demo->suppress_popups = true;
+ continue;
+ }
fprintf(stderr, "Usage:\n %s [--use_staging] [--validate] [--break] "
- "[--c <framecount>]\n",
+ "[--c <framecount>] [--suppress_popups]\n",
APP_SHORT_NAME);
fflush(stderr);
exit(1);