aboutsummaryrefslogtreecommitdiff
path: root/cube/cube.cpp
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.cpp
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.cpp')
-rw-r--r--cube/cube.cpp19
1 files changed, 17 insertions, 2 deletions
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 = &image;
+ }
result = device.createImageView(&view, nullptr, &depth.view);
VERIFY(result == vk::Result::eSuccess);
}