From 9a2addb243bfcd18f23cb1c615906de77784ad98 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 22 Aug 2016 15:20:11 +1200 Subject: layers: Require every input attachment used by FS to be present. Signed-off-by: Chris Forbes --- layers/core_validation.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index aa305d0e..cf772cf3 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -2780,6 +2780,32 @@ static bool validate_pipeline_shader_stage(debug_report_data *report_data, } } + /* validate use of input attachments against subpass structure */ + if (pStage->stage == VK_SHADER_STAGE_FRAGMENT_BIT) { + std::vector> input_attachment_uses; + collect_interface_by_input_attachment_index(report_data, module, accessible_ids, input_attachment_uses); + + auto rpci = pipeline->render_pass_ci.ptr(); + auto subpass = pipeline->graphicsPipelineCI.subpass; + + for (auto use : input_attachment_uses) { + auto input_attachments = rpci->pSubpasses[subpass].pInputAttachments; + auto index = (input_attachments && use.first < rpci->pSubpasses[subpass].inputAttachmentCount) ? + input_attachments[use.first].attachment : VK_ATTACHMENT_UNUSED; + + if (index == VK_ATTACHMENT_UNUSED) { + if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, + SHADER_CHECKER_MISSING_INPUT_ATTACHMENT, "SC", + "Shader consumes input attachment index %d but not provided in subpass", + use.first)) { + pass = false; + } + } + + /* TODO: type match, etc */ + } + } + return pass; } -- cgit v1.2.3