convert_to_half_pass.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. // Copyright (c) 2019 The Khronos Group Inc.
  2. // Copyright (c) 2019 Valve Corporation
  3. // Copyright (c) 2019 LunarG Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. #include "convert_to_half_pass.h"
  17. #include "source/opt/ir_builder.h"
  18. namespace spvtools {
  19. namespace opt {
  20. namespace {
  21. // Indices of operands in SPIR-V instructions
  22. constexpr int kImageSampleDrefIdInIdx = 2;
  23. } // namespace
  24. bool ConvertToHalfPass::IsArithmetic(Instruction* inst) {
  25. return target_ops_core_.count(inst->opcode()) != 0 ||
  26. (inst->opcode() == spv::Op::OpExtInst &&
  27. inst->GetSingleWordInOperand(0) ==
  28. context()->get_feature_mgr()->GetExtInstImportId_GLSLstd450() &&
  29. target_ops_450_.count(inst->GetSingleWordInOperand(1)) != 0);
  30. }
  31. bool ConvertToHalfPass::IsFloat(Instruction* inst, uint32_t width) {
  32. uint32_t ty_id = inst->type_id();
  33. if (ty_id == 0) return false;
  34. return Pass::IsFloat(ty_id, width);
  35. }
  36. bool ConvertToHalfPass::IsDecoratedRelaxed(Instruction* inst) {
  37. uint32_t r_id = inst->result_id();
  38. for (auto r_inst : get_decoration_mgr()->GetDecorationsFor(r_id, false))
  39. if (r_inst->opcode() == spv::Op::OpDecorate &&
  40. spv::Decoration(r_inst->GetSingleWordInOperand(1)) ==
  41. spv::Decoration::RelaxedPrecision) {
  42. return true;
  43. }
  44. return false;
  45. }
  46. bool ConvertToHalfPass::IsRelaxed(uint32_t id) {
  47. return relaxed_ids_set_.count(id) > 0;
  48. }
  49. void ConvertToHalfPass::AddRelaxed(uint32_t id) { relaxed_ids_set_.insert(id); }
  50. analysis::Type* ConvertToHalfPass::FloatScalarType(uint32_t width) {
  51. analysis::Float float_ty(width);
  52. return context()->get_type_mgr()->GetRegisteredType(&float_ty);
  53. }
  54. analysis::Type* ConvertToHalfPass::FloatVectorType(uint32_t v_len,
  55. uint32_t width) {
  56. analysis::Type* reg_float_ty = FloatScalarType(width);
  57. analysis::Vector vec_ty(reg_float_ty, v_len);
  58. return context()->get_type_mgr()->GetRegisteredType(&vec_ty);
  59. }
  60. analysis::Type* ConvertToHalfPass::FloatMatrixType(uint32_t v_cnt,
  61. uint32_t vty_id,
  62. uint32_t width) {
  63. Instruction* vty_inst = get_def_use_mgr()->GetDef(vty_id);
  64. uint32_t v_len = vty_inst->GetSingleWordInOperand(1);
  65. analysis::Type* reg_vec_ty = FloatVectorType(v_len, width);
  66. analysis::Matrix mat_ty(reg_vec_ty, v_cnt);
  67. return context()->get_type_mgr()->GetRegisteredType(&mat_ty);
  68. }
  69. uint32_t ConvertToHalfPass::EquivFloatTypeId(uint32_t ty_id, uint32_t width) {
  70. analysis::Type* reg_equiv_ty;
  71. Instruction* ty_inst = get_def_use_mgr()->GetDef(ty_id);
  72. if (ty_inst->opcode() == spv::Op::OpTypeMatrix)
  73. reg_equiv_ty = FloatMatrixType(ty_inst->GetSingleWordInOperand(1),
  74. ty_inst->GetSingleWordInOperand(0), width);
  75. else if (ty_inst->opcode() == spv::Op::OpTypeVector)
  76. reg_equiv_ty = FloatVectorType(ty_inst->GetSingleWordInOperand(1), width);
  77. else // spv::Op::OpTypeFloat
  78. reg_equiv_ty = FloatScalarType(width);
  79. return context()->get_type_mgr()->GetTypeInstruction(reg_equiv_ty);
  80. }
  81. void ConvertToHalfPass::GenConvert(uint32_t* val_idp, uint32_t width,
  82. Instruction* inst) {
  83. Instruction* val_inst = get_def_use_mgr()->GetDef(*val_idp);
  84. uint32_t ty_id = val_inst->type_id();
  85. uint32_t nty_id = EquivFloatTypeId(ty_id, width);
  86. if (nty_id == ty_id) return;
  87. Instruction* cvt_inst;
  88. InstructionBuilder builder(
  89. context(), inst,
  90. IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping);
  91. if (val_inst->opcode() == spv::Op::OpUndef)
  92. cvt_inst = builder.AddNullaryOp(nty_id, spv::Op::OpUndef);
  93. else
  94. cvt_inst = builder.AddUnaryOp(nty_id, spv::Op::OpFConvert, *val_idp);
  95. *val_idp = cvt_inst->result_id();
  96. }
  97. bool ConvertToHalfPass::MatConvertCleanup(Instruction* inst) {
  98. if (inst->opcode() != spv::Op::OpFConvert) return false;
  99. uint32_t mty_id = inst->type_id();
  100. Instruction* mty_inst = get_def_use_mgr()->GetDef(mty_id);
  101. if (mty_inst->opcode() != spv::Op::OpTypeMatrix) return false;
  102. uint32_t vty_id = mty_inst->GetSingleWordInOperand(0);
  103. uint32_t v_cnt = mty_inst->GetSingleWordInOperand(1);
  104. Instruction* vty_inst = get_def_use_mgr()->GetDef(vty_id);
  105. uint32_t cty_id = vty_inst->GetSingleWordInOperand(0);
  106. Instruction* cty_inst = get_def_use_mgr()->GetDef(cty_id);
  107. InstructionBuilder builder(
  108. context(), inst,
  109. IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping);
  110. // Convert each component vector, combine them with OpCompositeConstruct
  111. // and replace original instruction.
  112. uint32_t orig_width = (cty_inst->GetSingleWordInOperand(0) == 16) ? 32 : 16;
  113. uint32_t orig_mat_id = inst->GetSingleWordInOperand(0);
  114. uint32_t orig_vty_id = EquivFloatTypeId(vty_id, orig_width);
  115. std::vector<Operand> opnds = {};
  116. for (uint32_t vidx = 0; vidx < v_cnt; ++vidx) {
  117. Instruction* ext_inst = builder.AddIdLiteralOp(
  118. orig_vty_id, spv::Op::OpCompositeExtract, orig_mat_id, vidx);
  119. Instruction* cvt_inst =
  120. builder.AddUnaryOp(vty_id, spv::Op::OpFConvert, ext_inst->result_id());
  121. opnds.push_back({SPV_OPERAND_TYPE_ID, {cvt_inst->result_id()}});
  122. }
  123. uint32_t mat_id = TakeNextId();
  124. std::unique_ptr<Instruction> mat_inst(new Instruction(
  125. context(), spv::Op::OpCompositeConstruct, mty_id, mat_id, opnds));
  126. (void)builder.AddInstruction(std::move(mat_inst));
  127. context()->ReplaceAllUsesWith(inst->result_id(), mat_id);
  128. // Turn original instruction into copy so it is valid.
  129. inst->SetOpcode(spv::Op::OpCopyObject);
  130. inst->SetResultType(EquivFloatTypeId(mty_id, orig_width));
  131. get_def_use_mgr()->AnalyzeInstUse(inst);
  132. return true;
  133. }
  134. bool ConvertToHalfPass::RemoveRelaxedDecoration(uint32_t id) {
  135. return context()->get_decoration_mgr()->RemoveDecorationsFrom(
  136. id, [](const Instruction& dec) {
  137. if (dec.opcode() == spv::Op::OpDecorate &&
  138. spv::Decoration(dec.GetSingleWordInOperand(1u)) ==
  139. spv::Decoration::RelaxedPrecision) {
  140. return true;
  141. } else
  142. return false;
  143. });
  144. }
  145. bool ConvertToHalfPass::GenHalfArith(Instruction* inst) {
  146. bool modified = false;
  147. // Convert all float32 based operands to float16 equivalent and change
  148. // instruction type to float16 equivalent.
  149. inst->ForEachInId([&inst, &modified, this](uint32_t* idp) {
  150. Instruction* op_inst = get_def_use_mgr()->GetDef(*idp);
  151. if (!IsFloat(op_inst, 32)) return;
  152. GenConvert(idp, 16, inst);
  153. modified = true;
  154. });
  155. if (IsFloat(inst, 32)) {
  156. inst->SetResultType(EquivFloatTypeId(inst->type_id(), 16));
  157. converted_ids_.insert(inst->result_id());
  158. modified = true;
  159. }
  160. if (modified) get_def_use_mgr()->AnalyzeInstUse(inst);
  161. return modified;
  162. }
  163. bool ConvertToHalfPass::ProcessPhi(Instruction* inst, uint32_t from_width,
  164. uint32_t to_width) {
  165. // Add converts of any float operands to to_width if they are of from_width.
  166. // If converting to 16, change type of phi to float16 equivalent and remember
  167. // result id. Converts need to be added to preceding blocks.
  168. uint32_t ocnt = 0;
  169. uint32_t* prev_idp;
  170. bool modified = false;
  171. inst->ForEachInId([&ocnt, &prev_idp, &from_width, &to_width, &modified,
  172. this](uint32_t* idp) {
  173. if (ocnt % 2 == 0) {
  174. prev_idp = idp;
  175. } else {
  176. Instruction* val_inst = get_def_use_mgr()->GetDef(*prev_idp);
  177. if (IsFloat(val_inst, from_width)) {
  178. BasicBlock* bp = context()->get_instr_block(*idp);
  179. auto insert_before = bp->tail();
  180. if (insert_before != bp->begin()) {
  181. --insert_before;
  182. if (insert_before->opcode() != spv::Op::OpSelectionMerge &&
  183. insert_before->opcode() != spv::Op::OpLoopMerge)
  184. ++insert_before;
  185. }
  186. GenConvert(prev_idp, to_width, &*insert_before);
  187. modified = true;
  188. }
  189. }
  190. ++ocnt;
  191. });
  192. if (to_width == 16u) {
  193. inst->SetResultType(EquivFloatTypeId(inst->type_id(), 16u));
  194. converted_ids_.insert(inst->result_id());
  195. modified = true;
  196. }
  197. if (modified) get_def_use_mgr()->AnalyzeInstUse(inst);
  198. return modified;
  199. }
  200. bool ConvertToHalfPass::ProcessConvert(Instruction* inst) {
  201. // If float32 and relaxed, change to float16 convert
  202. if (IsFloat(inst, 32) && IsRelaxed(inst->result_id())) {
  203. inst->SetResultType(EquivFloatTypeId(inst->type_id(), 16));
  204. get_def_use_mgr()->AnalyzeInstUse(inst);
  205. converted_ids_.insert(inst->result_id());
  206. }
  207. // If operand and result types are the same, change FConvert to CopyObject to
  208. // keep validator happy; simplification and DCE will clean it up
  209. // One way this can happen is if an FConvert generated during this pass
  210. // (likely by ProcessPhi) is later encountered here and its operand has been
  211. // changed to half.
  212. uint32_t val_id = inst->GetSingleWordInOperand(0);
  213. Instruction* val_inst = get_def_use_mgr()->GetDef(val_id);
  214. if (inst->type_id() == val_inst->type_id())
  215. inst->SetOpcode(spv::Op::OpCopyObject);
  216. return true; // modified
  217. }
  218. bool ConvertToHalfPass::ProcessImageRef(Instruction* inst) {
  219. bool modified = false;
  220. // If image reference, only need to convert dref args back to float32
  221. if (dref_image_ops_.count(inst->opcode()) != 0) {
  222. uint32_t dref_id = inst->GetSingleWordInOperand(kImageSampleDrefIdInIdx);
  223. if (converted_ids_.count(dref_id) > 0) {
  224. GenConvert(&dref_id, 32, inst);
  225. inst->SetInOperand(kImageSampleDrefIdInIdx, {dref_id});
  226. get_def_use_mgr()->AnalyzeInstUse(inst);
  227. modified = true;
  228. }
  229. }
  230. return modified;
  231. }
  232. bool ConvertToHalfPass::ProcessDefault(Instruction* inst) {
  233. // If non-relaxed instruction has changed operands, need to convert
  234. // them back to float32
  235. if (inst->opcode() == spv::Op::OpPhi) return ProcessPhi(inst, 16u, 32u);
  236. bool modified = false;
  237. inst->ForEachInId([&inst, &modified, this](uint32_t* idp) {
  238. if (converted_ids_.count(*idp) == 0) return;
  239. uint32_t old_id = *idp;
  240. GenConvert(idp, 32, inst);
  241. if (*idp != old_id) modified = true;
  242. });
  243. if (modified) get_def_use_mgr()->AnalyzeInstUse(inst);
  244. return modified;
  245. }
  246. bool ConvertToHalfPass::GenHalfInst(Instruction* inst) {
  247. bool modified = false;
  248. // Remember id for later deletion of RelaxedPrecision decoration
  249. bool inst_relaxed = IsRelaxed(inst->result_id());
  250. if (IsArithmetic(inst) && inst_relaxed)
  251. modified = GenHalfArith(inst);
  252. else if (inst->opcode() == spv::Op::OpPhi && inst_relaxed)
  253. modified = ProcessPhi(inst, 32u, 16u);
  254. else if (inst->opcode() == spv::Op::OpFConvert)
  255. modified = ProcessConvert(inst);
  256. else if (image_ops_.count(inst->opcode()) != 0)
  257. modified = ProcessImageRef(inst);
  258. else
  259. modified = ProcessDefault(inst);
  260. return modified;
  261. }
  262. bool ConvertToHalfPass::CloseRelaxInst(Instruction* inst) {
  263. if (inst->result_id() == 0) return false;
  264. if (IsRelaxed(inst->result_id())) return false;
  265. if (!IsFloat(inst, 32)) return false;
  266. if (IsDecoratedRelaxed(inst)) {
  267. AddRelaxed(inst->result_id());
  268. return true;
  269. }
  270. if (closure_ops_.count(inst->opcode()) == 0) return false;
  271. // Can relax if all float operands are relaxed
  272. bool relax = true;
  273. inst->ForEachInId([&relax, this](uint32_t* idp) {
  274. Instruction* op_inst = get_def_use_mgr()->GetDef(*idp);
  275. if (!IsFloat(op_inst, 32)) return;
  276. if (!IsRelaxed(*idp)) relax = false;
  277. });
  278. if (relax) {
  279. AddRelaxed(inst->result_id());
  280. return true;
  281. }
  282. // Can relax if all uses are relaxed
  283. relax = true;
  284. get_def_use_mgr()->ForEachUser(inst, [&relax, this](Instruction* uinst) {
  285. if (uinst->result_id() == 0 || !IsFloat(uinst, 32) ||
  286. (!IsDecoratedRelaxed(uinst) && !IsRelaxed(uinst->result_id()))) {
  287. relax = false;
  288. return;
  289. }
  290. });
  291. if (relax) {
  292. AddRelaxed(inst->result_id());
  293. return true;
  294. }
  295. return false;
  296. }
  297. bool ConvertToHalfPass::ProcessFunction(Function* func) {
  298. // Do a closure of Relaxed on composite and phi instructions
  299. bool changed = true;
  300. while (changed) {
  301. changed = false;
  302. cfg()->ForEachBlockInReversePostOrder(
  303. func->entry().get(), [&changed, this](BasicBlock* bb) {
  304. for (auto ii = bb->begin(); ii != bb->end(); ++ii)
  305. changed |= CloseRelaxInst(&*ii);
  306. });
  307. }
  308. // Do convert of relaxed instructions to half precision
  309. bool modified = false;
  310. cfg()->ForEachBlockInReversePostOrder(
  311. func->entry().get(), [&modified, this](BasicBlock* bb) {
  312. for (auto ii = bb->begin(); ii != bb->end(); ++ii)
  313. modified |= GenHalfInst(&*ii);
  314. });
  315. // Replace invalid converts of matrix into equivalent vector extracts,
  316. // converts and finally a composite construct
  317. cfg()->ForEachBlockInReversePostOrder(
  318. func->entry().get(), [&modified, this](BasicBlock* bb) {
  319. for (auto ii = bb->begin(); ii != bb->end(); ++ii)
  320. modified |= MatConvertCleanup(&*ii);
  321. });
  322. return modified;
  323. }
  324. Pass::Status ConvertToHalfPass::ProcessImpl() {
  325. Pass::ProcessFunction pfn = [this](Function* fp) {
  326. return ProcessFunction(fp);
  327. };
  328. bool modified = context()->ProcessReachableCallTree(pfn);
  329. // If modified, make sure module has Float16 capability
  330. if (modified) context()->AddCapability(spv::Capability::Float16);
  331. // Remove all RelaxedPrecision decorations from instructions and globals
  332. for (auto c_id : relaxed_ids_set_) {
  333. modified |= RemoveRelaxedDecoration(c_id);
  334. }
  335. for (auto& val : get_module()->types_values()) {
  336. uint32_t v_id = val.result_id();
  337. if (v_id != 0) {
  338. modified |= RemoveRelaxedDecoration(v_id);
  339. }
  340. }
  341. return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange;
  342. }
  343. Pass::Status ConvertToHalfPass::Process() {
  344. Initialize();
  345. return ProcessImpl();
  346. }
  347. void ConvertToHalfPass::Initialize() {
  348. target_ops_core_ = {
  349. spv::Op::OpVectorExtractDynamic,
  350. spv::Op::OpVectorInsertDynamic,
  351. spv::Op::OpVectorShuffle,
  352. spv::Op::OpCompositeConstruct,
  353. spv::Op::OpCompositeInsert,
  354. spv::Op::OpCompositeExtract,
  355. spv::Op::OpCopyObject,
  356. spv::Op::OpTranspose,
  357. spv::Op::OpConvertSToF,
  358. spv::Op::OpConvertUToF,
  359. // spv::Op::OpFConvert,
  360. // spv::Op::OpQuantizeToF16,
  361. spv::Op::OpFNegate,
  362. spv::Op::OpFAdd,
  363. spv::Op::OpFSub,
  364. spv::Op::OpFMul,
  365. spv::Op::OpFDiv,
  366. spv::Op::OpFMod,
  367. spv::Op::OpVectorTimesScalar,
  368. spv::Op::OpMatrixTimesScalar,
  369. spv::Op::OpVectorTimesMatrix,
  370. spv::Op::OpMatrixTimesVector,
  371. spv::Op::OpMatrixTimesMatrix,
  372. spv::Op::OpOuterProduct,
  373. spv::Op::OpDot,
  374. spv::Op::OpSelect,
  375. spv::Op::OpFOrdEqual,
  376. spv::Op::OpFUnordEqual,
  377. spv::Op::OpFOrdNotEqual,
  378. spv::Op::OpFUnordNotEqual,
  379. spv::Op::OpFOrdLessThan,
  380. spv::Op::OpFUnordLessThan,
  381. spv::Op::OpFOrdGreaterThan,
  382. spv::Op::OpFUnordGreaterThan,
  383. spv::Op::OpFOrdLessThanEqual,
  384. spv::Op::OpFUnordLessThanEqual,
  385. spv::Op::OpFOrdGreaterThanEqual,
  386. spv::Op::OpFUnordGreaterThanEqual,
  387. };
  388. target_ops_450_ = {
  389. GLSLstd450Round, GLSLstd450RoundEven, GLSLstd450Trunc, GLSLstd450FAbs,
  390. GLSLstd450FSign, GLSLstd450Floor, GLSLstd450Ceil, GLSLstd450Fract,
  391. GLSLstd450Radians, GLSLstd450Degrees, GLSLstd450Sin, GLSLstd450Cos,
  392. GLSLstd450Tan, GLSLstd450Asin, GLSLstd450Acos, GLSLstd450Atan,
  393. GLSLstd450Sinh, GLSLstd450Cosh, GLSLstd450Tanh, GLSLstd450Asinh,
  394. GLSLstd450Acosh, GLSLstd450Atanh, GLSLstd450Atan2, GLSLstd450Pow,
  395. GLSLstd450Exp, GLSLstd450Log, GLSLstd450Exp2, GLSLstd450Log2,
  396. GLSLstd450Sqrt, GLSLstd450InverseSqrt, GLSLstd450Determinant,
  397. GLSLstd450MatrixInverse,
  398. // TODO(greg-lunarg): GLSLstd450ModfStruct,
  399. GLSLstd450FMin, GLSLstd450FMax, GLSLstd450FClamp, GLSLstd450FMix,
  400. GLSLstd450Step, GLSLstd450SmoothStep, GLSLstd450Fma,
  401. // TODO(greg-lunarg): GLSLstd450FrexpStruct,
  402. GLSLstd450Ldexp, GLSLstd450Length, GLSLstd450Distance, GLSLstd450Cross,
  403. GLSLstd450Normalize, GLSLstd450FaceForward, GLSLstd450Reflect,
  404. GLSLstd450Refract, GLSLstd450NMin, GLSLstd450NMax, GLSLstd450NClamp};
  405. image_ops_ = {spv::Op::OpImageSampleImplicitLod,
  406. spv::Op::OpImageSampleExplicitLod,
  407. spv::Op::OpImageSampleDrefImplicitLod,
  408. spv::Op::OpImageSampleDrefExplicitLod,
  409. spv::Op::OpImageSampleProjImplicitLod,
  410. spv::Op::OpImageSampleProjExplicitLod,
  411. spv::Op::OpImageSampleProjDrefImplicitLod,
  412. spv::Op::OpImageSampleProjDrefExplicitLod,
  413. spv::Op::OpImageFetch,
  414. spv::Op::OpImageGather,
  415. spv::Op::OpImageDrefGather,
  416. spv::Op::OpImageRead,
  417. spv::Op::OpImageSparseSampleImplicitLod,
  418. spv::Op::OpImageSparseSampleExplicitLod,
  419. spv::Op::OpImageSparseSampleDrefImplicitLod,
  420. spv::Op::OpImageSparseSampleDrefExplicitLod,
  421. spv::Op::OpImageSparseSampleProjImplicitLod,
  422. spv::Op::OpImageSparseSampleProjExplicitLod,
  423. spv::Op::OpImageSparseSampleProjDrefImplicitLod,
  424. spv::Op::OpImageSparseSampleProjDrefExplicitLod,
  425. spv::Op::OpImageSparseFetch,
  426. spv::Op::OpImageSparseGather,
  427. spv::Op::OpImageSparseDrefGather,
  428. spv::Op::OpImageSparseTexelsResident,
  429. spv::Op::OpImageSparseRead};
  430. dref_image_ops_ = {
  431. spv::Op::OpImageSampleDrefImplicitLod,
  432. spv::Op::OpImageSampleDrefExplicitLod,
  433. spv::Op::OpImageSampleProjDrefImplicitLod,
  434. spv::Op::OpImageSampleProjDrefExplicitLod,
  435. spv::Op::OpImageDrefGather,
  436. spv::Op::OpImageSparseSampleDrefImplicitLod,
  437. spv::Op::OpImageSparseSampleDrefExplicitLod,
  438. spv::Op::OpImageSparseSampleProjDrefImplicitLod,
  439. spv::Op::OpImageSparseSampleProjDrefExplicitLod,
  440. spv::Op::OpImageSparseDrefGather,
  441. };
  442. closure_ops_ = {
  443. spv::Op::OpVectorExtractDynamic,
  444. spv::Op::OpVectorInsertDynamic,
  445. spv::Op::OpVectorShuffle,
  446. spv::Op::OpCompositeConstruct,
  447. spv::Op::OpCompositeInsert,
  448. spv::Op::OpCompositeExtract,
  449. spv::Op::OpCopyObject,
  450. spv::Op::OpTranspose,
  451. spv::Op::OpPhi,
  452. };
  453. relaxed_ids_set_.clear();
  454. converted_ids_.clear();
  455. }
  456. } // namespace opt
  457. } // namespace spvtools