diff options
| author | Michael Lentine <mlentine@google.com> | 2016-03-24 20:48:59 -0500 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-03-25 09:13:04 -0600 |
| commit | 76d2d1b0d753faf972fe15bed32092702c21abb9 (patch) | |
| tree | c30a30c1aa0ced0edac5e8bc9139c88148a2dff7 | |
| parent | f1239315d5271886be15f2aa14fe82857b7f6943 (diff) | |
| download | usermoji-76d2d1b0d753faf972fe15bed32092702c21abb9.tar.xz | |
layers: Add check for renderArea being within framebuffer bounds.
| -rw-r--r-- | layers/core_validation.cpp | 20 | ||||
| -rw-r--r-- | layers/core_validation.h | 3 | ||||
| -rw-r--r-- | layers/vk_validation_layer_details.md | 1 |
3 files changed, 24 insertions, 0 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index b22cdd4c..28548ca5 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -9565,6 +9565,25 @@ void TransitionFinalSubpassLayouts(VkCommandBuffer cmdBuffer, const VkRenderPass } } +bool VerifyRenderAreaBounds(const layer_data *my_data, const VkRenderPassBeginInfo *pRenderPassBegin) { + bool skip_call = false; + const VkFramebufferCreateInfo *pFramebufferInfo = &my_data->frameBufferMap.at(pRenderPassBegin->framebuffer).createInfo; + if (pRenderPassBegin->renderArea.offset.x < 0 || + (pRenderPassBegin->renderArea.offset.x + pRenderPassBegin->renderArea.extent.width) > pFramebufferInfo->width || + pRenderPassBegin->renderArea.offset.y < 0 || + (pRenderPassBegin->renderArea.offset.y + pRenderPassBegin->renderArea.extent.height) > pFramebufferInfo->height) { + skip_call |= static_cast<bool>(log_msg( + my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, 0, __LINE__, + DRAWSTATE_INVALID_RENDER_AREA, "CORE", + "Cannot execute a render pass with renderArea not within the bound of the " + "framebuffer. RenderArea: x %d, y %d, width %d, height %d. Framebuffer: width %d, " + "height %d.", + pRenderPassBegin->renderArea.offset.x, pRenderPassBegin->renderArea.offset.y, pRenderPassBegin->renderArea.extent.width, + pRenderPassBegin->renderArea.extent.height, pFramebufferInfo->width, pFramebufferInfo->height)); + } + return skip_call; +} + VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, VkSubpassContents contents) { VkBool32 skipCall = VK_FALSE; @@ -9625,6 +9644,7 @@ vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo } } #endif + skipCall |= static_cast<VkBool32>(VerifyRenderAreaBounds(dev_data, pRenderPassBegin)); skipCall |= VerifyFramebufferAndRenderPassLayouts(commandBuffer, pRenderPassBegin); auto render_pass_data = dev_data->renderPassMap.find(pRenderPassBegin->renderPass); if (render_pass_data != dev_data->renderPassMap.end()) { diff --git a/layers/core_validation.h b/layers/core_validation.h index 56eb8ef4..c4a516d4 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -192,11 +192,14 @@ struct MT_SWAP_CHAIN_INFO { #endif // Draw State ERROR codes typedef enum _DRAW_STATE_ERROR { + // TODO: Remove the comments here or expand them. There isn't any additional information in the + // comments than in the name in almost all cases. DRAWSTATE_NONE, // Used for INFO & other non-error messages DRAWSTATE_INTERNAL_ERROR, // Error with DrawState internal data structures DRAWSTATE_NO_PIPELINE_BOUND, // Unable to identify a bound pipeline DRAWSTATE_INVALID_POOL, // Invalid DS pool DRAWSTATE_INVALID_SET, // Invalid DS + DRAWSTATE_INVALID_RENDER_AREA, // Invalid renderArea DRAWSTATE_INVALID_LAYOUT, // Invalid DS layout DRAWSTATE_INVALID_IMAGE_LAYOUT, // Invalid Image layout DRAWSTATE_INVALID_PIPELINE, // Invalid Pipeline handle referenced diff --git a/layers/vk_validation_layer_details.md b/layers/vk_validation_layer_details.md index 7042cf16..6789bf3d 100644 --- a/layers/vk_validation_layer_details.md +++ b/layers/vk_validation_layer_details.md @@ -38,6 +38,7 @@ The Draw State portion of the core validation layer tracks state leading into Dr | Valid DescriptorPool | Verifies that the descriptor set pool object was properly created and is valid | INVALID_POOL | vkResetDescriptorPool vkAllocateDescriptorSets | None | This is just an internal layer data structure check. VK_LAYER_LUNARG_parameter_validation or VK_LAYER_LUNARG_object_tracker should really catch bad DSPool | | Valid DescriptorSet | Validate that descriptor set was properly created and is currently valid | INVALID_SET | vkCmdBindDescriptorSets | None | Is this needed other places (like Update/Clear descriptors) | | Valid DescriptorSetLayout | Flag DescriptorSetLayout object that was not properly created | INVALID_LAYOUT | vkAllocateDescriptorSets | None | Anywhere else to check this? | +| Valid RenderArea | Flag renderArea field that is outside of the framebuffer | INVALID_RENDER_AREA | vkCmdBeginRenderPass | None | Anywhere else to check this? | | Valid Pipeline | Flag VkPipeline object that was not properly created | INVALID_PIPELINE | vkCmdBindPipeline | InvalidPipeline | NA | | Valid PipelineLayout | Flag VkPipelineLayout object that was not properly created | INVALID_PIPELINE_LAYOUT | vkCmdBindPipeline | TODO | Write test for this case | | Valid Pipeline Create Info | Tests for the following: That compute shaders are not specified for the graphics pipeline, tess evaluation and tess control shaders are included or excluded as a pair, that VK_PRIMITIVE_TOPOLOGY_PATCH_LIST is set as IA topology for tessellation pipelines, that VK_PRIMITIVE_TOPOLOGY_PATCH_LIST primitive topology is only set for tessellation pipelines, and that Vtx Shader specified | INVALID_PIPELINE_CREATE_STATE | vkCreateGraphicsPipelines | InvalidPipelineCreateState | NA | |
