@@ -64,6 +64,7 @@ std::string GenerateModuleWithExtInstImports(const std::string& imports,
6464 %uint_2 = OpConstant %uint 2
6565 %uint_3 = OpConstant %uint 3
6666 %uint_4 = OpConstant %uint 4
67+ %undef_uint = OpUndef %uint
6768 %float_1 = OpConstant %float 1.0
6869 %int8tensor = OpTypeTensorARM %int8 %uint_4
6970 %int8r3tensor = OpTypeTensorARM %int8 %uint_3
@@ -778,6 +779,26 @@ TEST_F(ValidateGraph, InvalidGraphInputIndexWrongType) {
778779 HasSubstr (" GraphInputARM InputIndex must be a 32-bit integer" ));
779780}
780781
782+ TEST_F (ValidateGraph, InvalidGraphInputIndexNotConstantVulkan) {
783+ const std::string src = R"(
784+ %graph_type = OpTypeGraphARM 1 %int8tensor %int8tensor
785+ OpGraphEntryPointARM %graph "longname" %var_int8tensor %var_int8tensor
786+ %graph = OpGraphARM %graph_type
787+ %in = OpGraphInputARM %int8tensor %undef_uint
788+ OpGraphSetOutputARM %in %uint_0
789+ OpGraphEndARM
790+ )" ;
791+ std::string spvasm = GenerateModule (src);
792+
793+ CompileSuccessfully (spvasm, SPVENV );
794+ EXPECT_EQ (SPV_ERROR_INVALID_DATA , ValidateInstructions (SPVENV ));
795+ EXPECT_THAT (getDiagnosticString (),
796+ HasSubstr (" VUID-StandaloneSpirv-OpGraphInputARM-09931" ));
797+ EXPECT_THAT (getDiagnosticString (),
798+ HasSubstr (" OpGraphInputARM InputIndex must be the <id> of a "
799+ " constant instruction." ));
800+ }
801+
781802TEST_F (ValidateGraph, InvalidGraphInputElementIndexWrongType) {
782803 const std::string src = R"(
783804%graph_type = OpTypeGraphARM 1 %int8tensor_array3 %int8tensor
@@ -795,6 +816,26 @@ TEST_F(ValidateGraph, InvalidGraphInputElementIndexWrongType) {
795816 HasSubstr (" GraphInputARM ElementIndex must be a 32-bit integer" ));
796817}
797818
819+ TEST_F (ValidateGraph, InvalidGraphInputElementIndexNotConstantVulkan) {
820+ const std::string src = R"(
821+ %graph_type = OpTypeGraphARM 1 %int8tensor_array3 %int8tensor
822+ OpGraphEntryPointARM %graph "longname" %var_int8tensor_array3 %var_int8tensor
823+ %graph = OpGraphARM %graph_type
824+ %in = OpGraphInputARM %int8tensor %uint_0 %undef_uint
825+ OpGraphSetOutputARM %in %uint_0
826+ OpGraphEndARM
827+ )" ;
828+ std::string spvasm = GenerateModule (src);
829+
830+ CompileSuccessfully (spvasm, SPVENV );
831+ EXPECT_EQ (SPV_ERROR_INVALID_DATA , ValidateInstructions (SPVENV ));
832+ EXPECT_THAT (getDiagnosticString (),
833+ HasSubstr (" VUID-StandaloneSpirv-OpGraphInputARM-09931" ));
834+ EXPECT_THAT (getDiagnosticString (),
835+ HasSubstr (" OpGraphInputARM ElementIndex must be the <id> of a "
836+ " constant instruction." ));
837+ }
838+
798839TEST_F (ValidateGraph, InvalidGraphInputIndexDuplicate) {
799840 const std::string src = R"(
800841%graph_type = OpTypeGraphARM 1 %int8tensor %int8tensor
@@ -1123,6 +1164,26 @@ TEST_F(ValidateGraph, InvalidGraphOutputIndexWrongType) {
11231164 HasSubstr (" GraphSetOutputARM OutputIndex must be a 32-bit integer" ));
11241165}
11251166
1167+ TEST_F (ValidateGraph, InvalidGraphOutputIndexNotConstantVulkan) {
1168+ const std::string src = R"(
1169+ %graph_type = OpTypeGraphARM 1 %int8tensor %int8tensor
1170+ OpGraphEntryPointARM %graph "longname" %var_int8tensor %var_int8tensor
1171+ %graph = OpGraphARM %graph_type
1172+ %in = OpGraphInputARM %int8tensor %uint_0
1173+ OpGraphSetOutputARM %in %undef_uint
1174+ OpGraphEndARM
1175+ )" ;
1176+ std::string spvasm = GenerateModule (src);
1177+
1178+ CompileSuccessfully (spvasm, SPVENV );
1179+ EXPECT_EQ (SPV_ERROR_INVALID_DATA , ValidateInstructions (SPVENV ));
1180+ EXPECT_THAT (getDiagnosticString (),
1181+ HasSubstr (" VUID-StandaloneSpirv-OpGraphSetOutputARM-09932" ));
1182+ EXPECT_THAT (getDiagnosticString (),
1183+ HasSubstr (" OpGraphSetOutputARM OutputIndex must be the <id> of "
1184+ " a constant instruction." ));
1185+ }
1186+
11261187TEST_F (ValidateGraph, InvalidGraphOutputElementIndexWrongType) {
11271188 const std::string src = R"(
11281189%graph_type = OpTypeGraphARM 1 %int8tensor %int8tensor_array3
@@ -1141,6 +1202,26 @@ TEST_F(ValidateGraph, InvalidGraphOutputElementIndexWrongType) {
11411202 HasSubstr (" GraphSetOutputARM ElementIndex must be a 32-bit integer" ));
11421203}
11431204
1205+ TEST_F (ValidateGraph, InvalidGraphOutputElementIndexNotConstantVulkan) {
1206+ const std::string src = R"(
1207+ %graph_type = OpTypeGraphARM 1 %int8tensor %int8tensor_array3
1208+ OpGraphEntryPointARM %graph "longname" %var_int8tensor %var_int8tensor_array3
1209+ %graph = OpGraphARM %graph_type
1210+ %in = OpGraphInputARM %int8tensor %uint_0
1211+ OpGraphSetOutputARM %in %uint_0 %undef_uint
1212+ OpGraphEndARM
1213+ )" ;
1214+ std::string spvasm = GenerateModule (src);
1215+
1216+ CompileSuccessfully (spvasm, SPVENV );
1217+ EXPECT_EQ (SPV_ERROR_INVALID_DATA , ValidateInstructions (SPVENV ));
1218+ EXPECT_THAT (getDiagnosticString (),
1219+ HasSubstr (" VUID-StandaloneSpirv-OpGraphSetOutputARM-09932" ));
1220+ EXPECT_THAT (getDiagnosticString (),
1221+ HasSubstr (" OpGraphSetOutputARM ElementIndex must be the <id> of "
1222+ " a constant instruction." ));
1223+ }
1224+
11441225TEST_F (ValidateGraph, InvalidGraphOutputIndexDuplicate) {
11451226 const std::string src = R"(
11461227%graph_type = OpTypeGraphARM 1 %int8tensor %int8tensor
0 commit comments