spirv_reflect.h 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404
  1. /*
  2. Copyright 2017-2022 Google Inc.
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /*
  14. VERSION HISTORY
  15. 1.0 (2018-03-27) Initial public release
  16. */
  17. // clang-format off
  18. /*!
  19. @file spirv_reflect.h
  20. */
  21. #ifndef SPIRV_REFLECT_H
  22. #define SPIRV_REFLECT_H
  23. #if defined(SPIRV_REFLECT_USE_SYSTEM_SPIRV_H)
  24. #include <spirv/unified1/spirv.h>
  25. #else
  26. #include "./include/spirv/unified1/spirv.h"
  27. #endif
  28. #include <stdint.h>
  29. #include <string.h>
  30. #ifdef _MSC_VER
  31. #define SPV_REFLECT_DEPRECATED(msg_str) __declspec(deprecated("This symbol is deprecated. Details: " msg_str))
  32. #elif defined(__clang__)
  33. #define SPV_REFLECT_DEPRECATED(msg_str) __attribute__((deprecated(msg_str)))
  34. #elif defined(__GNUC__)
  35. #if GCC_VERSION >= 40500
  36. #define SPV_REFLECT_DEPRECATED(msg_str) __attribute__((deprecated(msg_str)))
  37. #else
  38. #define SPV_REFLECT_DEPRECATED(msg_str) __attribute__((deprecated))
  39. #endif
  40. #else
  41. #define SPV_REFLECT_DEPRECATED(msg_str)
  42. #endif
  43. /*! @enum SpvReflectResult
  44. */
  45. typedef enum SpvReflectResult {
  46. SPV_REFLECT_RESULT_SUCCESS,
  47. SPV_REFLECT_RESULT_NOT_READY,
  48. SPV_REFLECT_RESULT_ERROR_PARSE_FAILED,
  49. SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED,
  50. SPV_REFLECT_RESULT_ERROR_RANGE_EXCEEDED,
  51. SPV_REFLECT_RESULT_ERROR_NULL_POINTER,
  52. SPV_REFLECT_RESULT_ERROR_INTERNAL_ERROR,
  53. SPV_REFLECT_RESULT_ERROR_COUNT_MISMATCH,
  54. SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND,
  55. SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_CODE_SIZE,
  56. SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_MAGIC_NUMBER,
  57. SPV_REFLECT_RESULT_ERROR_SPIRV_UNEXPECTED_EOF,
  58. SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_ID_REFERENCE,
  59. SPV_REFLECT_RESULT_ERROR_SPIRV_SET_NUMBER_OVERFLOW,
  60. SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_STORAGE_CLASS,
  61. SPV_REFLECT_RESULT_ERROR_SPIRV_RECURSION,
  62. SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_INSTRUCTION,
  63. SPV_REFLECT_RESULT_ERROR_SPIRV_UNEXPECTED_BLOCK_DATA,
  64. SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_BLOCK_MEMBER_REFERENCE,
  65. SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_ENTRY_POINT,
  66. SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_EXECUTION_MODE,
  67. SPV_REFLECT_RESULT_ERROR_SPIRV_MAX_RECURSIVE_EXCEEDED,
  68. } SpvReflectResult;
  69. /*! @enum SpvReflectModuleFlagBits
  70. SPV_REFLECT_MODULE_FLAG_NO_COPY - Disables copying of SPIR-V code
  71. when a SPIRV-Reflect shader module is created. It is the
  72. responsibility of the calling program to ensure that the pointer
  73. remains valid and the memory it's pointing to is not freed while
  74. SPIRV-Reflect operations are taking place. Freeing the backing
  75. memory will cause undefined behavior or most likely a crash.
  76. This is flag is intended for cases where the memory overhead of
  77. storing the copied SPIR-V is undesirable.
  78. */
  79. typedef enum SpvReflectModuleFlagBits {
  80. SPV_REFLECT_MODULE_FLAG_NONE = 0x00000000,
  81. SPV_REFLECT_MODULE_FLAG_NO_COPY = 0x00000001,
  82. } SpvReflectModuleFlagBits;
  83. typedef uint32_t SpvReflectModuleFlags;
  84. /*! @enum SpvReflectTypeFlagBits
  85. */
  86. typedef enum SpvReflectTypeFlagBits {
  87. SPV_REFLECT_TYPE_FLAG_UNDEFINED = 0x00000000,
  88. SPV_REFLECT_TYPE_FLAG_VOID = 0x00000001,
  89. SPV_REFLECT_TYPE_FLAG_BOOL = 0x00000002,
  90. SPV_REFLECT_TYPE_FLAG_INT = 0x00000004,
  91. SPV_REFLECT_TYPE_FLAG_FLOAT = 0x00000008,
  92. SPV_REFLECT_TYPE_FLAG_VECTOR = 0x00000100,
  93. SPV_REFLECT_TYPE_FLAG_MATRIX = 0x00000200,
  94. SPV_REFLECT_TYPE_FLAG_EXTERNAL_IMAGE = 0x00010000,
  95. SPV_REFLECT_TYPE_FLAG_EXTERNAL_SAMPLER = 0x00020000,
  96. SPV_REFLECT_TYPE_FLAG_EXTERNAL_SAMPLED_IMAGE = 0x00040000,
  97. SPV_REFLECT_TYPE_FLAG_EXTERNAL_BLOCK = 0x00080000,
  98. SPV_REFLECT_TYPE_FLAG_EXTERNAL_ACCELERATION_STRUCTURE = 0x00100000,
  99. SPV_REFLECT_TYPE_FLAG_EXTERNAL_MASK = 0x00FF0000,
  100. SPV_REFLECT_TYPE_FLAG_STRUCT = 0x10000000,
  101. SPV_REFLECT_TYPE_FLAG_ARRAY = 0x20000000,
  102. SPV_REFLECT_TYPE_FLAG_REF = 0x40000000,
  103. } SpvReflectTypeFlagBits;
  104. typedef uint32_t SpvReflectTypeFlags;
  105. /*! @enum SpvReflectDecorationBits
  106. NOTE: HLSL row_major and column_major decorations are reversed
  107. in SPIR-V. Meaning that matrices declrations with row_major
  108. will get reflected as column_major and vice versa. The
  109. row and column decorations get appied during the compilation.
  110. SPIRV-Reflect reads the data as is and does not make any
  111. attempt to correct it to match what's in the source.
  112. The Patch, PerVertex, and PerTask are used for Interface
  113. variables that can have array
  114. */
  115. typedef enum SpvReflectDecorationFlagBits {
  116. SPV_REFLECT_DECORATION_NONE = 0x00000000,
  117. SPV_REFLECT_DECORATION_BLOCK = 0x00000001,
  118. SPV_REFLECT_DECORATION_BUFFER_BLOCK = 0x00000002,
  119. SPV_REFLECT_DECORATION_ROW_MAJOR = 0x00000004,
  120. SPV_REFLECT_DECORATION_COLUMN_MAJOR = 0x00000008,
  121. SPV_REFLECT_DECORATION_BUILT_IN = 0x00000010,
  122. SPV_REFLECT_DECORATION_NOPERSPECTIVE = 0x00000020,
  123. SPV_REFLECT_DECORATION_FLAT = 0x00000040,
  124. SPV_REFLECT_DECORATION_NON_WRITABLE = 0x00000080,
  125. SPV_REFLECT_DECORATION_RELAXED_PRECISION = 0x00000100,
  126. SPV_REFLECT_DECORATION_NON_READABLE = 0x00000200,
  127. SPV_REFLECT_DECORATION_PATCH = 0x00000400,
  128. SPV_REFLECT_DECORATION_PER_VERTEX = 0x00000800,
  129. SPV_REFLECT_DECORATION_PER_TASK = 0x00001000,
  130. SPV_REFLECT_DECORATION_WEIGHT_TEXTURE = 0x00002000,
  131. SPV_REFLECT_DECORATION_BLOCK_MATCH_TEXTURE = 0x00004000,
  132. } SpvReflectDecorationFlagBits;
  133. typedef uint32_t SpvReflectDecorationFlags;
  134. /*! @enum SpvReflectResourceType
  135. */
  136. typedef enum SpvReflectResourceType {
  137. SPV_REFLECT_RESOURCE_FLAG_UNDEFINED = 0x00000000,
  138. SPV_REFLECT_RESOURCE_FLAG_SAMPLER = 0x00000001,
  139. SPV_REFLECT_RESOURCE_FLAG_CBV = 0x00000002,
  140. SPV_REFLECT_RESOURCE_FLAG_SRV = 0x00000004,
  141. SPV_REFLECT_RESOURCE_FLAG_UAV = 0x00000008,
  142. } SpvReflectResourceType;
  143. /*! @enum SpvReflectFormat
  144. */
  145. typedef enum SpvReflectFormat {
  146. SPV_REFLECT_FORMAT_UNDEFINED = 0, // = VK_FORMAT_UNDEFINED
  147. SPV_REFLECT_FORMAT_R16_UINT = 74, // = VK_FORMAT_R16_UINT
  148. SPV_REFLECT_FORMAT_R16_SINT = 75, // = VK_FORMAT_R16_SINT
  149. SPV_REFLECT_FORMAT_R16_SFLOAT = 76, // = VK_FORMAT_R16_SFLOAT
  150. SPV_REFLECT_FORMAT_R16G16_UINT = 81, // = VK_FORMAT_R16G16_UINT
  151. SPV_REFLECT_FORMAT_R16G16_SINT = 82, // = VK_FORMAT_R16G16_SINT
  152. SPV_REFLECT_FORMAT_R16G16_SFLOAT = 83, // = VK_FORMAT_R16G16_SFLOAT
  153. SPV_REFLECT_FORMAT_R16G16B16_UINT = 88, // = VK_FORMAT_R16G16B16_UINT
  154. SPV_REFLECT_FORMAT_R16G16B16_SINT = 89, // = VK_FORMAT_R16G16B16_SINT
  155. SPV_REFLECT_FORMAT_R16G16B16_SFLOAT = 90, // = VK_FORMAT_R16G16B16_SFLOAT
  156. SPV_REFLECT_FORMAT_R16G16B16A16_UINT = 95, // = VK_FORMAT_R16G16B16A16_UINT
  157. SPV_REFLECT_FORMAT_R16G16B16A16_SINT = 96, // = VK_FORMAT_R16G16B16A16_SINT
  158. SPV_REFLECT_FORMAT_R16G16B16A16_SFLOAT = 97, // = VK_FORMAT_R16G16B16A16_SFLOAT
  159. SPV_REFLECT_FORMAT_R32_UINT = 98, // = VK_FORMAT_R32_UINT
  160. SPV_REFLECT_FORMAT_R32_SINT = 99, // = VK_FORMAT_R32_SINT
  161. SPV_REFLECT_FORMAT_R32_SFLOAT = 100, // = VK_FORMAT_R32_SFLOAT
  162. SPV_REFLECT_FORMAT_R32G32_UINT = 101, // = VK_FORMAT_R32G32_UINT
  163. SPV_REFLECT_FORMAT_R32G32_SINT = 102, // = VK_FORMAT_R32G32_SINT
  164. SPV_REFLECT_FORMAT_R32G32_SFLOAT = 103, // = VK_FORMAT_R32G32_SFLOAT
  165. SPV_REFLECT_FORMAT_R32G32B32_UINT = 104, // = VK_FORMAT_R32G32B32_UINT
  166. SPV_REFLECT_FORMAT_R32G32B32_SINT = 105, // = VK_FORMAT_R32G32B32_SINT
  167. SPV_REFLECT_FORMAT_R32G32B32_SFLOAT = 106, // = VK_FORMAT_R32G32B32_SFLOAT
  168. SPV_REFLECT_FORMAT_R32G32B32A32_UINT = 107, // = VK_FORMAT_R32G32B32A32_UINT
  169. SPV_REFLECT_FORMAT_R32G32B32A32_SINT = 108, // = VK_FORMAT_R32G32B32A32_SINT
  170. SPV_REFLECT_FORMAT_R32G32B32A32_SFLOAT = 109, // = VK_FORMAT_R32G32B32A32_SFLOAT
  171. SPV_REFLECT_FORMAT_R64_UINT = 110, // = VK_FORMAT_R64_UINT
  172. SPV_REFLECT_FORMAT_R64_SINT = 111, // = VK_FORMAT_R64_SINT
  173. SPV_REFLECT_FORMAT_R64_SFLOAT = 112, // = VK_FORMAT_R64_SFLOAT
  174. SPV_REFLECT_FORMAT_R64G64_UINT = 113, // = VK_FORMAT_R64G64_UINT
  175. SPV_REFLECT_FORMAT_R64G64_SINT = 114, // = VK_FORMAT_R64G64_SINT
  176. SPV_REFLECT_FORMAT_R64G64_SFLOAT = 115, // = VK_FORMAT_R64G64_SFLOAT
  177. SPV_REFLECT_FORMAT_R64G64B64_UINT = 116, // = VK_FORMAT_R64G64B64_UINT
  178. SPV_REFLECT_FORMAT_R64G64B64_SINT = 117, // = VK_FORMAT_R64G64B64_SINT
  179. SPV_REFLECT_FORMAT_R64G64B64_SFLOAT = 118, // = VK_FORMAT_R64G64B64_SFLOAT
  180. SPV_REFLECT_FORMAT_R64G64B64A64_UINT = 119, // = VK_FORMAT_R64G64B64A64_UINT
  181. SPV_REFLECT_FORMAT_R64G64B64A64_SINT = 120, // = VK_FORMAT_R64G64B64A64_SINT
  182. SPV_REFLECT_FORMAT_R64G64B64A64_SFLOAT = 121, // = VK_FORMAT_R64G64B64A64_SFLOAT
  183. } SpvReflectFormat;
  184. /*! @enum SpvReflectVariableFlagBits
  185. */
  186. enum SpvReflectVariableFlagBits{
  187. SPV_REFLECT_VARIABLE_FLAGS_NONE = 0x00000000,
  188. SPV_REFLECT_VARIABLE_FLAGS_UNUSED = 0x00000001,
  189. // If variable points to a copy of the PhysicalStorageBuffer struct
  190. SPV_REFLECT_VARIABLE_FLAGS_PHYSICAL_POINTER_COPY = 0x00000002,
  191. };
  192. typedef uint32_t SpvReflectVariableFlags;
  193. /*! @enum SpvReflectDescriptorType
  194. */
  195. typedef enum SpvReflectDescriptorType {
  196. SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLER = 0, // = VK_DESCRIPTOR_TYPE_SAMPLER
  197. SPV_REFLECT_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1, // = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
  198. SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2, // = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
  199. SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_IMAGE = 3, // = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
  200. SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER = 4, // = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
  201. SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER = 5, // = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
  202. SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 6, // = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
  203. SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7, // = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
  204. SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8, // = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
  205. SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9, // = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
  206. SPV_REFLECT_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10, // = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
  207. SPV_REFLECT_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR = 1000150000 // = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR
  208. } SpvReflectDescriptorType;
  209. /*! @enum SpvReflectShaderStageFlagBits
  210. */
  211. typedef enum SpvReflectShaderStageFlagBits {
  212. SPV_REFLECT_SHADER_STAGE_VERTEX_BIT = 0x00000001, // = VK_SHADER_STAGE_VERTEX_BIT
  213. SPV_REFLECT_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002, // = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT
  214. SPV_REFLECT_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004, // = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT
  215. SPV_REFLECT_SHADER_STAGE_GEOMETRY_BIT = 0x00000008, // = VK_SHADER_STAGE_GEOMETRY_BIT
  216. SPV_REFLECT_SHADER_STAGE_FRAGMENT_BIT = 0x00000010, // = VK_SHADER_STAGE_FRAGMENT_BIT
  217. SPV_REFLECT_SHADER_STAGE_COMPUTE_BIT = 0x00000020, // = VK_SHADER_STAGE_COMPUTE_BIT
  218. SPV_REFLECT_SHADER_STAGE_TASK_BIT_NV = 0x00000040, // = VK_SHADER_STAGE_TASK_BIT_NV
  219. SPV_REFLECT_SHADER_STAGE_TASK_BIT_EXT = SPV_REFLECT_SHADER_STAGE_TASK_BIT_NV, // = VK_SHADER_STAGE_CALLABLE_BIT_EXT
  220. SPV_REFLECT_SHADER_STAGE_MESH_BIT_NV = 0x00000080, // = VK_SHADER_STAGE_MESH_BIT_NV
  221. SPV_REFLECT_SHADER_STAGE_MESH_BIT_EXT = SPV_REFLECT_SHADER_STAGE_MESH_BIT_NV, // = VK_SHADER_STAGE_CALLABLE_BIT_EXT
  222. SPV_REFLECT_SHADER_STAGE_RAYGEN_BIT_KHR = 0x00000100, // = VK_SHADER_STAGE_RAYGEN_BIT_KHR
  223. SPV_REFLECT_SHADER_STAGE_ANY_HIT_BIT_KHR = 0x00000200, // = VK_SHADER_STAGE_ANY_HIT_BIT_KHR
  224. SPV_REFLECT_SHADER_STAGE_CLOSEST_HIT_BIT_KHR = 0x00000400, // = VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR
  225. SPV_REFLECT_SHADER_STAGE_MISS_BIT_KHR = 0x00000800, // = VK_SHADER_STAGE_MISS_BIT_KHR
  226. SPV_REFLECT_SHADER_STAGE_INTERSECTION_BIT_KHR = 0x00001000, // = VK_SHADER_STAGE_INTERSECTION_BIT_KHR
  227. SPV_REFLECT_SHADER_STAGE_CALLABLE_BIT_KHR = 0x00002000, // = VK_SHADER_STAGE_CALLABLE_BIT_KHR
  228. } SpvReflectShaderStageFlagBits;
  229. /*! @enum SpvReflectGenerator
  230. */
  231. typedef enum SpvReflectGenerator {
  232. SPV_REFLECT_GENERATOR_KHRONOS_LLVM_SPIRV_TRANSLATOR = 6,
  233. SPV_REFLECT_GENERATOR_KHRONOS_SPIRV_TOOLS_ASSEMBLER = 7,
  234. SPV_REFLECT_GENERATOR_KHRONOS_GLSLANG_REFERENCE_FRONT_END = 8,
  235. SPV_REFLECT_GENERATOR_GOOGLE_SHADERC_OVER_GLSLANG = 13,
  236. SPV_REFLECT_GENERATOR_GOOGLE_SPIREGG = 14,
  237. SPV_REFLECT_GENERATOR_GOOGLE_RSPIRV = 15,
  238. SPV_REFLECT_GENERATOR_X_LEGEND_MESA_MESAIR_SPIRV_TRANSLATOR = 16,
  239. SPV_REFLECT_GENERATOR_KHRONOS_SPIRV_TOOLS_LINKER = 17,
  240. SPV_REFLECT_GENERATOR_WINE_VKD3D_SHADER_COMPILER = 18,
  241. SPV_REFLECT_GENERATOR_CLAY_CLAY_SHADER_COMPILER = 19,
  242. } SpvReflectGenerator;
  243. enum {
  244. SPV_REFLECT_MAX_ARRAY_DIMS = 32,
  245. SPV_REFLECT_MAX_DESCRIPTOR_SETS = 64,
  246. };
  247. enum {
  248. SPV_REFLECT_BINDING_NUMBER_DONT_CHANGE = ~0,
  249. SPV_REFLECT_SET_NUMBER_DONT_CHANGE = ~0
  250. };
  251. typedef struct SpvReflectNumericTraits {
  252. struct Scalar {
  253. uint32_t width;
  254. uint32_t signedness;
  255. } scalar;
  256. struct Vector {
  257. uint32_t component_count;
  258. } vector;
  259. struct Matrix {
  260. uint32_t column_count;
  261. uint32_t row_count;
  262. uint32_t stride; // Measured in bytes
  263. } matrix;
  264. } SpvReflectNumericTraits;
  265. typedef struct SpvReflectImageTraits {
  266. SpvDim dim;
  267. uint32_t depth;
  268. uint32_t arrayed;
  269. uint32_t ms; // 0: single-sampled; 1: multisampled
  270. uint32_t sampled;
  271. SpvImageFormat image_format;
  272. } SpvReflectImageTraits;
  273. typedef enum SpvReflectArrayDimType {
  274. SPV_REFLECT_ARRAY_DIM_RUNTIME = 0, // OpTypeRuntimeArray
  275. SPV_REFLECT_ARRAY_DIM_SPEC_CONSTANT = 0xFFFFFFFF // specialization constant
  276. } SpvReflectArrayDimType;
  277. typedef struct SpvReflectArrayTraits {
  278. uint32_t dims_count;
  279. // Each entry is either:
  280. // - specialization constant dimension
  281. // - OpTypeRuntimeArray
  282. // - the array length otherwise
  283. uint32_t dims[SPV_REFLECT_MAX_ARRAY_DIMS];
  284. // Stores Ids for dimensions that are specialization constants
  285. uint32_t spec_constant_op_ids[SPV_REFLECT_MAX_ARRAY_DIMS];
  286. uint32_t stride; // Measured in bytes
  287. } SpvReflectArrayTraits;
  288. typedef struct SpvReflectBindingArrayTraits {
  289. uint32_t dims_count;
  290. uint32_t dims[SPV_REFLECT_MAX_ARRAY_DIMS];
  291. } SpvReflectBindingArrayTraits;
  292. /*! @struct SpvReflectTypeDescription
  293. @brief Information about an OpType* instruction
  294. */
  295. typedef struct SpvReflectTypeDescription {
  296. uint32_t id;
  297. SpvOp op;
  298. const char* type_name;
  299. // Non-NULL if type is member of a struct
  300. const char* struct_member_name;
  301. SpvStorageClass storage_class;
  302. SpvReflectTypeFlags type_flags;
  303. SpvReflectDecorationFlags decoration_flags;
  304. struct Traits {
  305. SpvReflectNumericTraits numeric;
  306. SpvReflectImageTraits image;
  307. SpvReflectArrayTraits array;
  308. } traits;
  309. // If underlying type is a struct (ex. array of structs)
  310. // this gives access to the OpTypeStruct
  311. struct SpvReflectTypeDescription* struct_type_description;
  312. // Some pointers to SpvReflectTypeDescription are really
  313. // just copies of another reference to the same OpType
  314. uint32_t copied;
  315. // @deprecated use struct_type_description instead
  316. uint32_t member_count;
  317. // @deprecated use struct_type_description instead
  318. struct SpvReflectTypeDescription* members;
  319. } SpvReflectTypeDescription;
  320. // -- GODOT begin --
  321. /*! @enum SpvReflectSpecializationConstantType
  322. */
  323. typedef enum SpvReflectSpecializationConstantType {
  324. SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL = 0,
  325. SPV_REFLECT_SPECIALIZATION_CONSTANT_INT = 1,
  326. SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT = 2,
  327. } SpvReflectSpecializationConstantType;
  328. /*! @struct SpvReflectSpecializationConstant
  329. */
  330. typedef struct SpvReflectSpecializationConstant {
  331. const char* name;
  332. uint32_t spirv_id;
  333. uint32_t constant_id;
  334. SpvReflectSpecializationConstantType constant_type;
  335. union {
  336. float float_value;
  337. uint32_t int_bool_value;
  338. } default_value;
  339. } SpvReflectSpecializationConstant;
  340. // -- GODOT end --
  341. /*! @struct SpvReflectInterfaceVariable
  342. @brief The OpVariable that is either an Input or Output to the module
  343. */
  344. typedef struct SpvReflectInterfaceVariable {
  345. uint32_t spirv_id;
  346. const char* name;
  347. uint32_t location;
  348. uint32_t component;
  349. SpvStorageClass storage_class;
  350. const char* semantic;
  351. SpvReflectDecorationFlags decoration_flags;
  352. SpvBuiltIn built_in;
  353. SpvReflectNumericTraits numeric;
  354. SpvReflectArrayTraits array;
  355. uint32_t member_count;
  356. struct SpvReflectInterfaceVariable* members;
  357. SpvReflectFormat format;
  358. // NOTE: SPIR-V shares type references for variables
  359. // that have the same underlying type. This means
  360. // that the same type name will appear for multiple
  361. // variables.
  362. SpvReflectTypeDescription* type_description;
  363. struct {
  364. uint32_t location;
  365. } word_offset;
  366. } SpvReflectInterfaceVariable;
  367. /*! @struct SpvReflectBlockVariable
  368. */
  369. typedef struct SpvReflectBlockVariable {
  370. uint32_t spirv_id;
  371. const char* name;
  372. // For Push Constants, this is the lowest offset of all memebers
  373. uint32_t offset; // Measured in bytes
  374. uint32_t absolute_offset; // Measured in bytes
  375. uint32_t size; // Measured in bytes
  376. uint32_t padded_size; // Measured in bytes
  377. SpvReflectDecorationFlags decoration_flags;
  378. SpvReflectNumericTraits numeric;
  379. SpvReflectArrayTraits array;
  380. SpvReflectVariableFlags flags;
  381. uint32_t member_count;
  382. struct SpvReflectBlockVariable* members;
  383. SpvReflectTypeDescription* type_description;
  384. struct {
  385. uint32_t offset;
  386. } word_offset;
  387. } SpvReflectBlockVariable;
  388. /*! @struct SpvReflectDescriptorBinding
  389. */
  390. typedef struct SpvReflectDescriptorBinding {
  391. uint32_t spirv_id;
  392. const char* name;
  393. uint32_t binding;
  394. uint32_t input_attachment_index;
  395. uint32_t set;
  396. SpvReflectDescriptorType descriptor_type;
  397. SpvReflectResourceType resource_type;
  398. SpvReflectImageTraits image;
  399. SpvReflectBlockVariable block;
  400. SpvReflectBindingArrayTraits array;
  401. uint32_t count;
  402. uint32_t accessed;
  403. uint32_t uav_counter_id;
  404. struct SpvReflectDescriptorBinding* uav_counter_binding;
  405. SpvReflectTypeDescription* type_description;
  406. struct {
  407. uint32_t binding;
  408. uint32_t set;
  409. } word_offset;
  410. SpvReflectDecorationFlags decoration_flags;
  411. } SpvReflectDescriptorBinding;
  412. /*! @struct SpvReflectDescriptorSet
  413. */
  414. typedef struct SpvReflectDescriptorSet {
  415. uint32_t set;
  416. uint32_t binding_count;
  417. SpvReflectDescriptorBinding** bindings;
  418. } SpvReflectDescriptorSet;
  419. typedef enum SpvReflectExecutionModeValue {
  420. SPV_REFLECT_EXECUTION_MODE_SPEC_CONSTANT = 0xFFFFFFFF // specialization constant
  421. } SpvReflectExecutionModeValue;
  422. /*! @struct SpvReflectEntryPoint
  423. */
  424. typedef struct SpvReflectEntryPoint {
  425. const char* name;
  426. uint32_t id;
  427. SpvExecutionModel spirv_execution_model;
  428. SpvReflectShaderStageFlagBits shader_stage;
  429. uint32_t input_variable_count;
  430. SpvReflectInterfaceVariable** input_variables;
  431. uint32_t output_variable_count;
  432. SpvReflectInterfaceVariable** output_variables;
  433. uint32_t interface_variable_count;
  434. SpvReflectInterfaceVariable* interface_variables;
  435. uint32_t descriptor_set_count;
  436. SpvReflectDescriptorSet* descriptor_sets;
  437. uint32_t used_uniform_count;
  438. uint32_t* used_uniforms;
  439. uint32_t used_push_constant_count;
  440. uint32_t* used_push_constants;
  441. uint32_t execution_mode_count;
  442. SpvExecutionMode* execution_modes;
  443. struct LocalSize {
  444. uint32_t x;
  445. uint32_t y;
  446. uint32_t z;
  447. } local_size;
  448. uint32_t invocations; // valid for geometry
  449. uint32_t output_vertices; // valid for geometry, tesselation
  450. } SpvReflectEntryPoint;
  451. /*! @struct SpvReflectCapability
  452. */
  453. typedef struct SpvReflectCapability {
  454. SpvCapability value;
  455. uint32_t word_offset;
  456. } SpvReflectCapability;
  457. /*! @struct SpvReflectShaderModule
  458. */
  459. typedef struct SpvReflectShaderModule {
  460. SpvReflectGenerator generator;
  461. const char* entry_point_name;
  462. uint32_t entry_point_id;
  463. uint32_t entry_point_count;
  464. SpvReflectEntryPoint* entry_points;
  465. SpvSourceLanguage source_language;
  466. uint32_t source_language_version;
  467. const char* source_file;
  468. const char* source_source;
  469. uint32_t capability_count;
  470. SpvReflectCapability* capabilities;
  471. SpvExecutionModel spirv_execution_model; // Uses value(s) from first entry point
  472. SpvReflectShaderStageFlagBits shader_stage; // Uses value(s) from first entry point
  473. uint32_t descriptor_binding_count; // Uses value(s) from first entry point
  474. SpvReflectDescriptorBinding* descriptor_bindings; // Uses value(s) from first entry point
  475. uint32_t descriptor_set_count; // Uses value(s) from first entry point
  476. SpvReflectDescriptorSet descriptor_sets[SPV_REFLECT_MAX_DESCRIPTOR_SETS]; // Uses value(s) from first entry point
  477. uint32_t input_variable_count; // Uses value(s) from first entry point
  478. SpvReflectInterfaceVariable** input_variables; // Uses value(s) from first entry point
  479. uint32_t output_variable_count; // Uses value(s) from first entry point
  480. SpvReflectInterfaceVariable** output_variables; // Uses value(s) from first entry point
  481. uint32_t interface_variable_count; // Uses value(s) from first entry point
  482. SpvReflectInterfaceVariable* interface_variables; // Uses value(s) from first entry point
  483. uint32_t push_constant_block_count; // Uses value(s) from first entry point
  484. SpvReflectBlockVariable* push_constant_blocks; // Uses value(s) from first entry point
  485. // -- GODOT begin --
  486. uint32_t specialization_constant_count;
  487. SpvReflectSpecializationConstant* specialization_constants;
  488. // -- GODOT end --
  489. struct Internal {
  490. SpvReflectModuleFlags module_flags;
  491. size_t spirv_size;
  492. uint32_t* spirv_code;
  493. uint32_t spirv_word_count;
  494. size_t type_description_count;
  495. SpvReflectTypeDescription* type_descriptions;
  496. } * _internal;
  497. } SpvReflectShaderModule;
  498. #if defined(__cplusplus)
  499. extern "C" {
  500. #endif
  501. /*! @fn spvReflectCreateShaderModule
  502. @param size Size in bytes of SPIR-V code.
  503. @param p_code Pointer to SPIR-V code.
  504. @param p_module Pointer to an instance of SpvReflectShaderModule.
  505. @return SPV_REFLECT_RESULT_SUCCESS on success.
  506. */
  507. SpvReflectResult spvReflectCreateShaderModule(
  508. size_t size,
  509. const void* p_code,
  510. SpvReflectShaderModule* p_module
  511. );
  512. /*! @fn spvReflectCreateShaderModule2
  513. @param flags Flags for module creations.
  514. @param size Size in bytes of SPIR-V code.
  515. @param p_code Pointer to SPIR-V code.
  516. @param p_module Pointer to an instance of SpvReflectShaderModule.
  517. @return SPV_REFLECT_RESULT_SUCCESS on success.
  518. */
  519. SpvReflectResult spvReflectCreateShaderModule2(
  520. SpvReflectModuleFlags flags,
  521. size_t size,
  522. const void* p_code,
  523. SpvReflectShaderModule* p_module
  524. );
  525. SPV_REFLECT_DEPRECATED("renamed to spvReflectCreateShaderModule")
  526. SpvReflectResult spvReflectGetShaderModule(
  527. size_t size,
  528. const void* p_code,
  529. SpvReflectShaderModule* p_module
  530. );
  531. /*! @fn spvReflectDestroyShaderModule
  532. @param p_module Pointer to an instance of SpvReflectShaderModule.
  533. */
  534. void spvReflectDestroyShaderModule(SpvReflectShaderModule* p_module);
  535. /*! @fn spvReflectGetCodeSize
  536. @param p_module Pointer to an instance of SpvReflectShaderModule.
  537. @return Returns the size of the SPIR-V in bytes
  538. */
  539. uint32_t spvReflectGetCodeSize(const SpvReflectShaderModule* p_module);
  540. /*! @fn spvReflectGetCode
  541. @param p_module Pointer to an instance of SpvReflectShaderModule.
  542. @return Returns a const pointer to the compiled SPIR-V bytecode.
  543. */
  544. const uint32_t* spvReflectGetCode(const SpvReflectShaderModule* p_module);
  545. /*! @fn spvReflectGetEntryPoint
  546. @param p_module Pointer to an instance of SpvReflectShaderModule.
  547. @param entry_point Name of the requested entry point.
  548. @return Returns a const pointer to the requested entry point,
  549. or NULL if it's not found.
  550. */
  551. const SpvReflectEntryPoint* spvReflectGetEntryPoint(
  552. const SpvReflectShaderModule* p_module,
  553. const char* entry_point
  554. );
  555. /*! @fn spvReflectEnumerateDescriptorBindings
  556. @param p_module Pointer to an instance of SpvReflectShaderModule.
  557. @param p_count If pp_bindings is NULL, the module's descriptor binding
  558. count (across all descriptor sets) will be stored here.
  559. If pp_bindings is not NULL, *p_count must contain the
  560. module's descriptor binding count.
  561. @param pp_bindings If NULL, the module's total descriptor binding count
  562. will be written to *p_count.
  563. If non-NULL, pp_bindings must point to an array with
  564. *p_count entries, where pointers to the module's
  565. descriptor bindings will be written. The caller must not
  566. free the binding pointers written to this array.
  567. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  568. Otherwise, the error code indicates the cause of the
  569. failure.
  570. */
  571. SpvReflectResult spvReflectEnumerateDescriptorBindings(
  572. const SpvReflectShaderModule* p_module,
  573. uint32_t* p_count,
  574. SpvReflectDescriptorBinding** pp_bindings
  575. );
  576. /*! @fn spvReflectEnumerateEntryPointDescriptorBindings
  577. @brief Creates a listing of all descriptor bindings that are used in the
  578. static call tree of the given entry point.
  579. @param p_module Pointer to an instance of SpvReflectShaderModule.
  580. @param entry_point The name of the entry point to get the descriptor bindings for.
  581. @param p_count If pp_bindings is NULL, the entry point's descriptor binding
  582. count (across all descriptor sets) will be stored here.
  583. If pp_bindings is not NULL, *p_count must contain the
  584. entry points's descriptor binding count.
  585. @param pp_bindings If NULL, the entry point's total descriptor binding count
  586. will be written to *p_count.
  587. If non-NULL, pp_bindings must point to an array with
  588. *p_count entries, where pointers to the entry point's
  589. descriptor bindings will be written. The caller must not
  590. free the binding pointers written to this array.
  591. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  592. Otherwise, the error code indicates the cause of the
  593. failure.
  594. */
  595. SpvReflectResult spvReflectEnumerateEntryPointDescriptorBindings(
  596. const SpvReflectShaderModule* p_module,
  597. const char* entry_point,
  598. uint32_t* p_count,
  599. SpvReflectDescriptorBinding** pp_bindings
  600. );
  601. /*! @fn spvReflectEnumerateDescriptorSets
  602. @param p_module Pointer to an instance of SpvReflectShaderModule.
  603. @param p_count If pp_sets is NULL, the module's descriptor set
  604. count will be stored here.
  605. If pp_sets is not NULL, *p_count must contain the
  606. module's descriptor set count.
  607. @param pp_sets If NULL, the module's total descriptor set count
  608. will be written to *p_count.
  609. If non-NULL, pp_sets must point to an array with
  610. *p_count entries, where pointers to the module's
  611. descriptor sets will be written. The caller must not
  612. free the descriptor set pointers written to this array.
  613. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  614. Otherwise, the error code indicates the cause of the
  615. failure.
  616. */
  617. SpvReflectResult spvReflectEnumerateDescriptorSets(
  618. const SpvReflectShaderModule* p_module,
  619. uint32_t* p_count,
  620. SpvReflectDescriptorSet** pp_sets
  621. );
  622. /*! @fn spvReflectEnumerateEntryPointDescriptorSets
  623. @brief Creates a listing of all descriptor sets and their bindings that are
  624. used in the static call tree of a given entry point.
  625. @param p_module Pointer to an instance of SpvReflectShaderModule.
  626. @param entry_point The name of the entry point to get the descriptor bindings for.
  627. @param p_count If pp_sets is NULL, the module's descriptor set
  628. count will be stored here.
  629. If pp_sets is not NULL, *p_count must contain the
  630. module's descriptor set count.
  631. @param pp_sets If NULL, the module's total descriptor set count
  632. will be written to *p_count.
  633. If non-NULL, pp_sets must point to an array with
  634. *p_count entries, where pointers to the module's
  635. descriptor sets will be written. The caller must not
  636. free the descriptor set pointers written to this array.
  637. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  638. Otherwise, the error code indicates the cause of the
  639. failure.
  640. */
  641. SpvReflectResult spvReflectEnumerateEntryPointDescriptorSets(
  642. const SpvReflectShaderModule* p_module,
  643. const char* entry_point,
  644. uint32_t* p_count,
  645. SpvReflectDescriptorSet** pp_sets
  646. );
  647. /*! @fn spvReflectEnumerateInterfaceVariables
  648. @brief If the module contains multiple entry points, this will only get
  649. the interface variables for the first one.
  650. @param p_module Pointer to an instance of SpvReflectShaderModule.
  651. @param p_count If pp_variables is NULL, the module's interface variable
  652. count will be stored here.
  653. If pp_variables is not NULL, *p_count must contain
  654. the module's interface variable count.
  655. @param pp_variables If NULL, the module's interface variable count will be
  656. written to *p_count.
  657. If non-NULL, pp_variables must point to an array with
  658. *p_count entries, where pointers to the module's
  659. interface variables will be written. The caller must not
  660. free the interface variables written to this array.
  661. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  662. Otherwise, the error code indicates the cause of the
  663. failure.
  664. */
  665. SpvReflectResult spvReflectEnumerateInterfaceVariables(
  666. const SpvReflectShaderModule* p_module,
  667. uint32_t* p_count,
  668. SpvReflectInterfaceVariable** pp_variables
  669. );
  670. /*! @fn spvReflectEnumerateEntryPointInterfaceVariables
  671. @brief Enumerate the interface variables for a given entry point.
  672. @param entry_point The name of the entry point to get the interface variables for.
  673. @param p_module Pointer to an instance of SpvReflectShaderModule.
  674. @param p_count If pp_variables is NULL, the entry point's interface variable
  675. count will be stored here.
  676. If pp_variables is not NULL, *p_count must contain
  677. the entry point's interface variable count.
  678. @param pp_variables If NULL, the entry point's interface variable count will be
  679. written to *p_count.
  680. If non-NULL, pp_variables must point to an array with
  681. *p_count entries, where pointers to the entry point's
  682. interface variables will be written. The caller must not
  683. free the interface variables written to this array.
  684. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  685. Otherwise, the error code indicates the cause of the
  686. failure.
  687. */
  688. SpvReflectResult spvReflectEnumerateEntryPointInterfaceVariables(
  689. const SpvReflectShaderModule* p_module,
  690. const char* entry_point,
  691. uint32_t* p_count,
  692. SpvReflectInterfaceVariable** pp_variables
  693. );
  694. /*! @fn spvReflectEnumerateInputVariables
  695. @brief If the module contains multiple entry points, this will only get
  696. the input variables for the first one.
  697. @param p_module Pointer to an instance of SpvReflectShaderModule.
  698. @param p_count If pp_variables is NULL, the module's input variable
  699. count will be stored here.
  700. If pp_variables is not NULL, *p_count must contain
  701. the module's input variable count.
  702. @param pp_variables If NULL, the module's input variable count will be
  703. written to *p_count.
  704. If non-NULL, pp_variables must point to an array with
  705. *p_count entries, where pointers to the module's
  706. input variables will be written. The caller must not
  707. free the interface variables written to this array.
  708. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  709. Otherwise, the error code indicates the cause of the
  710. failure.
  711. */
  712. SpvReflectResult spvReflectEnumerateInputVariables(
  713. const SpvReflectShaderModule* p_module,
  714. uint32_t* p_count,
  715. SpvReflectInterfaceVariable** pp_variables
  716. );
  717. // -- GOODT begin --
  718. /*! @fn spvReflectEnumerateSpecializationConstants
  719. @brief If the module contains multiple entry points, this will only get
  720. the specialization constants for the first one.
  721. @param p_module Pointer to an instance of SpvReflectShaderModule.
  722. @param p_count If pp_constants is NULL, the module's specialization constant
  723. count will be stored here.
  724. If pp_variables is not NULL, *p_count must contain
  725. the module's specialization constant count.
  726. @param pp_variables If NULL, the module's specialization constant count will be
  727. written to *p_count.
  728. If non-NULL, pp_constants must point to an array with
  729. *p_count entries, where pointers to the module's
  730. specialization constants will be written. The caller must not
  731. free the specialization constants written to this array.
  732. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  733. Otherwise, the error code indicates the cause of the
  734. failure.
  735. */
  736. SpvReflectResult spvReflectEnumerateSpecializationConstants(
  737. const SpvReflectShaderModule* p_module,
  738. uint32_t* p_count,
  739. SpvReflectSpecializationConstant** pp_constants
  740. );
  741. // -- GODOT end --
  742. /*! @fn spvReflectEnumerateEntryPointInputVariables
  743. @brief Enumerate the input variables for a given entry point.
  744. @param entry_point The name of the entry point to get the input variables for.
  745. @param p_module Pointer to an instance of SpvReflectShaderModule.
  746. @param p_count If pp_variables is NULL, the entry point's input variable
  747. count will be stored here.
  748. If pp_variables is not NULL, *p_count must contain
  749. the entry point's input variable count.
  750. @param pp_variables If NULL, the entry point's input variable count will be
  751. written to *p_count.
  752. If non-NULL, pp_variables must point to an array with
  753. *p_count entries, where pointers to the entry point's
  754. input variables will be written. The caller must not
  755. free the interface variables written to this array.
  756. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  757. Otherwise, the error code indicates the cause of the
  758. failure.
  759. */
  760. SpvReflectResult spvReflectEnumerateEntryPointInputVariables(
  761. const SpvReflectShaderModule* p_module,
  762. const char* entry_point,
  763. uint32_t* p_count,
  764. SpvReflectInterfaceVariable** pp_variables
  765. );
  766. /*! @fn spvReflectEnumerateOutputVariables
  767. @brief Note: If the module contains multiple entry points, this will only get
  768. the output variables for the first one.
  769. @param p_module Pointer to an instance of SpvReflectShaderModule.
  770. @param p_count If pp_variables is NULL, the module's output variable
  771. count will be stored here.
  772. If pp_variables is not NULL, *p_count must contain
  773. the module's output variable count.
  774. @param pp_variables If NULL, the module's output variable count will be
  775. written to *p_count.
  776. If non-NULL, pp_variables must point to an array with
  777. *p_count entries, where pointers to the module's
  778. output variables will be written. The caller must not
  779. free the interface variables written to this array.
  780. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  781. Otherwise, the error code indicates the cause of the
  782. failure.
  783. */
  784. SpvReflectResult spvReflectEnumerateOutputVariables(
  785. const SpvReflectShaderModule* p_module,
  786. uint32_t* p_count,
  787. SpvReflectInterfaceVariable** pp_variables
  788. );
  789. /*! @fn spvReflectEnumerateEntryPointOutputVariables
  790. @brief Enumerate the output variables for a given entry point.
  791. @param p_module Pointer to an instance of SpvReflectShaderModule.
  792. @param entry_point The name of the entry point to get the output variables for.
  793. @param p_count If pp_variables is NULL, the entry point's output variable
  794. count will be stored here.
  795. If pp_variables is not NULL, *p_count must contain
  796. the entry point's output variable count.
  797. @param pp_variables If NULL, the entry point's output variable count will be
  798. written to *p_count.
  799. If non-NULL, pp_variables must point to an array with
  800. *p_count entries, where pointers to the entry point's
  801. output variables will be written. The caller must not
  802. free the interface variables written to this array.
  803. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  804. Otherwise, the error code indicates the cause of the
  805. failure.
  806. */
  807. SpvReflectResult spvReflectEnumerateEntryPointOutputVariables(
  808. const SpvReflectShaderModule* p_module,
  809. const char* entry_point,
  810. uint32_t* p_count,
  811. SpvReflectInterfaceVariable** pp_variables
  812. );
  813. /*! @fn spvReflectEnumeratePushConstantBlocks
  814. @brief Note: If the module contains multiple entry points, this will only get
  815. the push constant blocks for the first one.
  816. @param p_module Pointer to an instance of SpvReflectShaderModule.
  817. @param p_count If pp_blocks is NULL, the module's push constant
  818. block count will be stored here.
  819. If pp_blocks is not NULL, *p_count must
  820. contain the module's push constant block count.
  821. @param pp_blocks If NULL, the module's push constant block count
  822. will be written to *p_count.
  823. If non-NULL, pp_blocks must point to an
  824. array with *p_count entries, where pointers to
  825. the module's push constant blocks will be written.
  826. The caller must not free the block variables written
  827. to this array.
  828. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  829. Otherwise, the error code indicates the cause of the
  830. failure.
  831. */
  832. SpvReflectResult spvReflectEnumeratePushConstantBlocks(
  833. const SpvReflectShaderModule* p_module,
  834. uint32_t* p_count,
  835. SpvReflectBlockVariable** pp_blocks
  836. );
  837. SPV_REFLECT_DEPRECATED("renamed to spvReflectEnumeratePushConstantBlocks")
  838. SpvReflectResult spvReflectEnumeratePushConstants(
  839. const SpvReflectShaderModule* p_module,
  840. uint32_t* p_count,
  841. SpvReflectBlockVariable** pp_blocks
  842. );
  843. /*! @fn spvReflectEnumerateEntryPointPushConstantBlocks
  844. @brief Enumerate the push constant blocks used in the static call tree of a
  845. given entry point.
  846. @param p_module Pointer to an instance of SpvReflectShaderModule.
  847. @param p_count If pp_blocks is NULL, the entry point's push constant
  848. block count will be stored here.
  849. If pp_blocks is not NULL, *p_count must
  850. contain the entry point's push constant block count.
  851. @param pp_blocks If NULL, the entry point's push constant block count
  852. will be written to *p_count.
  853. If non-NULL, pp_blocks must point to an
  854. array with *p_count entries, where pointers to
  855. the entry point's push constant blocks will be written.
  856. The caller must not free the block variables written
  857. to this array.
  858. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  859. Otherwise, the error code indicates the cause of the
  860. failure.
  861. */
  862. SpvReflectResult spvReflectEnumerateEntryPointPushConstantBlocks(
  863. const SpvReflectShaderModule* p_module,
  864. const char* entry_point,
  865. uint32_t* p_count,
  866. SpvReflectBlockVariable** pp_blocks
  867. );
  868. /*! @fn spvReflectGetDescriptorBinding
  869. @param p_module Pointer to an instance of SpvReflectShaderModule.
  870. @param binding_number The "binding" value of the requested descriptor
  871. binding.
  872. @param set_number The "set" value of the requested descriptor binding.
  873. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  874. written to *p_result. Otherwise, a error code
  875. indicating the cause of the failure will be stored
  876. here.
  877. @return If the module contains a descriptor binding that
  878. matches the provided [binding_number, set_number]
  879. values, a pointer to that binding is returned. The
  880. caller must not free this pointer.
  881. If no match can be found, or if an unrelated error
  882. occurs, the return value will be NULL. Detailed
  883. error results are written to *pResult.
  884. @note If the module contains multiple desriptor bindings
  885. with the same set and binding numbers, there are
  886. no guarantees about which binding will be returned.
  887. */
  888. const SpvReflectDescriptorBinding* spvReflectGetDescriptorBinding(
  889. const SpvReflectShaderModule* p_module,
  890. uint32_t binding_number,
  891. uint32_t set_number,
  892. SpvReflectResult* p_result
  893. );
  894. /*! @fn spvReflectGetEntryPointDescriptorBinding
  895. @brief Get the descriptor binding with the given binding number and set
  896. number that is used in the static call tree of a certain entry
  897. point.
  898. @param p_module Pointer to an instance of SpvReflectShaderModule.
  899. @param entry_point The entry point to get the binding from.
  900. @param binding_number The "binding" value of the requested descriptor
  901. binding.
  902. @param set_number The "set" value of the requested descriptor binding.
  903. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  904. written to *p_result. Otherwise, a error code
  905. indicating the cause of the failure will be stored
  906. here.
  907. @return If the entry point contains a descriptor binding that
  908. matches the provided [binding_number, set_number]
  909. values, a pointer to that binding is returned. The
  910. caller must not free this pointer.
  911. If no match can be found, or if an unrelated error
  912. occurs, the return value will be NULL. Detailed
  913. error results are written to *pResult.
  914. @note If the entry point contains multiple desriptor bindings
  915. with the same set and binding numbers, there are
  916. no guarantees about which binding will be returned.
  917. */
  918. const SpvReflectDescriptorBinding* spvReflectGetEntryPointDescriptorBinding(
  919. const SpvReflectShaderModule* p_module,
  920. const char* entry_point,
  921. uint32_t binding_number,
  922. uint32_t set_number,
  923. SpvReflectResult* p_result
  924. );
  925. /*! @fn spvReflectGetDescriptorSet
  926. @param p_module Pointer to an instance of SpvReflectShaderModule.
  927. @param set_number The "set" value of the requested descriptor set.
  928. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  929. written to *p_result. Otherwise, a error code
  930. indicating the cause of the failure will be stored
  931. here.
  932. @return If the module contains a descriptor set with the
  933. provided set_number, a pointer to that set is
  934. returned. The caller must not free this pointer.
  935. If no match can be found, or if an unrelated error
  936. occurs, the return value will be NULL. Detailed
  937. error results are written to *pResult.
  938. */
  939. const SpvReflectDescriptorSet* spvReflectGetDescriptorSet(
  940. const SpvReflectShaderModule* p_module,
  941. uint32_t set_number,
  942. SpvReflectResult* p_result
  943. );
  944. /*! @fn spvReflectGetEntryPointDescriptorSet
  945. @param p_module Pointer to an instance of SpvReflectShaderModule.
  946. @param entry_point The entry point to get the descriptor set from.
  947. @param set_number The "set" value of the requested descriptor set.
  948. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  949. written to *p_result. Otherwise, a error code
  950. indicating the cause of the failure will be stored
  951. here.
  952. @return If the entry point contains a descriptor set with the
  953. provided set_number, a pointer to that set is
  954. returned. The caller must not free this pointer.
  955. If no match can be found, or if an unrelated error
  956. occurs, the return value will be NULL. Detailed
  957. error results are written to *pResult.
  958. */
  959. const SpvReflectDescriptorSet* spvReflectGetEntryPointDescriptorSet(
  960. const SpvReflectShaderModule* p_module,
  961. const char* entry_point,
  962. uint32_t set_number,
  963. SpvReflectResult* p_result
  964. );
  965. /* @fn spvReflectGetInputVariableByLocation
  966. @param p_module Pointer to an instance of SpvReflectShaderModule.
  967. @param location The "location" value of the requested input variable.
  968. A location of 0xFFFFFFFF will always return NULL
  969. with *p_result == ELEMENT_NOT_FOUND.
  970. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  971. written to *p_result. Otherwise, a error code
  972. indicating the cause of the failure will be stored
  973. here.
  974. @return If the module contains an input interface variable
  975. with the provided location value, a pointer to that
  976. variable is returned. The caller must not free this
  977. pointer.
  978. If no match can be found, or if an unrelated error
  979. occurs, the return value will be NULL. Detailed
  980. error results are written to *pResult.
  981. @note
  982. */
  983. const SpvReflectInterfaceVariable* spvReflectGetInputVariableByLocation(
  984. const SpvReflectShaderModule* p_module,
  985. uint32_t location,
  986. SpvReflectResult* p_result
  987. );
  988. SPV_REFLECT_DEPRECATED("renamed to spvReflectGetInputVariableByLocation")
  989. const SpvReflectInterfaceVariable* spvReflectGetInputVariable(
  990. const SpvReflectShaderModule* p_module,
  991. uint32_t location,
  992. SpvReflectResult* p_result
  993. );
  994. /* @fn spvReflectGetEntryPointInputVariableByLocation
  995. @param p_module Pointer to an instance of SpvReflectShaderModule.
  996. @param entry_point The entry point to get the input variable from.
  997. @param location The "location" value of the requested input variable.
  998. A location of 0xFFFFFFFF will always return NULL
  999. with *p_result == ELEMENT_NOT_FOUND.
  1000. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1001. written to *p_result. Otherwise, a error code
  1002. indicating the cause of the failure will be stored
  1003. here.
  1004. @return If the entry point contains an input interface variable
  1005. with the provided location value, a pointer to that
  1006. variable is returned. The caller must not free this
  1007. pointer.
  1008. If no match can be found, or if an unrelated error
  1009. occurs, the return value will be NULL. Detailed
  1010. error results are written to *pResult.
  1011. @note
  1012. */
  1013. const SpvReflectInterfaceVariable* spvReflectGetEntryPointInputVariableByLocation(
  1014. const SpvReflectShaderModule* p_module,
  1015. const char* entry_point,
  1016. uint32_t location,
  1017. SpvReflectResult* p_result
  1018. );
  1019. /* @fn spvReflectGetInputVariableBySemantic
  1020. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1021. @param semantic The "semantic" value of the requested input variable.
  1022. A semantic of NULL will return NULL.
  1023. A semantic of "" will always return NULL with
  1024. *p_result == ELEMENT_NOT_FOUND.
  1025. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1026. written to *p_result. Otherwise, a error code
  1027. indicating the cause of the failure will be stored
  1028. here.
  1029. @return If the module contains an input interface variable
  1030. with the provided semantic, a pointer to that
  1031. variable is returned. The caller must not free this
  1032. pointer.
  1033. If no match can be found, or if an unrelated error
  1034. occurs, the return value will be NULL. Detailed
  1035. error results are written to *pResult.
  1036. @note
  1037. */
  1038. const SpvReflectInterfaceVariable* spvReflectGetInputVariableBySemantic(
  1039. const SpvReflectShaderModule* p_module,
  1040. const char* semantic,
  1041. SpvReflectResult* p_result
  1042. );
  1043. /* @fn spvReflectGetEntryPointInputVariableBySemantic
  1044. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1045. @param entry_point The entry point to get the input variable from.
  1046. @param semantic The "semantic" value of the requested input variable.
  1047. A semantic of NULL will return NULL.
  1048. A semantic of "" will always return NULL with
  1049. *p_result == ELEMENT_NOT_FOUND.
  1050. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1051. written to *p_result. Otherwise, a error code
  1052. indicating the cause of the failure will be stored
  1053. here.
  1054. @return If the entry point contains an input interface variable
  1055. with the provided semantic, a pointer to that
  1056. variable is returned. The caller must not free this
  1057. pointer.
  1058. If no match can be found, or if an unrelated error
  1059. occurs, the return value will be NULL. Detailed
  1060. error results are written to *pResult.
  1061. @note
  1062. */
  1063. const SpvReflectInterfaceVariable* spvReflectGetEntryPointInputVariableBySemantic(
  1064. const SpvReflectShaderModule* p_module,
  1065. const char* entry_point,
  1066. const char* semantic,
  1067. SpvReflectResult* p_result
  1068. );
  1069. /* @fn spvReflectGetOutputVariableByLocation
  1070. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1071. @param location The "location" value of the requested output variable.
  1072. A location of 0xFFFFFFFF will always return NULL
  1073. with *p_result == ELEMENT_NOT_FOUND.
  1074. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1075. written to *p_result. Otherwise, a error code
  1076. indicating the cause of the failure will be stored
  1077. here.
  1078. @return If the module contains an output interface variable
  1079. with the provided location value, a pointer to that
  1080. variable is returned. The caller must not free this
  1081. pointer.
  1082. If no match can be found, or if an unrelated error
  1083. occurs, the return value will be NULL. Detailed
  1084. error results are written to *pResult.
  1085. @note
  1086. */
  1087. const SpvReflectInterfaceVariable* spvReflectGetOutputVariableByLocation(
  1088. const SpvReflectShaderModule* p_module,
  1089. uint32_t location,
  1090. SpvReflectResult* p_result
  1091. );
  1092. SPV_REFLECT_DEPRECATED("renamed to spvReflectGetOutputVariableByLocation")
  1093. const SpvReflectInterfaceVariable* spvReflectGetOutputVariable(
  1094. const SpvReflectShaderModule* p_module,
  1095. uint32_t location,
  1096. SpvReflectResult* p_result
  1097. );
  1098. /* @fn spvReflectGetEntryPointOutputVariableByLocation
  1099. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1100. @param entry_point The entry point to get the output variable from.
  1101. @param location The "location" value of the requested output variable.
  1102. A location of 0xFFFFFFFF will always return NULL
  1103. with *p_result == ELEMENT_NOT_FOUND.
  1104. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1105. written to *p_result. Otherwise, a error code
  1106. indicating the cause of the failure will be stored
  1107. here.
  1108. @return If the entry point contains an output interface variable
  1109. with the provided location value, a pointer to that
  1110. variable is returned. The caller must not free this
  1111. pointer.
  1112. If no match can be found, or if an unrelated error
  1113. occurs, the return value will be NULL. Detailed
  1114. error results are written to *pResult.
  1115. @note
  1116. */
  1117. const SpvReflectInterfaceVariable* spvReflectGetEntryPointOutputVariableByLocation(
  1118. const SpvReflectShaderModule* p_module,
  1119. const char* entry_point,
  1120. uint32_t location,
  1121. SpvReflectResult* p_result
  1122. );
  1123. /* @fn spvReflectGetOutputVariableBySemantic
  1124. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1125. @param semantic The "semantic" value of the requested output variable.
  1126. A semantic of NULL will return NULL.
  1127. A semantic of "" will always return NULL with
  1128. *p_result == ELEMENT_NOT_FOUND.
  1129. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1130. written to *p_result. Otherwise, a error code
  1131. indicating the cause of the failure will be stored
  1132. here.
  1133. @return If the module contains an output interface variable
  1134. with the provided semantic, a pointer to that
  1135. variable is returned. The caller must not free this
  1136. pointer.
  1137. If no match can be found, or if an unrelated error
  1138. occurs, the return value will be NULL. Detailed
  1139. error results are written to *pResult.
  1140. @note
  1141. */
  1142. const SpvReflectInterfaceVariable* spvReflectGetOutputVariableBySemantic(
  1143. const SpvReflectShaderModule* p_module,
  1144. const char* semantic,
  1145. SpvReflectResult* p_result
  1146. );
  1147. /* @fn spvReflectGetEntryPointOutputVariableBySemantic
  1148. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1149. @param entry_point The entry point to get the output variable from.
  1150. @param semantic The "semantic" value of the requested output variable.
  1151. A semantic of NULL will return NULL.
  1152. A semantic of "" will always return NULL with
  1153. *p_result == ELEMENT_NOT_FOUND.
  1154. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1155. written to *p_result. Otherwise, a error code
  1156. indicating the cause of the failure will be stored
  1157. here.
  1158. @return If the entry point contains an output interface variable
  1159. with the provided semantic, a pointer to that
  1160. variable is returned. The caller must not free this
  1161. pointer.
  1162. If no match can be found, or if an unrelated error
  1163. occurs, the return value will be NULL. Detailed
  1164. error results are written to *pResult.
  1165. @note
  1166. */
  1167. const SpvReflectInterfaceVariable* spvReflectGetEntryPointOutputVariableBySemantic(
  1168. const SpvReflectShaderModule* p_module,
  1169. const char* entry_point,
  1170. const char* semantic,
  1171. SpvReflectResult* p_result
  1172. );
  1173. /*! @fn spvReflectGetPushConstantBlock
  1174. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1175. @param index The index of the desired block within the module's
  1176. array of push constant blocks.
  1177. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1178. written to *p_result. Otherwise, a error code
  1179. indicating the cause of the failure will be stored
  1180. here.
  1181. @return If the provided index is within range, a pointer to
  1182. the corresponding push constant block is returned.
  1183. The caller must not free this pointer.
  1184. If no match can be found, or if an unrelated error
  1185. occurs, the return value will be NULL. Detailed
  1186. error results are written to *pResult.
  1187. */
  1188. const SpvReflectBlockVariable* spvReflectGetPushConstantBlock(
  1189. const SpvReflectShaderModule* p_module,
  1190. uint32_t index,
  1191. SpvReflectResult* p_result
  1192. );
  1193. SPV_REFLECT_DEPRECATED("renamed to spvReflectGetPushConstantBlock")
  1194. const SpvReflectBlockVariable* spvReflectGetPushConstant(
  1195. const SpvReflectShaderModule* p_module,
  1196. uint32_t index,
  1197. SpvReflectResult* p_result
  1198. );
  1199. /*! @fn spvReflectGetEntryPointPushConstantBlock
  1200. @brief Get the push constant block corresponding to the given entry point.
  1201. As by the Vulkan specification there can be no more than one push
  1202. constant block used by a given entry point, so if there is one it will
  1203. be returned, otherwise NULL will be returned.
  1204. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1205. @param entry_point The entry point to get the push constant block from.
  1206. @param p_result If successful, SPV_REFLECT_RESULT_SUCCESS will be
  1207. written to *p_result. Otherwise, a error code
  1208. indicating the cause of the failure will be stored
  1209. here.
  1210. @return If the provided index is within range, a pointer to
  1211. the corresponding push constant block is returned.
  1212. The caller must not free this pointer.
  1213. If no match can be found, or if an unrelated error
  1214. occurs, the return value will be NULL. Detailed
  1215. error results are written to *pResult.
  1216. */
  1217. const SpvReflectBlockVariable* spvReflectGetEntryPointPushConstantBlock(
  1218. const SpvReflectShaderModule* p_module,
  1219. const char* entry_point,
  1220. SpvReflectResult* p_result
  1221. );
  1222. /*! @fn spvReflectChangeDescriptorBindingNumbers
  1223. @brief Assign new set and/or binding numbers to a descriptor binding.
  1224. In addition to updating the reflection data, this function modifies
  1225. the underlying SPIR-V bytecode. The updated code can be retrieved
  1226. with spvReflectGetCode(). If the binding is used in multiple
  1227. entry points within the module, it will be changed in all of them.
  1228. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1229. @param p_binding Pointer to the descriptor binding to modify.
  1230. @param new_binding_number The new binding number to assign to the
  1231. provided descriptor binding.
  1232. To leave the binding number unchanged, pass
  1233. SPV_REFLECT_BINDING_NUMBER_DONT_CHANGE.
  1234. @param new_set_number The new set number to assign to the
  1235. provided descriptor binding. Successfully changing
  1236. a descriptor binding's set number invalidates all
  1237. existing SpvReflectDescriptorBinding and
  1238. SpvReflectDescriptorSet pointers from this module.
  1239. To leave the set number unchanged, pass
  1240. SPV_REFLECT_SET_NUMBER_DONT_CHANGE.
  1241. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  1242. Otherwise, the error code indicates the cause of
  1243. the failure.
  1244. */
  1245. SpvReflectResult spvReflectChangeDescriptorBindingNumbers(
  1246. SpvReflectShaderModule* p_module,
  1247. const SpvReflectDescriptorBinding* p_binding,
  1248. uint32_t new_binding_number,
  1249. uint32_t new_set_number
  1250. );
  1251. SPV_REFLECT_DEPRECATED("Renamed to spvReflectChangeDescriptorBindingNumbers")
  1252. SpvReflectResult spvReflectChangeDescriptorBindingNumber(
  1253. SpvReflectShaderModule* p_module,
  1254. const SpvReflectDescriptorBinding* p_descriptor_binding,
  1255. uint32_t new_binding_number,
  1256. uint32_t optional_new_set_number
  1257. );
  1258. /*! @fn spvReflectChangeDescriptorSetNumber
  1259. @brief Assign a new set number to an entire descriptor set (including
  1260. all descriptor bindings in that set).
  1261. In addition to updating the reflection data, this function modifies
  1262. the underlying SPIR-V bytecode. The updated code can be retrieved
  1263. with spvReflectGetCode(). If the descriptor set is used in
  1264. multiple entry points within the module, it will be modified in all
  1265. of them.
  1266. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1267. @param p_set Pointer to the descriptor binding to modify.
  1268. @param new_set_number The new set number to assign to the
  1269. provided descriptor set, and all its descriptor
  1270. bindings. Successfully changing a descriptor
  1271. binding's set number invalidates all existing
  1272. SpvReflectDescriptorBinding and
  1273. SpvReflectDescriptorSet pointers from this module.
  1274. To leave the set number unchanged, pass
  1275. SPV_REFLECT_SET_NUMBER_DONT_CHANGE.
  1276. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  1277. Otherwise, the error code indicates the cause of
  1278. the failure.
  1279. */
  1280. SpvReflectResult spvReflectChangeDescriptorSetNumber(
  1281. SpvReflectShaderModule* p_module,
  1282. const SpvReflectDescriptorSet* p_set,
  1283. uint32_t new_set_number
  1284. );
  1285. /*! @fn spvReflectChangeInputVariableLocation
  1286. @brief Assign a new location to an input interface variable.
  1287. In addition to updating the reflection data, this function modifies
  1288. the underlying SPIR-V bytecode. The updated code can be retrieved
  1289. with spvReflectGetCode().
  1290. It is the caller's responsibility to avoid assigning the same
  1291. location to multiple input variables. If the input variable is used
  1292. by multiple entry points in the module, it will be changed in all of
  1293. them.
  1294. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1295. @param p_input_variable Pointer to the input variable to update.
  1296. @param new_location The new location to assign to p_input_variable.
  1297. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  1298. Otherwise, the error code indicates the cause of
  1299. the failure.
  1300. */
  1301. SpvReflectResult spvReflectChangeInputVariableLocation(
  1302. SpvReflectShaderModule* p_module,
  1303. const SpvReflectInterfaceVariable* p_input_variable,
  1304. uint32_t new_location
  1305. );
  1306. /*! @fn spvReflectChangeOutputVariableLocation
  1307. @brief Assign a new location to an output interface variable.
  1308. In addition to updating the reflection data, this function modifies
  1309. the underlying SPIR-V bytecode. The updated code can be retrieved
  1310. with spvReflectGetCode().
  1311. It is the caller's responsibility to avoid assigning the same
  1312. location to multiple output variables. If the output variable is used
  1313. by multiple entry points in the module, it will be changed in all of
  1314. them.
  1315. @param p_module Pointer to an instance of SpvReflectShaderModule.
  1316. @param p_output_variable Pointer to the output variable to update.
  1317. @param new_location The new location to assign to p_output_variable.
  1318. @return If successful, returns SPV_REFLECT_RESULT_SUCCESS.
  1319. Otherwise, the error code indicates the cause of
  1320. the failure.
  1321. */
  1322. SpvReflectResult spvReflectChangeOutputVariableLocation(
  1323. SpvReflectShaderModule* p_module,
  1324. const SpvReflectInterfaceVariable* p_output_variable,
  1325. uint32_t new_location
  1326. );
  1327. /*! @fn spvReflectSourceLanguage
  1328. @param source_lang The source language code.
  1329. @return Returns string of source language specified in \a source_lang.
  1330. The caller must not free the memory associated with this string.
  1331. */
  1332. const char* spvReflectSourceLanguage(SpvSourceLanguage source_lang);
  1333. /*! @fn spvReflectBlockVariableTypeName
  1334. @param p_var Pointer to block variable.
  1335. @return Returns string of block variable's type description type name
  1336. or NULL if p_var is NULL.
  1337. */
  1338. const char* spvReflectBlockVariableTypeName(
  1339. const SpvReflectBlockVariable* p_var
  1340. );
  1341. #if defined(__cplusplus)
  1342. };
  1343. #endif
  1344. #if defined(__cplusplus) && !defined(SPIRV_REFLECT_DISABLE_CPP_BINDINGS)
  1345. #include <cstdlib>
  1346. #include <string>
  1347. #include <vector>
  1348. namespace spv_reflect {
  1349. /*! \class ShaderModule
  1350. */
  1351. class ShaderModule {
  1352. public:
  1353. ShaderModule();
  1354. ShaderModule(size_t size, const void* p_code, SpvReflectModuleFlags flags = SPV_REFLECT_MODULE_FLAG_NONE);
  1355. ShaderModule(const std::vector<uint8_t>& code, SpvReflectModuleFlags flags = SPV_REFLECT_MODULE_FLAG_NONE);
  1356. ShaderModule(const std::vector<uint32_t>& code, SpvReflectModuleFlags flags = SPV_REFLECT_MODULE_FLAG_NONE);
  1357. ~ShaderModule();
  1358. ShaderModule(ShaderModule&& other);
  1359. ShaderModule& operator=(ShaderModule&& other);
  1360. SpvReflectResult GetResult() const;
  1361. const SpvReflectShaderModule& GetShaderModule() const;
  1362. uint32_t GetCodeSize() const;
  1363. const uint32_t* GetCode() const;
  1364. const char* GetEntryPointName() const;
  1365. const char* GetSourceFile() const;
  1366. uint32_t GetEntryPointCount() const;
  1367. const char* GetEntryPointName(uint32_t index) const;
  1368. SpvReflectShaderStageFlagBits GetEntryPointShaderStage(uint32_t index) const;
  1369. SpvReflectShaderStageFlagBits GetShaderStage() const;
  1370. SPV_REFLECT_DEPRECATED("Renamed to GetShaderStage")
  1371. SpvReflectShaderStageFlagBits GetVulkanShaderStage() const {
  1372. return GetShaderStage();
  1373. }
  1374. SpvReflectResult EnumerateDescriptorBindings(uint32_t* p_count, SpvReflectDescriptorBinding** pp_bindings) const;
  1375. SpvReflectResult EnumerateEntryPointDescriptorBindings(const char* entry_point, uint32_t* p_count, SpvReflectDescriptorBinding** pp_bindings) const;
  1376. SpvReflectResult EnumerateDescriptorSets( uint32_t* p_count, SpvReflectDescriptorSet** pp_sets) const ;
  1377. SpvReflectResult EnumerateEntryPointDescriptorSets(const char* entry_point, uint32_t* p_count, SpvReflectDescriptorSet** pp_sets) const ;
  1378. SpvReflectResult EnumerateInterfaceVariables(uint32_t* p_count, SpvReflectInterfaceVariable** pp_variables) const;
  1379. SpvReflectResult EnumerateEntryPointInterfaceVariables(const char* entry_point, uint32_t* p_count, SpvReflectInterfaceVariable** pp_variables) const;
  1380. SpvReflectResult EnumerateInputVariables(uint32_t* p_count,SpvReflectInterfaceVariable** pp_variables) const;
  1381. SpvReflectResult EnumerateEntryPointInputVariables(const char* entry_point, uint32_t* p_count, SpvReflectInterfaceVariable** pp_variables) const;
  1382. SpvReflectResult EnumerateOutputVariables(uint32_t* p_count,SpvReflectInterfaceVariable** pp_variables) const;
  1383. SpvReflectResult EnumerateEntryPointOutputVariables(const char* entry_point, uint32_t* p_count, SpvReflectInterfaceVariable** pp_variables) const;
  1384. SpvReflectResult EnumeratePushConstantBlocks(uint32_t* p_count, SpvReflectBlockVariable** pp_blocks) const;
  1385. SpvReflectResult EnumerateEntryPointPushConstantBlocks(const char* entry_point, uint32_t* p_count, SpvReflectBlockVariable** pp_blocks) const;
  1386. SPV_REFLECT_DEPRECATED("Renamed to EnumeratePushConstantBlocks")
  1387. SpvReflectResult EnumeratePushConstants(uint32_t* p_count, SpvReflectBlockVariable** pp_blocks) const {
  1388. return EnumeratePushConstantBlocks(p_count, pp_blocks);
  1389. }
  1390. const SpvReflectDescriptorBinding* GetDescriptorBinding(uint32_t binding_number, uint32_t set_number, SpvReflectResult* p_result = nullptr) const;
  1391. const SpvReflectDescriptorBinding* GetEntryPointDescriptorBinding(const char* entry_point, uint32_t binding_number, uint32_t set_number, SpvReflectResult* p_result = nullptr) const;
  1392. const SpvReflectDescriptorSet* GetDescriptorSet(uint32_t set_number, SpvReflectResult* p_result = nullptr) const;
  1393. const SpvReflectDescriptorSet* GetEntryPointDescriptorSet(const char* entry_point, uint32_t set_number, SpvReflectResult* p_result = nullptr) const;
  1394. const SpvReflectInterfaceVariable* GetInputVariableByLocation(uint32_t location, SpvReflectResult* p_result = nullptr) const;
  1395. SPV_REFLECT_DEPRECATED("Renamed to GetInputVariableByLocation")
  1396. const SpvReflectInterfaceVariable* GetInputVariable(uint32_t location, SpvReflectResult* p_result = nullptr) const {
  1397. return GetInputVariableByLocation(location, p_result);
  1398. }
  1399. const SpvReflectInterfaceVariable* GetEntryPointInputVariableByLocation(const char* entry_point, uint32_t location, SpvReflectResult* p_result = nullptr) const;
  1400. const SpvReflectInterfaceVariable* GetInputVariableBySemantic(const char* semantic, SpvReflectResult* p_result = nullptr) const;
  1401. const SpvReflectInterfaceVariable* GetEntryPointInputVariableBySemantic(const char* entry_point, const char* semantic, SpvReflectResult* p_result = nullptr) const;
  1402. const SpvReflectInterfaceVariable* GetOutputVariableByLocation(uint32_t location, SpvReflectResult* p_result = nullptr) const;
  1403. SPV_REFLECT_DEPRECATED("Renamed to GetOutputVariableByLocation")
  1404. const SpvReflectInterfaceVariable* GetOutputVariable(uint32_t location, SpvReflectResult* p_result = nullptr) const {
  1405. return GetOutputVariableByLocation(location, p_result);
  1406. }
  1407. const SpvReflectInterfaceVariable* GetEntryPointOutputVariableByLocation(const char* entry_point, uint32_t location, SpvReflectResult* p_result = nullptr) const;
  1408. const SpvReflectInterfaceVariable* GetOutputVariableBySemantic(const char* semantic, SpvReflectResult* p_result = nullptr) const;
  1409. const SpvReflectInterfaceVariable* GetEntryPointOutputVariableBySemantic(const char* entry_point, const char* semantic, SpvReflectResult* p_result = nullptr) const;
  1410. const SpvReflectBlockVariable* GetPushConstantBlock(uint32_t index, SpvReflectResult* p_result = nullptr) const;
  1411. SPV_REFLECT_DEPRECATED("Renamed to GetPushConstantBlock")
  1412. const SpvReflectBlockVariable* GetPushConstant(uint32_t index, SpvReflectResult* p_result = nullptr) const {
  1413. return GetPushConstantBlock(index, p_result);
  1414. }
  1415. const SpvReflectBlockVariable* GetEntryPointPushConstantBlock(const char* entry_point, SpvReflectResult* p_result = nullptr) const;
  1416. SpvReflectResult ChangeDescriptorBindingNumbers(const SpvReflectDescriptorBinding* p_binding,
  1417. uint32_t new_binding_number = SPV_REFLECT_BINDING_NUMBER_DONT_CHANGE,
  1418. uint32_t optional_new_set_number = SPV_REFLECT_SET_NUMBER_DONT_CHANGE);
  1419. SPV_REFLECT_DEPRECATED("Renamed to ChangeDescriptorBindingNumbers")
  1420. SpvReflectResult ChangeDescriptorBindingNumber(const SpvReflectDescriptorBinding* p_binding, uint32_t new_binding_number = SPV_REFLECT_BINDING_NUMBER_DONT_CHANGE,
  1421. uint32_t new_set_number = SPV_REFLECT_SET_NUMBER_DONT_CHANGE) {
  1422. return ChangeDescriptorBindingNumbers(p_binding, new_binding_number, new_set_number);
  1423. }
  1424. SpvReflectResult ChangeDescriptorSetNumber(const SpvReflectDescriptorSet* p_set, uint32_t new_set_number = SPV_REFLECT_SET_NUMBER_DONT_CHANGE);
  1425. SpvReflectResult ChangeInputVariableLocation(const SpvReflectInterfaceVariable* p_input_variable, uint32_t new_location);
  1426. SpvReflectResult ChangeOutputVariableLocation(const SpvReflectInterfaceVariable* p_output_variable, uint32_t new_location);
  1427. private:
  1428. // Make noncopyable
  1429. ShaderModule(const ShaderModule&);
  1430. ShaderModule& operator=(const ShaderModule&);
  1431. private:
  1432. mutable SpvReflectResult m_result = SPV_REFLECT_RESULT_NOT_READY;
  1433. SpvReflectShaderModule m_module = {};
  1434. };
  1435. // =================================================================================================
  1436. // ShaderModule
  1437. // =================================================================================================
  1438. /*! @fn ShaderModule
  1439. */
  1440. inline ShaderModule::ShaderModule() {}
  1441. /*! @fn ShaderModule
  1442. @param size
  1443. @param p_code
  1444. */
  1445. inline ShaderModule::ShaderModule(size_t size, const void* p_code, SpvReflectModuleFlags flags) {
  1446. m_result = spvReflectCreateShaderModule2(
  1447. flags,
  1448. size,
  1449. p_code,
  1450. &m_module);
  1451. }
  1452. /*! @fn ShaderModule
  1453. @param code
  1454. */
  1455. inline ShaderModule::ShaderModule(const std::vector<uint8_t>& code, SpvReflectModuleFlags flags) {
  1456. m_result = spvReflectCreateShaderModule2(
  1457. flags,
  1458. code.size(),
  1459. code.data(),
  1460. &m_module);
  1461. }
  1462. /*! @fn ShaderModule
  1463. @param code
  1464. */
  1465. inline ShaderModule::ShaderModule(const std::vector<uint32_t>& code, SpvReflectModuleFlags flags) {
  1466. m_result = spvReflectCreateShaderModule2(
  1467. flags,
  1468. code.size() * sizeof(uint32_t),
  1469. code.data(),
  1470. &m_module);
  1471. }
  1472. /*! @fn ~ShaderModule
  1473. */
  1474. inline ShaderModule::~ShaderModule() {
  1475. spvReflectDestroyShaderModule(&m_module);
  1476. }
  1477. inline ShaderModule::ShaderModule(ShaderModule&& other)
  1478. {
  1479. *this = std::move(other);
  1480. }
  1481. inline ShaderModule& ShaderModule::operator=(ShaderModule&& other)
  1482. {
  1483. m_result = std::move(other.m_result);
  1484. m_module = std::move(other.m_module);
  1485. other.m_module = {};
  1486. return *this;
  1487. }
  1488. /*! @fn GetResult
  1489. @return
  1490. */
  1491. inline SpvReflectResult ShaderModule::GetResult() const {
  1492. return m_result;
  1493. }
  1494. /*! @fn GetShaderModule
  1495. @return
  1496. */
  1497. inline const SpvReflectShaderModule& ShaderModule::GetShaderModule() const {
  1498. return m_module;
  1499. }
  1500. /*! @fn GetCodeSize
  1501. @return
  1502. */
  1503. inline uint32_t ShaderModule::GetCodeSize() const {
  1504. return spvReflectGetCodeSize(&m_module);
  1505. }
  1506. /*! @fn GetCode
  1507. @return
  1508. */
  1509. inline const uint32_t* ShaderModule::GetCode() const {
  1510. return spvReflectGetCode(&m_module);
  1511. }
  1512. /*! @fn GetEntryPoint
  1513. @return Returns entry point
  1514. */
  1515. inline const char* ShaderModule::GetEntryPointName() const {
  1516. return this->GetEntryPointName(0);
  1517. }
  1518. /*! @fn GetEntryPoint
  1519. @return Returns entry point
  1520. */
  1521. inline const char* ShaderModule::GetSourceFile() const {
  1522. return m_module.source_file;
  1523. }
  1524. /*! @fn GetEntryPointCount
  1525. @param
  1526. @return
  1527. */
  1528. inline uint32_t ShaderModule::GetEntryPointCount() const {
  1529. return m_module.entry_point_count;
  1530. }
  1531. /*! @fn GetEntryPointName
  1532. @param index
  1533. @return
  1534. */
  1535. inline const char* ShaderModule::GetEntryPointName(uint32_t index) const {
  1536. return m_module.entry_points[index].name;
  1537. }
  1538. /*! @fn GetEntryPointShaderStage
  1539. @param index
  1540. @return Returns the shader stage for the entry point at \b index
  1541. */
  1542. inline SpvReflectShaderStageFlagBits ShaderModule::GetEntryPointShaderStage(uint32_t index) const {
  1543. return m_module.entry_points[index].shader_stage;
  1544. }
  1545. /*! @fn GetShaderStage
  1546. @return Returns shader stage for the first entry point
  1547. */
  1548. inline SpvReflectShaderStageFlagBits ShaderModule::GetShaderStage() const {
  1549. return m_module.shader_stage;
  1550. }
  1551. /*! @fn EnumerateDescriptorBindings
  1552. @param count
  1553. @param p_binding_numbers
  1554. @param pp_bindings
  1555. @return
  1556. */
  1557. inline SpvReflectResult ShaderModule::EnumerateDescriptorBindings(
  1558. uint32_t* p_count,
  1559. SpvReflectDescriptorBinding** pp_bindings
  1560. ) const
  1561. {
  1562. m_result = spvReflectEnumerateDescriptorBindings(
  1563. &m_module,
  1564. p_count,
  1565. pp_bindings);
  1566. return m_result;
  1567. }
  1568. /*! @fn EnumerateEntryPointDescriptorBindings
  1569. @param entry_point
  1570. @param count
  1571. @param pp_bindings
  1572. @return
  1573. */
  1574. inline SpvReflectResult ShaderModule::EnumerateEntryPointDescriptorBindings(
  1575. const char* entry_point,
  1576. uint32_t* p_count,
  1577. SpvReflectDescriptorBinding** pp_bindings
  1578. ) const
  1579. {
  1580. m_result = spvReflectEnumerateEntryPointDescriptorBindings(
  1581. &m_module,
  1582. entry_point,
  1583. p_count,
  1584. pp_bindings);
  1585. return m_result;
  1586. }
  1587. /*! @fn EnumerateDescriptorSets
  1588. @param count
  1589. @param pp_sets
  1590. @return
  1591. */
  1592. inline SpvReflectResult ShaderModule::EnumerateDescriptorSets(
  1593. uint32_t* p_count,
  1594. SpvReflectDescriptorSet** pp_sets
  1595. ) const
  1596. {
  1597. m_result = spvReflectEnumerateDescriptorSets(
  1598. &m_module,
  1599. p_count,
  1600. pp_sets);
  1601. return m_result;
  1602. }
  1603. /*! @fn EnumerateEntryPointDescriptorSets
  1604. @param entry_point
  1605. @param count
  1606. @param pp_sets
  1607. @return
  1608. */
  1609. inline SpvReflectResult ShaderModule::EnumerateEntryPointDescriptorSets(
  1610. const char* entry_point,
  1611. uint32_t* p_count,
  1612. SpvReflectDescriptorSet** pp_sets
  1613. ) const
  1614. {
  1615. m_result = spvReflectEnumerateEntryPointDescriptorSets(
  1616. &m_module,
  1617. entry_point,
  1618. p_count,
  1619. pp_sets);
  1620. return m_result;
  1621. }
  1622. /*! @fn EnumerateInterfaceVariables
  1623. @param count
  1624. @param pp_variables
  1625. @return
  1626. */
  1627. inline SpvReflectResult ShaderModule::EnumerateInterfaceVariables(
  1628. uint32_t* p_count,
  1629. SpvReflectInterfaceVariable** pp_variables
  1630. ) const
  1631. {
  1632. m_result = spvReflectEnumerateInterfaceVariables(
  1633. &m_module,
  1634. p_count,
  1635. pp_variables);
  1636. return m_result;
  1637. }
  1638. /*! @fn EnumerateEntryPointInterfaceVariables
  1639. @param entry_point
  1640. @param count
  1641. @param pp_variables
  1642. @return
  1643. */
  1644. inline SpvReflectResult ShaderModule::EnumerateEntryPointInterfaceVariables(
  1645. const char* entry_point,
  1646. uint32_t* p_count,
  1647. SpvReflectInterfaceVariable** pp_variables
  1648. ) const
  1649. {
  1650. m_result = spvReflectEnumerateEntryPointInterfaceVariables(
  1651. &m_module,
  1652. entry_point,
  1653. p_count,
  1654. pp_variables);
  1655. return m_result;
  1656. }
  1657. /*! @fn EnumerateInputVariables
  1658. @param count
  1659. @param pp_variables
  1660. @return
  1661. */
  1662. inline SpvReflectResult ShaderModule::EnumerateInputVariables(
  1663. uint32_t* p_count,
  1664. SpvReflectInterfaceVariable** pp_variables
  1665. ) const
  1666. {
  1667. m_result = spvReflectEnumerateInputVariables(
  1668. &m_module,
  1669. p_count,
  1670. pp_variables);
  1671. return m_result;
  1672. }
  1673. /*! @fn EnumerateEntryPointInputVariables
  1674. @param entry_point
  1675. @param count
  1676. @param pp_variables
  1677. @return
  1678. */
  1679. inline SpvReflectResult ShaderModule::EnumerateEntryPointInputVariables(
  1680. const char* entry_point,
  1681. uint32_t* p_count,
  1682. SpvReflectInterfaceVariable** pp_variables
  1683. ) const
  1684. {
  1685. m_result = spvReflectEnumerateEntryPointInputVariables(
  1686. &m_module,
  1687. entry_point,
  1688. p_count,
  1689. pp_variables);
  1690. return m_result;
  1691. }
  1692. /*! @fn EnumerateOutputVariables
  1693. @param count
  1694. @param pp_variables
  1695. @return
  1696. */
  1697. inline SpvReflectResult ShaderModule::EnumerateOutputVariables(
  1698. uint32_t* p_count,
  1699. SpvReflectInterfaceVariable** pp_variables
  1700. ) const
  1701. {
  1702. m_result = spvReflectEnumerateOutputVariables(
  1703. &m_module,
  1704. p_count,
  1705. pp_variables);
  1706. return m_result;
  1707. }
  1708. /*! @fn EnumerateEntryPointOutputVariables
  1709. @param entry_point
  1710. @param count
  1711. @param pp_variables
  1712. @return
  1713. */
  1714. inline SpvReflectResult ShaderModule::EnumerateEntryPointOutputVariables(
  1715. const char* entry_point,
  1716. uint32_t* p_count,
  1717. SpvReflectInterfaceVariable** pp_variables
  1718. ) const
  1719. {
  1720. m_result = spvReflectEnumerateEntryPointOutputVariables(
  1721. &m_module,
  1722. entry_point,
  1723. p_count,
  1724. pp_variables);
  1725. return m_result;
  1726. }
  1727. /*! @fn EnumeratePushConstantBlocks
  1728. @param count
  1729. @param pp_blocks
  1730. @return
  1731. */
  1732. inline SpvReflectResult ShaderModule::EnumeratePushConstantBlocks(
  1733. uint32_t* p_count,
  1734. SpvReflectBlockVariable** pp_blocks
  1735. ) const
  1736. {
  1737. m_result = spvReflectEnumeratePushConstantBlocks(
  1738. &m_module,
  1739. p_count,
  1740. pp_blocks);
  1741. return m_result;
  1742. }
  1743. /*! @fn EnumerateEntryPointPushConstantBlocks
  1744. @param entry_point
  1745. @param count
  1746. @param pp_blocks
  1747. @return
  1748. */
  1749. inline SpvReflectResult ShaderModule::EnumerateEntryPointPushConstantBlocks(
  1750. const char* entry_point,
  1751. uint32_t* p_count,
  1752. SpvReflectBlockVariable** pp_blocks
  1753. ) const
  1754. {
  1755. m_result = spvReflectEnumerateEntryPointPushConstantBlocks(
  1756. &m_module,
  1757. entry_point,
  1758. p_count,
  1759. pp_blocks);
  1760. return m_result;
  1761. }
  1762. /*! @fn GetDescriptorBinding
  1763. @param binding_number
  1764. @param set_number
  1765. @param p_result
  1766. @return
  1767. */
  1768. inline const SpvReflectDescriptorBinding* ShaderModule::GetDescriptorBinding(
  1769. uint32_t binding_number,
  1770. uint32_t set_number,
  1771. SpvReflectResult* p_result
  1772. ) const
  1773. {
  1774. return spvReflectGetDescriptorBinding(
  1775. &m_module,
  1776. binding_number,
  1777. set_number,
  1778. p_result);
  1779. }
  1780. /*! @fn GetEntryPointDescriptorBinding
  1781. @param entry_point
  1782. @param binding_number
  1783. @param set_number
  1784. @param p_result
  1785. @return
  1786. */
  1787. inline const SpvReflectDescriptorBinding* ShaderModule::GetEntryPointDescriptorBinding(
  1788. const char* entry_point,
  1789. uint32_t binding_number,
  1790. uint32_t set_number,
  1791. SpvReflectResult* p_result
  1792. ) const
  1793. {
  1794. return spvReflectGetEntryPointDescriptorBinding(
  1795. &m_module,
  1796. entry_point,
  1797. binding_number,
  1798. set_number,
  1799. p_result);
  1800. }
  1801. /*! @fn GetDescriptorSet
  1802. @param set_number
  1803. @param p_result
  1804. @return
  1805. */
  1806. inline const SpvReflectDescriptorSet* ShaderModule::GetDescriptorSet(
  1807. uint32_t set_number,
  1808. SpvReflectResult* p_result
  1809. ) const
  1810. {
  1811. return spvReflectGetDescriptorSet(
  1812. &m_module,
  1813. set_number,
  1814. p_result);
  1815. }
  1816. /*! @fn GetEntryPointDescriptorSet
  1817. @param entry_point
  1818. @param set_number
  1819. @param p_result
  1820. @return
  1821. */
  1822. inline const SpvReflectDescriptorSet* ShaderModule::GetEntryPointDescriptorSet(
  1823. const char* entry_point,
  1824. uint32_t set_number,
  1825. SpvReflectResult* p_result
  1826. ) const
  1827. {
  1828. return spvReflectGetEntryPointDescriptorSet(
  1829. &m_module,
  1830. entry_point,
  1831. set_number,
  1832. p_result);
  1833. }
  1834. /*! @fn GetInputVariable
  1835. @param location
  1836. @param p_result
  1837. @return
  1838. */
  1839. inline const SpvReflectInterfaceVariable* ShaderModule::GetInputVariableByLocation(
  1840. uint32_t location,
  1841. SpvReflectResult* p_result
  1842. ) const
  1843. {
  1844. return spvReflectGetInputVariableByLocation(
  1845. &m_module,
  1846. location,
  1847. p_result);
  1848. }
  1849. inline const SpvReflectInterfaceVariable* ShaderModule::GetInputVariableBySemantic(
  1850. const char* semantic,
  1851. SpvReflectResult* p_result
  1852. ) const
  1853. {
  1854. return spvReflectGetInputVariableBySemantic(
  1855. &m_module,
  1856. semantic,
  1857. p_result);
  1858. }
  1859. /*! @fn GetEntryPointInputVariable
  1860. @param entry_point
  1861. @param location
  1862. @param p_result
  1863. @return
  1864. */
  1865. inline const SpvReflectInterfaceVariable* ShaderModule::GetEntryPointInputVariableByLocation(
  1866. const char* entry_point,
  1867. uint32_t location,
  1868. SpvReflectResult* p_result
  1869. ) const
  1870. {
  1871. return spvReflectGetEntryPointInputVariableByLocation(
  1872. &m_module,
  1873. entry_point,
  1874. location,
  1875. p_result);
  1876. }
  1877. inline const SpvReflectInterfaceVariable* ShaderModule::GetEntryPointInputVariableBySemantic(
  1878. const char* entry_point,
  1879. const char* semantic,
  1880. SpvReflectResult* p_result
  1881. ) const
  1882. {
  1883. return spvReflectGetEntryPointInputVariableBySemantic(
  1884. &m_module,
  1885. entry_point,
  1886. semantic,
  1887. p_result);
  1888. }
  1889. /*! @fn GetOutputVariable
  1890. @param location
  1891. @param p_result
  1892. @return
  1893. */
  1894. inline const SpvReflectInterfaceVariable* ShaderModule::GetOutputVariableByLocation(
  1895. uint32_t location,
  1896. SpvReflectResult* p_result
  1897. ) const
  1898. {
  1899. return spvReflectGetOutputVariableByLocation(
  1900. &m_module,
  1901. location,
  1902. p_result);
  1903. }
  1904. inline const SpvReflectInterfaceVariable* ShaderModule::GetOutputVariableBySemantic(
  1905. const char* semantic,
  1906. SpvReflectResult* p_result
  1907. ) const
  1908. {
  1909. return spvReflectGetOutputVariableBySemantic(&m_module,
  1910. semantic,
  1911. p_result);
  1912. }
  1913. /*! @fn GetEntryPointOutputVariable
  1914. @param entry_point
  1915. @param location
  1916. @param p_result
  1917. @return
  1918. */
  1919. inline const SpvReflectInterfaceVariable* ShaderModule::GetEntryPointOutputVariableByLocation(
  1920. const char* entry_point,
  1921. uint32_t location,
  1922. SpvReflectResult* p_result
  1923. ) const
  1924. {
  1925. return spvReflectGetEntryPointOutputVariableByLocation(
  1926. &m_module,
  1927. entry_point,
  1928. location,
  1929. p_result);
  1930. }
  1931. inline const SpvReflectInterfaceVariable* ShaderModule::GetEntryPointOutputVariableBySemantic(
  1932. const char* entry_point,
  1933. const char* semantic,
  1934. SpvReflectResult* p_result
  1935. ) const
  1936. {
  1937. return spvReflectGetEntryPointOutputVariableBySemantic(
  1938. &m_module,
  1939. entry_point,
  1940. semantic,
  1941. p_result);
  1942. }
  1943. /*! @fn GetPushConstant
  1944. @param index
  1945. @param p_result
  1946. @return
  1947. */
  1948. inline const SpvReflectBlockVariable* ShaderModule::GetPushConstantBlock(
  1949. uint32_t index,
  1950. SpvReflectResult* p_result
  1951. ) const
  1952. {
  1953. return spvReflectGetPushConstantBlock(
  1954. &m_module,
  1955. index,
  1956. p_result);
  1957. }
  1958. /*! @fn GetEntryPointPushConstant
  1959. @param entry_point
  1960. @param index
  1961. @param p_result
  1962. @return
  1963. */
  1964. inline const SpvReflectBlockVariable* ShaderModule::GetEntryPointPushConstantBlock(
  1965. const char* entry_point,
  1966. SpvReflectResult* p_result
  1967. ) const
  1968. {
  1969. return spvReflectGetEntryPointPushConstantBlock(
  1970. &m_module,
  1971. entry_point,
  1972. p_result);
  1973. }
  1974. /*! @fn ChangeDescriptorBindingNumbers
  1975. @param p_binding
  1976. @param new_binding_number
  1977. @param new_set_number
  1978. @return
  1979. */
  1980. inline SpvReflectResult ShaderModule::ChangeDescriptorBindingNumbers(
  1981. const SpvReflectDescriptorBinding* p_binding,
  1982. uint32_t new_binding_number,
  1983. uint32_t new_set_number
  1984. )
  1985. {
  1986. return spvReflectChangeDescriptorBindingNumbers(
  1987. &m_module,
  1988. p_binding,
  1989. new_binding_number,
  1990. new_set_number);
  1991. }
  1992. /*! @fn ChangeDescriptorSetNumber
  1993. @param p_set
  1994. @param new_set_number
  1995. @return
  1996. */
  1997. inline SpvReflectResult ShaderModule::ChangeDescriptorSetNumber(
  1998. const SpvReflectDescriptorSet* p_set,
  1999. uint32_t new_set_number
  2000. )
  2001. {
  2002. return spvReflectChangeDescriptorSetNumber(
  2003. &m_module,
  2004. p_set,
  2005. new_set_number);
  2006. }
  2007. /*! @fn ChangeInputVariableLocation
  2008. @param p_input_variable
  2009. @param new_location
  2010. @return
  2011. */
  2012. inline SpvReflectResult ShaderModule::ChangeInputVariableLocation(
  2013. const SpvReflectInterfaceVariable* p_input_variable,
  2014. uint32_t new_location)
  2015. {
  2016. return spvReflectChangeInputVariableLocation(
  2017. &m_module,
  2018. p_input_variable,
  2019. new_location);
  2020. }
  2021. /*! @fn ChangeOutputVariableLocation
  2022. @param p_input_variable
  2023. @param new_location
  2024. @return
  2025. */
  2026. inline SpvReflectResult ShaderModule::ChangeOutputVariableLocation(
  2027. const SpvReflectInterfaceVariable* p_output_variable,
  2028. uint32_t new_location)
  2029. {
  2030. return spvReflectChangeOutputVariableLocation(
  2031. &m_module,
  2032. p_output_variable,
  2033. new_location);
  2034. }
  2035. } // namespace spv_reflect
  2036. #endif // defined(__cplusplus) && !defined(SPIRV_REFLECT_DISABLE_CPP_WRAPPER)
  2037. #endif // SPIRV_REFLECT_H
  2038. // clang-format on