From 67a99448a827ed263ae90a3afa45399508397087 Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Wed, 23 Mar 2016 14:34:52 -0600 Subject: layers: Fix AV in core_validaton Caused crashes in DOTA2 Change-Id: I74d121641872597a63ea42e13ff860112fc7c314 --- layers/core_validation.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 56ba538d..e4946c40 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -3034,20 +3034,22 @@ static VkBool32 verifyPipelineCreateState(layer_data *my_data, const VkDevice de if (pPipeline->graphicsPipelineCI.pColorBlendState != NULL) { if (!my_data->physDevProperties.features.independentBlend) { - VkPipelineColorBlendAttachmentState *pAttachments = 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)) { - skipCall |= - 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"); + if (pPipeline->attachments.size() > 0) { + VkPipelineColorBlendAttachmentState *pAttachments = 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)) { + skipCall |= + 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"); + } } } } -- cgit v1.2.3