From fa77e8675b12dda69653d1c76e1a6f63b866bdd6 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Wed, 22 Jun 2016 10:02:02 -0600 Subject: layers: Add framebuffer attachmentCount check Verify that attachmentCount for a framebuffer matches the attachmentCount for the renderPass that framebuffer is being created with. --- layers/core_validation.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 75361f51..fd803cc9 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -8228,11 +8228,22 @@ static bool MatchUsage(layer_data *dev_data, uint32_t count, const VkAttachmentR return skip_call; } -static bool ValidateAttachmentImageUsage(layer_data *dev_data, const VkFramebufferCreateInfo *pCreateInfo) { +// Validate VkFramebufferCreateInfo which includes: +// 1. attachmentCount equals renderPass attachmentCount +static bool ValidateFramebufferCreateInfo(layer_data *dev_data, const VkFramebufferCreateInfo *pCreateInfo) { bool skip_call = false; - const VkRenderPassCreateInfo *rpci = getRenderPass(dev_data, pCreateInfo->renderPass)->pCreateInfo; - if (rpci != nullptr) { + auto rp_node = getRenderPass(dev_data, pCreateInfo->renderPass); + if (rp_node) { + const VkRenderPassCreateInfo *rpci = rp_node->pCreateInfo; + if (rpci->attachmentCount != pCreateInfo->attachmentCount) { + skip_call |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, + reinterpret_cast(pCreateInfo->renderPass), __LINE__, DRAWSTATE_RENDERPASS_INCOMPATIBLE, "DS", + "vkCreateFramebuffer(): VkFramebufferCreateInfo attachmentCount of %u does not match attachmentCount of %u of " + "renderPass (0x%" PRIxLEAST64 ") being used to create Framebuffer.", + pCreateInfo->attachmentCount, rpci->attachmentCount, reinterpret_cast(pCreateInfo->renderPass)); + } for (uint32_t subpass = 0; subpass < rpci->subpassCount; subpass++) { // Verify input attachments: skip_call |= MatchUsage(dev_data, rpci->pSubpasses[subpass].inputAttachmentCount, @@ -8246,6 +8257,12 @@ static bool ValidateAttachmentImageUsage(layer_data *dev_data, const VkFramebuff VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); } } + } else { + skip_call |= + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, + reinterpret_cast(pCreateInfo->renderPass), __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS", + "vkCreateFramebuffer(): Attempt to create framebuffer with invalid renderPass (0x%" PRIxLEAST64 ").", + reinterpret_cast(pCreateInfo->renderPass)); } return skip_call; } @@ -8256,7 +8273,7 @@ static bool ValidateAttachmentImageUsage(layer_data *dev_data, const VkFramebuff static bool PreCallValidateCreateFramebuffer(layer_data *dev_data, const VkFramebufferCreateInfo *pCreateInfo) { // TODO : Verify that renderPass FB is created with is compatible with FB bool skip_call = false; - skip_call |= ValidateAttachmentImageUsage(dev_data, pCreateInfo); + skip_call |= ValidateFramebufferCreateInfo(dev_data, pCreateInfo); return skip_call; } -- cgit v1.2.3