@@ -11123,6 +11123,177 @@ TEST_F(ValidateImage, QCOMImageProcessing2BlockMatchGatherSSDInvalidUseRefNI) {
1112311123 HasSubstr (" Illegal use of QCOM image processing decorated texture" ));
1112411124}
1112511125
11126+ TEST_F (ValidateImage, QCOMImageProcessing3ImageGatherQCOMCapabilityCheck1) {
11127+ const std::string body = R"(
11128+ %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
11129+ %sampler = OpLoad %type_sampler %uniform_sampler
11130+ %simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
11131+ %res1 = OpImageGatherQCOM %f32vec4 %simg %f32vec2_hh %u32_1 %u32_0
11132+ )" ;
11133+
11134+ const std::string extra = R"(
11135+ OpCapability ImageGatherExtendedModesQCOM
11136+ OpExtension "SPV_QCOM_image_processing3"
11137+ )" ;
11138+
11139+ CompileSuccessfully (GenerateShaderCode (body, extra).c_str ());
11140+ ASSERT_EQ (SPV_ERROR_INVALID_CAPABILITY ,
11141+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_4 ));
11142+ EXPECT_THAT (getDiagnosticString (),
11143+ HasSubstr (" Mode GatherModesGather4x1QCOM (== 0) requires "
11144+ " capability ImageGatherLinearQCOM." ));
11145+ }
11146+
11147+ TEST_F (ValidateImage, QCOMImageProcessing3ImageGatherQCOMCapabilityCheck2) {
11148+ const std::string body = R"(
11149+ %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
11150+ %sampler = OpLoad %type_sampler %uniform_sampler
11151+ %simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
11152+ %res1 = OpImageGatherQCOM %f32vec4 %simg %f32vec2_hh %u32_1 %u32_1
11153+ )" ;
11154+
11155+ const std::string extra = R"(
11156+ OpCapability ImageGatherLinearQCOM
11157+ OpExtension "SPV_QCOM_image_processing3"
11158+ )" ;
11159+
11160+ CompileSuccessfully (GenerateShaderCode (body, extra).c_str ());
11161+ ASSERT_EQ (SPV_ERROR_INVALID_CAPABILITY ,
11162+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_4 ));
11163+ EXPECT_THAT (
11164+ getDiagnosticString (),
11165+ HasSubstr (" Mode GatherModesGatherDQCOM (== 1)/GatherModesGatherH2QCOM "
11166+ " (== 2)/GatherModesGatherV2QCOM (== 3) requires capability "
11167+ " ImageGatherExtendedModesQCOM." ));
11168+ }
11169+
11170+ TEST_F (ValidateImage, QCOMImageProcessing3ImageGatherQCOMCapabilityCheck3) {
11171+ const std::string body = R"(
11172+ %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
11173+ %sampler = OpLoad %type_sampler %uniform_sampler
11174+ %simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
11175+ %res1 = OpImageGatherQCOM %f32vec4 %simg %f32vec2_hh %u32_1 %u32_2
11176+ )" ;
11177+
11178+ const std::string extra = R"(
11179+ OpCapability ImageGatherLinearQCOM
11180+ OpExtension "SPV_QCOM_image_processing3"
11181+ )" ;
11182+
11183+ CompileSuccessfully (GenerateShaderCode (body, extra).c_str ());
11184+ ASSERT_EQ (SPV_ERROR_INVALID_CAPABILITY ,
11185+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_4 ));
11186+ EXPECT_THAT (
11187+ getDiagnosticString (),
11188+ HasSubstr (" Mode GatherModesGatherDQCOM (== 1)/GatherModesGatherH2QCOM "
11189+ " (== 2)/GatherModesGatherV2QCOM (== 3) requires capability "
11190+ " ImageGatherExtendedModesQCOM." ));
11191+ }
11192+
11193+ TEST_F (ValidateImage, QCOMImageProcessing3ImageGatherQCOMCapabilityCheck4) {
11194+ const std::string body = R"(
11195+ %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
11196+ %sampler = OpLoad %type_sampler %uniform_sampler
11197+ %simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
11198+ %res1 = OpImageGatherQCOM %f32vec4 %simg %f32vec2_hh %u32_1 %u32_3
11199+ )" ;
11200+
11201+ const std::string extra = R"(
11202+ OpCapability ImageGatherLinearQCOM
11203+ OpExtension "SPV_QCOM_image_processing3"
11204+ )" ;
11205+
11206+ CompileSuccessfully (GenerateShaderCode (body, extra).c_str ());
11207+ ASSERT_EQ (SPV_ERROR_INVALID_CAPABILITY ,
11208+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_4 ));
11209+ EXPECT_THAT (
11210+ getDiagnosticString (),
11211+ HasSubstr (" Mode GatherModesGatherDQCOM (== 1)/GatherModesGatherH2QCOM "
11212+ " (== 2)/GatherModesGatherV2QCOM (== 3) requires capability "
11213+ " ImageGatherExtendedModesQCOM." ));
11214+ }
11215+
11216+ TEST_F (ValidateImage, QCOMImageProcessing3ImageGatherQCOMCapabilityCheck5) {
11217+ const std::string body = R"(
11218+ %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
11219+ %sampler = OpLoad %type_sampler %uniform_sampler
11220+ %simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
11221+ %res1 = OpImageGatherQCOM %f32vec4 %simg %f32vec2_hh %u32_1 %u32_4
11222+ )" ;
11223+
11224+ const std::string extra = R"(
11225+ OpCapability ImageGatherLinearQCOM
11226+ OpCapability ImageGatherExtendedModesQCOM
11227+ OpExtension "SPV_QCOM_image_processing3"
11228+ )" ;
11229+
11230+ CompileSuccessfully (GenerateShaderCode (body, extra).c_str ());
11231+ ASSERT_EQ (SPV_ERROR_INVALID_DATA ,
11232+ ValidateInstructions (SPV_ENV_UNIVERSAL_1_4 ));
11233+ EXPECT_THAT (
11234+ getDiagnosticString (),
11235+ HasSubstr (" GatherModesGather4x1QCOM (== 0)/GatherModesGatherDQCOM (== "
11236+ " 1)/GatherModesGatherH2QCOM (== 2)/GatherModesGatherV2QCOM (== "
11237+ " 3) are the only supported modes." ));
11238+ }
11239+
11240+ TEST_F (ValidateImage, QCOMImageProcessing3ImageGatherQCOMReturnType) {
11241+ const std::string body = R"(
11242+ %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
11243+ %sampler = OpLoad %type_sampler %uniform_sampler
11244+ %simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
11245+ %res1 = OpImageGatherQCOM %f32 %simg %f32vec2_hh %u32_1 %u32_0
11246+ )" ;
11247+
11248+ const std::string extra = R"(
11249+ OpCapability ImageGatherLinearQCOM
11250+ OpExtension "SPV_QCOM_image_processing3"
11251+ )" ;
11252+
11253+ CompileSuccessfully (GenerateShaderCode (body, extra).c_str ());
11254+ ASSERT_EQ (SPV_ERROR_INVALID_DATA , ValidateInstructions ());
11255+ EXPECT_THAT (getDiagnosticString (),
11256+ HasSubstr (" Expected Result Type to be int or float vector type" ));
11257+ }
11258+
11259+ TEST_F (ValidateImage, QCOMImageProcessing3ImageGatherQCOMModeIndexType1) {
11260+ const std::string body = R"(
11261+ %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
11262+ %sampler = OpLoad %type_sampler %uniform_sampler
11263+ %simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
11264+ %res1 = OpImageGatherQCOM %f32vec4 %simg %f32vec2_hh %u32_1 %f32_1
11265+ )" ;
11266+
11267+ const std::string extra = R"(
11268+ OpCapability ImageGatherExtendedModesQCOM
11269+ OpExtension "SPV_QCOM_image_processing3"
11270+ )" ;
11271+
11272+ CompileSuccessfully (GenerateShaderCode (body, extra).c_str ());
11273+ ASSERT_EQ (SPV_ERROR_INVALID_DATA , ValidateInstructions ());
11274+ EXPECT_THAT (getDiagnosticString (),
11275+ HasSubstr (" Expected Mode to be 32-bit int scalar" ));
11276+ }
11277+
11278+ TEST_F (ValidateImage, QCOMImageProcessing3ImageGatherQCOMModeIndexType2) {
11279+ const std::string body = R"(
11280+ %img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
11281+ %sampler = OpLoad %type_sampler %uniform_sampler
11282+ %simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
11283+ %res1 = OpImageGatherQCOM %f32vec4 %simg %f32vec2_hh %u32_1 %u16_0
11284+ )" ;
11285+
11286+ const std::string extra = R"(
11287+ OpCapability ImageGatherExtendedModesQCOM
11288+ OpExtension "SPV_QCOM_image_processing3"
11289+ )" ;
11290+
11291+ CompileSuccessfully (GenerateShaderCode (body, extra).c_str ());
11292+ ASSERT_EQ (SPV_ERROR_INVALID_DATA , ValidateInstructions ());
11293+ EXPECT_THAT (getDiagnosticString (),
11294+ HasSubstr (" Expected Mode to be 32-bit int scalar" ));
11295+ }
11296+
1112611297TEST_F (ValidateImage, ImageMSArray_ArrayedSampledTypeRequiresCapability) {
1112711298 const std::string code = R"(
1112811299 OpCapability Shader
0 commit comments