@@ -2169,7 +2169,8 @@ spv_result_t ValidateImageProcessingQCOMDecoration(ValidationState_t& _, int id,
21692169 spv::Decoration decor) {
21702170 const Instruction* si_inst = nullptr ;
21712171 const Instruction* ld_inst = _.FindDef (id);
2172- if (ld_inst->opcode () == spv::Op::OpSampledImage) {
2172+ bool is_intf_obj = (ld_inst->opcode () == spv::Op::OpSampledImage);
2173+ if (is_intf_obj == true ) {
21732174 si_inst = ld_inst;
21742175 int t_idx = si_inst->GetOperandAs <int >(2 ); // texture
21752176 ld_inst = _.FindDef (t_idx);
@@ -2186,6 +2187,56 @@ spv_result_t ValidateImageProcessingQCOMDecoration(ValidationState_t& _, int id,
21862187 return SPV_SUCCESS;
21872188}
21882189
2190+ spv_result_t ValidateImageProcessing2QCOMWindowDecoration (ValidationState_t& _,
2191+ int id) {
2192+ const Instruction* ld_inst = _.FindDef (id);
2193+ bool is_intf_obj = (ld_inst->opcode () != spv::Op::OpSampledImage);
2194+ if (is_intf_obj == true ) {
2195+ if (ld_inst->opcode () != spv::Op::OpLoad) {
2196+ return _.diag (SPV_ERROR_INVALID_DATA, ld_inst) << " Expect to see OpLoad" ;
2197+ }
2198+ int texture_id = ld_inst->GetOperandAs <int >(2 ); // variable to load
2199+ spv::Decoration decor = spv::Decoration::BlockMatchTextureQCOM;
2200+ if (!_.HasDecoration (texture_id, decor)) {
2201+ return _.diag (SPV_ERROR_INVALID_DATA, ld_inst)
2202+ << " Missing decoration " << _.SpvDecorationString (decor);
2203+ }
2204+ decor = spv::Decoration::BlockMatchSamplerQCOM;
2205+ if (!_.HasDecoration (texture_id, decor)) {
2206+ return _.diag (SPV_ERROR_INVALID_DATA, ld_inst)
2207+ << " Missing decoration " << _.SpvDecorationString (decor);
2208+ }
2209+ } else {
2210+ const Instruction* si_inst = ld_inst;
2211+ int t_idx = si_inst->GetOperandAs <int >(2 ); // texture
2212+ const Instruction* t_ld_inst = _.FindDef (t_idx);
2213+ if (t_ld_inst->opcode () != spv::Op::OpLoad) {
2214+ return _.diag (SPV_ERROR_INVALID_DATA, t_ld_inst)
2215+ << " Expect to see OpLoad" ;
2216+ }
2217+ int texture_id = t_ld_inst->GetOperandAs <int >(2 ); // variable to load
2218+ spv::Decoration decor = spv::Decoration::BlockMatchTextureQCOM;
2219+ if (!_.HasDecoration (texture_id, decor)) {
2220+ return _.diag (SPV_ERROR_INVALID_DATA, ld_inst)
2221+ << " Missing decoration " << _.SpvDecorationString (decor);
2222+ }
2223+ int s_idx = si_inst->GetOperandAs <int >(3 ); // sampler
2224+ const Instruction* s_ld_inst = _.FindDef (s_idx);
2225+ if (s_ld_inst->opcode () != spv::Op::OpLoad) {
2226+ return _.diag (SPV_ERROR_INVALID_DATA, s_ld_inst)
2227+ << " Expect to see OpLoad" ;
2228+ }
2229+ int sampler_id = s_ld_inst->GetOperandAs <int >(2 ); // variable to load
2230+ decor = spv::Decoration::BlockMatchSamplerQCOM;
2231+ if (!_.HasDecoration (sampler_id, decor)) {
2232+ return _.diag (SPV_ERROR_INVALID_DATA, ld_inst)
2233+ << " Missing decoration " << _.SpvDecorationString (decor);
2234+ }
2235+ }
2236+
2237+ return SPV_SUCCESS;
2238+ }
2239+
21892240spv_result_t ValidateImageProcessingQCOM (ValidationState_t& _,
21902241 const Instruction* inst) {
21912242 spv_result_t res = SPV_SUCCESS;
@@ -2211,18 +2262,10 @@ spv_result_t ValidateImageProcessingQCOM(ValidationState_t& _,
22112262 case spv::Op::OpImageBlockMatchWindowSSDQCOM:
22122263 case spv::Op::OpImageBlockMatchWindowSADQCOM: {
22132264 int tgt_idx = inst->GetOperandAs <int >(2 ); // target
2214- res = ValidateImageProcessingQCOMDecoration (
2215- _, tgt_idx, spv::Decoration::BlockMatchTextureQCOM);
2216- if (res != SPV_SUCCESS) break ;
2217- res = ValidateImageProcessingQCOMDecoration (
2218- _, tgt_idx, spv::Decoration::BlockMatchSamplerQCOM);
2265+ res = ValidateImageProcessing2QCOMWindowDecoration (_, tgt_idx);
22192266 if (res != SPV_SUCCESS) break ;
22202267 int ref_idx = inst->GetOperandAs <int >(4 ); // reference
2221- res = ValidateImageProcessingQCOMDecoration (
2222- _, ref_idx, spv::Decoration::BlockMatchTextureQCOM);
2223- if (res != SPV_SUCCESS) break ;
2224- res = ValidateImageProcessingQCOMDecoration (
2225- _, ref_idx, spv::Decoration::BlockMatchSamplerQCOM);
2268+ res = ValidateImageProcessing2QCOMWindowDecoration (_, ref_idx);
22262269 break ;
22272270 }
22282271 case spv::Op::OpImageBlockMatchGatherSSDQCOM:
0 commit comments