diff --git a/source/val/function.h b/source/val/function.h index 481179442e..c4cd5a4648 100644 --- a/source/val/function.h +++ b/source/val/function.h @@ -278,7 +278,7 @@ class Function { Construct& FindConstructForEntryBlock(const BasicBlock* entry_block, ConstructType t); - /// The result id of the OpLabel that defined this block + /// The result id of OpFunction uint32_t id_; /// The type of the function diff --git a/source/val/validate_extensions.cpp b/source/val/validate_extensions.cpp index 74974a4fef..cb4768dcfa 100644 --- a/source/val/validate_extensions.cpp +++ b/source/val/validate_extensions.cpp @@ -3090,7 +3090,6 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { // validation. case NonSemanticShaderDebugInfo100DebugInfoNone: case NonSemanticShaderDebugInfo100DebugCompilationUnit: - case NonSemanticShaderDebugInfo100DebugTypeBasic: case NonSemanticShaderDebugInfo100DebugTypePointer: case NonSemanticShaderDebugInfo100DebugTypeQualifier: case NonSemanticShaderDebugInfo100DebugTypeArray: @@ -3116,7 +3115,6 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { case NonSemanticShaderDebugInfo100DebugInlinedAt: case NonSemanticShaderDebugInfo100DebugLocalVariable: case NonSemanticShaderDebugInfo100DebugInlinedVariable: - case NonSemanticShaderDebugInfo100DebugDeclare: case NonSemanticShaderDebugInfo100DebugValue: case NonSemanticShaderDebugInfo100DebugOperation: case NonSemanticShaderDebugInfo100DebugExpression: @@ -3125,6 +3123,24 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { case NonSemanticShaderDebugInfo100DebugImportedEntity: case NonSemanticShaderDebugInfo100DebugSource: break; + + // These checks are for operands that are differnet in + // ShaderDebugInfo100 + case NonSemanticShaderDebugInfo100DebugTypeBasic: { + CHECK_CONST_UINT_OPERAND("Flags", 8); + break; + } + case NonSemanticShaderDebugInfo100DebugDeclare: { + for (uint32_t word_index = 8; word_index < num_words; ++word_index) { + auto index_inst = _.FindDef(inst->word(word_index)); + auto type_id = index_inst != nullptr ? index_inst->type_id() : 0; + if (type_id == 0 || !IsIntScalar(_, type_id, false, false)) + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": " + << "expected index must be scalar integer"; + } + break; + } case NonSemanticShaderDebugInfo100DebugTypeMatrix: { CHECK_DEBUG_OPERAND("Vector Type", CommonDebugInfoDebugTypeVector, 5); @@ -3146,14 +3162,83 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } break; } - // TODO: Add validation rules for remaining cases as well. - case NonSemanticShaderDebugInfo100DebugFunctionDefinition: - case NonSemanticShaderDebugInfo100DebugSourceContinued: - case NonSemanticShaderDebugInfo100DebugLine: + case NonSemanticShaderDebugInfo100DebugFunctionDefinition: { + CHECK_DEBUG_OPERAND("Function", CommonDebugInfoDebugFunction, 5); + CHECK_OPERAND("Definition", spv::Op::OpFunction, 6); + const auto* current_function = inst->function(); + if (current_function->first_block()->id() != inst->block()->id()) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() + << ": must be in the entry basic block of the function"; + } + + const uint32_t definition_id = inst->word(6); + if (definition_id != current_function->id()) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() + << ": operand Definition must point to the OpFunction it is " + "inside"; + } + break; + } + case NonSemanticShaderDebugInfo100DebugLine: { + CHECK_DEBUG_OPERAND("Source", CommonDebugInfoDebugSource, 5); + CHECK_CONST_UINT_OPERAND("Line Start", 6); + CHECK_CONST_UINT_OPERAND("Line End", 7); + CHECK_CONST_UINT_OPERAND("Column Start", 8); + CHECK_CONST_UINT_OPERAND("Column End", 9); + + // above already validates if 32-bit and non-spec constant + // but want to use EvalInt32IfConst to be consistent with other Eval + // locations + bool is_int32 = false, is_const_int32 = false; + uint32_t line_start = 0; + uint32_t line_end = 0; + uint32_t column_start = 0; + uint32_t column_end = 0; + std::tie(is_int32, is_const_int32, line_start) = + _.EvalInt32IfConst(inst->word(6)); + std::tie(is_int32, is_const_int32, line_end) = + _.EvalInt32IfConst(inst->word(7)); + std::tie(is_int32, is_const_int32, column_start) = + _.EvalInt32IfConst(inst->word(8)); + std::tie(is_int32, is_const_int32, column_end) = + _.EvalInt32IfConst(inst->word(9)); + if (line_end < line_start) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": operand Line End (" << line_end + << ") is less than Line Start (" << line_start << ")"; + } else if (column_end < column_start) { + return _.diag(SPV_ERROR_INVALID_DATA, inst) + << ext_inst_name() << ": operand Column End (" << column_end + << ") is less than Column Start (" << column_start << ")"; + } + break; + } + case NonSemanticShaderDebugInfo100DebugSourceContinued: { + CHECK_OPERAND("Text", spv::Op::OpString, 5); + break; + } + case NonSemanticShaderDebugInfo100DebugBuildIdentifier: { + CHECK_OPERAND("Identifier", spv::Op::OpString, 5); + CHECK_CONST_UINT_OPERAND("Flags", 6); + break; + } + case NonSemanticShaderDebugInfo100DebugStoragePath: { + CHECK_OPERAND("Path", spv::Op::OpString, 5); + break; + } + case NonSemanticShaderDebugInfo100DebugEntryPoint: { + CHECK_DEBUG_OPERAND("Entry Point", CommonDebugInfoDebugFunction, 5); + CHECK_DEBUG_OPERAND("Compilation Unit", + CommonDebugInfoDebugCompilationUnit, 6); + CHECK_OPERAND("Compiler Signature", spv::Op::OpString, 7); + CHECK_OPERAND("Command-line Arguments", spv::Op::OpString, 8); + break; + } + + // Has no additional checks case NonSemanticShaderDebugInfo100DebugNoLine: - case NonSemanticShaderDebugInfo100DebugBuildIdentifier: - case NonSemanticShaderDebugInfo100DebugStoragePath: - case NonSemanticShaderDebugInfo100DebugEntryPoint: break; case NonSemanticShaderDebugInfo100InstructionsMax: assert(0); @@ -3455,9 +3540,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } case CommonDebugInfoDebugFunction: { CHECK_OPERAND("Name", spv::Op::OpString, 5); - auto validate_type = ValidateOperandDebugType(_, "Type", inst, 6, - ext_inst_name, false); - if (validate_type != SPV_SUCCESS) return validate_type; + CHECK_DEBUG_OPERAND("Type", CommonDebugInfoDebugTypeFunction, 6); CHECK_DEBUG_OPERAND("Source", CommonDebugInfoDebugSource, 7); CHECK_CONST_UINT_OPERAND("Line", 8); CHECK_CONST_UINT_OPERAND("Column", 9); @@ -3492,9 +3575,7 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } case CommonDebugInfoDebugFunctionDeclaration: { CHECK_OPERAND("Name", spv::Op::OpString, 5); - auto validate_type = ValidateOperandDebugType(_, "Type", inst, 6, - ext_inst_name, false); - if (validate_type != SPV_SUCCESS) return validate_type; + CHECK_DEBUG_OPERAND("Type", CommonDebugInfoDebugTypeFunction, 6); CHECK_DEBUG_OPERAND("Source", CommonDebugInfoDebugSource, 7); CHECK_CONST_UINT_OPERAND("Line", 8); CHECK_CONST_UINT_OPERAND("Column", 9); @@ -3556,18 +3637,6 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) { } CHECK_DEBUG_OPERAND("Expression", CommonDebugInfoDebugExpression, 7); - - if (vulkanDebugInfo) { - for (uint32_t word_index = 8; word_index < num_words; - ++word_index) { - auto index_inst = _.FindDef(inst->word(word_index)); - auto type_id = index_inst != nullptr ? index_inst->type_id() : 0; - if (type_id == 0 || !IsIntScalar(_, type_id, false, false)) - return _.diag(SPV_ERROR_INVALID_DATA, inst) - << ext_inst_name() << ": " - << "expected index must be scalar integer"; - } - } break; } case CommonDebugInfoDebugExpression: { diff --git a/source/val/validate_layout.cpp b/source/val/validate_layout.cpp index 05a8675101..baf36b89bd 100644 --- a/source/val/validate_layout.cpp +++ b/source/val/validate_layout.cpp @@ -75,8 +75,8 @@ spv_result_t ModuleScopedInstructions(ValidationState_t& _, if (local_debug_info) { if (_.in_function_body() == false) { - // DebugScope, DebugNoScope, DebugDeclare, DebugValue must - // appear in a function body. + // TODO - Print the actual name of the instruction as this list is + // not complete (see ext_inst_name in ValidateExtInst() for example) return _.diag(SPV_ERROR_INVALID_LAYOUT, inst) << "DebugScope, DebugNoScope, DebugDeclare, DebugValue " << "of debug info extension must appear in a function " diff --git a/test/opt/inline_test.cpp b/test/opt/inline_test.cpp index bf791811d5..ef7ac37d18 100644 --- a/test/opt/inline_test.cpp +++ b/test/opt/inline_test.cpp @@ -3749,13 +3749,13 @@ float4 main(float4 color : COLOR) : SV_TARGET { %color = OpFunctionParameter %_ptr_Function_v4float %bb_entry = OpLabel %140 = OpExtInst %void %1 DebugFunctionDefinition %22 %src_main - %141 = OpExtInst %void %1 DebugLine %5 %uint_1 %uint_1 %uint_1 %uint_1 + %141 = OpExtInst %void %1 DebugLine %15 %uint_1 %uint_1 %uint_1 %uint_1 %34 = OpExtInst %void %1 DebugScope %22 %36 = OpExtInst %void %1 DebugDeclare %25 %color %13 %38 = OpExtInst %void %1 DebugScope %26 - %142 = OpExtInst %void %1 DebugLine %5 %uint_2 %uint_2 %uint_10 %uint_10 + %142 = OpExtInst %void %1 DebugLine %15 %uint_2 %uint_2 %uint_10 %uint_10 %39 = OpLoad %v4float %color - %143 = OpExtInst %void %1 DebugLine %5 %uint_2 %uint_2 %uint_3 %uint_3 + %143 = OpExtInst %void %1 DebugLine %15 %uint_2 %uint_2 %uint_3 %uint_3 OpReturnValue %39 OpFunctionEnd )"; diff --git a/test/opt/loop_optimizations/unroll_simple.cpp b/test/opt/loop_optimizations/unroll_simple.cpp index 6468adf48b..b4fd3eaa4d 100644 --- a/test/opt/loop_optimizations/unroll_simple.cpp +++ b/test/opt/loop_optimizations/unroll_simple.cpp @@ -510,36 +510,36 @@ OpBranch %24 %24 = OpLabel %35 = OpPhi %8 %10 %23 %34 %26 %s1 = OpExtInst %6 %ext DebugScope %dbg_main -%d10 = OpExtInst %6 %ext DebugLine %file_name %uint_1 %uint_1 %uint_0 %uint_0 +%d10 = OpExtInst %6 %ext DebugLine %src %uint_1 %uint_1 %uint_0 %uint_0 %value0 = OpExtInst %6 %ext DebugValue %dbg_f %35 %null_expr OpLoopMerge %25 %26 Unroll OpBranch %27 %27 = OpLabel %s2 = OpExtInst %6 %ext DebugScope %dbg_main -%d1 = OpExtInst %6 %ext DebugLine %file_name %uint_1 %uint_1 %uint_1 %uint_1 +%d1 = OpExtInst %6 %ext DebugLine %src %uint_1 %uint_1 %uint_1 %uint_1 %29 = OpSLessThan %12 %35 %11 -%d2 = OpExtInst %6 %ext DebugLine %file_name %uint_2 %uint_2 %uint_0 %uint_0 +%d2 = OpExtInst %6 %ext DebugLine %src %uint_2 %uint_2 %uint_0 %uint_0 OpBranchConditional %29 %30 %25 %30 = OpLabel %s3 = OpExtInst %6 %ext DebugScope %bb %decl0 = OpExtInst %6 %ext DebugDeclare %dbg_f %5 %null_expr %decl1 = OpExtInst %6 %ext DebugValue %dbg_i %5 %deref_expr -%d3 = OpExtInst %6 %ext DebugLine %file_name %uint_3 %uint_3 %uint_0 %uint_0 +%d3 = OpExtInst %6 %ext DebugLine %src %uint_3 %uint_3 %uint_0 %uint_0 %32 = OpAccessChain %19 %5 %35 -%d4 = OpExtInst %6 %ext DebugLine %file_name %uint_4 %uint_4 %uint_0 %uint_0 +%d4 = OpExtInst %6 %ext DebugLine %src %uint_4 %uint_4 %uint_0 %uint_0 OpStore %32 %18 -%d5 = OpExtInst %6 %ext DebugLine %file_name %uint_5 %uint_5 %uint_0 %uint_0 +%d5 = OpExtInst %6 %ext DebugLine %src %uint_5 %uint_5 %uint_0 %uint_0 OpBranch %26 %26 = OpLabel %s4 = OpExtInst %6 %ext DebugScope %dbg_main -%d6 = OpExtInst %6 %ext DebugLine %file_name %uint_6 %uint_6 %uint_0 %uint_0 +%d6 = OpExtInst %6 %ext DebugLine %src %uint_6 %uint_6 %uint_0 %uint_0 %34 = OpIAdd %8 %35 %20 %value1 = OpExtInst %6 %ext DebugValue %dbg_f %34 %null_expr -%d7 = OpExtInst %6 %ext DebugLine %file_name %uint_7 %uint_7 %uint_0 %uint_0 +%d7 = OpExtInst %6 %ext DebugLine %src %uint_7 %uint_7 %uint_0 %uint_0 OpBranch %24 %25 = OpLabel %s5 = OpExtInst %6 %ext DebugScope %dbg_main -%d8 = OpExtInst %6 %ext DebugLine %file_name %uint_8 %uint_8 %uint_0 %uint_0 +%d8 = OpExtInst %6 %ext DebugLine %src %uint_8 %uint_8 %uint_0 %uint_0 OpReturn OpFunctionEnd)"; diff --git a/test/val/val_ext_inst_debug_test.cpp b/test/val/val_ext_inst_debug_test.cpp index 8f0da42d55..bd4ab3c75b 100644 --- a/test/val/val_ext_inst_debug_test.cpp +++ b/test/val/val_ext_inst_debug_test.cpp @@ -21,6 +21,7 @@ #include #include "gmock/gmock.h" +#include "spirv-tools/libspirv.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" @@ -84,6 +85,15 @@ using ValidateVulkan100DebugInfoDebugValue = spvtest::ValidateBase>; using ValidateVulkan100DebugInfo = spvtest::ValidateBase; +const static std::string shader_extension = R"( +OpExtension "SPV_KHR_non_semantic_info" +%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +)"; + +const static std::string opencl_extension = R"( +%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" +)"; + std::string GenerateShaderCodeForDebugInfo( const std::string& op_string_instructions, const std::string& op_const_instructions, @@ -118,6 +128,7 @@ OpCapability Int64 ss << "OpExecutionMode %main OriginUpperLeft\n"; } + ss << "%main_name = OpString \"main\"\n"; ss << op_string_instructions; ss << R"( @@ -181,6 +192,9 @@ OpCapability Int64 %u32_1 = OpConstant %u32 1 %u32_2 = OpConstant %u32 2 %u32_3 = OpConstant %u32 3 +%u32_4 = OpConstant %u32 4 +%u32_5 = OpConstant %u32 5 +%u32_32 = OpConstant %u32 32 %s32_0 = OpConstant %s32 0 %s32_1 = OpConstant %s32 1 @@ -308,12 +322,8 @@ TEST_F(ValidateOpenCL100DebugInfo, UseDebugInstructionOutOfFunction) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -327,12 +337,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugSourceInFunction) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", "", dbg_inst, - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", "", dbg_inst, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -352,13 +358,8 @@ TEST_F(ValidateVulkan100DebugInfo, DebugSourceInFunction) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code )"; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", "", dbg_inst, - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", "", dbg_inst, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -373,8 +374,6 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, OpenCLDebugInfo100DebugScope) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %int_name = OpString "int" %foo_name = OpString "foo" )"; @@ -384,7 +383,7 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, OpenCLDebugInfo100DebugScope) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 Signed %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %int_info %dbg_src 1 1 %main_info FlagIsLocal %expr = OpExtInst %void %DbgExt DebugExpression )"; @@ -392,14 +391,10 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, OpenCLDebugInfo100DebugScope) { const std::string body = R"( %foo = OpVariable %u32_ptr_function Function %foo_val = OpLoad %u32 %foo -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header + GetParam(), body, extension, "Vertex")); + src, "", dbg_inst_header + GetParam(), body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("DebugScope, DebugNoScope, DebugDeclare, DebugValue " @@ -412,8 +407,6 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %int_name = OpString "int" %foo_name = OpString "foo" )"; @@ -423,7 +416,7 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 %u32_1 %u32_0 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_1 +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %int_info %dbg_src %u32_1 %u32_1 %main_info %u32_4 %expr = OpExtInst %void %DbgExt DebugExpression )"; @@ -432,20 +425,10 @@ TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) { %foo = OpVariable %u32_ptr_function Function %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main %foo_val = OpLoad %u32 %foo -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header + GetParam(), body, extension, "Vertex")); + src, "", dbg_inst_header + GetParam(), body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("DebugScope, DebugNoScope, DebugDeclare, DebugValue " @@ -465,27 +448,21 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionForwardReference) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -494,8 +471,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionMissingOpFunction) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( @@ -503,19 +478,15 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionMissingOpFunction) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %dbgNone +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %dbgNone )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -528,8 +499,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeBeforeOpVariableInFunction) { } " %float_name = OpString "float" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string size_const = R"( @@ -542,20 +511,16 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeBeforeOpVariableInFunction) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %foo = OpVariable %f32_ptr_function Function -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, body, extension, "Vertex")); + src, size_const, dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -575,12 +540,8 @@ main() {} %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name Class %dbg_src 1 1 %comp_unit %ty_name %dbg_none FlagIsPublic )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -613,14 +574,10 @@ main() {} %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic %VS_OUTPUT_color_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_color_name %v4float_info %dbg_src 3 3 %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -652,14 +609,10 @@ main() {} %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("forward referenced IDs have not been defined")); @@ -753,12 +706,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugCompilationUnit) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -773,12 +722,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugCompilationUnitFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %src HLSL )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Source must be a result id of " @@ -796,18 +741,8 @@ TEST_F(ValidateVulkan100DebugInfo, DebugCompilationUnitFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %src %u32_5 )"; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, dbg_inst, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Source must be a result id of " @@ -833,14 +768,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeBasicFailName) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %int_32 %int_32 Float -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Name must be a result id of " @@ -856,27 +787,16 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailName) { } " %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %u32_32 %u32_32 %u32_3 %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Name must be a result id of " @@ -902,14 +822,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeBasicFailSize) { %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %float_name Float -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Size must be a result id of " @@ -925,33 +841,47 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailSize) { } " %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %float_name %u32_3 %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Size must be a result id of " "OpConstant")); } +TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailFlags) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() {}" +%float_name = OpString "float" +)"; + + const std::string constants = R"( +%f32_32 = OpConstant %f32 32 +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_3 %u32_3 %f32_32 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("expected operand Flags must be a result id of 32-bit " + "unsigned OpConstant")); +} + TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointer) { const std::string src = R"( %src = OpString "simple.hlsl" @@ -972,14 +902,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointer) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %pfloat_info = OpExtInst %void %DbgExt DebugTypePointer %float_info Function FlagIsLocal -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1003,14 +929,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointerFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %pfloat_info = OpExtInst %void %DbgExt DebugTypePointer %dbg_src Function FlagIsLocal -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -1037,14 +959,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifier) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %float_info ConstType -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1068,14 +986,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifierFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %comp_unit ConstType -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -1090,12 +1004,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) { } " %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1103,15 +1011,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %float_info %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1124,12 +1027,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifierFail) { } " %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1137,15 +1034,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifierFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %comp_unit %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -1168,14 +1060,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArray) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %int_32 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1185,7 +1073,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayWithVariableSize) { %code = OpString "main() {}" %float_name = OpString "float" %int_name = OpString "int" -%main_name = OpString "main" %foo_name = OpString "foo" )"; @@ -1202,14 +1089,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayWithVariableSize) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %uint_info %dbg_src 1 1 %main_info FlagIsLocal %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1229,14 +1112,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailBaseType) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %comp_unit %int_32 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type is not a valid debug " @@ -1259,14 +1138,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCount) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %float_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1291,14 +1166,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCountFloat) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %f32_4 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1323,14 +1194,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCountZero) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_0 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1344,7 +1211,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -%main_name = OpString "main" %foo_name = OpString "foo" )"; @@ -1360,14 +1226,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 1 %main_info FlagIsLocal %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1381,12 +1243,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArray) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1394,15 +1250,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArray) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_32 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1412,15 +1263,11 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayWithVariableSize) { %code = OpString "main() {}" %float_name = OpString "float" %uint_name = OpString "uint" -%main_name = OpString "main" %foo_name = OpString "foo" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_6 = OpConstant %u32 6 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1432,15 +1279,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayWithVariableSize) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %uint_info %dbg_src %u32_1 %u32_1 %main_info %u32_4 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1449,12 +1291,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailBaseType) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1462,15 +1298,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailBaseType) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %comp_unit %u32_32 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type is not a valid debug " @@ -1482,12 +1313,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCount) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1495,15 +1320,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCount) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %float_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1517,12 +1337,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1530,15 +1344,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %f32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1552,12 +1361,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayComponentCountZero) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1565,15 +1368,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayComponentCountZero) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1582,15 +1380,11 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -%main_name = OpString "main" %foo_name = OpString "foo" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_6 = OpConstant %u32 6 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1601,15 +1395,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_1 %main_info %u32_4 %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be OpConstant with a 32- or " @@ -1634,14 +1423,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVector) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1661,14 +1446,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 4 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type must be a result id of " @@ -1691,14 +1472,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFailComponentZero) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 0 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type must be a result id of " @@ -1721,14 +1498,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFailComponentFive) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 5 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type must be a result id of " @@ -1740,12 +1513,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVector) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1753,15 +1520,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVector) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1770,12 +1532,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFail) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1783,15 +1539,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFail) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Base Type must be a result id of " @@ -1803,12 +1554,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentZero) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1816,15 +1561,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentZero) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be positive " @@ -1836,12 +1576,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentFive) { %src = OpString "simple.hlsl" %code = OpString "main() {}" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -1849,15 +1583,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentFive) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_5 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Component Count must be positive " @@ -1872,9 +1601,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrix) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -1884,15 +1610,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrix) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_4 %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -1904,9 +1625,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorTypeType) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -1916,15 +1634,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorTypeType) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %dbg_src %u32_4 %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Vector Type must be a result id of " @@ -1939,9 +1652,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountType) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -1951,15 +1661,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountType) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %dbg_src %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Vector Count must be a result id of " @@ -1974,9 +1679,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountZero) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -1986,15 +1688,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountZero) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_0 %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Vector Count must be positive " @@ -2009,9 +1706,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountFive) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %true = OpConstantTrue %bool )"; @@ -2021,15 +1715,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountFive) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_5 %true -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Vector Count must be positive " @@ -2053,14 +1742,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypedef) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo_info = OpExtInst %void %DbgExt DebugTypedef %foo_name %float_info %dbg_src 1 1 %comp_unit -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2086,12 +1771,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugTypedef, Fail) { %foo_info = OpExtInst %void %DbgExt DebugTypedef )"; ss << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second + @@ -2117,12 +1798,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypedef) { %code = OpString "main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2130,15 +1805,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypedef) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo_info = OpExtInst %void %DbgExt DebugTypedef %foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2148,12 +1818,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypedef, Fail) { %code = OpString "main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const auto& param = GetParam(); @@ -2166,13 +1830,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypedef, Fail) { %foo_info = OpExtInst %void %DbgExt DebugTypedef )"; ss << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second + @@ -2200,8 +1859,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunction) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" )"; @@ -2217,14 +1874,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunction) { %main_type_info2 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info %main_type_info3 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info %float_info %main_type_info4 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void %float_info %float_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2232,8 +1885,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailReturn) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" )"; @@ -2246,14 +1897,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailReturn) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %dbg_src %float_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -2264,8 +1911,6 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailParam) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" )"; @@ -2278,14 +1923,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailParam) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info %void -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -2296,15 +1937,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionAndParams) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2315,15 +1948,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionAndParams) { %main_type_info2 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info %main_type_info3 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info %float_info %main_type_info4 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void %float_info %float_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2331,15 +1959,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailReturn) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2347,15 +1967,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailReturn) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %dbg_src %float_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -2366,15 +1981,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailParam) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" %float_name = OpString "float" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2382,15 +1989,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailParam) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info %void -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -2417,14 +2019,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeEnum) { %foo_info1 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name %u32_1 %foo_name %foo_info2 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name %u32_1 %foo_name %foo_info3 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2450,12 +2048,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugTypeEnum, Fail) { %foo_info = OpExtInst %void %DbgExt DebugTypeEnum )"; ss << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -2496,12 +2090,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeEnum) { %code = OpString "main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -2512,15 +2100,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeEnum) { %foo_info1 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name %u32_1 %foo_name %foo_info2 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name %u32_1 %foo_name %foo_info3 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2530,12 +2113,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypeEnum, Fail) { %code = OpString "main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const auto& param = GetParam(); @@ -2548,13 +2125,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugTypeEnum, Fail) { %foo_info = OpExtInst %void %DbgExt DebugTypeEnum )"; ss << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -2604,8 +2176,6 @@ main() {} %foo_name = OpString "foo" %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string size_const = R"( @@ -2621,17 +2191,13 @@ main() {} %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Structure %dbg_src 1 1 %comp_unit %foo_name %u32_0 FlagIsPublic %child = OpExtInst %void %DbgExt DebugTypeInheritance %foo_info %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2650,8 +2216,6 @@ main() {} %foo_name = OpString "foo" %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string size_const = R"( @@ -2672,17 +2236,13 @@ main() {} %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4 %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Structure %dbg_src 1 1 %comp_unit %foo_name %u32_0 FlagIsPublic %child = OpExtInst %void %DbgExt DebugTypeInheritance %foo_info %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second + " must be ")); @@ -2746,12 +2306,8 @@ main() {} %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember )"; ss << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); if (!param.second.empty()) { EXPECT_THAT(getDiagnosticString(), @@ -2805,12 +2361,8 @@ struct foo : VS_OUTPUT {}; %child = OpExtInst %void %DbgExt DebugTypeInheritance )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -2849,14 +2401,9 @@ main() {} %foo_name = OpString "foo" %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %u32_128 = OpConstant %u32 128 )"; @@ -2868,15 +2415,10 @@ main() {} %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src %u32_2 %u32_3 %u32_0 %u32_128 %u32_3 %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %VS_OUTPUT_linkage_name %u32_128 %u32_3 %VS_OUTPUT_pos_info %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %foo_name %u32_0 %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -2895,14 +2437,9 @@ main() {} %foo_name = OpString "foo" %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %u32_128 = OpConstant %u32 128 )"; @@ -2918,13 +2455,8 @@ main() {} %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite )"; ss << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second + " must be ")); @@ -2971,9 +2503,6 @@ main() {} )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 %u32_128 = OpConstant %u32 128 )"; @@ -2987,13 +2516,8 @@ main() {} %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember )"; ss << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); if (!param.second.empty()) { EXPECT_THAT(getDiagnosticString(), @@ -3033,23 +2557,17 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionDeclaration) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; +%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)"; - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3061,8 +2579,6 @@ TEST_P(ValidateOpenCL100DebugInfoDebugFunction, Fail) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const auto& param = GetParam(); @@ -3072,16 +2588,12 @@ main() {} %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic +%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic %main_info = OpExtInst %void %DbgExt DebugFunction )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3091,25 +2603,25 @@ INSTANTIATE_TEST_SUITE_P( AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugFunction, ::testing::ValuesIn(std::vector>{ std::make_pair( - R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)", + R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)", "Name"), std::make_pair( - R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)", + R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)", "Type"), std::make_pair( - R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)", + R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_name FlagIsPublic 13 %main)", "Source"), std::make_pair( - R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_linkage_name FlagIsPublic 13 %main)", + R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_name FlagIsPublic 13 %main)", "Parent"), std::make_pair( R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %void FlagIsPublic 13 %main)", "Linkage Name"), std::make_pair( - R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %void)", + R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %void)", "Function"), std::make_pair( - R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main %dbg_src)", + R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main %dbg_src)", "Declaration"), })); @@ -3121,8 +2633,6 @@ TEST_P(ValidateOpenCL100DebugInfoDebugFunctionDeclaration, Fail) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const auto& param = GetParam(); @@ -3135,12 +2645,8 @@ main() {} %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3151,16 +2657,16 @@ INSTANTIATE_TEST_SUITE_P( ValidateOpenCL100DebugInfoDebugFunctionDeclaration, ::testing::ValuesIn(std::vector>{ std::make_pair( - R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic)", + R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic)", "Name"), std::make_pair( - R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic)", + R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_name FlagIsPublic)", "Type"), std::make_pair( - R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_linkage_name FlagIsPublic)", + R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_name FlagIsPublic)", "Source"), std::make_pair( - R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_linkage_name FlagIsPublic)", + R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_name FlagIsPublic)", "Parent"), std::make_pair( R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %void FlagIsPublic)", @@ -3175,13 +2681,9 @@ TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDeclaration) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_12 = OpConstant %u32 12 %u32_13 = OpConstant %u32 13 )"; @@ -3190,17 +2692,12 @@ main() {} %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void -%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" +%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13 )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3212,13 +2709,9 @@ TEST_P(ValidateVulkan100DebugInfoDebugFunction, Fail) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_12 = OpConstant %u32 12 %u32_13 = OpConstant %u32 13 )"; @@ -3230,17 +2723,12 @@ main() {} %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void -%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 +%main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %main_info = OpExtInst %void %DbgExt DebugFunction )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3250,22 +2738,22 @@ INSTANTIATE_TEST_SUITE_P( AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugFunction, ::testing::ValuesIn(std::vector>{ std::make_pair( - R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13)", + R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)", "Name"), std::make_pair( - R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13)", + R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)", "Type"), std::make_pair( - R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13)", + R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)", "Source"), std::make_pair( - R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_linkage_name %u32_3 %u32_13)", + R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_name %u32_3 %u32_13)", "Parent"), std::make_pair( R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %void %u32_3 %u32_13)", "Linkage Name"), std::make_pair( - R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3 %u32_13 %dbg_src)", + R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13 %dbg_src)", "Declaration"), })); @@ -3277,13 +2765,9 @@ TEST_P(ValidateVulkan100DebugInfoDebugFunctionDeclaration, Fail) { }; main() {} " -%main_name = OpString "main" -%main_linkage_name = OpString "v4f_main_f" )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_12 = OpConstant %u32 12 %u32_13 = OpConstant %u32 13 )"; @@ -3298,13 +2782,8 @@ main() {} %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3315,27 +2794,54 @@ INSTANTIATE_TEST_SUITE_P( ValidateVulkan100DebugInfoDebugFunctionDeclaration, ::testing::ValuesIn(std::vector>{ std::make_pair( - R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3)", + R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3)", "Name"), std::make_pair( - R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3)", + R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3)", "Type"), std::make_pair( - R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_linkage_name %u32_3)", + R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_name %u32_3)", "Source"), std::make_pair( - R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_linkage_name %u32_3)", + R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_name %u32_3)", "Parent"), std::make_pair( R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %void %u32_3)", "Linkage Name"), })); +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionType) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "main() {}" +%float_name = OpString "float" +%uint_name = OpString "uint" +)"; + + const std::string constants = R"( +%u32_6 = OpConstant %u32 6 +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 +%uint_info = OpExtInst %void %DbgExt DebugTypeBasic %uint_name %u32_32 %u32_6 %u32_0 +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %uint_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunction: expected operand Type must be a result " + "id of DebugTypeFunction")); +} + TEST_F(ValidateOpenCL100DebugInfo, DebugLexicalBlock) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" )"; const std::string dbg_inst_header = R"( @@ -3343,12 +2849,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugLexicalBlock) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_block = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src 1 1 %comp_unit %main_name)"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3356,7 +2858,6 @@ TEST_P(ValidateOpenCL100DebugInfoDebugLexicalBlock, Fail) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" )"; const auto& param = GetParam(); @@ -3368,12 +2869,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugLexicalBlock, Fail) { %main_block = OpExtInst %void %DbgExt DebugLexicalBlock )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "", - extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3400,14 +2897,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeFailScope) { const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %dbg_src -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope")); } @@ -3425,14 +2918,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeFailInlinedAt) { const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %comp_unit %dbg_src -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined At")); } @@ -3441,27 +2930,16 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLexicalBlock) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %main_block = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src %u32_1 %u32_1 %comp_unit %main_name -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3469,12 +2947,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugLexicalBlock, Fail) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "main() {}" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; const auto& param = GetParam(); @@ -3486,13 +2958,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugLexicalBlock, Fail) { %main_block = OpExtInst %void %DbgExt DebugLexicalBlock )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3512,11 +2979,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailScope) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "void main() {}" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; const std::string dbg_inst_header = R"( @@ -3526,15 +2988,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailScope) { const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %dbg_src -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope")); } @@ -3543,11 +3000,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailInlinedAt) { const std::string src = R"( %src = OpString "simple.hlsl" %code = OpString "void main() {}" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 )"; const std::string dbg_inst_header = R"( @@ -3557,15 +3009,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailInlinedAt) { const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %comp_unit %dbg_src -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined At")); } @@ -3587,14 +3034,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugLocalVariable) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 10 %comp_unit FlagIsLocal 0 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3620,12 +3063,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugLocalVariable, Fail) { %foo = OpExtInst %void %DbgExt DebugLocalVariable )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3657,10 +3096,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLocalVariable) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -3668,15 +3104,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugLocalVariable) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, constants, dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3689,10 +3120,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugLocalVariable, Fail) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const auto& param = GetParam(); @@ -3705,13 +3133,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugLocalVariable, Fail) { %foo = OpExtInst %void %DbgExt DebugLocalVariable )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3757,14 +3180,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugDeclare) { const std::string body = R"( %foo = OpVariable %f32_ptr_function Function %decl = OpExtInst %void %DbgExt DebugDeclare %foo_info %foo %null_expr -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, body, extension, "Vertex")); + src, size_const, dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3859,12 +3278,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugDeclare, Fail) { %decl = OpExtInst %void %DbgExt DebugDeclare )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, ss.str(), extension, "Vertex")); + src, size_const, dbg_inst_header, ss.str(), opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -3887,10 +3302,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugDeclare) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -3899,11 +3311,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugDeclare) { %null_expr = OpExtInst %void %DbgExt DebugExpression %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -3912,7 +3319,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, constants, dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -3994,10 +3401,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugDeclare, Fail) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4006,11 +3410,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugDeclare, Fail) { %null_expr = OpExtInst %void %DbgExt DebugExpression %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const auto& param = GetParam(); @@ -4022,7 +3421,7 @@ OpExtension "SPV_KHR_non_semantic_info" << param.first; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, ss.str(), extension, "Vertex")); + src, constants, dbg_inst_header, ss.str(), shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -4043,12 +3442,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugExpression) { %null_expr = OpExtInst %void %DbgExt DebugExpression %op0 %op1 )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + "", "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4058,12 +3453,8 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugExpressionFail) { %null_expr = OpExtInst %void %DbgExt DebugExpression %op %void )"; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + "", "", dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -4078,13 +3469,8 @@ TEST_F(ValidateVulkan100DebugInfo, DebugExpression) { %null_expr = OpExtInst %void %DbgExt DebugExpression %op0 %op1 )"; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + "", "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4094,13 +3480,8 @@ TEST_F(ValidateVulkan100DebugInfo, DebugExpressionFail) { %null_expr = OpExtInst %void %DbgExt DebugExpression %op %void )"; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header, - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + "", "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -4132,14 +3513,10 @@ main() {} %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name Class %dbg_src 1 1 %comp_unit %ty_name %dbg_none FlagIsPublic %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4169,14 +3546,10 @@ main() {} %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %temp %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4189,7 +3562,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" )"; const std::string size_const = R"( @@ -4206,14 +3578,10 @@ main() {} %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %param %param %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %param -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4226,7 +3594,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" )"; const std::string size_const = R"( @@ -4241,14 +3608,10 @@ main() {} %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %float_info %param -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Target must be DebugTypeComposite or " @@ -4264,7 +3627,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" )"; const std::string size_const = R"( @@ -4281,14 +3643,10 @@ main() {} %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %param %param %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %float_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -4306,12 +3664,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4322,15 +3674,10 @@ main() {} %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %ty_name %dbg_none %u32_3 %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4344,12 +3691,6 @@ main() {} %ty_name = OpString "Texture" %t_name = OpString "T" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4361,15 +3702,10 @@ main() {} %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %temp %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4382,13 +3718,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4400,15 +3729,10 @@ main() {} %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %param %param %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %param -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4421,13 +3745,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4437,15 +3754,10 @@ main() {} %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %float_info %param -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Target must be DebugTypeComposite or " @@ -4461,13 +3773,6 @@ main() {} %float_name = OpString "float" %ty_name = OpString "Texture" %t_name = OpString "T" -%main_name = OpString "main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4478,15 +3783,10 @@ main() {} %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %ty_name %dbg_none %u32_3 %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0 %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %float_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT( getDiagnosticString(), @@ -4512,14 +3812,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariable) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4542,14 +3838,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableStaticMember) { %t = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Class %dbg_src 0 0 %comp_unit %foo_name %int_32 FlagIsPublic %a %a = OpExtInst %void %DbgExt DebugTypeMember %foo_name %float_info %dbg_src 0 0 %t %u32_0 %int_32 FlagIsPublic %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate %a -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4571,14 +3863,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableDebugInfoNone) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %dbgNone FlagIsProtected|FlagIsPrivate -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4599,14 +3887,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableConst) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %int_32 FlagIsProtected|FlagIsPrivate -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, "", extension, "Vertex")); + src, size_const, dbg_inst_header, "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4632,12 +3916,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugGlobalVariable, Fail) { %foo = OpExtInst %void %DbgExt DebugGlobalVariable )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, size_const, ss.str(), "", opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -4672,12 +3952,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariable) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4685,15 +3959,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariable) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4703,12 +3972,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableStaticMember) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4718,15 +3981,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableStaticMember) { %a = OpExtInst %void %DbgExt DebugTypeMember %foo_name %float_info %dbg_src %u32_0 %u32_0 %u32_0 %u32_32 %u32_3 %t = OpExtInst %void %DbgExt DebugTypeComposite %foo_name %u32_1 %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %u32_32 %u32_3 %a %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %t %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4736,12 +3994,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableDebugInfoNone) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4750,15 +4002,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableDebugInfoNone) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %dbgNone %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4768,12 +4015,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableConst) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4781,15 +4022,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableConst) { %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %u32_32 %u32_3 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, "", extension, "Vertex")); + src, "", dbg_inst_header, "", shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4799,12 +4035,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugGlobalVariable, Fail) { %code = OpString "float foo; void main() {}" %float_name = OpString "float" %foo_name = OpString "foo" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const auto& param = GetParam(); @@ -4817,13 +4047,8 @@ TEST_P(ValidateVulkan100DebugInfoDebugGlobalVariable, Fail) { %foo = OpExtInst %void %DbgExt DebugGlobalVariable )" << param.first; - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -)"; - - CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, constants, ss.str(), - "", extension, "Vertex")); + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", ss.str(), "", shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -4857,29 +4082,23 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAt) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4888,29 +4107,23 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAtFail) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %inlined_at )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope")); } @@ -4920,29 +4133,23 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAtFail2) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" )"; const std::string dbg_inst_header = R"( %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void -%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %main_info )"; const std::string body = R"( %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, "", dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined")); } @@ -4952,14 +4159,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAt) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -4969,11 +4168,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAt) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -4981,7 +4175,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -4990,14 +4184,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5007,11 +4193,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %inlined_at %inlined_at -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -5019,7 +4200,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope")); } @@ -5029,14 +4210,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail2) { %src = OpString "simple.hlsl" %code = OpString "void main() {}" %void_name = OpString "void" -%main_name = OpString "main" -%main_linkage_name = OpString "v_main" -)"; - - const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5046,11 +4219,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail2) { %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %main_info -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -5058,7 +4226,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, "", dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined")); } @@ -5087,14 +4255,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugValue) { const std::string body = R"( %value = OpExtInst %void %DbgExt DebugValue %foo_info %int_32 %null_expr %int_3 -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, body, extension, "Vertex")); + src, size_const, dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -5126,14 +4290,10 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugValueWithVariableIndex) { const std::string body = R"( %value = OpExtInst %void %DbgExt DebugValue %foo_info %int_32 %null_expr %len_info -)"; - - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, body, extension, "Vertex")); + src, size_const, dbg_inst_header, body, opencl_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -5164,12 +4324,8 @@ TEST_P(ValidateOpenCL100DebugInfoDebugValue, Fail) { %decl = OpExtInst %void %DbgExt DebugValue )" << param.first; - const std::string extension = R"( -%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" -)"; - CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, size_const, dbg_inst_header, ss.str(), extension, "Vertex")); + src, size_const, dbg_inst_header, ss.str(), opencl_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -5192,10 +4348,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValue) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5205,11 +4358,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValue) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -5217,7 +4365,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, constants, dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -5232,10 +4380,7 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValueWithVariableIndex) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5247,11 +4392,6 @@ TEST_F(ValidateVulkan100DebugInfo, DebugValueWithVariableIndex) { %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 %u32_0 %len_info = OpExtInst %void %DbgExt DebugLocalVariable %len_name %int_info %dbg_src %u32_0 %u32_0 %comp_unit %u32_4 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const std::string body = R"( @@ -5259,7 +4399,7 @@ OpExtension "SPV_KHR_non_semantic_info" )"; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, body, extension, "Vertex")); + src, constants, dbg_inst_header, body, shader_extension, "Vertex")); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } @@ -5272,10 +4412,7 @@ TEST_P(ValidateVulkan100DebugInfoDebugValue, Fail) { )"; const std::string constants = R"( -%u32_4 = OpConstant %u32 4 -%u32_5 = OpConstant %u32 5 %u32_10 = OpConstant %u32 10 -%u32_32 = OpConstant %u32 32 )"; const std::string dbg_inst_header = R"( @@ -5285,11 +4422,6 @@ TEST_P(ValidateVulkan100DebugInfoDebugValue, Fail) { %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4 %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 %u32_0 -)"; - - const std::string extension = R"( -OpExtension "SPV_KHR_non_semantic_info" -%DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" )"; const auto& param = GetParam(); @@ -5300,7 +4432,7 @@ OpExtension "SPV_KHR_non_semantic_info" << param.first; CompileSuccessfully(GenerateShaderCodeForDebugInfo( - src, constants, dbg_inst_header, ss.str(), extension, "Vertex")); + src, constants, dbg_inst_header, ss.str(), shader_extension, "Vertex")); ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand " + param.second)); @@ -5475,6 +4607,428 @@ TEST_F(ValidateVulkan100DebugInfo, VulkanDebugInfoSample) { ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinition) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionFailFunction) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_type_info %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: expected operand Function " + "must be a result id of DebugFunction")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionFailDefinition) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main_name +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: expected operand Definition " + "must be a result id of OpFunction")); +} + +// TODO - Need to track in function scope +TEST_F(ValidateVulkan100DebugInfo, DISABLED_DebugFunctionDefinitionDuplicate) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info1 = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +%main_info2 = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def1 = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info1 %main +%main_def2 = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info2 %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: Was used multiple times in " + "single function block")); +} + +// TODO - Need to track in function scope +TEST_F(ValidateVulkan100DebugInfo, + DISABLED_DebugFunctionDefinitionDuplicateReference) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +OpReturn +OpFunctionEnd + +%foo = OpFunction %void None %func +%foo_entry = OpLabel +%foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %foo +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: Was referenced a " + "DebugFunction that was already referenced before")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionWrongDefinition) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +%foo_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +OpReturn +OpFunctionEnd + +%foo = OpFunction %void None %func +%foo_entry = OpLabel +%foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %foo_info %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: operand Definition must " + "point to the OpFunction it is inside")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionNonEntryBlock) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string constants = R"( +%false = OpConstantFalse %bool +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +OpSelectionMerge %merge_block None +OpBranchConditional %false %second_block %merge_block +%second_block = OpLabel +OpReturn +%merge_block = OpLabel +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, constants, dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugFunctionDefinition: must be in the entry basic " + "block of the function")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionMultiFunctions) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 +%main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void +%main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +%foo_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1 +)"; + + const std::string body = R"( +%main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main +OpReturn +OpFunctionEnd + +%foo = OpFunction %void None %func +%foo_entry = OpLabel +%foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %foo_info %foo +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLine) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0 +%line2 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0 +%no_line = OpExtInst %void %DbgExt DebugNoLine +%line3 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugNoLineOutOfBlock) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%no_line = OpExtInst %void %DbgExt DebugNoLine +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("debug info extension must appear in a function body")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineOutOfBlock) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%line = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, "", shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("debug info extension must appear in a function body")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineSource) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +%int_name = OpString "int" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 %u32_1 %u32_0 +)"; + + const std::string body = R"( +%line = OpExtInst %void %DbgExt DebugLine %int_info %u32_2 %u32_2 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: expected operand Source must be a result " + "id of DebugSource")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineFloat) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %f32_1 %u32_2 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: expected operand Line Start must be a " + "result id of 32-bit unsigned OpConstant")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineInt64) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u64_1 %u64_1 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: expected operand Line Start must be a " + "result id of 32-bit unsigned OpConstant")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineSpecConstant) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +%spec_int = OpSpecConstant %u32 2 +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %spec_int %u32_1 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("DebugLine: expected operand Line Start must be a " + "result id of 32-bit unsigned OpConstant")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineLineEndSmaller) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_2 %u32_1 %u32_0 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr("DebugLine: operand Line End (1) is less than Line Start (2)")); +} + +TEST_F(ValidateVulkan100DebugInfo, DebugLineColumnEndSmaller) { + const std::string src = R"( +%src = OpString "simple.hlsl" +%code = OpString "int main() { }" +)"; + + const std::string dbg_inst_header = R"( +%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code +)"; + + const std::string body = R"( +%line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_1 %u32_1 %u32_0 +)"; + + CompileSuccessfully(GenerateShaderCodeForDebugInfo( + src, "", dbg_inst_header, body, shader_extension, "Vertex")); + ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "DebugLine: operand Column End (0) is less than Column Start (1)")); +} + } // namespace } // namespace val } // namespace spvtools