validation_state.cpp 78 KB

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