From 87d55e68fbb5461a19ec2906b7ebcb05f3ec1973 Mon Sep 17 00:00:00 2001 From: Slawomir Cygan Date: Mon, 28 Nov 2016 17:53:23 +0100 Subject: layers: Warn if RenderPass clearvalues ignored PR 1203: Vulkan spec does permit clearValueCount to be greater than number of values used by clear ops. However we have seen apps that pass garbage as clearValueCount - the best we can do in this situation is to emit a warning. Change-Id: If52c02759410500e96976d91fd42a9b2a7e2df41 --- layers/core_validation.cpp | 30 +++++++++++++++++++----------- layers/core_validation_error_enums.h | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 6fec80d1..d9793683 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -10700,17 +10700,25 @@ CmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *p } } if (clear_op_size > pRenderPassBegin->clearValueCount) { - skip_call |= - log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, - reinterpret_cast(renderPass), __LINE__, VALIDATION_ERROR_00442, "DS", - "In vkCmdBeginRenderPass() the VkRenderPassBeginInfo struct has a clearValueCount of %u but there must " - "be at least %u " - "entries in pClearValues array to account for the highest index attachment in renderPass 0x%" PRIx64 - " that uses VK_ATTACHMENT_LOAD_OP_CLEAR is %u. Note that the pClearValues array " - "is indexed by attachment number so even if some pClearValues entries between 0 and %u correspond to " - "attachments that aren't cleared they will be ignored. %s", - pRenderPassBegin->clearValueCount, clear_op_size, reinterpret_cast(renderPass), - clear_op_size, clear_op_size - 1, validation_error_map[VALIDATION_ERROR_00442]); + skip_call |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, + reinterpret_cast(renderPass), __LINE__, VALIDATION_ERROR_00442, + "DS", "In vkCmdBeginRenderPass() the VkRenderPassBeginInfo struct has a clearValueCount of %u but there must " + "be at least %u entries in pClearValues array to account for the highest index attachment in renderPass " + "0x%" PRIx64 " that uses VK_ATTACHMENT_LOAD_OP_CLEAR is %u. Note that the pClearValues array " + "is indexed by attachment number so even if some pClearValues entries between 0 and %u correspond to " + "attachments that aren't cleared they will be ignored. %s", + pRenderPassBegin->clearValueCount, clear_op_size, reinterpret_cast(renderPass), clear_op_size, + clear_op_size - 1, validation_error_map[VALIDATION_ERROR_00442]); + } + if (clear_op_size < pRenderPassBegin->clearValueCount) { + skip_call |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, + reinterpret_cast(renderPass), __LINE__, DRAWSTATE_RENDERPASS_TOO_MANY_CLEAR_VALUES, "DS", + "In vkCmdBeginRenderPass() the VkRenderPassBeginInfo struct has a clearValueCount of %u but only first %u " + "entries in pClearValues array are used. The highest index attachment in renderPass 0x%" PRIx64 + " that uses VK_ATTACHMENT_LOAD_OP_CLEAR is %u - other pClearValues are ignored.", + pRenderPassBegin->clearValueCount, clear_op_size, reinterpret_cast(renderPass), clear_op_size); } skip_call |= VerifyRenderAreaBounds(dev_data, pRenderPassBegin); skip_call |= VerifyFramebufferAndRenderPassLayouts(dev_data, cb_node, pRenderPassBegin); diff --git a/layers/core_validation_error_enums.h b/layers/core_validation_error_enums.h index 2ea083cb..145e7e87 100644 --- a/layers/core_validation_error_enums.h +++ b/layers/core_validation_error_enums.h @@ -97,6 +97,7 @@ enum DRAW_STATE_ERROR { DRAWSTATE_INDEX_BUFFER_NOT_BOUND, DRAWSTATE_PIPELINE_LAYOUTS_INCOMPATIBLE, DRAWSTATE_RENDERPASS_INCOMPATIBLE, + DRAWSTATE_RENDERPASS_TOO_MANY_CLEAR_VALUES, DRAWSTATE_FRAMEBUFFER_INCOMPATIBLE, DRAWSTATE_INVALID_FRAMEBUFFER_CREATE_INFO, DRAWSTATE_INVALID_RENDERPASS, -- cgit v1.2.3