Skip to content

Commit

Permalink
layers: Fix ValidatePipelineShaderStage check
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Jun 10, 2024
1 parent 82a37fa commit 14da7bb
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 53 deletions.
90 changes: 43 additions & 47 deletions layers/core_checks/cc_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<VkPipelineShaderStageModuleIdentifierCreateInfoEXT>(stage_ci.pNext);
const auto module_create_info = vku::FindStructInPNextChain<VkShaderModuleCreateInfo>(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<VkShaderModuleCreateInfo>(stage_ci.pNext);
if (const auto module_identifier =
vku::FindStructInPNextChain<VkPipelineShaderStageModuleIdentifierCreateInfoEXT>(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;
}
9 changes: 7 additions & 2 deletions layers/core_checks/cc_pipeline_compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 4 additions & 1 deletion layers/core_checks/cc_pipeline_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 8 additions & 2 deletions layers/core_checks/cc_pipeline_ray_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion layers/core_checks/core_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 14da7bb

Please sign in to comment.