aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorMichael Lentine <mlentine@google.com>2016-04-05 11:38:12 -0500
committerTobin Ehlis <tobine@google.com>2016-04-06 09:41:19 -0600
commitc28e09fc31c687850e03dc726fcfb1726feb92ec (patch)
tree9fe43d7280cd84f50128896839136a91cb4789f7 /layers/core_validation.cpp
parente927ae89168f927e12861f550677cf386d860642 (diff)
downloadusermoji-c28e09fc31c687850e03dc726fcfb1726feb92ec.tar.xz
Validate attachment index is in range.
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 0c8d07d2..0f49d207 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -9397,8 +9397,28 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice devic
dev_data->renderPassMap[*pRenderPass]->attachment_first_layout;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {
const VkSubpassDescription &subpass = pCreateInfo->pSubpasses[i];
+ for (uint32_t j = 0; j < subpass.preserveAttachmentCount; ++j) {
+ uint32_t attachment = subpass.pPreserveAttachments[j];
+ if (attachment >= pCreateInfo->attachmentCount) {
+ skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0,
+ __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS",
+ "Preserve attachment %d cannot be greater than the total number of attachments %d.",
+ attachment, pCreateInfo->attachmentCount);
+ }
+ }
for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) {
- uint32_t attachment = subpass.pColorAttachments[j].attachment;
+ uint32_t attachment;
+ if (subpass.pResolveAttachments) {
+ attachment = subpass.pResolveAttachments[j].attachment;
+ if (attachment >= pCreateInfo->attachmentCount && attachment != VK_ATTACHMENT_UNUSED) {
+ skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0,
+ __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS",
+ "Color attachment %d cannot be greater than the total number of attachments %d.",
+ attachment, pCreateInfo->attachmentCount);
+ continue;
+ }
+ }
+ attachment = subpass.pColorAttachments[j].attachment;
if (attachment >= pCreateInfo->attachmentCount) {
skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0,
__LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS",