layers:Migrate image barrier check
authorTobin Ehlis <tobine@google.com>
Thu, 20 Jul 2017 16:20:44 +0000 (10:20 -0600)
committerTobin Ehlis <tobine@google.com>
Mon, 24 Jul 2017 21:28:18 +0000 (15:28 -0600)
This check is only relevant within a renderPass so move it to the
function specifically dedicated for in-renderPass barrier checks.

layers/core_validation.cpp
layers/vk_validation_error_database.txt

index 36d3f34..6a2e983 100644 (file)
@@ -6227,7 +6227,8 @@ static bool ValidateRenderPassPipelineBarriers(layer_data *device_data, const ch
             }
         }
         for (uint32_t i = 0; i < image_mem_barrier_count; ++i) {
-            const auto &img_src_access_mask = image_barriers[i].srcAccessMask;
+            const auto &img_barrier = image_barriers[i];
+            const auto &img_src_access_mask = img_barrier.srcAccessMask;
             if (img_src_access_mask != (sub_src_access_mask & img_src_access_mask)) {
                 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
                                 VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, rp_handle, __LINE__, VALIDATION_ERROR_1b80092e, "CORE",
@@ -6237,7 +6238,7 @@ static bool ValidateRenderPassPipelineBarriers(layer_data *device_data, const ch
                                 funcName, i, img_src_access_mask, sub_src_access_mask, cb_state->activeSubpass, rp_handle,
                                 validation_error_map[VALIDATION_ERROR_1b80092e]);
             }
-            const auto &img_dst_access_mask = image_barriers[i].dstAccessMask;
+            const auto &img_dst_access_mask = img_barrier.dstAccessMask;
             if (img_dst_access_mask != (sub_dst_access_mask & img_dst_access_mask)) {
                 skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
                                 VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, rp_handle, __LINE__, VALIDATION_ERROR_1b800930, "CORE",
@@ -6249,7 +6250,7 @@ static bool ValidateRenderPassPipelineBarriers(layer_data *device_data, const ch
             }
             // Verify that a framebuffer image matches barrier image
             const auto &fb_state = GetFramebufferState(device_data, cb_state->activeFramebuffer);
-            const auto img_bar_image = image_barriers[i].image;
+            const auto img_bar_image = img_barrier.image;
             bool image_match = false;
             for (const auto &fb_attach : fb_state->attachments) {
                 if (img_bar_image == fb_attach.image) {
@@ -6265,6 +6266,16 @@ static bool ValidateRenderPassPipelineBarriers(layer_data *device_data, const ch
                             ") does not match an image from the current framebuffer (0x%" PRIx64 "). %s",
                             funcName, i, HandleToUint64(img_bar_image), fb_handle, validation_error_map[VALIDATION_ERROR_1b800936]);
             }
+            if (img_barrier.oldLayout != img_barrier.newLayout) {
+                skip |=
+                    log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
+                            HandleToUint64(cb_state->commandBuffer), __LINE__, VALIDATION_ERROR_1b80093a, "CORE",
+                            "%s: As the Image Barrier for image 0x%" PRIx64
+                            " is being executed within a render pass instance, oldLayout must equal newLayout yet they are "
+                            "%s and %s. %s",
+                            funcName, HandleToUint64(img_barrier.image), string_VkImageLayout(img_barrier.oldLayout),
+                            string_VkImageLayout(img_barrier.newLayout), validation_error_map[VALIDATION_ERROR_1b80093a]);
+            }
         }
         if (sub_dep.dependencyFlags != dependency_flags) {
             skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT,
@@ -6337,16 +6348,6 @@ static bool ValidateBarriers(layer_data *device_data, const char *funcName, GLOB
         }
 
         if (mem_barrier->oldLayout != mem_barrier->newLayout) {
-            if (cb_state->activeRenderPass) {
-                skip |=
-                    log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
-                            HandleToUint64(cb_state->commandBuffer), __LINE__, VALIDATION_ERROR_1b80093a, "DS",
-                            "%s: As the Image Barrier for image 0x%" PRIx64
-                            " is being executed within a render pass instance, oldLayout must equal newLayout yet they are "
-                            "%s and %s. %s",
-                            funcName, HandleToUint64(mem_barrier->image), string_VkImageLayout(mem_barrier->oldLayout),
-                            string_VkImageLayout(mem_barrier->newLayout), validation_error_map[VALIDATION_ERROR_1b80093a]);
-            }
             skip |= ValidateMaskBitsFromLayouts(device_data, cb_state->commandBuffer, mem_barrier->srcAccessMask,
                                                 mem_barrier->oldLayout, "Source");
             skip |= ValidateMaskBitsFromLayouts(device_data, cb_state->commandBuffer, mem_barrier->dstAccessMask,
index b67007a..1561786 100644 (file)
@@ -2114,7 +2114,7 @@ VALIDATION_ERROR_1b800932~^~Y~^~RenderPassBarrierConflicts~^~vkCmdPipelineBarrie
 VALIDATION_ERROR_1b800934~^~Y~^~RenderPassBarrierConflicts~^~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~^~Y~^~RenderPassBarrierConflicts~^~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)~^~
 VALIDATION_ERROR_1b800938~^~N~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-oldLayout-01180~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the oldLayout and newLayout members of any element of pImageMemoryBarriers must be equal to the layout member of an element of the pColorAttachments, pResolveAttachments or pDepthStencilAttachment members of the VkSubpassDescription instance that the current subpass was created with, that refers to the same image' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-oldLayout-01180)~^~
-VALIDATION_ERROR_1b80093a~^~Y~^~InvalidBarriers~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-oldLayout-01181~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the oldLayout and newLayout members of an element of pImageMemoryBarriers must be equal' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-oldLayout-01181)~^~
+VALIDATION_ERROR_1b80093a~^~Y~^~RenderPassBarrierConflicts~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-oldLayout-01181~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the oldLayout and newLayout members of an element of pImageMemoryBarriers must be equal' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-oldLayout-01181)~^~
 VALIDATION_ERROR_1b80093c~^~N~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-srcQueueFamilyIndex-01182~^~core~^~The spec valid usage text states 'If vkCmdPipelineBarrier is called within a render pass instance, the srcQueueFamilyIndex and dstQueueFamilyIndex members of any element of pImageMemoryBarriers must be VK_QUEUE_FAMILY_IGNORED' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-srcQueueFamilyIndex-01182)~^~
 VALIDATION_ERROR_1b80093e~^~Y~^~InvalidBarriers~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-srcStageMask-01183~^~core~^~The spec valid usage text states 'Any pipeline stage included in srcStageMask or dstStageMask must be supported by the capabilities of the queue family specified by the queueFamilyIndex member of the VkCommandPoolCreateInfo structure that was used to create the VkCommandPool that commandBuffer was allocated from, as specified in the table of supported pipeline stages.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-srcStageMask-01183)~^~
 VALIDATION_ERROR_1b800940~^~N~^~Unknown~^~vkCmdPipelineBarrier~^~VUID-vkCmdPipelineBarrier-pMemoryBarriers-01184~^~core~^~The spec valid usage text states 'Any given element of pMemoryBarriers, pBufferMemoryBarriers or pImageMemoryBarriers must not have any access flag included in its srcAccessMask member if that bit is not supported by any of the pipeline stages in srcStageMask, as specified in the table of supported access types.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdPipelineBarrier-pMemoryBarriers-01184)~^~