diff options
| author | Mark Young <marky@lunarg.com> | 2021-11-30 16:38:25 -0700 |
|---|---|---|
| committer | Mark Young <marky@lunarg.com> | 2021-12-01 10:20:51 -0700 |
| commit | 43c08f83c2601ce30a9c2f9ba8a5d6059175e3bb (patch) | |
| tree | 94df4094b23f4d25a71b2760d0d3e4713e8b6be9 /cube | |
| parent | b50a0f786efc0b70ae05a9b1e1cc0526e43ee7d1 (diff) | |
| download | usermoji-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')
| -rw-r--r-- | cube/cube.c | 16 | ||||
| -rw-r--r-- | cube/cube.cpp | 19 |
2 files changed, 33 insertions, 2 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 = ℑ + } + 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" diff --git a/cube/cube.cpp b/cube/cube.cpp index cd983e06..ddbd1fc9 100644 --- a/cube/cube.cpp +++ b/cube/cube.cpp @@ -394,6 +394,7 @@ struct Demo { bool validate; bool use_break; bool suppress_popups; + bool force_errors; uint32_t current_buffer; uint32_t queue_family_count; @@ -566,6 +567,7 @@ Demo::Demo() validate{false}, use_break{false}, suppress_popups{false}, + force_errors{false}, current_buffer{0}, queue_family_count{0} { #if defined(VK_USE_PLATFORM_WIN32_KHR) @@ -923,7 +925,11 @@ void Demo::flush_init_cmd() { auto result = cmd.end(); VERIFY(result == vk::Result::eSuccess); - auto const fenceInfo = vk::FenceCreateInfo(); + auto fenceInfo = vk::FenceCreateInfo(); + if (force_errors) { + // Remove sType to intentionally force validation layer errors. + fenceInfo.sType = vk::StructureType::eRenderPassBeginInfo; + } vk::Fence fence; result = device.createFence(&fenceInfo, nullptr, &fence); VERIFY(result == vk::Result::eSuccess); @@ -1001,12 +1007,17 @@ void Demo::init(int argc, char **argv) { i++; continue; } + if (strcmp(argv[i], "--force_errors") == 0) { + force_errors = true; + continue; + } std::stringstream usage; usage << "Usage:\n " << APP_SHORT_NAME << "\t[--use_staging] [--validate]\n" << "\t[--break] [--c <framecount>] [--suppress_popups]\n" << "\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 = " << VK_PRESENT_MODE_IMMEDIATE_KHR << "\n" << "\t\tVK_PRESENT_MODE_MAILBOX_KHR = " << VK_PRESENT_MODE_MAILBOX_KHR << "\n" @@ -1896,11 +1907,15 @@ void Demo::prepare_depth() { result = device.bindImageMemory(depth.image, depth.mem, 0); VERIFY(result == vk::Result::eSuccess); - auto const view = vk::ImageViewCreateInfo() + auto view = vk::ImageViewCreateInfo() .setImage(depth.image) .setViewType(vk::ImageViewType::e2D) .setFormat(depth.format) .setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eDepth, 0, 1, 0, 1)); + if (force_errors) { + // Intentionally force a bad pNext value to generate a validation layer error + view.pNext = ℑ + } result = device.createImageView(&view, nullptr, &depth.view); VERIFY(result == vk::Result::eSuccess); } |
