layers:Move gfx pipe check to create time
authorTobin Ehlis <tobine@google.com>
Wed, 1 Feb 2017 20:31:22 +0000 (13:31 -0700)
committerTobin Ehlis <tobine@google.com>
Wed, 1 Feb 2017 22:08:07 +0000 (15:08 -0700)
Fixes #1424

The check to verify that the attachmentCount for blend state of a
Graphics Pipeline matches the attachmentCount for the given subpass of
the creation renderPass was occurring at draw time but can and should
be done at Gfx Pipeline creation time.

This change moves the check to creation time and updates the database
and test appropriately.

layers/core_validation.cpp
layers/vk_validation_error_database.txt

index ebb900db438b12d4951a3b6ccffee96abbdb618e..a4cde2523c906fddb994347b7eae519762c4b901 100644 (file)
@@ -2885,21 +2885,6 @@ static bool ValidatePipelineDrawtimeState(layer_data const *my_data, LAST_BOUND_
             auto const render_pass_info = pCB->activeRenderPass->createInfo.ptr();
             const VkSubpassDescription *subpass_desc = &render_pass_info->pSubpasses[pCB->activeSubpass];
             uint32_t i;
-
-            const safe_VkPipelineColorBlendStateCreateInfo *color_blend_state = pPipeline->graphicsPipelineCI.pColorBlendState;
-            if ((color_blend_state != NULL) && (pCB->activeSubpass == pPipeline->graphicsPipelineCI.subpass) &&
-                (color_blend_state->attachmentCount != subpass_desc->colorAttachmentCount)) {
-                skip_call |=
-                    log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
-                            reinterpret_cast<const uint64_t &>(pPipeline->pipeline), __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS",
-                            "Render pass subpass %u mismatch with blending state defined and blend state attachment "
-                            "count %u while subpass color attachment count %u in Pipeline (0x%" PRIxLEAST64
-                            ")!  These "
-                            "must be the same at draw-time.",
-                            pCB->activeSubpass, color_blend_state->attachmentCount, subpass_desc->colorAttachmentCount,
-                            reinterpret_cast<const uint64_t &>(pPipeline->pipeline));
-            }
-
             unsigned subpass_num_samples = 0;
 
             for (i = 0; i < subpass_desc->colorAttachmentCount; i++) {
@@ -3132,6 +3117,19 @@ static bool verifyPipelineCreateState(layer_data *my_data, std::vector<PIPELINE_
     }
 
     if (pPipeline->graphicsPipelineCI.pColorBlendState != NULL) {
+        const safe_VkPipelineColorBlendStateCreateInfo *color_blend_state = pPipeline->graphicsPipelineCI.pColorBlendState;
+        auto const render_pass_info = getRenderPassState(my_data, pPipeline->graphicsPipelineCI.renderPass)->createInfo.ptr();
+        const VkSubpassDescription *subpass_desc = &render_pass_info->pSubpasses[pPipeline->graphicsPipelineCI.subpass];
+        if (color_blend_state->attachmentCount != subpass_desc->colorAttachmentCount) {
+            skip_call |= log_msg(
+                my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
+                reinterpret_cast<const uint64_t &>(pPipeline->pipeline), __LINE__, VALIDATION_ERROR_02109, "DS",
+                "vkCreateGraphicsPipelines(): Render pass (0x%" PRIxLEAST64
+                ") subpass %u has colorAttachmentCount of %u which doesn't match the pColorBlendState->attachmentCount of %u. %s",
+                reinterpret_cast<const uint64_t &>(pPipeline->graphicsPipelineCI.renderPass), pPipeline->graphicsPipelineCI.subpass,
+                subpass_desc->colorAttachmentCount, color_blend_state->attachmentCount,
+                validation_error_map[VALIDATION_ERROR_02109]);
+        }
         if (!my_data->enabled_features.independentBlend) {
             if (pPipeline->attachments.size() > 1) {
                 VkPipelineColorBlendAttachmentState *pAttachments = &pPipeline->attachments[0];
index 4954be9f2d5c38e6b5292a120f5c67ba948836c9..f5b0c669027e1392c58fb2a99c64306096eda4c4 100644 (file)
@@ -2036,7 +2036,7 @@ VALIDATION_ERROR_02105~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~For more info
 VALIDATION_ERROR_02106~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~For more information refer to Vulkan Spec Section '9.2. Graphics Pipelines' which states 'If subpass uses a depth/stencil attachment in renderpass that has a layout of VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL in the VkAttachmentReference defined by subpass, and pDepthStencilState is not NULL, the depthWriteEnable member of pDepthStencilState must be VK_FALSE' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkPipelineCreateFlagBits)~^~
 VALIDATION_ERROR_02107~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~For more information refer to Vulkan Spec Section '9.2. Graphics Pipelines' which states 'If subpass uses a depth/stencil attachment in renderpass that has a layout of VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL in the VkAttachmentReference defined by subpass, and pDepthStencilState is not NULL, the failOp, passOp and depthFailOp members of each of the front and back members of pDepthStencilState must be VK_STENCIL_OP_KEEP' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkPipelineCreateFlagBits)~^~
 VALIDATION_ERROR_02108~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~For more information refer to Vulkan Spec Section '9.2. Graphics Pipelines' which states 'If pColorBlendState is not NULL, the blendEnable member of each element of the pAttachment member of pColorBlendState must be VK_FALSE if the format of the attachment referred to in subpass of renderPass does not support color blend operations, as specified by the VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT flag in VkFormatProperties::linearTilingFeatures or VkFormatProperties::optimalTilingFeatures returned by vkGetPhysicalDeviceFormatProperties' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkPipelineCreateFlagBits)~^~
-VALIDATION_ERROR_02109~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~For more information refer to Vulkan Spec Section '9.2. Graphics Pipelines' which states 'If pColorBlendState is not NULL, The attachmentCount member of pColorBlendState must be equal to the colorAttachmentCount used to create subpass' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkPipelineCreateFlagBits)~^~
+VALIDATION_ERROR_02109~^~Y~^~NumBlendAttachMismatch~^~vkCreateGraphicsPipelines~^~For more information refer to Vulkan Spec Section '9.2. Graphics Pipelines' which states 'If pColorBlendState is not NULL, The attachmentCount member of pColorBlendState must be equal to the colorAttachmentCount used to create subpass' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkPipelineCreateFlagBits)~^~
 VALIDATION_ERROR_02110~^~Y~^~PSOViewportCountWithoutDataAndDynScissorMismatch~^~vkCreateGraphicsPipelines~^~For more information refer to Vulkan Spec Section '9.2. Graphics Pipelines' which states 'If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_VIEWPORT, the pViewports member of pViewportState must be a pointer to an array of pViewportState::viewportCount VkViewport structures' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkPipelineCreateFlagBits)~^~
 VALIDATION_ERROR_02111~^~Y~^~PSOScissorCountWithoutDataAndDynViewportMismatch~^~vkCreateGraphicsPipelines~^~For more information refer to Vulkan Spec Section '9.2. Graphics Pipelines' which states 'If no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_SCISSOR, the pScissors member of pViewportState must be a pointer to an array of pViewportState::scissorCount VkRect2D structures' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkPipelineCreateFlagBits)~^~
 VALIDATION_ERROR_02112~^~N~^~Unknown~^~vkCreateGraphicsPipelines~^~For more information refer to Vulkan Spec Section '9.2. Graphics Pipelines' which states 'If the wide lines feature is not enabled, and no element of the pDynamicStates member of pDynamicState is VK_DYNAMIC_STATE_LINE_WIDTH, the lineWidth member of pRasterizationState must be 1.0' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkPipelineCreateFlagBits)~^~