From 43c08f83c2601ce30a9c2f9ba8a5d6059175e3bb Mon Sep 17 00:00:00 2001 From: Mark Young Date: Tue, 30 Nov 2021 16:38:25 -0700 Subject: 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. --- cube/cube.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cube/cube.c') 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 = ℑ + } + 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 ]\n" "\t[--present_mode ]\n" "\t[--width ] [--height ]\n" + "\t[--force_errors]\n" "\t\n" "\t\tVK_PRESENT_MODE_IMMEDIATE_KHR = %d\n" "\t\tVK_PRESENT_MODE_MAILBOX_KHR = %d\n" -- cgit v1.2.3