layers: draw_state validates VkPipelineColorBlendStateCreateInfo
authorIan Elliott <ianelliott@google.com>
Thu, 18 Feb 2016 21:26:42 +0000 (14:26 -0700)
committerJon Ashburn <jon@lunarg.com>
Fri, 26 Feb 2016 17:20:34 +0000 (10:20 -0700)
This is a squash of 3 commits/validationtests:

- If independentBlend not enabled, validate that all elements of pAttachments
  must be identical (for the vkCreateGraphicsPipelines() function).

- If logicOp not enabled, validate that logicOpEnable is VK_FALSE.

- If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value.

layers/draw_state.cpp
layers/draw_state.h
layers/vk_validation_layer_details.md

index 889f124..0a5ea99 100644 (file)
@@ -1873,6 +1873,39 @@ static VkBool32 verifyPipelineCreateState(layer_data* my_data, const VkDevice de
 {
     VkBool32 skipCall = VK_FALSE;
 
+    if (pPipeline->graphicsPipelineCI.pColorBlendState != NULL) {
+        if (!my_data->physDevProperties.features.independentBlend) {
+            VkPipelineColorBlendAttachmentState *pAttachments = pPipeline->pAttachments;
+            for (uint i = 1 ; i < pPipeline->attachmentCount ; i++) {
+                if ((pAttachments[0].blendEnable != pAttachments[i].blendEnable) ||
+                    (pAttachments[0].srcColorBlendFactor != pAttachments[i].srcColorBlendFactor) ||
+                    (pAttachments[0].dstColorBlendFactor != pAttachments[i].dstColorBlendFactor) ||
+                    (pAttachments[0].colorBlendOp != pAttachments[i].colorBlendOp) ||
+                    (pAttachments[0].srcAlphaBlendFactor != pAttachments[i].srcAlphaBlendFactor) ||
+                    (pAttachments[0].dstAlphaBlendFactor != pAttachments[i].dstAlphaBlendFactor) ||
+                    (pAttachments[0].alphaBlendOp != pAttachments[i].alphaBlendOp) ||
+                    (pAttachments[0].colorWriteMask != pAttachments[i].colorWriteMask)) {
+                    skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                        (VkDebugReportObjectTypeEXT) 0, 0, __LINE__, DRAWSTATE_INDEPENDENT_BLEND, "DS",
+                                        "Invalid Pipeline CreateInfo: If independent blend feature not enabled, all elements of pAttachments must be identical");
+                }
+            }
+        }
+        if (!my_data->physDevProperties.features.logicOp &&
+            (pPipeline->graphicsPipelineCI.pColorBlendState->logicOpEnable != VK_FALSE)) {
+            skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                (VkDebugReportObjectTypeEXT) 0, 0, __LINE__, DRAWSTATE_DISABLED_LOGIC_OP, "DS",
+                                "Invalid Pipeline CreateInfo: If logic operations feature not enabled, logicOpEnable must be VK_FALSE");
+        }
+        if ((pPipeline->graphicsPipelineCI.pColorBlendState->logicOpEnable == VK_TRUE) &&
+            (pPipeline->graphicsPipelineCI.pColorBlendState->logicOp < VK_LOGIC_OP_CLEAR) ||
+            (pPipeline->graphicsPipelineCI.pColorBlendState->logicOp > VK_LOGIC_OP_SET)) {
+            skipCall |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                (VkDebugReportObjectTypeEXT) 0, 0, __LINE__, DRAWSTATE_INVALID_LOGIC_OP, "DS",
+                                "Invalid Pipeline CreateInfo: If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value");
+        }
+    }
+
     if (!validate_pipeline_shaders(my_data, device, pPipeline)) {
         skipCall = VK_TRUE;
     }
index d17a218..41c7174 100755 (executable)
@@ -193,6 +193,12 @@ typedef enum _DRAW_STATE_ERROR {
                                              // violate device limit
     DRAWSTATE_INVALID_STORAGE_BUFFER_OFFSET, // Dynamic Storage Buffer Offsets
                                              // violate device limit
+    DRAWSTATE_INDEPENDENT_BLEND, // If independent blending is not enabled, all
+                                 // elements of pAttachmentsMustBeIdentical
+    DRAWSTATE_DISABLED_LOGIC_OP, // If logic operations is not enabled, logicOpEnable
+                                 // must be VK_FALSE
+    DRAWSTATE_INVALID_LOGIC_OP,  // If logicOpEnable is VK_TRUE, logicOp must
+                                 // must be a valid VkLogicOp value
 } DRAW_STATE_ERROR;
 
 typedef enum _SHADER_CHECKER_ERROR {
index 2e56f29..c419ace 100644 (file)
@@ -78,6 +78,9 @@ The VK_LAYER_LUNARG_draw_state layer tracks state leading into Draw cmds. This i
 | Live Semaphore  | When waiting on a semaphore, need to make sure that the semaphore is live and therefore can be signalled, otherwise queue is stalled and cannot make forward progress. | QUEUE_FORWARD_PROGRESS | vkQueueSubmit vkQueueBindSparse vkQueuePresentKHR vkAcquireNextImageKHR | TODO | Create test |
 | Storage Buffer Alignment  | Storage Buffer offsets in BindDescriptorSets must agree with offset alignment device limit | INVALID_STORAGE_BUFFER_OFFSET | vkCmdBindDescriptorSets | TODO | Create test |
 | Uniform Buffer Alignment  | Uniform Buffer offsets in BindDescriptorSets must agree with offset alignment device limit | INVALID_UNIFORM_BUFFER_OFFSET | vkCmdBindDescriptorSets | TODO | Create test |
+| Independent Blending  | If independent blending is not enabled, all elements of pAttachments must be identical | INDEPENDENT_BLEND | vkCreateGraphicsPipelines | TODO | Create test |
+| Enabled Logic Operations  | If logic operations is not enabled, logicOpEnable must be VK_FALSE | DISABLED_LOGIC_OP | vkCreateGraphicsPipelines | TODO | Create test |
+| Valid Logic Operations  | If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value | VALID_LOGIC_OP | vkCreateGraphicsPipelines | TODO | Create 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 VK_LAYER_LUNARG_draw_state attempts to allocate memory for its own internal use and is unable to. | OUT_OF_MEMORY | | NA | None |