validation_state.cpp 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160
  1. // Copyright (c) 2015-2016 The Khronos Group Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "source/val/validation_state.h"
  15. #include <cassert>
  16. #include <stack>
  17. #include <utility>
  18. #include "source/opcode.h"
  19. #include "source/spirv_constant.h"
  20. #include "source/spirv_target_env.h"
  21. #include "source/val/basic_block.h"
  22. #include "source/val/construct.h"
  23. #include "source/val/function.h"
  24. #include "spirv-tools/libspirv.h"
  25. namespace spvtools {
  26. namespace val {
  27. namespace {
  28. ModuleLayoutSection InstructionLayoutSection(
  29. ModuleLayoutSection current_section, SpvOp op) {
  30. // See Section 2.4
  31. if (spvOpcodeGeneratesType(op) || spvOpcodeIsConstant(op))
  32. return kLayoutTypes;
  33. switch (op) {
  34. case SpvOpCapability:
  35. return kLayoutCapabilities;
  36. case SpvOpExtension:
  37. return kLayoutExtensions;
  38. case SpvOpExtInstImport:
  39. return kLayoutExtInstImport;
  40. case SpvOpMemoryModel:
  41. return kLayoutMemoryModel;
  42. case SpvOpEntryPoint:
  43. return kLayoutEntryPoint;
  44. case SpvOpExecutionMode:
  45. case SpvOpExecutionModeId:
  46. return kLayoutExecutionMode;
  47. case SpvOpSourceContinued:
  48. case SpvOpSource:
  49. case SpvOpSourceExtension:
  50. case SpvOpString:
  51. return kLayoutDebug1;
  52. case SpvOpName:
  53. case SpvOpMemberName:
  54. return kLayoutDebug2;
  55. case SpvOpModuleProcessed:
  56. return kLayoutDebug3;
  57. case SpvOpDecorate:
  58. case SpvOpMemberDecorate:
  59. case SpvOpGroupDecorate:
  60. case SpvOpGroupMemberDecorate:
  61. case SpvOpDecorationGroup:
  62. case SpvOpDecorateId:
  63. case SpvOpDecorateStringGOOGLE:
  64. case SpvOpMemberDecorateStringGOOGLE:
  65. return kLayoutAnnotations;
  66. case SpvOpTypeForwardPointer:
  67. return kLayoutTypes;
  68. case SpvOpVariable:
  69. if (current_section == kLayoutTypes) return kLayoutTypes;
  70. return kLayoutFunctionDefinitions;
  71. case SpvOpExtInst:
  72. // SpvOpExtInst is only allowed in types section for certain extended
  73. // instruction sets. This will be checked separately.
  74. if (current_section == kLayoutTypes) return kLayoutTypes;
  75. return kLayoutFunctionDefinitions;
  76. case SpvOpLine:
  77. case SpvOpNoLine:
  78. case SpvOpUndef:
  79. if (current_section == kLayoutTypes) return kLayoutTypes;
  80. return kLayoutFunctionDefinitions;
  81. case SpvOpFunction:
  82. case SpvOpFunctionParameter:
  83. case SpvOpFunctionEnd:
  84. if (current_section == kLayoutFunctionDeclarations)
  85. return kLayoutFunctionDeclarations;
  86. return kLayoutFunctionDefinitions;
  87. case SpvOpSamplerImageAddressingModeNV:
  88. return kLayoutSamplerImageAddressMode;
  89. default:
  90. break;
  91. }
  92. return kLayoutFunctionDefinitions;
  93. }
  94. bool IsInstructionInLayoutSection(ModuleLayoutSection layout, SpvOp op) {
  95. return layout == InstructionLayoutSection(layout, op);
  96. }
  97. // Counts the number of instructions and functions in the file.
  98. spv_result_t CountInstructions(void* user_data,
  99. const spv_parsed_instruction_t* inst) {
  100. ValidationState_t& _ = *(reinterpret_cast<ValidationState_t*>(user_data));
  101. if (inst->opcode == SpvOpFunction) _.increment_total_functions();
  102. _.increment_total_instructions();
  103. return SPV_SUCCESS;
  104. }
  105. spv_result_t setHeader(void* user_data, spv_endianness_t, uint32_t,
  106. uint32_t version, uint32_t generator, uint32_t id_bound,
  107. uint32_t) {
  108. ValidationState_t& vstate =
  109. *(reinterpret_cast<ValidationState_t*>(user_data));
  110. vstate.setIdBound(id_bound);
  111. vstate.setGenerator(generator);
  112. vstate.setVersion(version);
  113. return SPV_SUCCESS;
  114. }
  115. // Add features based on SPIR-V core version number.
  116. void UpdateFeaturesBasedOnSpirvVersion(ValidationState_t::Feature* features,
  117. uint32_t version) {
  118. assert(features);
  119. if (version >= SPV_SPIRV_VERSION_WORD(1, 4)) {
  120. features->select_between_composites = true;
  121. features->copy_memory_permits_two_memory_accesses = true;
  122. features->uconvert_spec_constant_op = true;
  123. features->nonwritable_var_in_function_or_private = true;
  124. }
  125. }
  126. } // namespace
  127. ValidationState_t::ValidationState_t(const spv_const_context ctx,
  128. const spv_const_validator_options opt,
  129. const uint32_t* words,
  130. const size_t num_words,
  131. const uint32_t max_warnings)
  132. : context_(ctx),
  133. options_(opt),
  134. words_(words),
  135. num_words_(num_words),
  136. unresolved_forward_ids_{},
  137. operand_names_{},
  138. current_layout_section_(kLayoutCapabilities),
  139. module_functions_(),
  140. module_capabilities_(),
  141. module_extensions_(),
  142. ordered_instructions_(),
  143. all_definitions_(),
  144. global_vars_(),
  145. local_vars_(),
  146. struct_nesting_depth_(),
  147. struct_has_nested_blockorbufferblock_struct_(),
  148. grammar_(ctx),
  149. addressing_model_(SpvAddressingModelMax),
  150. memory_model_(SpvMemoryModelMax),
  151. pointer_size_and_alignment_(0),
  152. sampler_image_addressing_mode_(0),
  153. in_function_(false),
  154. num_of_warnings_(0),
  155. max_num_of_warnings_(max_warnings) {
  156. assert(opt && "Validator options may not be Null.");
  157. const auto env = context_->target_env;
  158. if (spvIsVulkanEnv(env)) {
  159. // Vulkan 1.1 includes VK_KHR_relaxed_block_layout in core.
  160. if (env != SPV_ENV_VULKAN_1_0) {
  161. features_.env_relaxed_block_layout = true;
  162. }
  163. }
  164. // LocalSizeId is only disallowed prior to Vulkan 1.3 without maintenance4.
  165. switch (env) {
  166. case SPV_ENV_VULKAN_1_0:
  167. case SPV_ENV_VULKAN_1_1:
  168. case SPV_ENV_VULKAN_1_1_SPIRV_1_4:
  169. case SPV_ENV_VULKAN_1_2:
  170. features_.env_allow_localsizeid = false;
  171. break;
  172. default:
  173. features_.env_allow_localsizeid = true;
  174. break;
  175. }
  176. // Only attempt to count if we have words, otherwise let the other validation
  177. // fail and generate an error.
  178. if (num_words > 0) {
  179. // Count the number of instructions in the binary.
  180. // This parse should not produce any error messages. Hijack the context and
  181. // replace the message consumer so that we do not pollute any state in input
  182. // consumer.
  183. spv_context_t hijacked_context = *ctx;
  184. hijacked_context.consumer = [](spv_message_level_t, const char*,
  185. const spv_position_t&, const char*) {};
  186. spvBinaryParse(&hijacked_context, this, words, num_words, setHeader,
  187. CountInstructions,
  188. /* diagnostic = */ nullptr);
  189. preallocateStorage();
  190. }
  191. UpdateFeaturesBasedOnSpirvVersion(&features_, version_);
  192. name_mapper_ = spvtools::GetTrivialNameMapper();
  193. if (options_->use_friendly_names) {
  194. friendly_mapper_ = spvtools::MakeUnique<spvtools::FriendlyNameMapper>(
  195. context_, words_, num_words_);
  196. name_mapper_ = friendly_mapper_->GetNameMapper();
  197. }
  198. }
  199. void ValidationState_t::preallocateStorage() {
  200. ordered_instructions_.reserve(total_instructions_);
  201. module_functions_.reserve(total_functions_);
  202. }
  203. spv_result_t ValidationState_t::ForwardDeclareId(uint32_t id) {
  204. unresolved_forward_ids_.insert(id);
  205. return SPV_SUCCESS;
  206. }
  207. spv_result_t ValidationState_t::RemoveIfForwardDeclared(uint32_t id) {
  208. unresolved_forward_ids_.erase(id);
  209. return SPV_SUCCESS;
  210. }
  211. spv_result_t ValidationState_t::RegisterForwardPointer(uint32_t id) {
  212. forward_pointer_ids_.insert(id);
  213. return SPV_SUCCESS;
  214. }
  215. bool ValidationState_t::IsForwardPointer(uint32_t id) const {
  216. return (forward_pointer_ids_.find(id) != forward_pointer_ids_.end());
  217. }
  218. void ValidationState_t::AssignNameToId(uint32_t id, std::string name) {
  219. operand_names_[id] = name;
  220. }
  221. std::string ValidationState_t::getIdName(uint32_t id) const {
  222. const std::string id_name = name_mapper_(id);
  223. std::stringstream out;
  224. out << "'" << id << "[%" << id_name << "]'";
  225. return out.str();
  226. }
  227. size_t ValidationState_t::unresolved_forward_id_count() const {
  228. return unresolved_forward_ids_.size();
  229. }
  230. std::vector<uint32_t> ValidationState_t::UnresolvedForwardIds() const {
  231. std::vector<uint32_t> out(std::begin(unresolved_forward_ids_),
  232. std::end(unresolved_forward_ids_));
  233. return out;
  234. }
  235. bool ValidationState_t::IsDefinedId(uint32_t id) const {
  236. return all_definitions_.find(id) != std::end(all_definitions_);
  237. }
  238. const Instruction* ValidationState_t::FindDef(uint32_t id) const {
  239. auto it = all_definitions_.find(id);
  240. if (it == all_definitions_.end()) return nullptr;
  241. return it->second;
  242. }
  243. Instruction* ValidationState_t::FindDef(uint32_t id) {
  244. auto it = all_definitions_.find(id);
  245. if (it == all_definitions_.end()) return nullptr;
  246. return it->second;
  247. }
  248. ModuleLayoutSection ValidationState_t::current_layout_section() const {
  249. return current_layout_section_;
  250. }
  251. void ValidationState_t::ProgressToNextLayoutSectionOrder() {
  252. // Guard against going past the last element(kLayoutFunctionDefinitions)
  253. if (current_layout_section_ <= kLayoutFunctionDefinitions) {
  254. current_layout_section_ =
  255. static_cast<ModuleLayoutSection>(current_layout_section_ + 1);
  256. }
  257. }
  258. bool ValidationState_t::IsOpcodeInPreviousLayoutSection(SpvOp op) {
  259. ModuleLayoutSection section =
  260. InstructionLayoutSection(current_layout_section_, op);
  261. return section < current_layout_section_;
  262. }
  263. bool ValidationState_t::IsOpcodeInCurrentLayoutSection(SpvOp op) {
  264. return IsInstructionInLayoutSection(current_layout_section_, op);
  265. }
  266. DiagnosticStream ValidationState_t::diag(spv_result_t error_code,
  267. const Instruction* inst) {
  268. if (error_code == SPV_WARNING) {
  269. if (num_of_warnings_ == max_num_of_warnings_) {
  270. DiagnosticStream({0, 0, 0}, context_->consumer, "", error_code)
  271. << "Other warnings have been suppressed.\n";
  272. }
  273. if (num_of_warnings_ >= max_num_of_warnings_) {
  274. return DiagnosticStream({0, 0, 0}, nullptr, "", error_code);
  275. }
  276. ++num_of_warnings_;
  277. }
  278. std::string disassembly;
  279. if (inst) disassembly = Disassemble(*inst);
  280. return DiagnosticStream({0, 0, inst ? inst->LineNum() : 0},
  281. context_->consumer, disassembly, error_code);
  282. }
  283. std::vector<Function>& ValidationState_t::functions() {
  284. return module_functions_;
  285. }
  286. Function& ValidationState_t::current_function() {
  287. assert(in_function_body());
  288. return module_functions_.back();
  289. }
  290. const Function& ValidationState_t::current_function() const {
  291. assert(in_function_body());
  292. return module_functions_.back();
  293. }
  294. const Function* ValidationState_t::function(uint32_t id) const {
  295. const auto it = id_to_function_.find(id);
  296. if (it == id_to_function_.end()) return nullptr;
  297. return it->second;
  298. }
  299. Function* ValidationState_t::function(uint32_t id) {
  300. auto it = id_to_function_.find(id);
  301. if (it == id_to_function_.end()) return nullptr;
  302. return it->second;
  303. }
  304. bool ValidationState_t::in_function_body() const { return in_function_; }
  305. bool ValidationState_t::in_block() const {
  306. return module_functions_.empty() == false &&
  307. module_functions_.back().current_block() != nullptr;
  308. }
  309. void ValidationState_t::RegisterCapability(SpvCapability cap) {
  310. // Avoid redundant work. Otherwise the recursion could induce work
  311. // quadrdatic in the capability dependency depth. (Ok, not much, but
  312. // it's something.)
  313. if (module_capabilities_.Contains(cap)) return;
  314. module_capabilities_.Add(cap);
  315. spv_operand_desc desc;
  316. if (SPV_SUCCESS ==
  317. grammar_.lookupOperand(SPV_OPERAND_TYPE_CAPABILITY, cap, &desc)) {
  318. CapabilitySet(desc->numCapabilities, desc->capabilities)
  319. .ForEach([this](SpvCapability c) { RegisterCapability(c); });
  320. }
  321. switch (cap) {
  322. case SpvCapabilityKernel:
  323. features_.group_ops_reduce_and_scans = true;
  324. break;
  325. case SpvCapabilityInt8:
  326. features_.use_int8_type = true;
  327. features_.declare_int8_type = true;
  328. break;
  329. case SpvCapabilityStorageBuffer8BitAccess:
  330. case SpvCapabilityUniformAndStorageBuffer8BitAccess:
  331. case SpvCapabilityStoragePushConstant8:
  332. case SpvCapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR:
  333. features_.declare_int8_type = true;
  334. break;
  335. case SpvCapabilityInt16:
  336. features_.declare_int16_type = true;
  337. break;
  338. case SpvCapabilityFloat16:
  339. case SpvCapabilityFloat16Buffer:
  340. features_.declare_float16_type = true;
  341. break;
  342. case SpvCapabilityStorageUniformBufferBlock16:
  343. case SpvCapabilityStorageUniform16:
  344. case SpvCapabilityStoragePushConstant16:
  345. case SpvCapabilityStorageInputOutput16:
  346. case SpvCapabilityWorkgroupMemoryExplicitLayout16BitAccessKHR:
  347. features_.declare_int16_type = true;
  348. features_.declare_float16_type = true;
  349. features_.free_fp_rounding_mode = true;
  350. break;
  351. case SpvCapabilityVariablePointers:
  352. case SpvCapabilityVariablePointersStorageBuffer:
  353. features_.variable_pointers = true;
  354. break;
  355. default:
  356. // TODO(dneto): For now don't validate SPV_NV_ray_tracing, which uses
  357. // capability SpvCapabilityRayTracingNV.
  358. // SpvCapabilityRayTracingProvisionalKHR would need the same treatment.
  359. // One of the differences going from SPV_KHR_ray_tracing from
  360. // provisional to final spec was the provisional spec uses Locations
  361. // for variables in certain storage classes, just like the
  362. // SPV_NV_ray_tracing extension. So it mimics the NVIDIA extension.
  363. // The final SPV_KHR_ray_tracing uses a different capability token
  364. // number, so it doesn't fall into this case.
  365. break;
  366. }
  367. }
  368. void ValidationState_t::RegisterExtension(Extension ext) {
  369. if (module_extensions_.Contains(ext)) return;
  370. module_extensions_.Add(ext);
  371. switch (ext) {
  372. case kSPV_AMD_gpu_shader_half_float:
  373. case kSPV_AMD_gpu_shader_half_float_fetch:
  374. // SPV_AMD_gpu_shader_half_float enables float16 type.
  375. // https://github.com/KhronosGroup/SPIRV-Tools/issues/1375
  376. features_.declare_float16_type = true;
  377. break;
  378. case kSPV_AMD_gpu_shader_int16:
  379. // This is not yet in the extension, but it's recommended for it.
  380. // See https://github.com/KhronosGroup/glslang/issues/848
  381. features_.uconvert_spec_constant_op = true;
  382. break;
  383. case kSPV_AMD_shader_ballot:
  384. // The grammar doesn't encode the fact that SPV_AMD_shader_ballot
  385. // enables the use of group operations Reduce, InclusiveScan,
  386. // and ExclusiveScan. Enable it manually.
  387. // https://github.com/KhronosGroup/SPIRV-Tools/issues/991
  388. features_.group_ops_reduce_and_scans = true;
  389. break;
  390. default:
  391. break;
  392. }
  393. }
  394. bool ValidationState_t::HasAnyOfCapabilities(
  395. const CapabilitySet& capabilities) const {
  396. return module_capabilities_.HasAnyOf(capabilities);
  397. }
  398. bool ValidationState_t::HasAnyOfExtensions(
  399. const ExtensionSet& extensions) const {
  400. return module_extensions_.HasAnyOf(extensions);
  401. }
  402. void ValidationState_t::set_addressing_model(SpvAddressingModel am) {
  403. addressing_model_ = am;
  404. switch (am) {
  405. case SpvAddressingModelPhysical32:
  406. pointer_size_and_alignment_ = 4;
  407. break;
  408. default:
  409. // fall through
  410. case SpvAddressingModelPhysical64:
  411. case SpvAddressingModelPhysicalStorageBuffer64:
  412. pointer_size_and_alignment_ = 8;
  413. break;
  414. }
  415. }
  416. SpvAddressingModel ValidationState_t::addressing_model() const {
  417. return addressing_model_;
  418. }
  419. void ValidationState_t::set_memory_model(SpvMemoryModel mm) {
  420. memory_model_ = mm;
  421. }
  422. SpvMemoryModel ValidationState_t::memory_model() const { return memory_model_; }
  423. void ValidationState_t::set_samplerimage_variable_address_mode(
  424. uint32_t bit_width) {
  425. sampler_image_addressing_mode_ = bit_width;
  426. }
  427. uint32_t ValidationState_t::samplerimage_variable_address_mode() const {
  428. return sampler_image_addressing_mode_;
  429. }
  430. spv_result_t ValidationState_t::RegisterFunction(
  431. uint32_t id, uint32_t ret_type_id, SpvFunctionControlMask function_control,
  432. uint32_t function_type_id) {
  433. assert(in_function_body() == false &&
  434. "RegisterFunction can only be called when parsing the binary outside "
  435. "of another function");
  436. in_function_ = true;
  437. module_functions_.emplace_back(id, ret_type_id, function_control,
  438. function_type_id);
  439. id_to_function_.emplace(id, &current_function());
  440. // TODO(umar): validate function type and type_id
  441. return SPV_SUCCESS;
  442. }
  443. spv_result_t ValidationState_t::RegisterFunctionEnd() {
  444. assert(in_function_body() == true &&
  445. "RegisterFunctionEnd can only be called when parsing the binary "
  446. "inside of another function");
  447. assert(in_block() == false &&
  448. "RegisterFunctionParameter can only be called when parsing the binary "
  449. "outside of a block");
  450. current_function().RegisterFunctionEnd();
  451. in_function_ = false;
  452. return SPV_SUCCESS;
  453. }
  454. Instruction* ValidationState_t::AddOrderedInstruction(
  455. const spv_parsed_instruction_t* inst) {
  456. ordered_instructions_.emplace_back(inst);
  457. ordered_instructions_.back().SetLineNum(ordered_instructions_.size());
  458. return &ordered_instructions_.back();
  459. }
  460. // Improves diagnostic messages by collecting names of IDs
  461. void ValidationState_t::RegisterDebugInstruction(const Instruction* inst) {
  462. switch (inst->opcode()) {
  463. case SpvOpName: {
  464. const auto target = inst->GetOperandAs<uint32_t>(0);
  465. const std::string str = inst->GetOperandAs<std::string>(1);
  466. AssignNameToId(target, str);
  467. break;
  468. }
  469. case SpvOpMemberName: {
  470. const auto target = inst->GetOperandAs<uint32_t>(0);
  471. const std::string str = inst->GetOperandAs<std::string>(2);
  472. AssignNameToId(target, str);
  473. break;
  474. }
  475. case SpvOpSourceContinued:
  476. case SpvOpSource:
  477. case SpvOpSourceExtension:
  478. case SpvOpString:
  479. case SpvOpLine:
  480. case SpvOpNoLine:
  481. default:
  482. break;
  483. }
  484. }
  485. void ValidationState_t::RegisterInstruction(Instruction* inst) {
  486. if (inst->id()) all_definitions_.insert(std::make_pair(inst->id(), inst));
  487. // Some validation checks are easier by getting all the consumers
  488. for (size_t i = 0; i < inst->operands().size(); ++i) {
  489. const spv_parsed_operand_t& operand = inst->operand(i);
  490. if ((SPV_OPERAND_TYPE_ID == operand.type) ||
  491. (SPV_OPERAND_TYPE_TYPE_ID == operand.type)) {
  492. const uint32_t operand_word = inst->word(operand.offset);
  493. Instruction* operand_inst = FindDef(operand_word);
  494. if (!operand_inst) {
  495. continue;
  496. }
  497. // If the instruction is using an OpTypeSampledImage as an operand, it
  498. // should be recorded. The validator will ensure that all usages of an
  499. // OpTypeSampledImage and its definition are in the same basic block.
  500. if ((SPV_OPERAND_TYPE_ID == operand.type) &&
  501. (SpvOpSampledImage == operand_inst->opcode())) {
  502. RegisterSampledImageConsumer(operand_word, inst);
  503. }
  504. // In order to track storage classes (not Function) used per execution
  505. // model we can't use RegisterExecutionModelLimitation on instructions
  506. // like OpTypePointer which are going to be in the pre-function section.
  507. // Instead just need to register storage class usage for consumers in a
  508. // function block.
  509. if (inst->function()) {
  510. if (operand_inst->opcode() == SpvOpTypePointer) {
  511. RegisterStorageClassConsumer(
  512. operand_inst->GetOperandAs<SpvStorageClass>(1), inst);
  513. } else if (operand_inst->opcode() == SpvOpVariable) {
  514. RegisterStorageClassConsumer(
  515. operand_inst->GetOperandAs<SpvStorageClass>(2), inst);
  516. }
  517. }
  518. }
  519. }
  520. }
  521. std::vector<Instruction*> ValidationState_t::getSampledImageConsumers(
  522. uint32_t sampled_image_id) const {
  523. std::vector<Instruction*> result;
  524. auto iter = sampled_image_consumers_.find(sampled_image_id);
  525. if (iter != sampled_image_consumers_.end()) {
  526. result = iter->second;
  527. }
  528. return result;
  529. }
  530. void ValidationState_t::RegisterSampledImageConsumer(uint32_t sampled_image_id,
  531. Instruction* consumer) {
  532. sampled_image_consumers_[sampled_image_id].push_back(consumer);
  533. }
  534. void ValidationState_t::RegisterStorageClassConsumer(
  535. SpvStorageClass storage_class, Instruction* consumer) {
  536. if (spvIsVulkanEnv(context()->target_env)) {
  537. if (storage_class == SpvStorageClassOutput) {
  538. std::string errorVUID = VkErrorID(4644);
  539. function(consumer->function()->id())
  540. ->RegisterExecutionModelLimitation([errorVUID](
  541. SpvExecutionModel model,
  542. std::string* message) {
  543. if (model == SpvExecutionModelGLCompute ||
  544. model == SpvExecutionModelRayGenerationKHR ||
  545. model == SpvExecutionModelIntersectionKHR ||
  546. model == SpvExecutionModelAnyHitKHR ||
  547. model == SpvExecutionModelClosestHitKHR ||
  548. model == SpvExecutionModelMissKHR ||
  549. model == SpvExecutionModelCallableKHR) {
  550. if (message) {
  551. *message =
  552. errorVUID +
  553. "in Vulkan environment, Output Storage Class must not be "
  554. "used in GLCompute, RayGenerationKHR, IntersectionKHR, "
  555. "AnyHitKHR, ClosestHitKHR, MissKHR, or CallableKHR "
  556. "execution models";
  557. }
  558. return false;
  559. }
  560. return true;
  561. });
  562. }
  563. if (storage_class == SpvStorageClassWorkgroup) {
  564. std::string errorVUID = VkErrorID(4645);
  565. function(consumer->function()->id())
  566. ->RegisterExecutionModelLimitation([errorVUID](
  567. SpvExecutionModel model,
  568. std::string* message) {
  569. if (model != SpvExecutionModelGLCompute &&
  570. model != SpvExecutionModelTaskNV &&
  571. model != SpvExecutionModelMeshNV &&
  572. model != SpvExecutionModelTaskEXT &&
  573. model != SpvExecutionModelMeshEXT) {
  574. if (message) {
  575. *message =
  576. errorVUID +
  577. "in Vulkan environment, Workgroup Storage Class is limited "
  578. "to MeshNV, TaskNV, and GLCompute execution model";
  579. }
  580. return false;
  581. }
  582. return true;
  583. });
  584. }
  585. }
  586. if (storage_class == SpvStorageClassCallableDataKHR) {
  587. std::string errorVUID = VkErrorID(4704);
  588. function(consumer->function()->id())
  589. ->RegisterExecutionModelLimitation([errorVUID](SpvExecutionModel model,
  590. std::string* message) {
  591. if (model != SpvExecutionModelRayGenerationKHR &&
  592. model != SpvExecutionModelClosestHitKHR &&
  593. model != SpvExecutionModelCallableKHR &&
  594. model != SpvExecutionModelMissKHR) {
  595. if (message) {
  596. *message = errorVUID +
  597. "CallableDataKHR Storage Class is limited to "
  598. "RayGenerationKHR, ClosestHitKHR, CallableKHR, and "
  599. "MissKHR execution model";
  600. }
  601. return false;
  602. }
  603. return true;
  604. });
  605. } else if (storage_class == SpvStorageClassIncomingCallableDataKHR) {
  606. std::string errorVUID = VkErrorID(4705);
  607. function(consumer->function()->id())
  608. ->RegisterExecutionModelLimitation([errorVUID](SpvExecutionModel model,
  609. std::string* message) {
  610. if (model != SpvExecutionModelCallableKHR) {
  611. if (message) {
  612. *message = errorVUID +
  613. "IncomingCallableDataKHR Storage Class is limited to "
  614. "CallableKHR execution model";
  615. }
  616. return false;
  617. }
  618. return true;
  619. });
  620. } else if (storage_class == SpvStorageClassRayPayloadKHR) {
  621. std::string errorVUID = VkErrorID(4698);
  622. function(consumer->function()->id())
  623. ->RegisterExecutionModelLimitation([errorVUID](SpvExecutionModel model,
  624. std::string* message) {
  625. if (model != SpvExecutionModelRayGenerationKHR &&
  626. model != SpvExecutionModelClosestHitKHR &&
  627. model != SpvExecutionModelMissKHR) {
  628. if (message) {
  629. *message =
  630. errorVUID +
  631. "RayPayloadKHR Storage Class is limited to RayGenerationKHR, "
  632. "ClosestHitKHR, and MissKHR execution model";
  633. }
  634. return false;
  635. }
  636. return true;
  637. });
  638. } else if (storage_class == SpvStorageClassHitAttributeKHR) {
  639. std::string errorVUID = VkErrorID(4701);
  640. function(consumer->function()->id())
  641. ->RegisterExecutionModelLimitation(
  642. [errorVUID](SpvExecutionModel model, std::string* message) {
  643. if (model != SpvExecutionModelIntersectionKHR &&
  644. model != SpvExecutionModelAnyHitKHR &&
  645. model != SpvExecutionModelClosestHitKHR) {
  646. if (message) {
  647. *message = errorVUID +
  648. "HitAttributeKHR Storage Class is limited to "
  649. "IntersectionKHR, AnyHitKHR, sand ClosestHitKHR "
  650. "execution model";
  651. }
  652. return false;
  653. }
  654. return true;
  655. });
  656. } else if (storage_class == SpvStorageClassIncomingRayPayloadKHR) {
  657. std::string errorVUID = VkErrorID(4699);
  658. function(consumer->function()->id())
  659. ->RegisterExecutionModelLimitation(
  660. [errorVUID](SpvExecutionModel model, std::string* message) {
  661. if (model != SpvExecutionModelAnyHitKHR &&
  662. model != SpvExecutionModelClosestHitKHR &&
  663. model != SpvExecutionModelMissKHR) {
  664. if (message) {
  665. *message =
  666. errorVUID +
  667. "IncomingRayPayloadKHR Storage Class is limited to "
  668. "AnyHitKHR, ClosestHitKHR, and MissKHR execution model";
  669. }
  670. return false;
  671. }
  672. return true;
  673. });
  674. } else if (storage_class == SpvStorageClassShaderRecordBufferKHR) {
  675. std::string errorVUID = VkErrorID(7119);
  676. function(consumer->function()->id())
  677. ->RegisterExecutionModelLimitation(
  678. [errorVUID](SpvExecutionModel model, std::string* message) {
  679. if (model != SpvExecutionModelRayGenerationKHR &&
  680. model != SpvExecutionModelIntersectionKHR &&
  681. model != SpvExecutionModelAnyHitKHR &&
  682. model != SpvExecutionModelClosestHitKHR &&
  683. model != SpvExecutionModelCallableKHR &&
  684. model != SpvExecutionModelMissKHR) {
  685. if (message) {
  686. *message =
  687. errorVUID +
  688. "ShaderRecordBufferKHR Storage Class is limited to "
  689. "RayGenerationKHR, IntersectionKHR, AnyHitKHR, "
  690. "ClosestHitKHR, CallableKHR, and MissKHR execution model";
  691. }
  692. return false;
  693. }
  694. return true;
  695. });
  696. } else if (storage_class == SpvStorageClassTaskPayloadWorkgroupEXT) {
  697. function(consumer->function()->id())
  698. ->RegisterExecutionModelLimitation(
  699. [](SpvExecutionModel model, std::string* message) {
  700. if (model != SpvExecutionModelTaskEXT &&
  701. model != SpvExecutionModelMeshEXT) {
  702. if (message) {
  703. *message =
  704. "TaskPayloadWorkgroupEXT Storage Class is limited to "
  705. "TaskEXT and MeshKHR execution model";
  706. }
  707. return false;
  708. }
  709. return true;
  710. });
  711. }
  712. }
  713. uint32_t ValidationState_t::getIdBound() const { return id_bound_; }
  714. void ValidationState_t::setIdBound(const uint32_t bound) { id_bound_ = bound; }
  715. bool ValidationState_t::RegisterUniqueTypeDeclaration(const Instruction* inst) {
  716. std::vector<uint32_t> key;
  717. key.push_back(static_cast<uint32_t>(inst->opcode()));
  718. for (size_t index = 0; index < inst->operands().size(); ++index) {
  719. const spv_parsed_operand_t& operand = inst->operand(index);
  720. if (operand.type == SPV_OPERAND_TYPE_RESULT_ID) continue;
  721. const int words_begin = operand.offset;
  722. const int words_end = words_begin + operand.num_words;
  723. assert(words_end <= static_cast<int>(inst->words().size()));
  724. key.insert(key.end(), inst->words().begin() + words_begin,
  725. inst->words().begin() + words_end);
  726. }
  727. return unique_type_declarations_.insert(std::move(key)).second;
  728. }
  729. uint32_t ValidationState_t::GetTypeId(uint32_t id) const {
  730. const Instruction* inst = FindDef(id);
  731. return inst ? inst->type_id() : 0;
  732. }
  733. SpvOp ValidationState_t::GetIdOpcode(uint32_t id) const {
  734. const Instruction* inst = FindDef(id);
  735. return inst ? inst->opcode() : SpvOpNop;
  736. }
  737. uint32_t ValidationState_t::GetComponentType(uint32_t id) const {
  738. const Instruction* inst = FindDef(id);
  739. assert(inst);
  740. switch (inst->opcode()) {
  741. case SpvOpTypeFloat:
  742. case SpvOpTypeInt:
  743. case SpvOpTypeBool:
  744. return id;
  745. case SpvOpTypeVector:
  746. return inst->word(2);
  747. case SpvOpTypeMatrix:
  748. return GetComponentType(inst->word(2));
  749. case SpvOpTypeCooperativeMatrixNV:
  750. return inst->word(2);
  751. default:
  752. break;
  753. }
  754. if (inst->type_id()) return GetComponentType(inst->type_id());
  755. assert(0);
  756. return 0;
  757. }
  758. uint32_t ValidationState_t::GetDimension(uint32_t id) const {
  759. const Instruction* inst = FindDef(id);
  760. assert(inst);
  761. switch (inst->opcode()) {
  762. case SpvOpTypeFloat:
  763. case SpvOpTypeInt:
  764. case SpvOpTypeBool:
  765. return 1;
  766. case SpvOpTypeVector:
  767. case SpvOpTypeMatrix:
  768. return inst->word(3);
  769. case SpvOpTypeCooperativeMatrixNV:
  770. // Actual dimension isn't known, return 0
  771. return 0;
  772. default:
  773. break;
  774. }
  775. if (inst->type_id()) return GetDimension(inst->type_id());
  776. assert(0);
  777. return 0;
  778. }
  779. uint32_t ValidationState_t::GetBitWidth(uint32_t id) const {
  780. const uint32_t component_type_id = GetComponentType(id);
  781. const Instruction* inst = FindDef(component_type_id);
  782. assert(inst);
  783. if (inst->opcode() == SpvOpTypeFloat || inst->opcode() == SpvOpTypeInt)
  784. return inst->word(2);
  785. if (inst->opcode() == SpvOpTypeBool) return 1;
  786. assert(0);
  787. return 0;
  788. }
  789. bool ValidationState_t::IsVoidType(uint32_t id) const {
  790. const Instruction* inst = FindDef(id);
  791. return inst && inst->opcode() == SpvOpTypeVoid;
  792. }
  793. bool ValidationState_t::IsFloatScalarType(uint32_t id) const {
  794. const Instruction* inst = FindDef(id);
  795. return inst && inst->opcode() == SpvOpTypeFloat;
  796. }
  797. bool ValidationState_t::IsFloatVectorType(uint32_t id) const {
  798. const Instruction* inst = FindDef(id);
  799. if (!inst) {
  800. return false;
  801. }
  802. if (inst->opcode() == SpvOpTypeVector) {
  803. return IsFloatScalarType(GetComponentType(id));
  804. }
  805. return false;
  806. }
  807. bool ValidationState_t::IsFloatScalarOrVectorType(uint32_t id) const {
  808. const Instruction* inst = FindDef(id);
  809. if (!inst) {
  810. return false;
  811. }
  812. if (inst->opcode() == SpvOpTypeFloat) {
  813. return true;
  814. }
  815. if (inst->opcode() == SpvOpTypeVector) {
  816. return IsFloatScalarType(GetComponentType(id));
  817. }
  818. return false;
  819. }
  820. bool ValidationState_t::IsIntScalarType(uint32_t id) const {
  821. const Instruction* inst = FindDef(id);
  822. return inst && inst->opcode() == SpvOpTypeInt;
  823. }
  824. bool ValidationState_t::IsIntVectorType(uint32_t id) const {
  825. const Instruction* inst = FindDef(id);
  826. if (!inst) {
  827. return false;
  828. }
  829. if (inst->opcode() == SpvOpTypeVector) {
  830. return IsIntScalarType(GetComponentType(id));
  831. }
  832. return false;
  833. }
  834. bool ValidationState_t::IsIntScalarOrVectorType(uint32_t id) const {
  835. const Instruction* inst = FindDef(id);
  836. if (!inst) {
  837. return false;
  838. }
  839. if (inst->opcode() == SpvOpTypeInt) {
  840. return true;
  841. }
  842. if (inst->opcode() == SpvOpTypeVector) {
  843. return IsIntScalarType(GetComponentType(id));
  844. }
  845. return false;
  846. }
  847. bool ValidationState_t::IsUnsignedIntScalarType(uint32_t id) const {
  848. const Instruction* inst = FindDef(id);
  849. return inst && inst->opcode() == SpvOpTypeInt && inst->word(3) == 0;
  850. }
  851. bool ValidationState_t::IsUnsignedIntVectorType(uint32_t id) const {
  852. const Instruction* inst = FindDef(id);
  853. if (!inst) {
  854. return false;
  855. }
  856. if (inst->opcode() == SpvOpTypeVector) {
  857. return IsUnsignedIntScalarType(GetComponentType(id));
  858. }
  859. return false;
  860. }
  861. bool ValidationState_t::IsSignedIntScalarType(uint32_t id) const {
  862. const Instruction* inst = FindDef(id);
  863. return inst && inst->opcode() == SpvOpTypeInt && inst->word(3) == 1;
  864. }
  865. bool ValidationState_t::IsSignedIntVectorType(uint32_t id) const {
  866. const Instruction* inst = FindDef(id);
  867. if (!inst) {
  868. return false;
  869. }
  870. if (inst->opcode() == SpvOpTypeVector) {
  871. return IsSignedIntScalarType(GetComponentType(id));
  872. }
  873. return false;
  874. }
  875. bool ValidationState_t::IsBoolScalarType(uint32_t id) const {
  876. const Instruction* inst = FindDef(id);
  877. return inst && inst->opcode() == SpvOpTypeBool;
  878. }
  879. bool ValidationState_t::IsBoolVectorType(uint32_t id) const {
  880. const Instruction* inst = FindDef(id);
  881. if (!inst) {
  882. return false;
  883. }
  884. if (inst->opcode() == SpvOpTypeVector) {
  885. return IsBoolScalarType(GetComponentType(id));
  886. }
  887. return false;
  888. }
  889. bool ValidationState_t::IsBoolScalarOrVectorType(uint32_t id) const {
  890. const Instruction* inst = FindDef(id);
  891. if (!inst) {
  892. return false;
  893. }
  894. if (inst->opcode() == SpvOpTypeBool) {
  895. return true;
  896. }
  897. if (inst->opcode() == SpvOpTypeVector) {
  898. return IsBoolScalarType(GetComponentType(id));
  899. }
  900. return false;
  901. }
  902. bool ValidationState_t::IsFloatMatrixType(uint32_t id) const {
  903. const Instruction* inst = FindDef(id);
  904. if (!inst) {
  905. return false;
  906. }
  907. if (inst->opcode() == SpvOpTypeMatrix) {
  908. return IsFloatScalarType(GetComponentType(id));
  909. }
  910. return false;
  911. }
  912. bool ValidationState_t::GetMatrixTypeInfo(uint32_t id, uint32_t* num_rows,
  913. uint32_t* num_cols,
  914. uint32_t* column_type,
  915. uint32_t* component_type) const {
  916. if (!id) return false;
  917. const Instruction* mat_inst = FindDef(id);
  918. assert(mat_inst);
  919. if (mat_inst->opcode() != SpvOpTypeMatrix) return false;
  920. const uint32_t vec_type = mat_inst->word(2);
  921. const Instruction* vec_inst = FindDef(vec_type);
  922. assert(vec_inst);
  923. if (vec_inst->opcode() != SpvOpTypeVector) {
  924. assert(0);
  925. return false;
  926. }
  927. *num_cols = mat_inst->word(3);
  928. *num_rows = vec_inst->word(3);
  929. *column_type = mat_inst->word(2);
  930. *component_type = vec_inst->word(2);
  931. return true;
  932. }
  933. bool ValidationState_t::GetStructMemberTypes(
  934. uint32_t struct_type_id, std::vector<uint32_t>* member_types) const {
  935. member_types->clear();
  936. if (!struct_type_id) return false;
  937. const Instruction* inst = FindDef(struct_type_id);
  938. assert(inst);
  939. if (inst->opcode() != SpvOpTypeStruct) return false;
  940. *member_types =
  941. std::vector<uint32_t>(inst->words().cbegin() + 2, inst->words().cend());
  942. if (member_types->empty()) return false;
  943. return true;
  944. }
  945. bool ValidationState_t::IsPointerType(uint32_t id) const {
  946. const Instruction* inst = FindDef(id);
  947. return inst && inst->opcode() == SpvOpTypePointer;
  948. }
  949. bool ValidationState_t::GetPointerTypeInfo(uint32_t id, uint32_t* data_type,
  950. uint32_t* storage_class) const {
  951. if (!id) return false;
  952. const Instruction* inst = FindDef(id);
  953. assert(inst);
  954. if (inst->opcode() != SpvOpTypePointer) return false;
  955. *storage_class = inst->word(2);
  956. *data_type = inst->word(3);
  957. return true;
  958. }
  959. bool ValidationState_t::IsAccelerationStructureType(uint32_t id) const {
  960. const Instruction* inst = FindDef(id);
  961. return inst && inst->opcode() == SpvOpTypeAccelerationStructureKHR;
  962. }
  963. bool ValidationState_t::IsCooperativeMatrixType(uint32_t id) const {
  964. const Instruction* inst = FindDef(id);
  965. return inst && inst->opcode() == SpvOpTypeCooperativeMatrixNV;
  966. }
  967. bool ValidationState_t::IsFloatCooperativeMatrixType(uint32_t id) const {
  968. if (!IsCooperativeMatrixType(id)) return false;
  969. return IsFloatScalarType(FindDef(id)->word(2));
  970. }
  971. bool ValidationState_t::IsIntCooperativeMatrixType(uint32_t id) const {
  972. if (!IsCooperativeMatrixType(id)) return false;
  973. return IsIntScalarType(FindDef(id)->word(2));
  974. }
  975. bool ValidationState_t::IsUnsignedIntCooperativeMatrixType(uint32_t id) const {
  976. if (!IsCooperativeMatrixType(id)) return false;
  977. return IsUnsignedIntScalarType(FindDef(id)->word(2));
  978. }
  979. // Either a 32 bit 2-component uint vector or a 64 bit uint scalar
  980. bool ValidationState_t::IsUnsigned64BitHandle(uint32_t id) const {
  981. return ((IsUnsignedIntScalarType(id) && GetBitWidth(id) == 64) ||
  982. (IsUnsignedIntVectorType(id) && GetDimension(id) == 2 &&
  983. GetBitWidth(id) == 32));
  984. }
  985. spv_result_t ValidationState_t::CooperativeMatrixShapesMatch(
  986. const Instruction* inst, uint32_t m1, uint32_t m2) {
  987. const auto m1_type = FindDef(m1);
  988. const auto m2_type = FindDef(m2);
  989. if (m1_type->opcode() != SpvOpTypeCooperativeMatrixNV ||
  990. m2_type->opcode() != SpvOpTypeCooperativeMatrixNV) {
  991. return diag(SPV_ERROR_INVALID_DATA, inst)
  992. << "Expected cooperative matrix types";
  993. }
  994. uint32_t m1_scope_id = m1_type->GetOperandAs<uint32_t>(2);
  995. uint32_t m1_rows_id = m1_type->GetOperandAs<uint32_t>(3);
  996. uint32_t m1_cols_id = m1_type->GetOperandAs<uint32_t>(4);
  997. uint32_t m2_scope_id = m2_type->GetOperandAs<uint32_t>(2);
  998. uint32_t m2_rows_id = m2_type->GetOperandAs<uint32_t>(3);
  999. uint32_t m2_cols_id = m2_type->GetOperandAs<uint32_t>(4);
  1000. bool m1_is_int32 = false, m1_is_const_int32 = false, m2_is_int32 = false,
  1001. m2_is_const_int32 = false;
  1002. uint32_t m1_value = 0, m2_value = 0;
  1003. std::tie(m1_is_int32, m1_is_const_int32, m1_value) =
  1004. EvalInt32IfConst(m1_scope_id);
  1005. std::tie(m2_is_int32, m2_is_const_int32, m2_value) =
  1006. EvalInt32IfConst(m2_scope_id);
  1007. if (m1_is_const_int32 && m2_is_const_int32 && m1_value != m2_value) {
  1008. return diag(SPV_ERROR_INVALID_DATA, inst)
  1009. << "Expected scopes of Matrix and Result Type to be "
  1010. << "identical";
  1011. }
  1012. std::tie(m1_is_int32, m1_is_const_int32, m1_value) =
  1013. EvalInt32IfConst(m1_rows_id);
  1014. std::tie(m2_is_int32, m2_is_const_int32, m2_value) =
  1015. EvalInt32IfConst(m2_rows_id);
  1016. if (m1_is_const_int32 && m2_is_const_int32 && m1_value != m2_value) {
  1017. return diag(SPV_ERROR_INVALID_DATA, inst)
  1018. << "Expected rows of Matrix type and Result Type to be "
  1019. << "identical";
  1020. }
  1021. std::tie(m1_is_int32, m1_is_const_int32, m1_value) =
  1022. EvalInt32IfConst(m1_cols_id);
  1023. std::tie(m2_is_int32, m2_is_const_int32, m2_value) =
  1024. EvalInt32IfConst(m2_cols_id);
  1025. if (m1_is_const_int32 && m2_is_const_int32 && m1_value != m2_value) {
  1026. return diag(SPV_ERROR_INVALID_DATA, inst)
  1027. << "Expected columns of Matrix type and Result Type to be "
  1028. << "identical";
  1029. }
  1030. return SPV_SUCCESS;
  1031. }
  1032. uint32_t ValidationState_t::GetOperandTypeId(const Instruction* inst,
  1033. size_t operand_index) const {
  1034. return GetTypeId(inst->GetOperandAs<uint32_t>(operand_index));
  1035. }
  1036. bool ValidationState_t::GetConstantValUint64(uint32_t id, uint64_t* val) const {
  1037. const Instruction* inst = FindDef(id);
  1038. if (!inst) {
  1039. assert(0 && "Instruction not found");
  1040. return false;
  1041. }
  1042. if (inst->opcode() != SpvOpConstant && inst->opcode() != SpvOpSpecConstant)
  1043. return false;
  1044. if (!IsIntScalarType(inst->type_id())) return false;
  1045. if (inst->words().size() == 4) {
  1046. *val = inst->word(3);
  1047. } else {
  1048. assert(inst->words().size() == 5);
  1049. *val = inst->word(3);
  1050. *val |= uint64_t(inst->word(4)) << 32;
  1051. }
  1052. return true;
  1053. }
  1054. std::tuple<bool, bool, uint32_t> ValidationState_t::EvalInt32IfConst(
  1055. uint32_t id) const {
  1056. const Instruction* const inst = FindDef(id);
  1057. assert(inst);
  1058. const uint32_t type = inst->type_id();
  1059. if (type == 0 || !IsIntScalarType(type) || GetBitWidth(type) != 32) {
  1060. return std::make_tuple(false, false, 0);
  1061. }
  1062. // Spec constant values cannot be evaluated so don't consider constant for
  1063. // the purpose of this method.
  1064. if (!spvOpcodeIsConstant(inst->opcode()) ||
  1065. spvOpcodeIsSpecConstant(inst->opcode())) {
  1066. return std::make_tuple(true, false, 0);
  1067. }
  1068. if (inst->opcode() == SpvOpConstantNull) {
  1069. return std::make_tuple(true, true, 0);
  1070. }
  1071. assert(inst->words().size() == 4);
  1072. return std::make_tuple(true, true, inst->word(3));
  1073. }
  1074. void ValidationState_t::ComputeFunctionToEntryPointMapping() {
  1075. for (const uint32_t entry_point : entry_points()) {
  1076. std::stack<uint32_t> call_stack;
  1077. std::set<uint32_t> visited;
  1078. call_stack.push(entry_point);
  1079. while (!call_stack.empty()) {
  1080. const uint32_t called_func_id = call_stack.top();
  1081. call_stack.pop();
  1082. if (!visited.insert(called_func_id).second) continue;
  1083. function_to_entry_points_[called_func_id].push_back(entry_point);
  1084. const Function* called_func = function(called_func_id);
  1085. if (called_func) {
  1086. // Other checks should error out on this invalid SPIR-V.
  1087. for (const uint32_t new_call : called_func->function_call_targets()) {
  1088. call_stack.push(new_call);
  1089. }
  1090. }
  1091. }
  1092. }
  1093. }
  1094. void ValidationState_t::ComputeRecursiveEntryPoints() {
  1095. for (const Function& func : functions()) {
  1096. std::stack<uint32_t> call_stack;
  1097. std::set<uint32_t> visited;
  1098. for (const uint32_t new_call : func.function_call_targets()) {
  1099. call_stack.push(new_call);
  1100. }
  1101. while (!call_stack.empty()) {
  1102. const uint32_t called_func_id = call_stack.top();
  1103. call_stack.pop();
  1104. if (!visited.insert(called_func_id).second) continue;
  1105. if (called_func_id == func.id()) {
  1106. for (const uint32_t entry_point :
  1107. function_to_entry_points_[called_func_id])
  1108. recursive_entry_points_.insert(entry_point);
  1109. break;
  1110. }
  1111. const Function* called_func = function(called_func_id);
  1112. if (called_func) {
  1113. // Other checks should error out on this invalid SPIR-V.
  1114. for (const uint32_t new_call : called_func->function_call_targets()) {
  1115. call_stack.push(new_call);
  1116. }
  1117. }
  1118. }
  1119. }
  1120. }
  1121. const std::vector<uint32_t>& ValidationState_t::FunctionEntryPoints(
  1122. uint32_t func) const {
  1123. auto iter = function_to_entry_points_.find(func);
  1124. if (iter == function_to_entry_points_.end()) {
  1125. return empty_ids_;
  1126. } else {
  1127. return iter->second;
  1128. }
  1129. }
  1130. std::set<uint32_t> ValidationState_t::EntryPointReferences(uint32_t id) const {
  1131. std::set<uint32_t> referenced_entry_points;
  1132. const auto inst = FindDef(id);
  1133. if (!inst) return referenced_entry_points;
  1134. std::vector<const Instruction*> stack;
  1135. stack.push_back(inst);
  1136. while (!stack.empty()) {
  1137. const auto current_inst = stack.back();
  1138. stack.pop_back();
  1139. if (const auto func = current_inst->function()) {
  1140. // Instruction lives in a function, we can stop searching.
  1141. const auto function_entry_points = FunctionEntryPoints(func->id());
  1142. referenced_entry_points.insert(function_entry_points.begin(),
  1143. function_entry_points.end());
  1144. } else {
  1145. // Instruction is in the global scope, keep searching its uses.
  1146. for (auto pair : current_inst->uses()) {
  1147. const auto next_inst = pair.first;
  1148. stack.push_back(next_inst);
  1149. }
  1150. }
  1151. }
  1152. return referenced_entry_points;
  1153. }
  1154. std::string ValidationState_t::Disassemble(const Instruction& inst) const {
  1155. const spv_parsed_instruction_t& c_inst(inst.c_inst());
  1156. return Disassemble(c_inst.words, c_inst.num_words);
  1157. }
  1158. std::string ValidationState_t::Disassemble(const uint32_t* words,
  1159. uint16_t num_words) const {
  1160. uint32_t disassembly_options = SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
  1161. SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES;
  1162. return spvInstructionBinaryToText(context()->target_env, words, num_words,
  1163. words_, num_words_, disassembly_options);
  1164. }
  1165. bool ValidationState_t::LogicallyMatch(const Instruction* lhs,
  1166. const Instruction* rhs,
  1167. bool check_decorations) {
  1168. if (lhs->opcode() != rhs->opcode()) {
  1169. return false;
  1170. }
  1171. if (check_decorations) {
  1172. const auto& dec_a = id_decorations(lhs->id());
  1173. const auto& dec_b = id_decorations(rhs->id());
  1174. for (const auto& dec : dec_b) {
  1175. if (std::find(dec_a.begin(), dec_a.end(), dec) == dec_a.end()) {
  1176. return false;
  1177. }
  1178. }
  1179. }
  1180. if (lhs->opcode() == SpvOpTypeArray) {
  1181. // Size operands must match.
  1182. if (lhs->GetOperandAs<uint32_t>(2u) != rhs->GetOperandAs<uint32_t>(2u)) {
  1183. return false;
  1184. }
  1185. // Elements must match or logically match.
  1186. const auto lhs_ele_id = lhs->GetOperandAs<uint32_t>(1u);
  1187. const auto rhs_ele_id = rhs->GetOperandAs<uint32_t>(1u);
  1188. if (lhs_ele_id == rhs_ele_id) {
  1189. return true;
  1190. }
  1191. const auto lhs_ele = FindDef(lhs_ele_id);
  1192. const auto rhs_ele = FindDef(rhs_ele_id);
  1193. if (!lhs_ele || !rhs_ele) {
  1194. return false;
  1195. }
  1196. return LogicallyMatch(lhs_ele, rhs_ele, check_decorations);
  1197. } else if (lhs->opcode() == SpvOpTypeStruct) {
  1198. // Number of elements must match.
  1199. if (lhs->operands().size() != rhs->operands().size()) {
  1200. return false;
  1201. }
  1202. for (size_t i = 1u; i < lhs->operands().size(); ++i) {
  1203. const auto lhs_ele_id = lhs->GetOperandAs<uint32_t>(i);
  1204. const auto rhs_ele_id = rhs->GetOperandAs<uint32_t>(i);
  1205. // Elements must match or logically match.
  1206. if (lhs_ele_id == rhs_ele_id) {
  1207. continue;
  1208. }
  1209. const auto lhs_ele = FindDef(lhs_ele_id);
  1210. const auto rhs_ele = FindDef(rhs_ele_id);
  1211. if (!lhs_ele || !rhs_ele) {
  1212. return false;
  1213. }
  1214. if (!LogicallyMatch(lhs_ele, rhs_ele, check_decorations)) {
  1215. return false;
  1216. }
  1217. }
  1218. // All checks passed.
  1219. return true;
  1220. }
  1221. // No other opcodes are acceptable at this point. Arrays and structs are
  1222. // caught above and if they're elements are not arrays or structs they are
  1223. // required to match exactly.
  1224. return false;
  1225. }
  1226. const Instruction* ValidationState_t::TracePointer(
  1227. const Instruction* inst) const {
  1228. auto base_ptr = inst;
  1229. while (base_ptr->opcode() == SpvOpAccessChain ||
  1230. base_ptr->opcode() == SpvOpInBoundsAccessChain ||
  1231. base_ptr->opcode() == SpvOpPtrAccessChain ||
  1232. base_ptr->opcode() == SpvOpInBoundsPtrAccessChain ||
  1233. base_ptr->opcode() == SpvOpCopyObject) {
  1234. base_ptr = FindDef(base_ptr->GetOperandAs<uint32_t>(2u));
  1235. }
  1236. return base_ptr;
  1237. }
  1238. bool ValidationState_t::ContainsType(
  1239. uint32_t id, const std::function<bool(const Instruction*)>& f,
  1240. bool traverse_all_types) const {
  1241. const auto inst = FindDef(id);
  1242. if (!inst) return false;
  1243. if (f(inst)) return true;
  1244. switch (inst->opcode()) {
  1245. case SpvOpTypeArray:
  1246. case SpvOpTypeRuntimeArray:
  1247. case SpvOpTypeVector:
  1248. case SpvOpTypeMatrix:
  1249. case SpvOpTypeImage:
  1250. case SpvOpTypeSampledImage:
  1251. case SpvOpTypeCooperativeMatrixNV:
  1252. return ContainsType(inst->GetOperandAs<uint32_t>(1u), f,
  1253. traverse_all_types);
  1254. case SpvOpTypePointer:
  1255. if (IsForwardPointer(id)) return false;
  1256. if (traverse_all_types) {
  1257. return ContainsType(inst->GetOperandAs<uint32_t>(2u), f,
  1258. traverse_all_types);
  1259. }
  1260. break;
  1261. case SpvOpTypeFunction:
  1262. case SpvOpTypeStruct:
  1263. if (inst->opcode() == SpvOpTypeFunction && !traverse_all_types) {
  1264. return false;
  1265. }
  1266. for (uint32_t i = 1; i < inst->operands().size(); ++i) {
  1267. if (ContainsType(inst->GetOperandAs<uint32_t>(i), f,
  1268. traverse_all_types)) {
  1269. return true;
  1270. }
  1271. }
  1272. break;
  1273. default:
  1274. break;
  1275. }
  1276. return false;
  1277. }
  1278. bool ValidationState_t::ContainsSizedIntOrFloatType(uint32_t id, SpvOp type,
  1279. uint32_t width) const {
  1280. if (type != SpvOpTypeInt && type != SpvOpTypeFloat) return false;
  1281. const auto f = [type, width](const Instruction* inst) {
  1282. if (inst->opcode() == type) {
  1283. return inst->GetOperandAs<uint32_t>(1u) == width;
  1284. }
  1285. return false;
  1286. };
  1287. return ContainsType(id, f);
  1288. }
  1289. bool ValidationState_t::ContainsLimitedUseIntOrFloatType(uint32_t id) const {
  1290. if ((!HasCapability(SpvCapabilityInt16) &&
  1291. ContainsSizedIntOrFloatType(id, SpvOpTypeInt, 16)) ||
  1292. (!HasCapability(SpvCapabilityInt8) &&
  1293. ContainsSizedIntOrFloatType(id, SpvOpTypeInt, 8)) ||
  1294. (!HasCapability(SpvCapabilityFloat16) &&
  1295. ContainsSizedIntOrFloatType(id, SpvOpTypeFloat, 16))) {
  1296. return true;
  1297. }
  1298. return false;
  1299. }
  1300. bool ValidationState_t::ContainsRuntimeArray(uint32_t id) const {
  1301. const auto f = [](const Instruction* inst) {
  1302. return inst->opcode() == SpvOpTypeRuntimeArray;
  1303. };
  1304. return ContainsType(id, f, /* traverse_all_types = */ false);
  1305. }
  1306. bool ValidationState_t::IsValidStorageClass(
  1307. SpvStorageClass storage_class) const {
  1308. if (spvIsVulkanEnv(context()->target_env)) {
  1309. switch (storage_class) {
  1310. case SpvStorageClassUniformConstant:
  1311. case SpvStorageClassUniform:
  1312. case SpvStorageClassStorageBuffer:
  1313. case SpvStorageClassInput:
  1314. case SpvStorageClassOutput:
  1315. case SpvStorageClassImage:
  1316. case SpvStorageClassWorkgroup:
  1317. case SpvStorageClassPrivate:
  1318. case SpvStorageClassFunction:
  1319. case SpvStorageClassPushConstant:
  1320. case SpvStorageClassPhysicalStorageBuffer:
  1321. case SpvStorageClassRayPayloadKHR:
  1322. case SpvStorageClassIncomingRayPayloadKHR:
  1323. case SpvStorageClassHitAttributeKHR:
  1324. case SpvStorageClassCallableDataKHR:
  1325. case SpvStorageClassIncomingCallableDataKHR:
  1326. case SpvStorageClassShaderRecordBufferKHR:
  1327. case SpvStorageClassTaskPayloadWorkgroupEXT:
  1328. return true;
  1329. default:
  1330. return false;
  1331. }
  1332. }
  1333. return true;
  1334. }
  1335. #define VUID_WRAP(vuid) "[" #vuid "] "
  1336. // Currently no 2 VUID share the same id, so no need for |reference|
  1337. std::string ValidationState_t::VkErrorID(uint32_t id,
  1338. const char* /*reference*/) const {
  1339. if (!spvIsVulkanEnv(context_->target_env)) {
  1340. return "";
  1341. }
  1342. // This large switch case is only searched when an error has occurred.
  1343. // If an id is changed, the old case must be modified or removed. Each string
  1344. // here is interpreted as being "implemented"
  1345. // Clang format adds spaces between hyphens
  1346. // clang-format off
  1347. switch (id) {
  1348. case 4154:
  1349. return VUID_WRAP(VUID-BaryCoordKHR-BaryCoordKHR-04154);
  1350. case 4155:
  1351. return VUID_WRAP(VUID-BaryCoordKHR-BaryCoordKHR-04155);
  1352. case 4156:
  1353. return VUID_WRAP(VUID-BaryCoordKHR-BaryCoordKHR-04156);
  1354. case 4160:
  1355. return VUID_WRAP(VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04160);
  1356. case 4161:
  1357. return VUID_WRAP(VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04161);
  1358. case 4162:
  1359. return VUID_WRAP(VUID-BaryCoordNoPerspKHR-BaryCoordNoPerspKHR-04162);
  1360. case 4181:
  1361. return VUID_WRAP(VUID-BaseInstance-BaseInstance-04181);
  1362. case 4182:
  1363. return VUID_WRAP(VUID-BaseInstance-BaseInstance-04182);
  1364. case 4183:
  1365. return VUID_WRAP(VUID-BaseInstance-BaseInstance-04183);
  1366. case 4184:
  1367. return VUID_WRAP(VUID-BaseVertex-BaseVertex-04184);
  1368. case 4185:
  1369. return VUID_WRAP(VUID-BaseVertex-BaseVertex-04185);
  1370. case 4186:
  1371. return VUID_WRAP(VUID-BaseVertex-BaseVertex-04186);
  1372. case 4187:
  1373. return VUID_WRAP(VUID-ClipDistance-ClipDistance-04187);
  1374. case 4188:
  1375. return VUID_WRAP(VUID-ClipDistance-ClipDistance-04188);
  1376. case 4189:
  1377. return VUID_WRAP(VUID-ClipDistance-ClipDistance-04189);
  1378. case 4190:
  1379. return VUID_WRAP(VUID-ClipDistance-ClipDistance-04190);
  1380. case 4191:
  1381. return VUID_WRAP(VUID-ClipDistance-ClipDistance-04191);
  1382. case 4196:
  1383. return VUID_WRAP(VUID-CullDistance-CullDistance-04196);
  1384. case 4197:
  1385. return VUID_WRAP(VUID-CullDistance-CullDistance-04197);
  1386. case 4198:
  1387. return VUID_WRAP(VUID-CullDistance-CullDistance-04198);
  1388. case 4199:
  1389. return VUID_WRAP(VUID-CullDistance-CullDistance-04199);
  1390. case 4200:
  1391. return VUID_WRAP(VUID-CullDistance-CullDistance-04200);
  1392. case 6735:
  1393. return VUID_WRAP(VUID-CullMaskKHR-CullMaskKHR-06735); // Execution Model
  1394. case 6736:
  1395. return VUID_WRAP(VUID-CullMaskKHR-CullMaskKHR-06736); // input storage
  1396. case 6737:
  1397. return VUID_WRAP(VUID-CullMaskKHR-CullMaskKHR-06737); // 32 int scalar
  1398. case 4205:
  1399. return VUID_WRAP(VUID-DeviceIndex-DeviceIndex-04205);
  1400. case 4206:
  1401. return VUID_WRAP(VUID-DeviceIndex-DeviceIndex-04206);
  1402. case 4207:
  1403. return VUID_WRAP(VUID-DrawIndex-DrawIndex-04207);
  1404. case 4208:
  1405. return VUID_WRAP(VUID-DrawIndex-DrawIndex-04208);
  1406. case 4209:
  1407. return VUID_WRAP(VUID-DrawIndex-DrawIndex-04209);
  1408. case 4210:
  1409. return VUID_WRAP(VUID-FragCoord-FragCoord-04210);
  1410. case 4211:
  1411. return VUID_WRAP(VUID-FragCoord-FragCoord-04211);
  1412. case 4212:
  1413. return VUID_WRAP(VUID-FragCoord-FragCoord-04212);
  1414. case 4213:
  1415. return VUID_WRAP(VUID-FragDepth-FragDepth-04213);
  1416. case 4214:
  1417. return VUID_WRAP(VUID-FragDepth-FragDepth-04214);
  1418. case 4215:
  1419. return VUID_WRAP(VUID-FragDepth-FragDepth-04215);
  1420. case 4216:
  1421. return VUID_WRAP(VUID-FragDepth-FragDepth-04216);
  1422. case 4217:
  1423. return VUID_WRAP(VUID-FragInvocationCountEXT-FragInvocationCountEXT-04217);
  1424. case 4218:
  1425. return VUID_WRAP(VUID-FragInvocationCountEXT-FragInvocationCountEXT-04218);
  1426. case 4219:
  1427. return VUID_WRAP(VUID-FragInvocationCountEXT-FragInvocationCountEXT-04219);
  1428. case 4220:
  1429. return VUID_WRAP(VUID-FragSizeEXT-FragSizeEXT-04220);
  1430. case 4221:
  1431. return VUID_WRAP(VUID-FragSizeEXT-FragSizeEXT-04221);
  1432. case 4222:
  1433. return VUID_WRAP(VUID-FragSizeEXT-FragSizeEXT-04222);
  1434. case 4223:
  1435. return VUID_WRAP(VUID-FragStencilRefEXT-FragStencilRefEXT-04223);
  1436. case 4224:
  1437. return VUID_WRAP(VUID-FragStencilRefEXT-FragStencilRefEXT-04224);
  1438. case 4225:
  1439. return VUID_WRAP(VUID-FragStencilRefEXT-FragStencilRefEXT-04225);
  1440. case 4229:
  1441. return VUID_WRAP(VUID-FrontFacing-FrontFacing-04229);
  1442. case 4230:
  1443. return VUID_WRAP(VUID-FrontFacing-FrontFacing-04230);
  1444. case 4231:
  1445. return VUID_WRAP(VUID-FrontFacing-FrontFacing-04231);
  1446. case 4232:
  1447. return VUID_WRAP(VUID-FullyCoveredEXT-FullyCoveredEXT-04232);
  1448. case 4233:
  1449. return VUID_WRAP(VUID-FullyCoveredEXT-FullyCoveredEXT-04233);
  1450. case 4234:
  1451. return VUID_WRAP(VUID-FullyCoveredEXT-FullyCoveredEXT-04234);
  1452. case 4236:
  1453. return VUID_WRAP(VUID-GlobalInvocationId-GlobalInvocationId-04236);
  1454. case 4237:
  1455. return VUID_WRAP(VUID-GlobalInvocationId-GlobalInvocationId-04237);
  1456. case 4238:
  1457. return VUID_WRAP(VUID-GlobalInvocationId-GlobalInvocationId-04238);
  1458. case 4239:
  1459. return VUID_WRAP(VUID-HelperInvocation-HelperInvocation-04239);
  1460. case 4240:
  1461. return VUID_WRAP(VUID-HelperInvocation-HelperInvocation-04240);
  1462. case 4241:
  1463. return VUID_WRAP(VUID-HelperInvocation-HelperInvocation-04241);
  1464. case 4242:
  1465. return VUID_WRAP(VUID-HitKindKHR-HitKindKHR-04242);
  1466. case 4243:
  1467. return VUID_WRAP(VUID-HitKindKHR-HitKindKHR-04243);
  1468. case 4244:
  1469. return VUID_WRAP(VUID-HitKindKHR-HitKindKHR-04244);
  1470. case 4245:
  1471. return VUID_WRAP(VUID-HitTNV-HitTNV-04245);
  1472. case 4246:
  1473. return VUID_WRAP(VUID-HitTNV-HitTNV-04246);
  1474. case 4247:
  1475. return VUID_WRAP(VUID-HitTNV-HitTNV-04247);
  1476. case 4248:
  1477. return VUID_WRAP(VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04248);
  1478. case 4249:
  1479. return VUID_WRAP(VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04249);
  1480. case 4250:
  1481. return VUID_WRAP(VUID-IncomingRayFlagsKHR-IncomingRayFlagsKHR-04250);
  1482. case 4251:
  1483. return VUID_WRAP(VUID-InstanceCustomIndexKHR-InstanceCustomIndexKHR-04251);
  1484. case 4252:
  1485. return VUID_WRAP(VUID-InstanceCustomIndexKHR-InstanceCustomIndexKHR-04252);
  1486. case 4253:
  1487. return VUID_WRAP(VUID-InstanceCustomIndexKHR-InstanceCustomIndexKHR-04253);
  1488. case 4254:
  1489. return VUID_WRAP(VUID-InstanceId-InstanceId-04254);
  1490. case 4255:
  1491. return VUID_WRAP(VUID-InstanceId-InstanceId-04255);
  1492. case 4256:
  1493. return VUID_WRAP(VUID-InstanceId-InstanceId-04256);
  1494. case 4257:
  1495. return VUID_WRAP(VUID-InvocationId-InvocationId-04257);
  1496. case 4258:
  1497. return VUID_WRAP(VUID-InvocationId-InvocationId-04258);
  1498. case 4259:
  1499. return VUID_WRAP(VUID-InvocationId-InvocationId-04259);
  1500. case 4263:
  1501. return VUID_WRAP(VUID-InstanceIndex-InstanceIndex-04263);
  1502. case 4264:
  1503. return VUID_WRAP(VUID-InstanceIndex-InstanceIndex-04264);
  1504. case 4265:
  1505. return VUID_WRAP(VUID-InstanceIndex-InstanceIndex-04265);
  1506. case 4266:
  1507. return VUID_WRAP(VUID-LaunchIdKHR-LaunchIdKHR-04266);
  1508. case 4267:
  1509. return VUID_WRAP(VUID-LaunchIdKHR-LaunchIdKHR-04267);
  1510. case 4268:
  1511. return VUID_WRAP(VUID-LaunchIdKHR-LaunchIdKHR-04268);
  1512. case 4269:
  1513. return VUID_WRAP(VUID-LaunchSizeKHR-LaunchSizeKHR-04269);
  1514. case 4270:
  1515. return VUID_WRAP(VUID-LaunchSizeKHR-LaunchSizeKHR-04270);
  1516. case 4271:
  1517. return VUID_WRAP(VUID-LaunchSizeKHR-LaunchSizeKHR-04271);
  1518. case 4272:
  1519. return VUID_WRAP(VUID-Layer-Layer-04272);
  1520. case 4273:
  1521. return VUID_WRAP(VUID-Layer-Layer-04273);
  1522. case 4274:
  1523. return VUID_WRAP(VUID-Layer-Layer-04274);
  1524. case 4275:
  1525. return VUID_WRAP(VUID-Layer-Layer-04275);
  1526. case 4276:
  1527. return VUID_WRAP(VUID-Layer-Layer-04276);
  1528. case 4281:
  1529. return VUID_WRAP(VUID-LocalInvocationId-LocalInvocationId-04281);
  1530. case 4282:
  1531. return VUID_WRAP(VUID-LocalInvocationId-LocalInvocationId-04282);
  1532. case 4283:
  1533. return VUID_WRAP(VUID-LocalInvocationId-LocalInvocationId-04283);
  1534. case 4293:
  1535. return VUID_WRAP(VUID-NumSubgroups-NumSubgroups-04293);
  1536. case 4294:
  1537. return VUID_WRAP(VUID-NumSubgroups-NumSubgroups-04294);
  1538. case 4295:
  1539. return VUID_WRAP(VUID-NumSubgroups-NumSubgroups-04295);
  1540. case 4296:
  1541. return VUID_WRAP(VUID-NumWorkgroups-NumWorkgroups-04296);
  1542. case 4297:
  1543. return VUID_WRAP(VUID-NumWorkgroups-NumWorkgroups-04297);
  1544. case 4298:
  1545. return VUID_WRAP(VUID-NumWorkgroups-NumWorkgroups-04298);
  1546. case 4299:
  1547. return VUID_WRAP(VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04299);
  1548. case 4300:
  1549. return VUID_WRAP(VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04300);
  1550. case 4301:
  1551. return VUID_WRAP(VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04301);
  1552. case 4302:
  1553. return VUID_WRAP(VUID-ObjectRayOriginKHR-ObjectRayOriginKHR-04302);
  1554. case 4303:
  1555. return VUID_WRAP(VUID-ObjectRayOriginKHR-ObjectRayOriginKHR-04303);
  1556. case 4304:
  1557. return VUID_WRAP(VUID-ObjectRayOriginKHR-ObjectRayOriginKHR-04304);
  1558. case 4305:
  1559. return VUID_WRAP(VUID-ObjectToWorldKHR-ObjectToWorldKHR-04305);
  1560. case 4306:
  1561. return VUID_WRAP(VUID-ObjectToWorldKHR-ObjectToWorldKHR-04306);
  1562. case 4307:
  1563. return VUID_WRAP(VUID-ObjectToWorldKHR-ObjectToWorldKHR-04307);
  1564. case 4308:
  1565. return VUID_WRAP(VUID-PatchVertices-PatchVertices-04308);
  1566. case 4309:
  1567. return VUID_WRAP(VUID-PatchVertices-PatchVertices-04309);
  1568. case 4310:
  1569. return VUID_WRAP(VUID-PatchVertices-PatchVertices-04310);
  1570. case 4311:
  1571. return VUID_WRAP(VUID-PointCoord-PointCoord-04311);
  1572. case 4312:
  1573. return VUID_WRAP(VUID-PointCoord-PointCoord-04312);
  1574. case 4313:
  1575. return VUID_WRAP(VUID-PointCoord-PointCoord-04313);
  1576. case 4314:
  1577. return VUID_WRAP(VUID-PointSize-PointSize-04314);
  1578. case 4315:
  1579. return VUID_WRAP(VUID-PointSize-PointSize-04315);
  1580. case 4316:
  1581. return VUID_WRAP(VUID-PointSize-PointSize-04316);
  1582. case 4317:
  1583. return VUID_WRAP(VUID-PointSize-PointSize-04317);
  1584. case 4318:
  1585. return VUID_WRAP(VUID-Position-Position-04318);
  1586. case 4319:
  1587. return VUID_WRAP(VUID-Position-Position-04319);
  1588. case 4320:
  1589. return VUID_WRAP(VUID-Position-Position-04320);
  1590. case 4321:
  1591. return VUID_WRAP(VUID-Position-Position-04321);
  1592. case 4330:
  1593. return VUID_WRAP(VUID-PrimitiveId-PrimitiveId-04330);
  1594. case 4334:
  1595. return VUID_WRAP(VUID-PrimitiveId-PrimitiveId-04334);
  1596. case 4337:
  1597. return VUID_WRAP(VUID-PrimitiveId-PrimitiveId-04337);
  1598. case 4345:
  1599. return VUID_WRAP(VUID-RayGeometryIndexKHR-RayGeometryIndexKHR-04345);
  1600. case 4346:
  1601. return VUID_WRAP(VUID-RayGeometryIndexKHR-RayGeometryIndexKHR-04346);
  1602. case 4347:
  1603. return VUID_WRAP(VUID-RayGeometryIndexKHR-RayGeometryIndexKHR-04347);
  1604. case 4348:
  1605. return VUID_WRAP(VUID-RayTmaxKHR-RayTmaxKHR-04348);
  1606. case 4349:
  1607. return VUID_WRAP(VUID-RayTmaxKHR-RayTmaxKHR-04349);
  1608. case 4350:
  1609. return VUID_WRAP(VUID-RayTmaxKHR-RayTmaxKHR-04350);
  1610. case 4351:
  1611. return VUID_WRAP(VUID-RayTminKHR-RayTminKHR-04351);
  1612. case 4352:
  1613. return VUID_WRAP(VUID-RayTminKHR-RayTminKHR-04352);
  1614. case 4353:
  1615. return VUID_WRAP(VUID-RayTminKHR-RayTminKHR-04353);
  1616. case 4354:
  1617. return VUID_WRAP(VUID-SampleId-SampleId-04354);
  1618. case 4355:
  1619. return VUID_WRAP(VUID-SampleId-SampleId-04355);
  1620. case 4356:
  1621. return VUID_WRAP(VUID-SampleId-SampleId-04356);
  1622. case 4357:
  1623. return VUID_WRAP(VUID-SampleMask-SampleMask-04357);
  1624. case 4358:
  1625. return VUID_WRAP(VUID-SampleMask-SampleMask-04358);
  1626. case 4359:
  1627. return VUID_WRAP(VUID-SampleMask-SampleMask-04359);
  1628. case 4360:
  1629. return VUID_WRAP(VUID-SamplePosition-SamplePosition-04360);
  1630. case 4361:
  1631. return VUID_WRAP(VUID-SamplePosition-SamplePosition-04361);
  1632. case 4362:
  1633. return VUID_WRAP(VUID-SamplePosition-SamplePosition-04362);
  1634. case 4367:
  1635. return VUID_WRAP(VUID-SubgroupId-SubgroupId-04367);
  1636. case 4368:
  1637. return VUID_WRAP(VUID-SubgroupId-SubgroupId-04368);
  1638. case 4369:
  1639. return VUID_WRAP(VUID-SubgroupId-SubgroupId-04369);
  1640. case 4370:
  1641. return VUID_WRAP(VUID-SubgroupEqMask-SubgroupEqMask-04370);
  1642. case 4371:
  1643. return VUID_WRAP(VUID-SubgroupEqMask-SubgroupEqMask-04371);
  1644. case 4372:
  1645. return VUID_WRAP(VUID-SubgroupGeMask-SubgroupGeMask-04372);
  1646. case 4373:
  1647. return VUID_WRAP(VUID-SubgroupGeMask-SubgroupGeMask-04373);
  1648. case 4374:
  1649. return VUID_WRAP(VUID-SubgroupGtMask-SubgroupGtMask-04374);
  1650. case 4375:
  1651. return VUID_WRAP(VUID-SubgroupGtMask-SubgroupGtMask-04375);
  1652. case 4376:
  1653. return VUID_WRAP(VUID-SubgroupLeMask-SubgroupLeMask-04376);
  1654. case 4377:
  1655. return VUID_WRAP(VUID-SubgroupLeMask-SubgroupLeMask-04377);
  1656. case 4378:
  1657. return VUID_WRAP(VUID-SubgroupLtMask-SubgroupLtMask-04378);
  1658. case 4379:
  1659. return VUID_WRAP(VUID-SubgroupLtMask-SubgroupLtMask-04379);
  1660. case 4380:
  1661. return VUID_WRAP(VUID-SubgroupLocalInvocationId-SubgroupLocalInvocationId-04380);
  1662. case 4381:
  1663. return VUID_WRAP(VUID-SubgroupLocalInvocationId-SubgroupLocalInvocationId-04381);
  1664. case 4382:
  1665. return VUID_WRAP(VUID-SubgroupSize-SubgroupSize-04382);
  1666. case 4383:
  1667. return VUID_WRAP(VUID-SubgroupSize-SubgroupSize-04383);
  1668. case 4387:
  1669. return VUID_WRAP(VUID-TessCoord-TessCoord-04387);
  1670. case 4388:
  1671. return VUID_WRAP(VUID-TessCoord-TessCoord-04388);
  1672. case 4389:
  1673. return VUID_WRAP(VUID-TessCoord-TessCoord-04389);
  1674. case 4390:
  1675. return VUID_WRAP(VUID-TessLevelOuter-TessLevelOuter-04390);
  1676. case 4391:
  1677. return VUID_WRAP(VUID-TessLevelOuter-TessLevelOuter-04391);
  1678. case 4392:
  1679. return VUID_WRAP(VUID-TessLevelOuter-TessLevelOuter-04392);
  1680. case 4393:
  1681. return VUID_WRAP(VUID-TessLevelOuter-TessLevelOuter-04393);
  1682. case 4394:
  1683. return VUID_WRAP(VUID-TessLevelInner-TessLevelInner-04394);
  1684. case 4395:
  1685. return VUID_WRAP(VUID-TessLevelInner-TessLevelInner-04395);
  1686. case 4396:
  1687. return VUID_WRAP(VUID-TessLevelInner-TessLevelInner-04396);
  1688. case 4397:
  1689. return VUID_WRAP(VUID-TessLevelInner-TessLevelInner-04397);
  1690. case 4398:
  1691. return VUID_WRAP(VUID-VertexIndex-VertexIndex-04398);
  1692. case 4399:
  1693. return VUID_WRAP(VUID-VertexIndex-VertexIndex-04399);
  1694. case 4400:
  1695. return VUID_WRAP(VUID-VertexIndex-VertexIndex-04400);
  1696. case 4401:
  1697. return VUID_WRAP(VUID-ViewIndex-ViewIndex-04401);
  1698. case 4402:
  1699. return VUID_WRAP(VUID-ViewIndex-ViewIndex-04402);
  1700. case 4403:
  1701. return VUID_WRAP(VUID-ViewIndex-ViewIndex-04403);
  1702. case 4404:
  1703. return VUID_WRAP(VUID-ViewportIndex-ViewportIndex-04404);
  1704. case 4405:
  1705. return VUID_WRAP(VUID-ViewportIndex-ViewportIndex-04405);
  1706. case 4406:
  1707. return VUID_WRAP(VUID-ViewportIndex-ViewportIndex-04406);
  1708. case 4407:
  1709. return VUID_WRAP(VUID-ViewportIndex-ViewportIndex-04407);
  1710. case 4408:
  1711. return VUID_WRAP(VUID-ViewportIndex-ViewportIndex-04408);
  1712. case 4422:
  1713. return VUID_WRAP(VUID-WorkgroupId-WorkgroupId-04422);
  1714. case 4423:
  1715. return VUID_WRAP(VUID-WorkgroupId-WorkgroupId-04423);
  1716. case 4424:
  1717. return VUID_WRAP(VUID-WorkgroupId-WorkgroupId-04424);
  1718. case 4425:
  1719. return VUID_WRAP(VUID-WorkgroupSize-WorkgroupSize-04425);
  1720. case 4426:
  1721. return VUID_WRAP(VUID-WorkgroupSize-WorkgroupSize-04426);
  1722. case 4427:
  1723. return VUID_WRAP(VUID-WorkgroupSize-WorkgroupSize-04427);
  1724. case 4428:
  1725. return VUID_WRAP(VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04428);
  1726. case 4429:
  1727. return VUID_WRAP(VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04429);
  1728. case 4430:
  1729. return VUID_WRAP(VUID-WorldRayDirectionKHR-WorldRayDirectionKHR-04430);
  1730. case 4431:
  1731. return VUID_WRAP(VUID-WorldRayOriginKHR-WorldRayOriginKHR-04431);
  1732. case 4432:
  1733. return VUID_WRAP(VUID-WorldRayOriginKHR-WorldRayOriginKHR-04432);
  1734. case 4433:
  1735. return VUID_WRAP(VUID-WorldRayOriginKHR-WorldRayOriginKHR-04433);
  1736. case 4434:
  1737. return VUID_WRAP(VUID-WorldToObjectKHR-WorldToObjectKHR-04434);
  1738. case 4435:
  1739. return VUID_WRAP(VUID-WorldToObjectKHR-WorldToObjectKHR-04435);
  1740. case 4436:
  1741. return VUID_WRAP(VUID-WorldToObjectKHR-WorldToObjectKHR-04436);
  1742. case 4484:
  1743. return VUID_WRAP(VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-04484);
  1744. case 4485:
  1745. return VUID_WRAP(VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-04485);
  1746. case 4486:
  1747. return VUID_WRAP(VUID-PrimitiveShadingRateKHR-PrimitiveShadingRateKHR-04486);
  1748. case 4490:
  1749. return VUID_WRAP(VUID-ShadingRateKHR-ShadingRateKHR-04490);
  1750. case 4491:
  1751. return VUID_WRAP(VUID-ShadingRateKHR-ShadingRateKHR-04491);
  1752. case 4492:
  1753. return VUID_WRAP(VUID-ShadingRateKHR-ShadingRateKHR-04492);
  1754. case 4633:
  1755. return VUID_WRAP(VUID-StandaloneSpirv-None-04633);
  1756. case 4634:
  1757. return VUID_WRAP(VUID-StandaloneSpirv-None-04634);
  1758. case 4635:
  1759. return VUID_WRAP(VUID-StandaloneSpirv-None-04635);
  1760. case 4636:
  1761. return VUID_WRAP(VUID-StandaloneSpirv-None-04636);
  1762. case 4637:
  1763. return VUID_WRAP(VUID-StandaloneSpirv-None-04637);
  1764. case 4638:
  1765. return VUID_WRAP(VUID-StandaloneSpirv-None-04638);
  1766. case 7321:
  1767. return VUID_WRAP(VUID-StandaloneSpirv-None-07321);
  1768. case 4640:
  1769. return VUID_WRAP(VUID-StandaloneSpirv-None-04640);
  1770. case 4641:
  1771. return VUID_WRAP(VUID-StandaloneSpirv-None-04641);
  1772. case 4642:
  1773. return VUID_WRAP(VUID-StandaloneSpirv-None-04642);
  1774. case 4643:
  1775. return VUID_WRAP(VUID-StandaloneSpirv-None-04643);
  1776. case 4644:
  1777. return VUID_WRAP(VUID-StandaloneSpirv-None-04644);
  1778. case 4645:
  1779. return VUID_WRAP(VUID-StandaloneSpirv-None-04645);
  1780. case 4651:
  1781. return VUID_WRAP(VUID-StandaloneSpirv-OpVariable-04651);
  1782. case 4652:
  1783. return VUID_WRAP(VUID-StandaloneSpirv-OpReadClockKHR-04652);
  1784. case 4653:
  1785. return VUID_WRAP(VUID-StandaloneSpirv-OriginLowerLeft-04653);
  1786. case 4654:
  1787. return VUID_WRAP(VUID-StandaloneSpirv-PixelCenterInteger-04654);
  1788. case 4655:
  1789. return VUID_WRAP(VUID-StandaloneSpirv-UniformConstant-04655);
  1790. case 4656:
  1791. return VUID_WRAP(VUID-StandaloneSpirv-OpTypeImage-04656);
  1792. case 4657:
  1793. return VUID_WRAP(VUID-StandaloneSpirv-OpTypeImage-04657);
  1794. case 4658:
  1795. return VUID_WRAP(VUID-StandaloneSpirv-OpImageTexelPointer-04658);
  1796. case 4659:
  1797. return VUID_WRAP(VUID-StandaloneSpirv-OpImageQuerySizeLod-04659);
  1798. case 4662:
  1799. return VUID_WRAP(VUID-StandaloneSpirv-Offset-04662);
  1800. case 4663:
  1801. return VUID_WRAP(VUID-StandaloneSpirv-Offset-04663);
  1802. case 4664:
  1803. return VUID_WRAP(VUID-StandaloneSpirv-OpImageGather-04664);
  1804. case 4667:
  1805. return VUID_WRAP(VUID-StandaloneSpirv-None-04667);
  1806. case 4669:
  1807. return VUID_WRAP(VUID-StandaloneSpirv-GLSLShared-04669);
  1808. case 4670:
  1809. return VUID_WRAP(VUID-StandaloneSpirv-Flat-04670);
  1810. case 4675:
  1811. return VUID_WRAP(VUID-StandaloneSpirv-FPRoundingMode-04675);
  1812. case 4677:
  1813. return VUID_WRAP(VUID-StandaloneSpirv-Invariant-04677);
  1814. case 4680:
  1815. return VUID_WRAP(VUID-StandaloneSpirv-OpTypeRuntimeArray-04680);
  1816. case 4682:
  1817. return VUID_WRAP(VUID-StandaloneSpirv-OpControlBarrier-04682);
  1818. case 6426:
  1819. return VUID_WRAP(VUID-StandaloneSpirv-LocalSize-06426); // formally 04683
  1820. case 4685:
  1821. return VUID_WRAP(VUID-StandaloneSpirv-OpGroupNonUniformBallotBitCount-04685);
  1822. case 4686:
  1823. return VUID_WRAP(VUID-StandaloneSpirv-None-04686);
  1824. case 4698:
  1825. return VUID_WRAP(VUID-StandaloneSpirv-RayPayloadKHR-04698);
  1826. case 4699:
  1827. return VUID_WRAP(VUID-StandaloneSpirv-IncomingRayPayloadKHR-04699);
  1828. case 4701:
  1829. return VUID_WRAP(VUID-StandaloneSpirv-HitAttributeKHR-04701);
  1830. case 4703:
  1831. return VUID_WRAP(VUID-StandaloneSpirv-HitAttributeKHR-04703);
  1832. case 4704:
  1833. return VUID_WRAP(VUID-StandaloneSpirv-CallableDataKHR-04704);
  1834. case 4705:
  1835. return VUID_WRAP(VUID-StandaloneSpirv-IncomingCallableDataKHR-04705);
  1836. case 7119:
  1837. return VUID_WRAP(VUID-StandaloneSpirv-ShaderRecordBufferKHR-07119);
  1838. case 4708:
  1839. return VUID_WRAP(VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708);
  1840. case 4710:
  1841. return VUID_WRAP(VUID-StandaloneSpirv-PhysicalStorageBuffer64-04710);
  1842. case 4711:
  1843. return VUID_WRAP(VUID-StandaloneSpirv-OpTypeForwardPointer-04711);
  1844. case 4730:
  1845. return VUID_WRAP(VUID-StandaloneSpirv-OpAtomicStore-04730);
  1846. case 4731:
  1847. return VUID_WRAP(VUID-StandaloneSpirv-OpAtomicLoad-04731);
  1848. case 4732:
  1849. return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04732);
  1850. case 4733:
  1851. return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04733);
  1852. case 4734:
  1853. return VUID_WRAP(VUID-StandaloneSpirv-OpVariable-04734);
  1854. case 4744:
  1855. return VUID_WRAP(VUID-StandaloneSpirv-Flat-04744);
  1856. case 4777:
  1857. return VUID_WRAP(VUID-StandaloneSpirv-OpImage-04777);
  1858. case 4780:
  1859. return VUID_WRAP(VUID-StandaloneSpirv-Result-04780);
  1860. case 4781:
  1861. return VUID_WRAP(VUID-StandaloneSpirv-Base-04781);
  1862. case 4915:
  1863. return VUID_WRAP(VUID-StandaloneSpirv-Location-04915);
  1864. case 4916:
  1865. return VUID_WRAP(VUID-StandaloneSpirv-Location-04916);
  1866. case 4917:
  1867. return VUID_WRAP(VUID-StandaloneSpirv-Location-04917);
  1868. case 4918:
  1869. return VUID_WRAP(VUID-StandaloneSpirv-Location-04918);
  1870. case 4919:
  1871. return VUID_WRAP(VUID-StandaloneSpirv-Location-04919);
  1872. case 4920:
  1873. return VUID_WRAP(VUID-StandaloneSpirv-Component-04920);
  1874. case 4921:
  1875. return VUID_WRAP(VUID-StandaloneSpirv-Component-04921);
  1876. case 4922:
  1877. return VUID_WRAP(VUID-StandaloneSpirv-Component-04922);
  1878. case 4923:
  1879. return VUID_WRAP(VUID-StandaloneSpirv-Component-04923);
  1880. case 4924:
  1881. return VUID_WRAP(VUID-StandaloneSpirv-Component-04924);
  1882. case 6201:
  1883. return VUID_WRAP(VUID-StandaloneSpirv-Flat-06201);
  1884. case 6202:
  1885. return VUID_WRAP(VUID-StandaloneSpirv-Flat-06202);
  1886. case 6214:
  1887. return VUID_WRAP(VUID-StandaloneSpirv-OpTypeImage-06214);
  1888. case 6491:
  1889. return VUID_WRAP(VUID-StandaloneSpirv-DescriptorSet-06491);
  1890. case 6671:
  1891. return VUID_WRAP(VUID-StandaloneSpirv-OpTypeSampledImage-06671);
  1892. case 6672:
  1893. return VUID_WRAP(VUID-StandaloneSpirv-Location-06672);
  1894. case 6674:
  1895. return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-06674);
  1896. case 6675:
  1897. return VUID_WRAP(VUID-StandaloneSpirv-PushConstant-06675);
  1898. case 6676:
  1899. return VUID_WRAP(VUID-StandaloneSpirv-Uniform-06676);
  1900. case 6677:
  1901. return VUID_WRAP(VUID-StandaloneSpirv-UniformConstant-06677);
  1902. case 6678:
  1903. return VUID_WRAP(VUID-StandaloneSpirv-InputAttachmentIndex-06678);
  1904. case 6777:
  1905. return VUID_WRAP(VUID-StandaloneSpirv-PerVertexKHR-06777);
  1906. case 6778:
  1907. return VUID_WRAP(VUID-StandaloneSpirv-Input-06778);
  1908. case 6807:
  1909. return VUID_WRAP(VUID-StandaloneSpirv-Uniform-06807);
  1910. case 6808:
  1911. return VUID_WRAP(VUID-StandaloneSpirv-PushConstant-06808);
  1912. case 6925:
  1913. return VUID_WRAP(VUID-StandaloneSpirv-Uniform-06925);
  1914. case 6997:
  1915. return VUID_WRAP(VUID-StandaloneSpirv-SubgroupVoteKHR-06997);
  1916. case 7102:
  1917. return VUID_WRAP(VUID-StandaloneSpirv-MeshEXT-07102);
  1918. case 7320:
  1919. return VUID_WRAP(VUID-StandaloneSpirv-ExecutionModel-07320);
  1920. case 7290:
  1921. return VUID_WRAP(VUID-StandaloneSpirv-Input-07290);
  1922. case 7650:
  1923. return VUID_WRAP(VUID-StandaloneSpirv-Base-07650);
  1924. case 7651:
  1925. return VUID_WRAP(VUID-StandaloneSpirv-Base-07651);
  1926. case 7652:
  1927. return VUID_WRAP(VUID-StandaloneSpirv-Base-07652);
  1928. default:
  1929. return ""; // unknown id
  1930. }
  1931. // clang-format on
  1932. }
  1933. } // namespace val
  1934. } // namespace spvtools