diff --git a/layers/core_checks/cc_pipeline.cpp b/layers/core_checks/cc_pipeline.cpp index 5a984b18e22..283f93056a2 100644 --- a/layers/core_checks/cc_pipeline.cpp +++ b/layers/core_checks/cc_pipeline.cpp @@ -643,67 +643,63 @@ bool CoreChecks::ValidateShaderStageMaxResources(VkShaderStageFlagBits stage, co return skip; } -bool CoreChecks::ValidateShaderModuleId(const vvl::Pipeline &pipeline, const Location &loc) const { +bool CoreChecks::ValidatePipelineShaderStage(const vvl::Pipeline &pipeline, + const vku::safe_VkPipelineShaderStageCreateInfo &stage_ci, const Location &loc) const { bool skip = false; - for (const auto &stage_ci : pipeline.shader_stages_ci) { - const auto module_identifier = vku::FindStructInPNextChain(stage_ci.pNext); - const auto module_create_info = vku::FindStructInPNextChain(stage_ci.pNext); - if (module_identifier) { - if (module_identifier->identifierSize > 0) { - if (!(enabled_features.shaderModuleIdentifier)) { - skip |= LogError("VUID-VkPipelineShaderStageModuleIdentifierCreateInfoEXT-pNext-06850", device, loc, - "has a " - "VkPipelineShaderStageModuleIdentifierCreateInfoEXT " - "struct in the pNext chain but the shaderModuleIdentifier feature was not enabled. (stage %s)", - string_VkShaderStageFlagBits(stage_ci.stage)); - } - if (!(pipeline.create_flags & VK_PIPELINE_CREATE_2_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_KHR)) { - skip |= - LogError("VUID-VkPipelineShaderStageModuleIdentifierCreateInfoEXT-pNext-06851", pipeline.Handle(), + const auto module_create_info = vku::FindStructInPNextChain(stage_ci.pNext); + if (const auto module_identifier = + vku::FindStructInPNextChain(stage_ci.pNext)) { + if (module_identifier->identifierSize > 0) { + if (!(enabled_features.shaderModuleIdentifier)) { + skip |= + LogError("VUID-VkPipelineShaderStageModuleIdentifierCreateInfoEXT-pNext-06850", device, loc.dot(Field::pNext), + "has a " + "VkPipelineShaderStageModuleIdentifierCreateInfoEXT " + "struct in the pNext chain but the shaderModuleIdentifier feature was not enabled. (stage %s)", + string_VkShaderStageFlagBits(stage_ci.stage)); + } + if (!(pipeline.create_flags & VK_PIPELINE_CREATE_2_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_KHR)) { + skip |= LogError("VUID-VkPipelineShaderStageModuleIdentifierCreateInfoEXT-pNext-06851", pipeline.Handle(), loc.pNext(Struct::VkPipelineShaderStageModuleIdentifierCreateInfoEXT, Field::identifierSize), "(%" PRIu32 "), but the pipeline was created with %s. (stage %s)", module_identifier->identifierSize, string_VkPipelineCreateFlags2KHR(pipeline.create_flags).c_str(), string_VkShaderStageFlagBits(stage_ci.stage)); - } - if (module_identifier->identifierSize > VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT) { - skip |= - LogError("VUID-VkPipelineShaderStageModuleIdentifierCreateInfoEXT-identifierSize-06852", device, + } + if (module_identifier->identifierSize > VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT) { + skip |= LogError("VUID-VkPipelineShaderStageModuleIdentifierCreateInfoEXT-identifierSize-06852", device, loc.pNext(Struct::VkPipelineShaderStageModuleIdentifierCreateInfoEXT, Field::identifierSize), "(%" PRIu32 ") is larger than VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT (%" PRIu32 "). (stage %s).", module_identifier->identifierSize, VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT, string_VkShaderStageFlagBits(stage_ci.stage)); - } - if (stage_ci.module != VK_NULL_HANDLE) { - skip |= LogError("VUID-VkPipelineShaderStageCreateInfo-stage-06848", device, loc, - "has a VkPipelineShaderStageModuleIdentifierCreateInfoEXT " - "struct in the pNext chain, but module is not VK_NULL_HANDLE. (stage %s).", - string_VkShaderStageFlagBits(stage_ci.stage)); - } } - if (module_create_info) { - skip |= LogError("VUID-VkPipelineShaderStageCreateInfo-stage-06844", device, loc, - "has both a " - "VkPipelineShaderStageModuleIdentifierCreateInfoEXT " - "struct and a VkShaderModuleCreateInfo struct in the pNext chain. (stage %s).", - string_VkShaderStageFlagBits(stage_ci.stage)); - } - } else { - if (enabled_features.graphicsPipelineLibrary) { - if (stage_ci.module == VK_NULL_HANDLE && !module_create_info) { - skip |= LogError("VUID-VkPipelineShaderStageCreateInfo-stage-06845", device, loc, - "module is not a valid VkShaderModule, but no " - "VkPipelineShaderStageModuleIdentifierCreateInfoEXT or VkShaderModuleCreateInfo found in the " - "pNext chain. (stage %s).", - string_VkShaderStageFlagBits(stage_ci.stage)); - } - } else if (stage_ci.module == VK_NULL_HANDLE && !enabled_features.maintenance5) { - skip |= LogError("VUID-VkPipelineShaderStageCreateInfo-stage-08771", device, loc, - "module is not a valid VkShaderModule and both the graphicsPipelineLibrary and maintenance5 " - "features were not enabled. (stage %s).", + if (stage_ci.module != VK_NULL_HANDLE) { + skip |= LogError("VUID-VkPipelineShaderStageCreateInfo-stage-06848", device, loc.dot(Field::pNext), + "has a VkPipelineShaderStageModuleIdentifierCreateInfoEXT " + "struct in the pNext chain, but module is not VK_NULL_HANDLE. (stage %s).", string_VkShaderStageFlagBits(stage_ci.stage)); } } + if (module_create_info) { + skip |= LogError("VUID-VkPipelineShaderStageCreateInfo-stage-06844", device, loc.dot(Field::pNext), + "has both a " + "VkPipelineShaderStageModuleIdentifierCreateInfoEXT " + "struct and a VkShaderModuleCreateInfo struct in the pNext chain. (stage %s).", + string_VkShaderStageFlagBits(stage_ci.stage)); + } + } else if (stage_ci.module == VK_NULL_HANDLE) { + if (!enabled_features.maintenance5 && !enabled_features.graphicsPipelineLibrary) { + skip |= LogError("VUID-VkPipelineShaderStageCreateInfo-stage-08771", device, loc.dot(Field::module), + "is VK_NULL_HANDLE and both the graphicsPipelineLibrary and maintenance5 " + "features were not enabled. (stage %s).", + string_VkShaderStageFlagBits(stage_ci.stage)); + } else if (!module_create_info) { + skip |= LogError("VUID-VkPipelineShaderStageCreateInfo-stage-06845", device, loc.dot(Field::module), + "is VK_NULL_HANDLE, but no " + "VkPipelineShaderStageModuleIdentifierCreateInfoEXT or VkShaderModuleCreateInfo found in the " + "pNext chain. (stage %s).", + string_VkShaderStageFlagBits(stage_ci.stage)); + } } return skip; } diff --git a/layers/core_checks/cc_pipeline_compute.cpp b/layers/core_checks/cc_pipeline_compute.cpp index 95568212015..a3949f0d92c 100644 --- a/layers/core_checks/cc_pipeline_compute.cpp +++ b/layers/core_checks/cc_pipeline_compute.cpp @@ -38,8 +38,13 @@ bool CoreChecks::PreCallValidateCreateComputePipelines(VkDevice device, VkPipeli continue; } const Location create_info_loc = error_obj.location.dot(Field::pCreateInfos, i); - skip |= ValidateShaderStage(pipeline->stage_states[0], pipeline, create_info_loc.dot(Field::stage)); - skip |= ValidateShaderModuleId(*pipeline, create_info_loc); + const Location stage_info = create_info_loc.dot(Field::stage); + const auto &stage_state = pipeline->stage_states[0]; + skip |= ValidateShaderStage(stage_state, pipeline, stage_info); + if (stage_state.pipeline_create_info) { + skip |= ValidatePipelineShaderStage(*pipeline, *stage_state.pipeline_create_info, stage_info); + } + skip |= ValidatePipelineCacheControlFlags(pipeline->create_flags, create_info_loc.dot(Field::flags), "VUID-VkComputePipelineCreateInfo-pipelineCreationCacheControl-02875"); skip |= ValidatePipelineIndirectBindableFlags(pipeline->create_flags, create_info_loc.dot(Field::flags), diff --git a/layers/core_checks/cc_pipeline_graphics.cpp b/layers/core_checks/cc_pipeline_graphics.cpp index a160340216b..c4fa3be27fb 100644 --- a/layers/core_checks/cc_pipeline_graphics.cpp +++ b/layers/core_checks/cc_pipeline_graphics.cpp @@ -116,7 +116,10 @@ bool CoreChecks::ValidateGraphicsPipeline(const vvl::Pipeline &pipeline, const L // pStages are ignored if not using one of these sub states if (pipeline.OwnsSubState(pipeline.fragment_shader_state) || pipeline.OwnsSubState(pipeline.pre_raster_state)) { - skip |= ValidateShaderModuleId(pipeline, create_info_loc); + uint32_t stage_index = 0; + for (const auto &stage_ci : pipeline.shader_stages_ci) { + skip |= ValidatePipelineShaderStage(pipeline, stage_ci, create_info_loc.dot(Field::pStages, stage_index++)); + } } skip |= ValidatePipelineCacheControlFlags(pipeline.create_flags, create_info_loc.dot(Field::flags), diff --git a/layers/core_checks/cc_pipeline_ray_tracing.cpp b/layers/core_checks/cc_pipeline_ray_tracing.cpp index 3ab6ce983a0..7be44fdab89 100644 --- a/layers/core_checks/cc_pipeline_ray_tracing.cpp +++ b/layers/core_checks/cc_pipeline_ray_tracing.cpp @@ -200,7 +200,10 @@ bool CoreChecks::PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkP } } skip |= ValidateRayTracingPipeline(*pipeline, create_info, pCreateInfos[i].flags, create_info_loc); - skip |= ValidateShaderModuleId(*pipeline, create_info_loc); + uint32_t stage_index = 0; + for (const auto &stage_ci : pipeline->shader_stages_ci) { + skip |= ValidatePipelineShaderStage(*pipeline, stage_ci, create_info_loc.dot(Field::pStages, stage_index++)); + } skip |= ValidatePipelineCacheControlFlags(pCreateInfos[i].flags, create_info_loc.dot(Field::flags), "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905"); } @@ -246,7 +249,10 @@ bool CoreChecks::PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, Vk } } skip |= ValidateRayTracingPipeline(*pipeline, create_info, pCreateInfos[i].flags, create_info_loc); - skip |= ValidateShaderModuleId(*pipeline, create_info_loc); + uint32_t stage_index = 0; + for (const auto &stage_ci : pipeline->shader_stages_ci) { + skip |= ValidatePipelineShaderStage(*pipeline, stage_ci, create_info_loc.dot(Field::pStages, stage_index++)); + } skip |= ValidatePipelineCacheControlFlags(pCreateInfos[i].flags, create_info_loc.dot(Field::flags), "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905"); if (create_info.pLibraryInfo) { diff --git a/layers/core_checks/core_validation.h b/layers/core_checks/core_validation.h index 1fd28a522a5..fa573b346b1 100644 --- a/layers/core_checks/core_validation.h +++ b/layers/core_checks/core_validation.h @@ -731,7 +731,8 @@ class CoreChecks : public ValidationStateTracker { bool ValidateTransformFeedbackDecorations(const spirv::Module& module_state, const Location& loc) const; bool ValidateTransformFeedbackEmitStreams(const spirv::Module& module_state, const spirv::EntryPoint& entrypoint, const spirv::StatelessData& stateless_data, const Location& loc) const; - virtual bool ValidateShaderModuleId(const vvl::Pipeline& pipeline, const Location& loc) const; + virtual bool ValidatePipelineShaderStage(const vvl::Pipeline& pipeline, + const vku::safe_VkPipelineShaderStageCreateInfo& stage_ci, const Location& loc) const; bool ValidateShaderClock(const spirv::Module& module_state, const spirv::StatelessData& stateless_data, const Location& loc) const; bool ValidateImageWrite(const spirv::Module& module_state, const Location& loc) const;