MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ValidateExtInstImport

Function ValidateExtInstImport

source/val/validate_extensions.cpp:1313–1356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1311}
1312
1313spv_result_t ValidateExtInstImport(ValidationState_t& _,
1314 const Instruction* inst) {
1315 const auto name_id = 1;
1316 const std::string name = inst->GetOperandAs<std::string>(name_id);
1317 if (_.version() <= SPV_SPIRV_VERSION_WORD(1, 5) &&
1318 !_.HasExtension(kSPV_KHR_non_semantic_info)) {
1319 if (name.find("NonSemantic.") == 0) {
1320 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1321 << "NonSemantic extended instruction "
1322 "sets cannot be declared "
1323 "without SPV_KHR_non_semantic_info. (This can also be fixed "
1324 "having SPIR-V 1.6 or later)";
1325 }
1326 }
1327
1328 // Validate the version suffix of a NonSemantic.Shader.DebugInfo import.
1329 // Accept any version >= kNSDIMinVersion; no upper bound is imposed because
1330 // later versions are backward-compatible supersets of earlier ones.
1331 const std::string nsdi_prefix = "NonSemantic.Shader.DebugInfo.";
1332 if (name.find(nsdi_prefix) == 0) {
1333 static const uint32_t kNSDIMinVersion = 100;
1334 auto version_string = name.substr(nsdi_prefix.size());
1335 if (version_string.empty()) {
1336 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1337 << "NonSemantic.Shader.DebugInfo import does not encode the "
1338 "version correctly";
1339 }
1340 char* end_ptr;
1341 uint32_t ver = static_cast<uint32_t>(
1342 std::strtoul(version_string.c_str(), &end_ptr, 10));
1343 if (end_ptr && *end_ptr != '\0') {
1344 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1345 << "NonSemantic.Shader.DebugInfo import does not encode the "
1346 "version correctly";
1347 }
1348 if (ver < kNSDIMinVersion) {
1349 return _.diag(SPV_ERROR_INVALID_DATA, inst)
1350 << "NonSemantic.Shader.DebugInfo import version " << ver
1351 << " is below the minimum supported version " << kNSDIMinVersion;
1352 }
1353 }
1354
1355 return SPV_SUCCESS;
1356}
1357
1358spv_result_t ValidateExtInstGlslStd450(ValidationState_t& _,
1359 const Instruction* inst) {

Callers 1

ExtensionPassFunction · 0.85

Calls 6

diagMethod · 0.80
c_strMethod · 0.80
versionMethod · 0.45
HasExtensionMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected