@@ -1237,6 +1237,36 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) {
12371237 " integer scalar type" ));
12381238}
12391239
1240+ TEST_F (ValidateOpenCL100DebugInfo,
1241+ DebugTypeArrayOpSpecConstantComponentCountFail) {
1242+ const std::string src = R"(
1243+ %src = OpString "simple.hlsl"
1244+ %code = OpString "main() {}"
1245+ %float_name = OpString "float"
1246+ )" ;
1247+
1248+ const std::string size_const = R"(
1249+ %int_32 = OpConstant %u32 32
1250+ %spec_u32 = OpSpecConstant %u32 4
1251+ )" ;
1252+
1253+ const std::string dbg_inst_header = R"(
1254+ %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
1255+ %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
1256+ %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
1257+ %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %spec_u32
1258+ )" ;
1259+
1260+ CompileSuccessfully (GenerateShaderCodeForDebugInfo (
1261+ src, size_const, dbg_inst_header, " " , opencl_extension, " Vertex" ));
1262+ ASSERT_EQ (SPV_ERROR_INVALID_DATA, ValidateInstructions ());
1263+ EXPECT_THAT (getDiagnosticString (),
1264+ HasSubstr (" Component Count must be OpConstant with a 32- or "
1265+ " 64-bits integer scalar type or DebugGlobalVariable or "
1266+ " DebugLocalVariable with a 32- or 64-bits unsigned "
1267+ " integer scalar type" ));
1268+ }
1269+
12401270TEST_F (ValidateVulkan100DebugInfo, DebugTypeArray) {
12411271 const std::string src = R"(
12421272%src = OpString "simple.hlsl"
@@ -1325,10 +1355,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCount) {
13251355 src, " " , dbg_inst_header, " " , shader_extension, " Vertex" ));
13261356 ASSERT_EQ (SPV_ERROR_INVALID_DATA, ValidateInstructions ());
13271357 EXPECT_THAT (getDiagnosticString (),
1328- HasSubstr (" Component Count must be OpConstant with a 32- or "
1329- " 64-bits integer scalar type or DebugGlobalVariable or "
1330- " DebugLocalVariable with a 32- or 64-bits unsigned "
1331- " integer scalar type" ));
1358+ HasSubstr (" Component Count must be a constant instruction with a "
1359+ " 32- or 64-bits integer scalar type or "
1360+ " DebugGlobalVariable or DebugLocalVariable with a 32- "
1361+ " or 64-bits unsigned integer scalar type" ));
13321362}
13331363
13341364TEST_F (ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) {
@@ -1349,10 +1379,10 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) {
13491379 src, " " , dbg_inst_header, " " , shader_extension, " Vertex" ));
13501380 ASSERT_EQ (SPV_ERROR_INVALID_DATA, ValidateInstructions ());
13511381 EXPECT_THAT (getDiagnosticString (),
1352- HasSubstr (" Component Count must be OpConstant with a 32- or "
1353- " 64-bits integer scalar type or DebugGlobalVariable or "
1354- " DebugLocalVariable with a 32- or 64-bits unsigned "
1355- " integer scalar type" ));
1382+ HasSubstr (" Component Count must be a constant instruction with a "
1383+ " 32- or 64-bits integer scalar type or "
1384+ " DebugGlobalVariable or DebugLocalVariable with a 32- "
1385+ " or 64-bits unsigned integer scalar type" ));
13561386}
13571387
13581388TEST_F (ValidateVulkan100DebugInfo, DebugTypeArrayComponentCountZero) {
@@ -1400,10 +1430,59 @@ TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) {
14001430 src, constants, dbg_inst_header, " " , shader_extension, " Vertex" ));
14011431 ASSERT_EQ (SPV_ERROR_INVALID_DATA, ValidateInstructions ());
14021432 EXPECT_THAT (getDiagnosticString (),
1403- HasSubstr (" Component Count must be OpConstant with a 32- or "
1404- " 64-bits integer scalar type or DebugGlobalVariable or "
1405- " DebugLocalVariable with a 32- or 64-bits unsigned "
1406- " integer scalar type" ));
1433+ HasSubstr (" Component Count must be a constant instruction with a "
1434+ " 32- or 64-bits integer scalar type or "
1435+ " DebugGlobalVariable or DebugLocalVariable with a 32- "
1436+ " or 64-bits unsigned integer scalar type" ));
1437+ }
1438+
1439+ TEST_F (ValidateVulkan100DebugInfo, DebugTypeArrayOpSpecConstantComponentCount) {
1440+ const std::string src = R"(
1441+ %src = OpString "simple.hlsl"
1442+ %code = OpString "main() {}"
1443+ %float_name = OpString "float"
1444+ )" ;
1445+
1446+ const std::string constants = R"(
1447+ %spec_u32 = OpSpecConstant %u32 4
1448+ )" ;
1449+
1450+ const std::string dbg_inst_header = R"(
1451+ %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
1452+ %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
1453+ %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
1454+ %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %spec_u32
1455+ )" ;
1456+
1457+ CompileSuccessfully (GenerateShaderCodeForDebugInfo (
1458+ src, constants, dbg_inst_header, " " , shader_extension, " Vertex" ));
1459+ ASSERT_EQ (SPV_SUCCESS, ValidateInstructions ());
1460+ }
1461+
1462+ TEST_F (ValidateVulkan100DebugInfo,
1463+ DebugTypeArrayOpSpecConstantOpComponentCount) {
1464+ const std::string src = R"(
1465+ %src = OpString "simple.hlsl"
1466+ %code = OpString "main() {}"
1467+ %float_name = OpString "float"
1468+ )" ;
1469+
1470+ const std::string constants = R"(
1471+ %spec_a = OpSpecConstant %u32 2
1472+ %spec_b = OpSpecConstant %u32 2
1473+ %spec_op = OpSpecConstantOp %u32 IMul %spec_a %spec_b
1474+ )" ;
1475+
1476+ const std::string dbg_inst_header = R"(
1477+ %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
1478+ %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
1479+ %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
1480+ %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %spec_op
1481+ )" ;
1482+
1483+ CompileSuccessfully (GenerateShaderCodeForDebugInfo (
1484+ src, constants, dbg_inst_header, " " , shader_extension, " Vertex" ));
1485+ ASSERT_EQ (SPV_SUCCESS, ValidateInstructions ());
14071486}
14081487
14091488TEST_F (ValidateOpenCL100DebugInfo, DebugTypeVector) {
0 commit comments