aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2015-10-16 09:17:27 -0600
committerMark Lobodzinski <mark@lunarg.com>2015-10-16 14:50:46 -0600
commit04e23cb13d1e9d51134b77ed8c60441308afe3f3 (patch)
tree1bdcb1699473181dea0124840c75a8ebbea58f0e
parent8a51747d56f8d601bf6651a88e5ef9a255baa4b8 (diff)
downloadusermoji-04e23cb13d1e9d51134b77ed8c60441308afe3f3.tar.xz
layers: LX161, validate attachment references in subpasses
For CmdClearColorAttachment, attachment ref must be in attachment reference array of current subpass.
-rwxr-xr-xlayers/draw_state.cpp23
-rwxr-xr-xlayers/draw_state.h1
-rw-r--r--layers/vk_validation_layer_details.md1
3 files changed, 23 insertions, 2 deletions
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index 368493e6..4797a662 100755
--- a/layers/draw_state.cpp
+++ b/layers/draw_state.cpp
@@ -2722,8 +2722,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearColorAttachment(
if (pCB->state == CB_UPDATE_ACTIVE) {
// Warn if this is issued prior to Draw Cmd
if (!hasDrawCmd(pCB)) {
- // TODO : cmdBuffer should be srcObj
- skipCall |= log_msg(mdd(cmdBuffer), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, 0, 0, DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, "DS",
+ skipCall |= log_msg(mdd(cmdBuffer), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)cmdBuffer, 0, DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, "DS",
"vkCmdClearColorAttachment() issued on CB object 0x%" PRIxLEAST64 " prior to any Draw Cmds."
" It is recommended you use RenderPass LOAD_OP_CLEAR on Color Attachments prior to any Draw.", reinterpret_cast<uint64_t>(cmdBuffer));
}
@@ -2732,6 +2731,26 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearColorAttachment(
} else {
skipCall |= report_error_no_cb_begin(cmdBuffer, "vkCmdClearColorAttachment()");
}
+
+ // Validate that attachment is in reference list of active subpass
+ if (pCB->activeRenderPass) {
+ const VkRenderPassCreateInfo *pRPCI = dev_data->renderPassMap[pCB->activeRenderPass.handle];
+ const VkSubpassDescription *pSD = &pRPCI->pSubpasses[pCB->activeSubpass];
+
+ VkBool32 found = VK_FALSE;
+ for (uint32_t i = 0; i < pSD->colorCount; i++) {
+ if (colorAttachment == pSD->pColorAttachments[i].attachment) {
+ found = VK_TRUE;
+ break;
+ }
+ }
+ if (VK_FALSE == found) {
+ skipCall |= log_msg(mdd(cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER,
+ (uint64_t)cmdBuffer, 0, DRAWSTATE_MISSING_ATTACHMENT_REFERENCE, "DS",
+ "vkCmdClearColorAttachment() attachment index %d not found in attachment reference array of active subpass %d",
+ colorAttachment, pCB->activeSubpass);
+ }
+ }
skipCall |= outsideRenderPass(pCB, "vkCmdClearColorAttachment");
}
if (VK_FALSE == skipCall)
diff --git a/layers/draw_state.h b/layers/draw_state.h
index 86c84a00..2328936f 100755
--- a/layers/draw_state.h
+++ b/layers/draw_state.h
@@ -71,6 +71,7 @@ typedef enum _DRAW_STATE_ERROR
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_MISSING_ATTACHMENT_REFERENCE, // Attachment reference must be present in active subpass
DRAWSTATE_INVALID_EXTENSION,
} DRAW_STATE_ERROR;
diff --git a/layers/vk_validation_layer_details.md b/layers/vk_validation_layer_details.md
index 49fd9cb9..0cade3e5 100644
--- a/layers/vk_validation_layer_details.md
+++ b/layers/vk_validation_layer_details.md
@@ -49,6 +49,7 @@ The DrawState layer tracks state leading into Draw cmds. This includes the Pipel
| 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 |
+| Attachment References in Subpass | Attachment reference must be present in active subpass | MISSING_ATTACHMENT_REFERENCE | vkCmdClearColorAttachment | 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 |