diff options
| author | Mark Lobodzinski <mark@lunarg.com> | 2015-10-16 13:32:24 -0600 |
|---|---|---|
| committer | Mark Lobodzinski <mark@lunarg.com> | 2015-10-16 13:32:24 -0600 |
| commit | 8a51747d56f8d601bf6651a88e5ef9a255baa4b8 (patch) | |
| tree | 7380b4b4ce76d6a4ce9dd3e39515c82fbabdaad6 | |
| parent | 715ccfa7be9fdee91a25e8be556348ddfd61f1f3 (diff) | |
| download | usermoji-8a51747d56f8d601bf6651a88e5ef9a255baa4b8.tar.xz | |
layers: LX160, Validate Descriptor Set Image Aspects
Validated that Descriptor Sets do not have both the STENCIL and
DEPTH aspect bits set in their imageViews.
| -rwxr-xr-x[-rw-r--r--] | layers/draw_state.cpp | 35 | ||||
| -rwxr-xr-x[-rw-r--r--] | layers/draw_state.h | 1 | ||||
| -rw-r--r-- | layers/vk_validation_layer_details.md | 1 |
3 files changed, 33 insertions, 4 deletions
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index 63cf6346..368493e6 100644..100755 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -869,6 +869,31 @@ static VkBool32 shadowUpdateNode(const VkDevice device, GENERIC_HEADER* pUpdate, (*pNewNode)->pNext = NULL; return skipCall; } + +static VkBool32 validateDescriptorSetImageView(VkDevice device, uint32_t writeDsCount, const VkWriteDescriptorSet *pWDS) +{ + VkBool32 skipCall = VK_FALSE; + layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + + // Check ImageAspects of each descriptorSet in each writeDescriptorSet array + for (uint32_t i = 0; i < writeDsCount; i++) { + for (uint32_t j = 0; j < pWDS[i].count; j++) { + const VkDescriptorInfo *dInfo = &pWDS[i].pDescriptors[j]; + auto imageViewItem = dev_data->imageViewMap.find(dInfo->imageView.handle); + if (imageViewItem != dev_data->imageViewMap.end()) { + VkImageAspectFlags flags = ((*imageViewItem).second)->subresourceRange.aspectMask; + if ((flags & VK_IMAGE_ASPECT_DEPTH_BIT) && + (flags & VK_IMAGE_ASPECT_STENCIL_BIT)) { + skipCall |= log_msg(mdd(device), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_IMAGE_VIEW, dInfo->imageView.handle, 0, + DRAWSTATE_INVALID_IMAGE_ASPECT, "DS", "vkUpdateDescriptorSets: DesriptorSet[%d] in WriteDesriptorSet[%d] " + "has ImageView with both STENCIL and DEPTH aspects set", i, j); + } + } + } + } + return skipCall; +} + // update DS mappings based on ppUpdateArray static VkBool32 dsUpdate(layer_data* my_data, VkDevice device, VkStructureType type, uint32_t updateCount, const void* pUpdateArray) { @@ -876,10 +901,12 @@ static VkBool32 dsUpdate(layer_data* my_data, VkDevice device, VkStructureType t const VkCopyDescriptorSet *pCDS = NULL; VkBool32 skipCall = VK_FALSE; - if (type == VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET) - pWDS = (const VkWriteDescriptorSet *) pUpdateArray; - else - pCDS = (const VkCopyDescriptorSet *) pUpdateArray; + if (type == VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET) { + pWDS = (const VkWriteDescriptorSet *)pUpdateArray; + skipCall |= validateDescriptorSetImageView(device, updateCount, pWDS); + } else { + pCDS = (const VkCopyDescriptorSet *)pUpdateArray; + } loader_platform_thread_lock_mutex(&globalLock); LAYOUT_NODE* pLayout = NULL; diff --git a/layers/draw_state.h b/layers/draw_state.h index 47145cb8..86c84a00 100644..100755 --- a/layers/draw_state.h +++ b/layers/draw_state.h @@ -70,6 +70,7 @@ typedef enum _DRAW_STATE_ERROR DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, // Clear cmd issued before any Draw in CmdBuffer, should use RenderPass Ops instead DRAWSTATE_BEGIN_CB_INVALID_STATE, // Primary/Secondary CB created with mismatched FB/RP information DRAWSTATE_VIEWPORT_SCISSOR_MISMATCH, // Count for viewports and scissors mismatch and/or state doesn't match count + DRAWSTATE_INVALID_IMAGE_ASPECT, // Image aspect is invalid for the current operation DRAWSTATE_INVALID_EXTENSION, } DRAW_STATE_ERROR; diff --git a/layers/vk_validation_layer_details.md b/layers/vk_validation_layer_details.md index fd5ce9d5..49fd9cb9 100644 --- a/layers/vk_validation_layer_details.md +++ b/layers/vk_validation_layer_details.md @@ -48,6 +48,7 @@ The DrawState layer tracks state leading into Draw cmds. This includes the Pipel | Correct Clear Use | Warn user if CmdClear for Color or DepthStencil issued to Cmd Buffer prior to a Draw Cmd. RenderPass LOAD_OP_CLEAR is preferred in this case. | CLEAR_CMD_BEFORE_DRAW | vkCmdClearColorImage vkCmdClearDepthStencilImage | ClearCmdNoDraw | NA | | Index Buffer Binding | Verify that an index buffer is bound at the point when an indexed draw is attempted. | INDEX_BUFFER_NOT_BOUND | vkCmdDrawIndexed vkCmdDrawIndexedIndirect | TODO | Implement validation test | | Viewport and Scissors match | In PSO viewportCount and scissorCount must match. Also for each count that is non-zero, there corresponding data array ptr should be non-NULL. | VIEWPORT_SCISSOR_MISMATCH | vkCreateGraphicsPipelines vkCmdSetViewport vkCmdSetScissor | TODO | Implement validation test | +| Valid Image Aspects for DS Updates | When updating Descriptor Sets, the Image Aspect must not have both the DEPTH and STENCIL aspects set | INVALID_IMAGE_ASPECT | vkUpdateDescriptorSets | TODO | Implement validation test | | NA | Enum used for informational messages | NONE | | NA | None | | NA | Enum used for errors in the layer itself. This does not indicate an app issue, but instead a bug in the layer. | INTERNAL_ERROR | | NA | None | | NA | Enum used when Drawstate attempts to allocate memory for its own internal use and is unable to. | OUT_OF_MEMORY | | NA | None | |
