diff options
| author | Peter Lohrmann <plohrmann@gmail.com> | 2017-03-17 16:58:14 -0700 |
|---|---|---|
| committer | Mark Lobodzinski <mark@lunarg.com> | 2017-03-22 12:07:28 -0600 |
| commit | c93b7a7bd9d1bbf1f12da7d80e6e901758a8667d (patch) | |
| tree | e367387b539dbd8cc631c0d48ca2c89afaf76073 | |
| parent | a6e625b7a5c389af261752853e8e7fe5463ddc50 (diff) | |
| download | usermoji-c93b7a7bd9d1bbf1f12da7d80e6e901758a8667d.tar.xz | |
layers: Deep copy pQueueFamilyIndicies
IMAGE_STATE/BUFFER_STATE classes did not make deep copies of the
createinfo.pQueueFamilyIndices array, which could cause invalid
warnings to be reported to the user.
Change-Id: I7ebda777de9decb0c532a4999f78573460197fd7
| -rw-r--r-- | layers/core_validation_types.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h index 73b5c802..f2659aed 100644 --- a/layers/core_validation_types.h +++ b/layers/core_validation_types.h @@ -221,12 +221,27 @@ class BUFFER_STATE : public BINDABLE { VkBuffer buffer; VkBufferCreateInfo createInfo; BUFFER_STATE(VkBuffer buff, const VkBufferCreateInfo *pCreateInfo) : buffer(buff), createInfo(*pCreateInfo) { + if (createInfo.queueFamilyIndexCount > 0) { + uint32_t *pQueueFamilyIndices = new uint32_t[createInfo.queueFamilyIndexCount]; + for (uint32_t i = 0; i < createInfo.queueFamilyIndexCount; i++) { + pQueueFamilyIndices[i] = pCreateInfo->pQueueFamilyIndices[i]; + } + createInfo.pQueueFamilyIndices = pQueueFamilyIndices; + } + if (createInfo.flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) { sparse = true; } }; BUFFER_STATE(BUFFER_STATE const &rh_obj) = delete; + + ~BUFFER_STATE() { + if (createInfo.queueFamilyIndexCount > 0) { + delete createInfo.pQueueFamilyIndices; + createInfo.pQueueFamilyIndices = nullptr; + } + }; }; class BUFFER_VIEW_STATE : public BASE_NODE { @@ -252,12 +267,27 @@ class IMAGE_STATE : public BINDABLE { bool acquired; // If this is a swapchain image, has it been acquired by the app. IMAGE_STATE(VkImage img, const VkImageCreateInfo *pCreateInfo) : image(img), createInfo(*pCreateInfo), valid(false), acquired(false) { + if (createInfo.queueFamilyIndexCount > 0) { + uint32_t *pQueueFamilyIndices = new uint32_t[createInfo.queueFamilyIndexCount]; + for (uint32_t i = 0; i < createInfo.queueFamilyIndexCount; i++) { + pQueueFamilyIndices[i] = pCreateInfo->pQueueFamilyIndices[i]; + } + createInfo.pQueueFamilyIndices = pQueueFamilyIndices; + } + if (createInfo.flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) { sparse = true; } }; IMAGE_STATE(IMAGE_STATE const &rh_obj) = delete; + + ~IMAGE_STATE() { + if (createInfo.queueFamilyIndexCount > 0) { + delete createInfo.pQueueFamilyIndices; + createInfo.pQueueFamilyIndices = nullptr; + } + }; }; class IMAGE_VIEW_STATE : public BASE_NODE { |
