aboutsummaryrefslogtreecommitdiff
path: root/cube/cube.c
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2021-11-30 16:38:25 -0700
committerMark Young <marky@lunarg.com>2021-12-01 10:20:51 -0700
commit43c08f83c2601ce30a9c2f9ba8a5d6059175e3bb (patch)
tree94df4094b23f4d25a71b2760d0d3e4713e8b6be9 /cube/cube.c
parentb50a0f786efc0b70ae05a9b1e1cc0526e43ee7d1 (diff)
downloadusermoji-43c08f83c2601ce30a9c2f9ba8a5d6059175e3bb.tar.xz
vkcube/vkcubepp: Add option to force validation errors
During tests, it's hard to determine if the --validation option is actually working properly. So add an option (--force_errors) to intentionally force a few validation error messages to make sure that validation is working properly.
Diffstat (limited to 'cube/cube.c')
-rw-r--r--cube/cube.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/cube/cube.c b/cube/cube.c
index ae37be45..0f503647 100644
--- a/cube/cube.c
+++ b/cube/cube.c
@@ -446,6 +446,7 @@ struct demo {
bool validate_checks_disabled;
bool use_break;
bool suppress_popups;
+ bool force_errors;
PFN_vkCreateDebugUtilsMessengerEXT CreateDebugUtilsMessengerEXT;
PFN_vkDestroyDebugUtilsMessengerEXT DestroyDebugUtilsMessengerEXT;
@@ -633,6 +634,10 @@ static void demo_flush_init_cmd(struct demo *demo) {
VkFence fence;
VkFenceCreateInfo fence_ci = {.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .pNext = NULL, .flags = 0};
+ if (demo->force_errors) {
+ // Remove sType to intentionally force validation layer errors.
+ fence_ci.sType = 0;
+ }
err = vkCreateFence(demo->device, &fence_ci, NULL, &fence);
assert(!err);
@@ -1446,6 +1451,12 @@ static void demo_prepare_depth(struct demo *demo) {
.viewType = VK_IMAGE_VIEW_TYPE_2D,
};
+
+ if (demo->force_errors) {
+ // Intentionally force a bad pNext value to generate a validation layer error
+ view.pNext = &image;
+ }
+
VkMemoryRequirements mem_reqs;
VkResult U_ASSERT_ONLY err;
bool U_ASSERT_ONLY pass;
@@ -4010,6 +4021,10 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
i++;
continue;
}
+ if (strcmp(argv[i], "--force_errors") == 0) {
+ demo->force_errors = true;
+ continue;
+ }
#if defined(ANDROID)
ERR_EXIT("Usage: vkcube [--validate]\n", "Usage");
@@ -4021,6 +4036,7 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
"\t[--gpu_number <index of physical device>]\n"
"\t[--present_mode <present mode enum>]\n"
"\t[--width <width>] [--height <height>]\n"
+ "\t[--force_errors]\n"
"\t<present_mode_enum>\n"
"\t\tVK_PRESENT_MODE_IMMEDIATE_KHR = %d\n"
"\t\tVK_PRESENT_MODE_MAILBOX_KHR = %d\n"