From a6ab2abe79559aa76df2283abea52893c9da31b9 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Fri, 10 Jun 2016 02:36:25 -0600 Subject: layers: Add bug fix to handle NULL attachment case Correctly handle null resolve attachment case. When verifying attachment compatibility, matching null resolves is ok. --- layers/core_validation.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index b4d8e510..a95f99b7 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -2133,6 +2133,15 @@ static bool attachment_references_compatible(const uint32_t index, const VkAttac const uint32_t primaryCount, const VkAttachmentDescription *pPrimaryAttachments, const VkAttachmentReference *pSecondary, const uint32_t secondaryCount, const VkAttachmentDescription *pSecondaryAttachments) { + // Check potential NULL cases first to avoid nullptr issues later + if (pPrimary == nullptr) { + if (pSecondary == nullptr) { + return true; + } + return false; + } else if (pSecondary == nullptr) { + return false; + } if (index >= primaryCount) { // Check secondary as if primary is VK_ATTACHMENT_UNUSED if (VK_ATTACHMENT_UNUSED == pSecondary[index].attachment) return true; @@ -2150,7 +2159,7 @@ static bool attachment_references_compatible(const uint32_t index, const VkAttac return false; } -// For give primary and secondary RenderPass objects, verify that they're compatible +// For given primary and secondary RenderPass objects, verify that they're compatible static bool verify_renderpass_compatibility(const layer_data *my_data, const VkRenderPass primaryRP, const VkRenderPass secondaryRP, string &errorMsg) { auto primary_render_pass = getRenderPass(my_data, primaryRP); @@ -8248,6 +8257,7 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateFramebuffer(VkDevice device, const VkFrameb VkFramebuffer *pFramebuffer) { bool skip_call = false; VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; + // TODO : Verify that renderPass FB is created with is compatible with FB layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); skip_call |= ValidateAttachmentImageUsage(dev_data, pCreateInfo); -- cgit v1.2.3