From 44dd16bb27045ef45fa64d694c0864426c66405e Mon Sep 17 00:00:00 2001 From: Mike Weiblen Date: Thu, 9 Feb 2017 12:26:58 -0700 Subject: layers: Refactor checking code Combine code blocks to avoid repetitive checking of the same state. Change-Id: I788538b82ce9420035d9ab2ba9fefb9befb67722 --- layers/core_validation.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 22ca66e5..d225af42 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -3198,32 +3198,34 @@ static bool verifyPipelineCreateState(layer_data *dev_data, std::vectorgraphicsPipelineCI.pRasterizationState) { + + // Make sure that the line width conforms to the HW. if (!isDynamic(pPipeline, VK_DYNAMIC_STATE_LINE_WIDTH)) { skip_call |= verifyLineWidth(dev_data, DRAWSTATE_INVALID_PIPELINE_CREATE_STATE, reinterpret_cast(pPipeline->pipeline), pPipeline->graphicsPipelineCI.pRasterizationState->lineWidth); } - } - // If rasterization is not disabled and subpass uses a depth/stencil attachment, pDepthStencilState must be a pointer to a - // valid structure - if (pPipeline->graphicsPipelineCI.pRasterizationState && - (pPipeline->graphicsPipelineCI.pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { - auto subpass_desc = renderPass ? &renderPass->createInfo.pSubpasses[pPipeline->graphicsPipelineCI.subpass] : nullptr; - if (subpass_desc && subpass_desc->pDepthStencilAttachment && - subpass_desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { - if (!pPipeline->graphicsPipelineCI.pDepthStencilState) { - skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, - 0, __LINE__, VALIDATION_ERROR_02115, "DS", - "Invalid Pipeline CreateInfo State: " - "pDepthStencilState is NULL when rasterization is enabled and subpass uses a " - "depth/stencil attachment. %s", - validation_error_map[VALIDATION_ERROR_02115]); + // If rasterization is enabled... + if (pPipeline->graphicsPipelineCI.pRasterizationState->rasterizerDiscardEnable == VK_FALSE) { + auto subpass_desc = renderPass ? &renderPass->createInfo.pSubpasses[pPipeline->graphicsPipelineCI.subpass] : nullptr; + + // If subpass uses a depth/stencil attachment, pDepthStencilState must be a pointer to a valid structure + if (subpass_desc && subpass_desc->pDepthStencilAttachment && + subpass_desc->pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { + if (!pPipeline->graphicsPipelineCI.pDepthStencilState) { + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__, VALIDATION_ERROR_02115, "DS", + "Invalid Pipeline CreateInfo State: pDepthStencilState is NULL when rasterization is " + "enabled and subpass uses a depth/stencil attachment. %s", + validation_error_map[VALIDATION_ERROR_02115]); + } } } } + return skip_call; } -- cgit v1.2.3