| 3334 | } |
| 3335 | |
| 3336 | spv_result_t ValidateExtInstDebugInfo(ValidationState_t& _, |
| 3337 | const Instruction* inst) { |
| 3338 | const uint32_t result_type = inst->type_id(); |
| 3339 | const uint32_t ext_inst_index = inst->word(4); |
| 3340 | if (!_.IsVoidType(result_type)) { |
| 3341 | return _.diag(SPV_ERROR_INVALID_DATA, inst) |
| 3342 | << GetExtInstName(_, inst) << ": " |
| 3343 | << "expected result type must be a result id of " << "OpTypeVoid"; |
| 3344 | } |
| 3345 | |
| 3346 | const spv_ext_inst_type_t ext_inst_type = |
| 3347 | spv_ext_inst_type_t(inst->ext_inst_type()); |
| 3348 | const bool vulkanDebugInfo = |
| 3349 | ext_inst_type == SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100; |
| 3350 | |
| 3351 | auto num_words = inst->words().size(); |
| 3352 | |
| 3353 | // Parse the declared NSDI version so optional-operand checks are strict |
| 3354 | // (num_words == n) for version kNSDIKnownVersion and lenient (num_words >= n) |
| 3355 | // for future versions that may add trailing operands. |
| 3356 | static const uint32_t kNSDIKnownVersion = NonSemanticShaderDebugInfoVersion; |
| 3357 | const uint32_t nsdi_version = vulkanDebugInfo ? GetNSDIVersion(_, inst) : 0; |
| 3358 | // True if the optional operand at word |n| is present and should be checked. |
| 3359 | auto has_optional_at = [&](uint32_t n) -> bool { |
| 3360 | return num_words >= n && |
| 3361 | (nsdi_version > kNSDIKnownVersion || num_words == n); |
| 3362 | }; |
| 3363 | |
| 3364 | // Handle any non-common NonSemanticShaderDebugInfo instructions. |
| 3365 | if (vulkanDebugInfo) { |
| 3366 | const NonSemanticShaderDebugInfoInstructions ext_inst_key = |
| 3367 | NonSemanticShaderDebugInfoInstructions(ext_inst_index); |
| 3368 | switch (ext_inst_key) { |
| 3369 | // The following block of instructions will be handled by the common |
| 3370 | // validation. |
| 3371 | case NonSemanticShaderDebugInfoDebugInfoNone: |
| 3372 | case NonSemanticShaderDebugInfoDebugCompilationUnit: |
| 3373 | case NonSemanticShaderDebugInfoDebugTypePointer: |
| 3374 | case NonSemanticShaderDebugInfoDebugTypeQualifier: |
| 3375 | case NonSemanticShaderDebugInfoDebugTypeArray: |
| 3376 | case NonSemanticShaderDebugInfoDebugTypeVector: |
| 3377 | case NonSemanticShaderDebugInfoDebugTypedef: |
| 3378 | case NonSemanticShaderDebugInfoDebugTypeFunction: |
| 3379 | case NonSemanticShaderDebugInfoDebugTypeEnum: |
| 3380 | case NonSemanticShaderDebugInfoDebugTypeComposite: |
| 3381 | case NonSemanticShaderDebugInfoDebugTypeMember: |
| 3382 | case NonSemanticShaderDebugInfoDebugTypeInheritance: |
| 3383 | case NonSemanticShaderDebugInfoDebugTypePtrToMember: |
| 3384 | case NonSemanticShaderDebugInfoDebugTypeTemplate: |
| 3385 | case NonSemanticShaderDebugInfoDebugTypeTemplateParameter: |
| 3386 | case NonSemanticShaderDebugInfoDebugTypeTemplateTemplateParameter: |
| 3387 | case NonSemanticShaderDebugInfoDebugTypeTemplateParameterPack: |
| 3388 | case NonSemanticShaderDebugInfoDebugGlobalVariable: |
| 3389 | case NonSemanticShaderDebugInfoDebugFunctionDeclaration: |
| 3390 | case NonSemanticShaderDebugInfoDebugFunction: |
| 3391 | case NonSemanticShaderDebugInfoDebugLexicalBlock: |
| 3392 | case NonSemanticShaderDebugInfoDebugLexicalBlockDiscriminator: |
| 3393 | case NonSemanticShaderDebugInfoDebugScope: |
no test coverage detected