aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lentine <mlentine@google.com>2016-03-31 14:45:20 -0500
committerTobin Ehlis <tobine@google.com>2016-03-31 14:15:58 -0600
commit49f4fedd0bf98e3927dcd10cde514f20a2ab0437 (patch)
treed6accf43bc9bee5651ce5948afeab83cd45fab19
parentae5cfe4e50b13e870321ea8a974aeccfbeaba280 (diff)
downloadusermoji-49f4fedd0bf98e3927dcd10cde514f20a2ab0437.tar.xz
layers: Adding attachment checks to make sure they aren't out of range.
-rw-r--r--layers/core_validation.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index b79114e5..8ebc10b9 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -9420,6 +9420,13 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice devic
const VkSubpassDescription &subpass = pCreateInfo->pSubpasses[i];
for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) {
uint32_t 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",
+ "Color attachment %d cannot be greater than the total number of attachments %d.",
+ attachment, pCreateInfo->attachmentCount);
+ continue;
+ }
if (attachment_first_read.count(attachment))
continue;
attachment_first_read.insert(std::make_pair(attachment, false));
@@ -9427,6 +9434,13 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice devic
}
if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
uint32_t attachment = subpass.pDepthStencilAttachment->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",
+ "Depth stencil attachment %d cannot be greater than the total number of attachments %d.",
+ attachment, pCreateInfo->attachmentCount);
+ continue;
+ }
if (attachment_first_read.count(attachment))
continue;
attachment_first_read.insert(std::make_pair(attachment, false));
@@ -9434,6 +9448,13 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice devic
}
for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) {
uint32_t attachment = subpass.pInputAttachments[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",
+ "Input attachment %d cannot be greater than the total number of attachments %d.",
+ attachment, pCreateInfo->attachmentCount);
+ continue;
+ }
if (attachment_first_read.count(attachment))
continue;
attachment_first_read.insert(std::make_pair(attachment, true));