aboutsummaryrefslogtreecommitdiff
path: root/layers/buffer_validation.cpp
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2017-12-03 20:16:32 -0800
committerMark Lobodzinski <mark@lunarg.com>2017-12-05 13:55:16 -0700
commit57fb625663db6fe1d11c6fa0f6047b29695aac78 (patch)
treefeae8800ae7b19adfea8d31a55d85d44bf287b94 /layers/buffer_validation.cpp
parent4449a761d5dba8a95c536777f6c09be2bc01657e (diff)
downloadusermoji-57fb625663db6fe1d11c6fa0f6047b29695aac78.tar.xz
layers: Add warning for LOAD_OP_LOAD+LAYOUT_UNDEFINED
While not technically an error (VK_IMAGE_LAYOUT_UNDEFINED is always allowed as an initial layout), this combination is almost never what you actually want. If nothing else, it's a potential performance problem because VK_ATTACHMENT_LOAD_OP_LOAD is liable to be more expensive than VK_ATTACHMENT_LOAD_OP_DONT_CARE. Give developers a helpful warning in this case. This would have caught an actual bug in some of the Sascha Willems demos as fixed in this PR: https://github.com/SaschaWillems/Vulkan/pull/400 Change-Id: I73c64ae60a65cfb200db00707d650ec8da7ba130
Diffstat (limited to 'layers/buffer_validation.cpp')
-rw-r--r--layers/buffer_validation.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp
index 60e7842b..77314a2a 100644
--- a/layers/buffer_validation.cpp
+++ b/layers/buffer_validation.cpp
@@ -2793,6 +2793,32 @@ bool ValidateLayouts(core_validation::layer_data *device_data, VkDevice device,
const debug_report_data *report_data = core_validation::GetReportData(device_data);
bool skip = false;
+ for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) {
+ VkFormat format = pCreateInfo->pAttachments[i].format;
+ if (pCreateInfo->pAttachments[i].initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) {
+ if ((FormatIsColor(format) || FormatHasDepth(format)) &&
+ pCreateInfo->pAttachments[i].loadOp == VK_ATTACHMENT_LOAD_OP_LOAD) {
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
+ __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS",
+ "Render pass has an attachment with loadOp == VK_ATTACHMENT_LOAD_OP_LOAD and "
+ "initialLayout == VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you "
+ "intended. Consider using VK_ATTACHMENT_LOAD_OP_DONT_CARE instead if the "
+ "image truely is undefined at the start of the render pass.");
+ }
+ if (FormatHasStencil(format) &&
+ pCreateInfo->pAttachments[i].stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD) {
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
+ __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS",
+ "Render pass has an attachment with stencilLoadOp == VK_ATTACHMENT_LOAD_OP_LOAD "
+ "and initialLayout == VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you "
+ "intended. Consider using VK_ATTACHMENT_LOAD_OP_DONT_CARE instead if the "
+ "image truely is undefined at the start of the render pass.");
+ }
+ }
+ }
+
// Track when we're observing the first use of an attachment
std::vector<bool> attach_first_use(pCreateInfo->attachmentCount, true);
for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {