| // Copyright (c) 2017 Google Inc. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| // Tests validation rules of GLSL.450.std and OpenCL.std extended instructions. |
| // Doesn't test OpenCL.std vector size 2, 3, 4, 8 or 16 rules (not supported |
| // by standard SPIR-V). |
| |
| #include <sstream> |
| #include <string> |
| #include <vector> |
| |
| #include "gmock/gmock.h" |
| #include "test/unit_spirv.h" |
| #include "test/val/val_fixtures.h" |
| |
| namespace spvtools { |
| namespace val { |
| namespace { |
| |
| using ::testing::Eq; |
| using ::testing::HasSubstr; |
| using ::testing::Not; |
| |
| using ValidateOldDebugInfo = spvtest::ValidateBase<std::string>; |
| using ValidateOpenCL100DebugInfo = spvtest::ValidateBase<std::string>; |
| using ValidateXDebugInfo = spvtest::ValidateBase<std::string>; |
| using ValidateLocalDebugInfoOutOfFunction = spvtest::ValidateBase<std::string>; |
| using ValidateOpenCL100DebugInfoDebugTypedef = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugTypedef = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugTypeEnum = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugTypeEnum = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugTypeComposite = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugTypeComposite = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugTypeMember = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugTypeMember = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugTypeInheritance = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugFunction = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugFunction = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugFunctionDeclaration = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugFunctionDeclaration = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugLexicalBlock = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugLexicalBlock = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugLocalVariable = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugLocalVariable = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugGlobalVariable = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugGlobalVariable = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugDeclare = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugDeclare = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateOpenCL100DebugInfoDebugValue = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfoDebugValue = |
| spvtest::ValidateBase<std::pair<std::string, std::string>>; |
| using ValidateVulkan100DebugInfo = spvtest::ValidateBase<std::string>; |
| |
| std::string GenerateShaderCodeForDebugInfo( |
| const std::string& op_string_instructions, |
| const std::string& op_const_instructions, |
| const std::string& debug_instructions_before_main, const std::string& body, |
| const std::string& capabilities_and_extensions = "", |
| const std::string& execution_model = "Fragment") { |
| std::ostringstream ss; |
| ss << R"( |
| OpCapability Shader |
| OpCapability Float16 |
| OpCapability Float64 |
| OpCapability Int16 |
| OpCapability Int64 |
| )"; |
| |
| ss << capabilities_and_extensions; |
| ss << "%extinst = OpExtInstImport \"GLSL.std.450\"\n"; |
| ss << "OpMemoryModel Logical GLSL450\n"; |
| ss << "OpEntryPoint " << execution_model << " %main \"main\"" |
| << " %f32_output" |
| << " %f32vec2_output" |
| << " %u32_output" |
| << " %u32vec2_output" |
| << " %u64_output" |
| << " %f32_input" |
| << " %f32vec2_input" |
| << " %u32_input" |
| << " %u32vec2_input" |
| << " %u64_input" |
| << "\n"; |
| if (execution_model == "Fragment") { |
| ss << "OpExecutionMode %main OriginUpperLeft\n"; |
| } |
| |
| ss << op_string_instructions; |
| |
| ss << R"( |
| %void = OpTypeVoid |
| %func = OpTypeFunction %void |
| %bool = OpTypeBool |
| %f16 = OpTypeFloat 16 |
| %f32 = OpTypeFloat 32 |
| %f64 = OpTypeFloat 64 |
| %u32 = OpTypeInt 32 0 |
| %s32 = OpTypeInt 32 1 |
| %u64 = OpTypeInt 64 0 |
| %s64 = OpTypeInt 64 1 |
| %u16 = OpTypeInt 16 0 |
| %s16 = OpTypeInt 16 1 |
| %f32vec2 = OpTypeVector %f32 2 |
| %f32vec3 = OpTypeVector %f32 3 |
| %f32vec4 = OpTypeVector %f32 4 |
| %f64vec2 = OpTypeVector %f64 2 |
| %f64vec3 = OpTypeVector %f64 3 |
| %f64vec4 = OpTypeVector %f64 4 |
| %u32vec2 = OpTypeVector %u32 2 |
| %u32vec3 = OpTypeVector %u32 3 |
| %s32vec2 = OpTypeVector %s32 2 |
| %u32vec4 = OpTypeVector %u32 4 |
| %s32vec4 = OpTypeVector %s32 4 |
| %u64vec2 = OpTypeVector %u64 2 |
| %s64vec2 = OpTypeVector %s64 2 |
| %f64mat22 = OpTypeMatrix %f64vec2 2 |
| %f32mat22 = OpTypeMatrix %f32vec2 2 |
| %f32mat23 = OpTypeMatrix %f32vec2 3 |
| %f32mat32 = OpTypeMatrix %f32vec3 2 |
| %f32mat33 = OpTypeMatrix %f32vec3 3 |
| |
| %f32_0 = OpConstant %f32 0 |
| %f32_1 = OpConstant %f32 1 |
| %f32_2 = OpConstant %f32 2 |
| %f32_3 = OpConstant %f32 3 |
| %f32_4 = OpConstant %f32 4 |
| %f32_h = OpConstant %f32 0.5 |
| %f32vec2_01 = OpConstantComposite %f32vec2 %f32_0 %f32_1 |
| %f32vec2_12 = OpConstantComposite %f32vec2 %f32_1 %f32_2 |
| %f32vec3_012 = OpConstantComposite %f32vec3 %f32_0 %f32_1 %f32_2 |
| %f32vec3_123 = OpConstantComposite %f32vec3 %f32_1 %f32_2 %f32_3 |
| %f32vec4_0123 = OpConstantComposite %f32vec4 %f32_0 %f32_1 %f32_2 %f32_3 |
| %f32vec4_1234 = OpConstantComposite %f32vec4 %f32_1 %f32_2 %f32_3 %f32_4 |
| |
| %f64_0 = OpConstant %f64 0 |
| %f64_1 = OpConstant %f64 1 |
| %f64_2 = OpConstant %f64 2 |
| %f64_3 = OpConstant %f64 3 |
| %f64vec2_01 = OpConstantComposite %f64vec2 %f64_0 %f64_1 |
| %f64vec3_012 = OpConstantComposite %f64vec3 %f64_0 %f64_1 %f64_2 |
| %f64vec4_0123 = OpConstantComposite %f64vec4 %f64_0 %f64_1 %f64_2 %f64_3 |
| |
| %f16_0 = OpConstant %f16 0 |
| %f16_1 = OpConstant %f16 1 |
| %f16_h = OpConstant %f16 0.5 |
| |
| %u32_0 = OpConstant %u32 0 |
| %u32_1 = OpConstant %u32 1 |
| %u32_2 = OpConstant %u32 2 |
| %u32_3 = OpConstant %u32 3 |
| |
| %s32_0 = OpConstant %s32 0 |
| %s32_1 = OpConstant %s32 1 |
| %s32_2 = OpConstant %s32 2 |
| %s32_3 = OpConstant %s32 3 |
| |
| %u64_0 = OpConstant %u64 0 |
| %u64_1 = OpConstant %u64 1 |
| %u64_2 = OpConstant %u64 2 |
| %u64_3 = OpConstant %u64 3 |
| |
| %s64_0 = OpConstant %s64 0 |
| %s64_1 = OpConstant %s64 1 |
| %s64_2 = OpConstant %s64 2 |
| %s64_3 = OpConstant %s64 3 |
| )"; |
| |
| ss << op_const_instructions; |
| |
| ss << R"( |
| %s32vec2_01 = OpConstantComposite %s32vec2 %s32_0 %s32_1 |
| %u32vec2_01 = OpConstantComposite %u32vec2 %u32_0 %u32_1 |
| |
| %s32vec2_12 = OpConstantComposite %s32vec2 %s32_1 %s32_2 |
| %u32vec2_12 = OpConstantComposite %u32vec2 %u32_1 %u32_2 |
| |
| %s32vec4_0123 = OpConstantComposite %s32vec4 %s32_0 %s32_1 %s32_2 %s32_3 |
| %u32vec4_0123 = OpConstantComposite %u32vec4 %u32_0 %u32_1 %u32_2 %u32_3 |
| |
| %s64vec2_01 = OpConstantComposite %s64vec2 %s64_0 %s64_1 |
| %u64vec2_01 = OpConstantComposite %u64vec2 %u64_0 %u64_1 |
| |
| %f32mat22_1212 = OpConstantComposite %f32mat22 %f32vec2_12 %f32vec2_12 |
| %f32mat23_121212 = OpConstantComposite %f32mat23 %f32vec2_12 %f32vec2_12 %f32vec2_12 |
| |
| %f32_ptr_output = OpTypePointer Output %f32 |
| %f32vec2_ptr_output = OpTypePointer Output %f32vec2 |
| |
| %u32_ptr_output = OpTypePointer Output %u32 |
| %u32vec2_ptr_output = OpTypePointer Output %u32vec2 |
| |
| %u64_ptr_output = OpTypePointer Output %u64 |
| |
| %f32_output = OpVariable %f32_ptr_output Output |
| %f32vec2_output = OpVariable %f32vec2_ptr_output Output |
| |
| %u32_output = OpVariable %u32_ptr_output Output |
| %u32vec2_output = OpVariable %u32vec2_ptr_output Output |
| |
| %u64_output = OpVariable %u64_ptr_output Output |
| |
| %f32_ptr_input = OpTypePointer Input %f32 |
| %f32vec2_ptr_input = OpTypePointer Input %f32vec2 |
| |
| %u32_ptr_input = OpTypePointer Input %u32 |
| %u32vec2_ptr_input = OpTypePointer Input %u32vec2 |
| |
| %u64_ptr_input = OpTypePointer Input %u64 |
| |
| %f32_ptr_function = OpTypePointer Function %f32 |
| |
| %f32_input = OpVariable %f32_ptr_input Input |
| %f32vec2_input = OpVariable %f32vec2_ptr_input Input |
| |
| %u32_input = OpVariable %u32_ptr_input Input |
| %u32vec2_input = OpVariable %u32vec2_ptr_input Input |
| |
| %u64_input = OpVariable %u64_ptr_input Input |
| |
| %u32_ptr_function = OpTypePointer Function %u32 |
| |
| %struct_f16_u16 = OpTypeStruct %f16 %u16 |
| %struct_f32_f32 = OpTypeStruct %f32 %f32 |
| %struct_f32_f32_f32 = OpTypeStruct %f32 %f32 %f32 |
| %struct_f32_u32 = OpTypeStruct %f32 %u32 |
| %struct_f32_u32_f32 = OpTypeStruct %f32 %u32 %f32 |
| %struct_u32_f32 = OpTypeStruct %u32 %f32 |
| %struct_u32_u32 = OpTypeStruct %u32 %u32 |
| %struct_f32_f64 = OpTypeStruct %f32 %f64 |
| %struct_f32vec2_f32vec2 = OpTypeStruct %f32vec2 %f32vec2 |
| %struct_f32vec2_u32vec2 = OpTypeStruct %f32vec2 %u32vec2 |
| )"; |
| |
| ss << debug_instructions_before_main; |
| |
| ss << R"( |
| %main = OpFunction %void None %func |
| %main_entry = OpLabel |
| )"; |
| |
| ss << body; |
| |
| ss << R"( |
| OpReturn |
| OpFunctionEnd)"; |
| |
| return ss.str(); |
| } |
| |
| TEST_F(ValidateOldDebugInfo, UseDebugInstructionOutOfFunction) { |
| const std::string src = R"( |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %cu = OpExtInst %void %DbgExt DebugCompilationUnit %code 1 1 |
| )"; |
| |
| const std::string extension = R"( |
| %DbgExt = OpExtInstImport "DebugInfo" |
| )"; |
| |
| CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", |
| extension, "Vertex")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, UseDebugInstructionOutOfFunction) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugSourceInFunction) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("Debug info extension instructions other than DebugScope, " |
| "DebugNoScope, DebugDeclare, DebugValue must appear between " |
| "section 9 (types, constants, global variables) and section 10 " |
| "(function declarations)")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugSourceInFunction) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("Debug info extension instructions other than DebugScope, " |
| "DebugNoScope, DebugDeclare, DebugValue must appear between " |
| "section 9 (types, constants, global variables) and section 10 " |
| "(function declarations)")); |
| } |
| |
| TEST_P(ValidateLocalDebugInfoOutOfFunction, OpenCLDebugInfo100DebugScope) { |
| const std::string src = R"( |
| %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" |
| )"; |
| |
| 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 |
| %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 |
| %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %int_info %dbg_src 1 1 %main_info FlagIsLocal |
| %expr = OpExtInst %void %DbgExt DebugExpression |
| )"; |
| |
| 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("DebugScope, DebugNoScope, DebugDeclare, DebugValue " |
| "of debug info extension must appear in a function " |
| "body")); |
| } |
| |
| TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) { |
| const std::string src = R"( |
| %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" |
| )"; |
| |
| 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 |
| %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 |
| %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 |
| )"; |
| |
| const std::string body = R"( |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("DebugScope, DebugNoScope, DebugDeclare, DebugValue " |
| "of debug info extension must appear in a function " |
| "body")); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P( |
| AllLocalDebugInfo, ValidateLocalDebugInfoOutOfFunction, |
| ::testing::ValuesIn(std::vector<std::string>{ |
| "%main_scope = OpExtInst %void %DbgExt DebugScope %main_info", |
| "%no_scope = OpExtInst %void %DbgExt DebugNoScope", |
| })); |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionForwardReference) { |
| const std::string src = R"( |
| %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 |
| )"; |
| |
| 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionMissingOpFunction) { |
| const std::string src = R"( |
| %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"( |
| %dbgNone = OpExtInst %void %DbgExt DebugInfoNone |
| %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 |
| )"; |
| |
| 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugScopeBeforeOpVariableInFunction) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %float_name = OpString "float" |
| %main_name = OpString "main" |
| %main_linkage_name = OpString "v4f_main_f" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 2 4 %dbg_src HLSL |
| %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 |
| )"; |
| |
| 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeSizeDebugInfoNone) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "OpaqueType foo; |
| main() {} |
| " |
| %ty_name = OpString "struct VS_OUTPUT" |
| )"; |
| |
| const std::string dbg_inst_header = R"( |
| %dbg_none = OpExtInst %void %DbgExt DebugInfoNone |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code |
| %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeForwardReference) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "struct VS_OUTPUT { |
| float4 pos : SV_POSITION; |
| float4 color : COLOR; |
| }; |
| main() {} |
| " |
| %VS_OUTPUT_name = OpString "struct VS_OUTPUT" |
| %float_name = OpString "float" |
| %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" |
| %VS_OUTPUT_color_name = OpString "color : COLOR" |
| %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_32 = OpConstant %u32 32 |
| %int_128 = OpConstant %u32 128 |
| )"; |
| |
| 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 |
| %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %VS_OUTPUT_color_info |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeMissingReference) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "struct VS_OUTPUT { |
| float4 pos : SV_POSITION; |
| float4 color : COLOR; |
| }; |
| main() {} |
| " |
| %VS_OUTPUT_name = OpString "struct VS_OUTPUT" |
| %float_name = OpString "float" |
| %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION" |
| %VS_OUTPUT_color_name = OpString "color : COLOR" |
| %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_32 = OpConstant %u32 32 |
| %int_128 = OpConstant %u32 128 |
| )"; |
| |
| 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 |
| %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %VS_OUTPUT_color_info |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("forward referenced IDs have not been defined")); |
| } |
| |
| TEST_P(ValidateXDebugInfo, DebugSourceWrongResultType) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %dbg_src = OpExtInst %bool %DbgExt DebugSource %src %code |
| )"; |
| |
| CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", |
| GetParam(), "Vertex")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected result type must be a result id of " |
| "OpTypeVoid")); |
| } |
| |
| TEST_P(ValidateXDebugInfo, DebugSourceFailFile) { |
| const std::string src = R"( |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %DbgExt %code |
| )"; |
| |
| CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", |
| GetParam(), "Vertex")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand File must be a result id of " |
| "OpString")); |
| } |
| |
| TEST_P(ValidateXDebugInfo, DebugSourceFailSource) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src %DbgExt |
| )"; |
| |
| CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", |
| GetParam(), "Vertex")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Text must be a result id of " |
| "OpString")); |
| } |
| |
| TEST_P(ValidateXDebugInfo, DebugSourceNoText) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src |
| )"; |
| |
| CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "", |
| GetParam(), "Vertex")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(OpenCLAndVkDebugInfo100, ValidateXDebugInfo, |
| ::testing::ValuesIn(std::vector<std::string>{ |
| R"( |
| %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100" |
| )", |
| R"( |
| OpExtension "SPV_KHR_non_semantic_info" |
| %DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" |
| )", |
| })); |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugCompilationUnit) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugCompilationUnitFail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Source must be a result id of " |
| "DebugSource")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugCompilationUnitFail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| )"; |
| |
| const std::string dbg_inst = R"( |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Source must be a result id of " |
| "DebugSource")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeBasicFailName) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Name must be a result id of " |
| "OpString")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailName) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Name must be a result id of " |
| "OpString")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeBasicFailSize) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Size must be a result id of " |
| "OpConstant")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailSize) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Size must be a result id of " |
| "OpConstant")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointer) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointerFail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("expected operand Base Type is not a valid debug type")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifier) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifierFail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("expected operand Base Type is not a valid debug type")); |
| } |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %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 %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifierFail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "float4 main(float arg) { |
| float foo; |
| return float4(0, 0, 0, 0); |
| } |
| " |
| %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 %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("expected operand Base Type is not a valid debug type")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArray) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayWithVariableSize) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| %int_name = OpString "int" |
| %main_name = OpString "main" |
| %foo_name = OpString "foo" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 2 4 %dbg_src HLSL |
| %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float |
| %uint_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %int_32 Unsigned |
| %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_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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailBaseType) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Base Type is not a valid debug " |
| "type")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCount) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be OpConstant with a 32- or " |
| "64-bits integer scalar type or DebugGlobalVariable or " |
| "DebugLocalVariable with a 32- or 64-bits unsigned " |
| "integer scalar type")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCountFloat) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be OpConstant with a 32- or " |
| "64-bits integer scalar type or DebugGlobalVariable or " |
| "DebugLocalVariable with a 32- or 64-bits unsigned " |
| "integer scalar type")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCountZero) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be OpConstant with a 32- or " |
| "64-bits integer scalar type or DebugGlobalVariable or " |
| "DebugLocalVariable with a 32- or 64-bits unsigned " |
| "integer scalar type")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| %main_name = OpString "main" |
| %foo_name = OpString "foo" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 2 4 %dbg_src HLSL |
| %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float |
| %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_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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be OpConstant with a 32- or " |
| "64-bits integer scalar type or DebugGlobalVariable or " |
| "DebugLocalVariable with a 32- or 64-bits unsigned " |
| "integer scalar type")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeArray) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayWithVariableSize) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %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"( |
| %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_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 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailBaseType) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Base Type is not a valid debug " |
| "type")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCount) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be OpConstant with a 32- or " |
| "64-bits integer scalar type or DebugGlobalVariable or " |
| "DebugLocalVariable with a 32- or 64-bits unsigned " |
| "integer scalar type")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be OpConstant with a 32- or " |
| "64-bits integer scalar type or DebugGlobalVariable or " |
| "DebugLocalVariable with a 32- or 64-bits unsigned " |
| "integer scalar type")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayComponentCountZero) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be OpConstant with a 32- or " |
| "64-bits integer scalar type or DebugGlobalVariable or " |
| "DebugLocalVariable with a 32- or 64-bits unsigned " |
| "integer scalar type")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVector) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Base Type must be a result id of " |
| "DebugTypeBasic")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFailComponentZero) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Base Type must be a result id of " |
| "DebugTypeBasic")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFailComponentFive) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Base Type must be a result id of " |
| "DebugTypeBasic")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeVector) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFail) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Base Type must be a result id of " |
| "DebugTypeBasic")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentZero) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be positive " |
| "integer less than or equal to 4")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentFive) { |
| const std::string src = R"( |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Component Count must be positive " |
| "integer less than or equal to 4")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrix) { |
| const std::string src = R"( |
| %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 |
| %true = OpConstantTrue %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 |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorTypeType) { |
| const std::string src = R"( |
| %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 |
| %true = OpConstantTrue %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Vector Type must be a result id of " |
| "DebugTypeVector")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountType) { |
| const std::string src = R"( |
| %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 |
| %true = OpConstantTrue %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand Vector Count must be a result id of " |
| "32-bit unsigned OpConstant")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountZero) { |
| const std::string src = R"( |
| %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 |
| %true = OpConstantTrue %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Vector Count must be positive " |
| "integer less than or equal to 4")); |
| } |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountFive) { |
| const std::string src = R"( |
| %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 |
| %true = OpConstantTrue %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("Vector Count must be positive " |
| "integer less than or equal to 4")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypedef) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| %foo_name = OpString "foo" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_P(ValidateOpenCL100DebugInfoDebugTypedef, Fail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| %foo_name = OpString "foo" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_32 = OpConstant %u32 32 |
| )"; |
| |
| const auto& param = GetParam(); |
| |
| std::ostringstream ss; |
| ss << R"( |
| %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 %int_32 Float |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand " + param.second + |
| " must be a result id of ")); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P( |
| AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugTypedef, |
| ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{ |
| std::make_pair(R"(%dbg_src %float_info %dbg_src 1 1 %comp_unit)", |
| "Name"), |
| std::make_pair(R"(%foo_name %dbg_src %dbg_src 1 1 %comp_unit)", |
| "Base Type"), |
| std::make_pair(R"(%foo_name %float_info %comp_unit 1 1 %comp_unit)", |
| "Source"), |
| std::make_pair(R"(%foo_name %float_info %dbg_src 1 1 %dbg_src)", |
| "Parent"), |
| })); |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypedef) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_P(ValidateVulkan100DebugInfoDebugTypedef, Fail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %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(); |
| |
| std::ostringstream ss; |
| ss << 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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand " + param.second + |
| " must be a result id of ")); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P( |
| AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugTypedef, |
| ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{ |
| std::make_pair( |
| R"(%dbg_src %float_info %dbg_src %u32_1 %u32_1 %comp_unit)", |
| "Name"), |
| std::make_pair( |
| R"(%foo_name %dbg_src %dbg_src %u32_1 %u32_1 %comp_unit)", |
| "Base Type"), |
| std::make_pair( |
| R"(%foo_name %float_info %comp_unit %u32_1 %u32_1 %comp_unit)", |
| "Source"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %dbg_src)", |
| "Parent"), |
| })); |
| |
| 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" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 2 4 %dbg_src HLSL |
| %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float |
| %main_type_info1 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| 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" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("expected operand Return Type is not a valid debug type")); |
| } |
| |
| 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" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("expected operand Parameter Types is not a valid debug type")); |
| } |
| |
| 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"( |
| %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 |
| %main_type_info1 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| 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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("expected operand Return Type is not a valid debug type")); |
| } |
| |
| 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"( |
| %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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT( |
| getDiagnosticString(), |
| HasSubstr("expected operand Parameter Types is not a valid debug type")); |
| } |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeEnum) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| %foo_name = OpString "foo" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_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 2 4 %dbg_src HLSL |
| %none = OpExtInst %void %DbgExt DebugInfoNone |
| %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_P(ValidateOpenCL100DebugInfoDebugTypeEnum, Fail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "main() {}" |
| %float_name = OpString "float" |
| %foo_name = OpString "foo" |
| )"; |
| |
| const std::string size_const = R"( |
| %int_32 = OpConstant %u32 32 |
| )"; |
| |
| const auto& param = GetParam(); |
| |
| std::ostringstream ss; |
| ss << R"( |
| %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 %int_32 Float |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand " + param.second)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P( |
| AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugTypeEnum, |
| ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{ |
| std::make_pair( |
| R"(%dbg_src %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name)", |
| "Name"), |
| std::make_pair( |
| R"(%foo_name %dbg_src %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name)", |
| "Underlying Types"), |
| std::make_pair( |
| R"(%foo_name %float_info %comp_unit 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name)", |
| "Source"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src 1 1 %dbg_src %int_32 FlagIsPublic %u32_0 %foo_name)", |
| "Parent"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src 1 1 %comp_unit %void FlagIsPublic %u32_0 %foo_name)", |
| "Size"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src 1 1 %comp_unit %u32_0 FlagIsPublic %u32_0 %foo_name)", |
| "Size"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %foo_name %foo_name)", |
| "Value"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %u32_1)", |
| "Name"), |
| })); |
| |
| TEST_F(ValidateVulkan100DebugInfo, DebugTypeEnum) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %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"( |
| %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code |
| %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5 |
| %none = OpExtInst %void %DbgExt DebugInfoNone |
| %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0 |
| %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")); |
| ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); |
| } |
| |
| TEST_P(ValidateVulkan100DebugInfoDebugTypeEnum, Fail) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %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(); |
| |
| std::ostringstream ss; |
| ss << 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 |
| %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")); |
| ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()); |
| EXPECT_THAT(getDiagnosticString(), |
| HasSubstr("expected operand " + param.second)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P( |
| AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugTypeEnum, |
| ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{ |
| std::make_pair( |
| R"(%dbg_src %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name)", |
| "Name"), |
| std::make_pair( |
| R"(%foo_name %dbg_src %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name)", |
| "Underlying Types"), |
| std::make_pair( |
| R"(%foo_name %float_info %comp_unit %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name)", |
| "Source"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %dbg_src %u32_32 %u32_3 %u32_0 %foo_name)", |
| "Parent"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %void %u32_3 %u32_0 %foo_name)", |
| "Size"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_0 %u32_3 %u32_0 %foo_name)", |
| "Size"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %foo_name %foo_name)", |
| "Value"), |
| std::make_pair( |
| R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %u32_1)", |
| "Name"), |
| })); |
| |
| TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeFunctionAndInheritance) { |
| const std::string src = R"( |
| %src = OpString "simple.hlsl" |
| %code = OpString "struct VS_OUTPUT { |
| float4 pos : SV_POSITION; |
| }; |
| struct foo : VS_OUTPUT { |
| }; |
| main() {} |
| " |
| %VS_OUTPUT_name = OpString "struct VS_OUTPUT" |
| %float_name = OpString "float" |
| %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"( |
| %int_32 = OpConstant %u32 32 |
| %int_128 = OpConstant %u32 128 |
|