From 9918c0920c6c3fdcf3076e3c834f4dae1900863d Mon Sep 17 00:00:00 2001 From: Mark Mueller Date: Wed, 13 Jul 2016 14:49:35 -0600 Subject: layers: Fix minor completeness/performance issue The first time the condition is discovered it will be the same as every subsequent time, so there is no need to continue. Also, the whole structure must be compared, so memcmp assures that will happen with good efficiency Change-Id: I71f608c71f83ebcd02212bb391a30bdf15279ff6 --- layers/core_validation.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 9211503f..4ca938fe 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -3093,18 +3093,16 @@ static bool verifyPipelineCreateState(layer_data *my_data, const VkDevice device if (pPipeline->attachments.size() > 1) { VkPipelineColorBlendAttachmentState *pAttachments = &pPipeline->attachments[0]; for (size_t i = 1; i < pPipeline->attachments.size(); 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)) { + // Quoting the spec: "If [the independent blend] feature is not enabled, the VkPipelineColorBlendAttachmentState + // settings for all color attachments must be identical." VkPipelineColorBlendAttachmentState contains + // only attachment state, so memcmp is best suited for the comparison + if (memcmp(static_cast(pAttachments), static_cast(&pAttachments[i]), + sizeof(pAttachments[0]))) { skip_call |= 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"); + break; } } } -- cgit v1.2.3