diff --git a/layers/core_checks/cc_pipeline_graphics.cpp b/layers/core_checks/cc_pipeline_graphics.cpp index 025949449b7..bd9b0f3c3b5 100644 --- a/layers/core_checks/cc_pipeline_graphics.cpp +++ b/layers/core_checks/cc_pipeline_graphics.cpp @@ -1651,26 +1651,30 @@ bool CoreChecks::ValidateGraphicsPipelineColorBlendAttachmentState(const vvl::Pi } if (advance_blend) { - const uint32_t color_attachment_count = pipeline.rendering_create_info - ? pipeline.rendering_create_info->colorAttachmentCount - : subpass_desc->colorAttachmentCount; if (attachment_state.colorBlendOp != attachment_state.alphaBlendOp) { skip |= LogError("VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01406", device, attachment_loc, "has different colorBlendOp (%s) and alphaBlendOp (%s) but one of " "them is an advance blend operation.", string_VkBlendOp(attachment_state.colorBlendOp), string_VkBlendOp(attachment_state.alphaBlendOp)); - } else if (color_attachment_count > - phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments) { - // color_attachment_count is found one of multiple spots above - // - // error can guarantee it is the same VkBlendOp - skip |= LogError("VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01410", device, attachment_loc, - "has an advance blend operation (%s) but the colorAttachmentCount (%" PRIu32 - ") is larger than advancedBlendMaxColorAttachments (%" PRIu32 ").", - string_VkBlendOp(attachment_state.colorBlendOp), color_attachment_count, - phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments); - break; // if this fails once, will fail every iteration + } else { + const uint32_t color_attachment_count = pipeline.rendering_create_info + ? pipeline.rendering_create_info->colorAttachmentCount + : subpass_desc ? subpass_desc->colorAttachmentCount + : 0; + if (color_attachment_count != 0 && + color_attachment_count > + phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments) { + // color_attachment_count is found one of multiple spots above + // + // error can guarantee it is the same VkBlendOp + skip |= LogError("VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-01410", device, attachment_loc, + "has an advance blend operation (%s) but the colorAttachmentCount (%" PRIu32 + ") is larger than advancedBlendMaxColorAttachments (%" PRIu32 ").", + string_VkBlendOp(attachment_state.colorBlendOp), color_attachment_count, + phys_dev_ext_props.blend_operation_advanced_props.advancedBlendMaxColorAttachments); + break; // if this fails once, will fail every iteration + } } } } @@ -1727,8 +1731,7 @@ bool CoreChecks::ValidateGraphicsPipelineColorBlendState(const vvl::Pipeline &pi color_loc.dot(Field::logicOpEnable), "is VK_TRUE, but the logicOp feature was not enabled."); } - auto color_write = vku::FindStructInPNextChain(color_blend_state->pNext); - if (color_write) { + if (auto color_write = vku::FindStructInPNextChain(color_blend_state->pNext)) { if (color_write->attachmentCount > phys_dev_props.limits.maxColorAttachments) { skip |= LogError("VUID-VkPipelineColorWriteCreateInfoEXT-attachmentCount-06655", device, color_loc.pNext(Struct::VkPipelineColorWriteCreateInfoEXT, Field::attachmentCount), @@ -1745,8 +1748,9 @@ bool CoreChecks::ValidateGraphicsPipelineColorBlendState(const vvl::Pipeline &pi } } } - const auto *color_blend_advanced = vku::FindStructInPNextChain(color_blend_state->pNext); - if (color_blend_advanced) { + + if (const auto *color_blend_advanced = + vku::FindStructInPNextChain(color_blend_state->pNext)) { if (!phys_dev_ext_props.blend_operation_advanced_props.advancedBlendCorrelatedOverlap && color_blend_advanced->blendOverlap != VK_BLEND_OVERLAP_UNCORRELATED_EXT) { skip |= LogError("VUID-VkPipelineColorBlendAdvancedStateCreateInfoEXT-blendOverlap-01426", device, @@ -1772,8 +1776,9 @@ bool CoreChecks::ValidateGraphicsPipelineColorBlendState(const vvl::Pipeline &pi bool CoreChecks::ValidateGraphicsPipelineRasterizationState(const vvl::Pipeline &pipeline, const Location &create_info_loc) const { bool skip = false; - const Location raster_loc = create_info_loc.dot(Field::pRasterizationState); const auto raster_state = pipeline.RasterizationState(); + if (!raster_state) return skip; + const Location raster_loc = create_info_loc.dot(Field::pRasterizationState); if ((raster_state->depthClampEnable == VK_TRUE) && (!enabled_features.depthClamp)) { skip |= LogError("VUID-VkPipelineRasterizationStateCreateInfo-depthClampEnable-00782", device, diff --git a/tests/unit/graphics_library.cpp b/tests/unit/graphics_library.cpp index d31893d4b29..e3e0eb9f332 100644 --- a/tests/unit/graphics_library.cpp +++ b/tests/unit/graphics_library.cpp @@ -940,7 +940,6 @@ TEST_F(NegativeGraphicsLibrary, BadRenderPassFragmentShader) { pipe.InitFragmentLibInfo(&fs_stage.stage_ci); VkRenderPass bad_rp = CastToHandle(0xbaadbeef); pipe.gp_ci_.renderPass = bad_rp; - m_errorMonitor->SetDesiredError("VUID-VkGraphicsPipelineCreateInfo-renderPass-09035"); m_errorMonitor->SetDesiredError("VUID-VkGraphicsPipelineCreateInfo-flags-06643"); pipe.CreateGraphicsPipeline(); m_errorMonitor->VerifyFound(); @@ -3206,6 +3205,7 @@ TEST_F(NegativeGraphicsLibrary, MissingFragmentOutput) { VkGraphicsPipelineCreateInfo exe_pipe_ci = vku::InitStructHelper(&link_info); exe_pipe_ci.layout = pre_raster_lib.gp_ci_.layout; + exe_pipe_ci.renderPass = renderPass(); m_errorMonitor->SetDesiredError("VUID-VkGraphicsPipelineCreateInfo-flags-08909"); vkt::Pipeline exe_pipe(*m_device, exe_pipe_ci); m_errorMonitor->VerifyFound();