From 445f91a458ffb79dfe08e0177ecbd2ec51a920b8 Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Mon, 17 Jul 2017 14:49:12 -0600 Subject: [PATCH] layers:Add barrer access mask checks Verify that src/dstAccessMask from pMemoryBarriers is a subset of the corresponding mask from the relevant VkSubpassDependency instance. --- layers/core_validation.cpp | 40 ++++++++++++++++++++----- layers/vk_validation_error_database.txt | 4 +-- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index e5b11c9c..e85ceeed 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -6147,7 +6147,7 @@ VKAPI_ATTR void VKAPI_CALL CmdResetEvent(VkCommandBuffer commandBuffer, VkEvent // Pre: cb_state->activeRenderPass must be a pointer to valid renderPass state static bool ValidateRenderPassPipelineBarriers(layer_data *device_data, const char *funcName, GLOBAL_CB_NODE const *cb_state, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, - uint32_t memBarrierCount, const VkMemoryBarrier *pMemBarriers, + uint32_t mem_barrier_count, const VkMemoryBarrier *mem_barriers, uint32_t bufferBarrierCount, const VkBufferMemoryBarrier *pBufferMemBarriers, uint32_t imageMemBarrierCount, const VkImageMemoryBarrier *pImageMemBarriers) { bool skip = false; @@ -6162,24 +6162,50 @@ static bool ValidateRenderPassPipelineBarriers(layer_data *device_data, const ch } else { assert(rp_state->subpass_to_dependency_index[cb_state->activeSubpass] != -1); const auto &sub_dep = rp_state->createInfo.pDependencies[rp_state->subpass_to_dependency_index[cb_state->activeSubpass]]; - const auto &sub_src_mask = sub_dep.srcStageMask; - const auto &sub_dst_mask = sub_dep.dstStageMask; - if (src_stage_mask != (sub_src_mask & src_stage_mask)) { + const auto &sub_src_stage_mask = sub_dep.srcStageMask; + const auto &sub_dst_stage_mask = sub_dep.dstStageMask; + if (src_stage_mask != (sub_src_stage_mask & src_stage_mask)) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, rp_handle, __LINE__, VALIDATION_ERROR_1b80092a, "CORE", "%s: Barrier srcStageMask(0x%X) is not a subset of VkSubpassDependency srcStageMask(0x%X) of " "subpass %d of renderPass 0x%" PRIx64 ". %s", - funcName, src_stage_mask, sub_src_mask, cb_state->activeSubpass, rp_handle, + funcName, src_stage_mask, sub_src_stage_mask, cb_state->activeSubpass, rp_handle, validation_error_map[VALIDATION_ERROR_1b80092a]); } - if (dst_stage_mask != (sub_dst_mask & dst_stage_mask)) { + if (dst_stage_mask != (sub_dst_stage_mask & dst_stage_mask)) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, rp_handle, __LINE__, VALIDATION_ERROR_1b80092c, "CORE", "%s: Barrier dstStageMask(0x%X) is not a subset of VkSubpassDependency dstStageMask(0x%X) of " "subpass %d of renderPass 0x%" PRIx64 ". %s", - funcName, dst_stage_mask, sub_dst_mask, cb_state->activeSubpass, rp_handle, + funcName, dst_stage_mask, sub_dst_stage_mask, cb_state->activeSubpass, rp_handle, validation_error_map[VALIDATION_ERROR_1b80092c]); } + const auto &sub_src_access_mask = sub_dep.srcAccessMask; + const auto &sub_dst_access_mask = sub_dep.dstAccessMask; + for (uint32_t i = 0; i < mem_barrier_count; ++i) { + const auto &mb_src_access_mask = mem_barriers[i].srcAccessMask; + if (mb_src_access_mask != (sub_src_access_mask & mb_src_access_mask)) { + skip |= + log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + rp_handle, __LINE__, VALIDATION_ERROR_1b80092e, "CORE", + "%s: Barrier pMemoryBarriers[%d].srcAccessMask(0x%X) is not a subset of VkSubpassDependency " + "srcAccessMask(0x%X) of " + "subpass %d of renderPass 0x%" PRIx64 ". %s", + funcName, i, mb_src_access_mask, sub_src_access_mask, cb_state->activeSubpass, rp_handle, + validation_error_map[VALIDATION_ERROR_1b80092e]); + } + const auto &mb_dst_access_mask = mem_barriers[i].dstAccessMask; + if (mb_dst_access_mask != (sub_dst_access_mask & mb_dst_access_mask)) { + skip |= + log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, + rp_handle, __LINE__, VALIDATION_ERROR_1b800930, "CORE", + "%s: Barrier pMemoryBarriers[%d].dstAccessMask(0x%X) is not a subset of VkSubpassDependency " + "dstAccessMask(0x%X) of " + "subpass %d of renderPass 0x%" PRIx64 ". %s", + funcName, i, mb_src_access_mask, sub_src_access_mask, cb_state->activeSubpass, rp_handle, + validation_error_map[VALIDATION_ERROR_1b800930]); + } + } } return skip; } diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt index d799144c..352405c3 100644 --- a/layers/vk_validation_error_database.txt +++ b/layers/vk_validation_error_database.txt @@ -2108,8 +2108,8 @@ VALIDATION_ERROR_1b800926~^~Y~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipel VALIDATION_ERROR_1b800928~^~Y~^~InvalidBarriers~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-pDependencies-01172~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the render pass must have been created with a VkSubpassDependency instance in pDependencies that expresses a dependency from the current subpass to itself.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-pDependencies-01172)~^~ VALIDATION_ERROR_1b80092a~^~Y~^~RenderPassBarrierConflicts~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-srcStageMask-01173~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, srcStageMask must contain a subset of the bit values in the srcStageMask member of that instance of VkSubpassDependency' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-srcStageMask-01173)~^~ VALIDATION_ERROR_1b80092c~^~Y~^~RenderPassBarrierConflicts~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-dstStageMask-01174~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, dstStageMask must contain a subset of the bit values in the dstStageMask member of that instance of VkSubpassDependency' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-dstStageMask-01174)~^~ -VALIDATION_ERROR_1b80092e~^~N~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-srcAccessMask-01175~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the srcAccessMask of any element of pMemoryBarriers or pImageMemoryBarriers must contain a subset of the bit values the srcAccessMask member of that instance of VkSubpassDependency' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-srcAccessMask-01175)~^~ -VALIDATION_ERROR_1b800930~^~N~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-dstAccessMask-01176~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the dstAccessMask of any element of pMemoryBarriers or pImageMemoryBarriers must contain a subset of the bit values the dstAccessMask member of that instance of VkSubpassDependency' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-dstAccessMask-01176)~^~ +VALIDATION_ERROR_1b80092e~^~Y~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-srcAccessMask-01175~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the srcAccessMask of any element of pMemoryBarriers or pImageMemoryBarriers must contain a subset of the bit values the srcAccessMask member of that instance of VkSubpassDependency' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-srcAccessMask-01175)~^~ +VALIDATION_ERROR_1b800930~^~Y~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-dstAccessMask-01176~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the dstAccessMask of any element of pMemoryBarriers or pImageMemoryBarriers must contain a subset of the bit values the dstAccessMask member of that instance of VkSubpassDependency' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-dstAccessMask-01176)~^~ VALIDATION_ERROR_1b800932~^~N~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-dependencyFlags-01177~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, dependencyFlags must be equal to the dependencyFlags member of that instance of VkSubpassDependency' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-dependencyFlags-01177)~^~ VALIDATION_ERROR_1b800934~^~N~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-bufferMemoryBarrierCount-01178~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, bufferMemoryBarrierCount must be 0' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-bufferMemoryBarrierCount-01178)~^~ VALIDATION_ERROR_1b800936~^~N~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-image-01179~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the image member of any element of pImageMemoryBarriers must be equal to one of the elements of pAttachments that the current framebuffer was created with, that is also referred to by one of the elements of the pColorAttachments, pResolveAttachments or pDepthStencilAttachment members of the VkSubpassDescription instance that the current subpass was created with' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-image-01179)~^~ -- 2.34.1