spirv_cross_c.h 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. /*
  2. * Copyright 2019-2021 Hans-Kristian Arntzen
  3. * SPDX-License-Identifier: Apache-2.0 OR MIT
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /*
  18. * At your option, you may choose to accept this material under either:
  19. * 1. The Apache License, Version 2.0, found at <http://www.apache.org/licenses/LICENSE-2.0>, or
  20. * 2. The MIT License, found at <http://opensource.org/licenses/MIT>.
  21. */
  22. #ifndef SPIRV_CROSS_C_API_H
  23. #define SPIRV_CROSS_C_API_H
  24. #include <stddef.h>
  25. #include "spirv.h"
  26. /*
  27. * C89-compatible wrapper for SPIRV-Cross' API.
  28. * Documentation here is sparse unless the behavior does not map 1:1 with C++ API.
  29. * It is recommended to look at the canonical C++ API for more detailed information.
  30. */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Bumped if ABI or API breaks backwards compatibility. */
  35. #define SPVC_C_API_VERSION_MAJOR 0
  36. /* Bumped if APIs or enumerations are added in a backwards compatible way. */
  37. #define SPVC_C_API_VERSION_MINOR 68
  38. /* Bumped if internal implementation details change. */
  39. #define SPVC_C_API_VERSION_PATCH 0
  40. #if !defined(SPVC_PUBLIC_API)
  41. #if defined(SPVC_EXPORT_SYMBOLS)
  42. /* Exports symbols. Standard C calling convention is used. */
  43. #if defined(__GNUC__)
  44. #define SPVC_PUBLIC_API __attribute__((visibility("default")))
  45. #elif defined(_MSC_VER)
  46. #define SPVC_PUBLIC_API __declspec(dllexport)
  47. #else
  48. #define SPVC_PUBLIC_API
  49. #endif
  50. #else
  51. #define SPVC_PUBLIC_API
  52. #endif
  53. #endif
  54. /*
  55. * Gets the SPVC_C_API_VERSION_* used to build this library.
  56. * Can be used to check for ABI mismatch if so-versioning did not catch it.
  57. */
  58. SPVC_PUBLIC_API void spvc_get_version(unsigned *major, unsigned *minor, unsigned *patch);
  59. /* Gets a human readable version string to identify which commit a particular binary was created from. */
  60. SPVC_PUBLIC_API const char *spvc_get_commit_revision_and_timestamp(void);
  61. /* These types are opaque to the user. */
  62. typedef struct spvc_context_s *spvc_context;
  63. typedef struct spvc_parsed_ir_s *spvc_parsed_ir;
  64. typedef struct spvc_compiler_s *spvc_compiler;
  65. typedef struct spvc_compiler_options_s *spvc_compiler_options;
  66. typedef struct spvc_resources_s *spvc_resources;
  67. struct spvc_type_s;
  68. typedef const struct spvc_type_s *spvc_type;
  69. typedef struct spvc_constant_s *spvc_constant;
  70. struct spvc_set_s;
  71. typedef const struct spvc_set_s *spvc_set;
  72. /*
  73. * Shallow typedefs. All SPIR-V IDs are plain 32-bit numbers, but this helps communicate which data is used.
  74. * Maps to a SPIRType.
  75. */
  76. typedef SpvId spvc_type_id;
  77. /* Maps to a SPIRVariable. */
  78. typedef SpvId spvc_variable_id;
  79. /* Maps to a SPIRConstant. */
  80. typedef SpvId spvc_constant_id;
  81. /* See C++ API. */
  82. typedef struct spvc_reflected_resource
  83. {
  84. spvc_variable_id id;
  85. spvc_type_id base_type_id;
  86. spvc_type_id type_id;
  87. const char *name;
  88. } spvc_reflected_resource;
  89. typedef struct spvc_reflected_builtin_resource
  90. {
  91. SpvBuiltIn builtin;
  92. spvc_type_id value_type_id;
  93. spvc_reflected_resource resource;
  94. } spvc_reflected_builtin_resource;
  95. /* See C++ API. */
  96. typedef struct spvc_entry_point
  97. {
  98. SpvExecutionModel execution_model;
  99. const char *name;
  100. } spvc_entry_point;
  101. /* See C++ API. */
  102. typedef struct spvc_combined_image_sampler
  103. {
  104. spvc_variable_id combined_id;
  105. spvc_variable_id image_id;
  106. spvc_variable_id sampler_id;
  107. } spvc_combined_image_sampler;
  108. /* See C++ API. */
  109. typedef struct spvc_specialization_constant
  110. {
  111. spvc_constant_id id;
  112. unsigned constant_id;
  113. } spvc_specialization_constant;
  114. /* See C++ API. */
  115. typedef struct spvc_buffer_range
  116. {
  117. unsigned index;
  118. size_t offset;
  119. size_t range;
  120. } spvc_buffer_range;
  121. /* See C++ API. */
  122. typedef struct spvc_hlsl_root_constants
  123. {
  124. unsigned start;
  125. unsigned end;
  126. unsigned binding;
  127. unsigned space;
  128. } spvc_hlsl_root_constants;
  129. /* See C++ API. */
  130. typedef struct spvc_hlsl_vertex_attribute_remap
  131. {
  132. unsigned location;
  133. const char *semantic;
  134. } spvc_hlsl_vertex_attribute_remap;
  135. /*
  136. * Be compatible with non-C99 compilers, which do not have stdbool.
  137. * Only recent MSVC compilers supports this for example, and ideally SPIRV-Cross should be linkable
  138. * from a wide range of compilers in its C wrapper.
  139. */
  140. typedef unsigned char spvc_bool;
  141. #define SPVC_TRUE ((spvc_bool)1)
  142. #define SPVC_FALSE ((spvc_bool)0)
  143. typedef enum spvc_result
  144. {
  145. /* Success. */
  146. SPVC_SUCCESS = 0,
  147. /* The SPIR-V is invalid. Should have been caught by validation ideally. */
  148. SPVC_ERROR_INVALID_SPIRV = -1,
  149. /* The SPIR-V might be valid or invalid, but SPIRV-Cross currently cannot correctly translate this to your target language. */
  150. SPVC_ERROR_UNSUPPORTED_SPIRV = -2,
  151. /* If for some reason we hit this, new or malloc failed. */
  152. SPVC_ERROR_OUT_OF_MEMORY = -3,
  153. /* Invalid API argument. */
  154. SPVC_ERROR_INVALID_ARGUMENT = -4,
  155. SPVC_ERROR_INT_MAX = 0x7fffffff
  156. } spvc_result;
  157. typedef enum spvc_capture_mode
  158. {
  159. /* The Parsed IR payload will be copied, and the handle can be reused to create other compiler instances. */
  160. SPVC_CAPTURE_MODE_COPY = 0,
  161. /*
  162. * The payload will now be owned by the compiler.
  163. * parsed_ir should now be considered a dead blob and must not be used further.
  164. * This is optimal for performance and should be the go-to option.
  165. */
  166. SPVC_CAPTURE_MODE_TAKE_OWNERSHIP = 1,
  167. SPVC_CAPTURE_MODE_INT_MAX = 0x7fffffff
  168. } spvc_capture_mode;
  169. typedef enum spvc_backend
  170. {
  171. /* This backend can only perform reflection, no compiler options are supported. Maps to spirv_cross::Compiler. */
  172. SPVC_BACKEND_NONE = 0,
  173. SPVC_BACKEND_GLSL = 1, /* spirv_cross::CompilerGLSL */
  174. SPVC_BACKEND_HLSL = 2, /* CompilerHLSL */
  175. SPVC_BACKEND_MSL = 3, /* CompilerMSL */
  176. SPVC_BACKEND_CPP = 4, /* CompilerCPP */
  177. SPVC_BACKEND_JSON = 5, /* CompilerReflection w/ JSON backend */
  178. SPVC_BACKEND_INT_MAX = 0x7fffffff
  179. } spvc_backend;
  180. /* Maps to C++ API. */
  181. typedef enum spvc_resource_type
  182. {
  183. SPVC_RESOURCE_TYPE_UNKNOWN = 0,
  184. SPVC_RESOURCE_TYPE_UNIFORM_BUFFER = 1,
  185. SPVC_RESOURCE_TYPE_STORAGE_BUFFER = 2,
  186. SPVC_RESOURCE_TYPE_STAGE_INPUT = 3,
  187. SPVC_RESOURCE_TYPE_STAGE_OUTPUT = 4,
  188. SPVC_RESOURCE_TYPE_SUBPASS_INPUT = 5,
  189. SPVC_RESOURCE_TYPE_STORAGE_IMAGE = 6,
  190. SPVC_RESOURCE_TYPE_SAMPLED_IMAGE = 7,
  191. SPVC_RESOURCE_TYPE_ATOMIC_COUNTER = 8,
  192. SPVC_RESOURCE_TYPE_PUSH_CONSTANT = 9,
  193. SPVC_RESOURCE_TYPE_SEPARATE_IMAGE = 10,
  194. SPVC_RESOURCE_TYPE_SEPARATE_SAMPLERS = 11,
  195. SPVC_RESOURCE_TYPE_ACCELERATION_STRUCTURE = 12,
  196. SPVC_RESOURCE_TYPE_RAY_QUERY = 13,
  197. SPVC_RESOURCE_TYPE_SHADER_RECORD_BUFFER = 14,
  198. SPVC_RESOURCE_TYPE_GL_PLAIN_UNIFORM = 15,
  199. SPVC_RESOURCE_TYPE_TENSOR = 16,
  200. SPVC_RESOURCE_TYPE_INT_MAX = 0x7fffffff
  201. } spvc_resource_type;
  202. typedef enum spvc_builtin_resource_type
  203. {
  204. SPVC_BUILTIN_RESOURCE_TYPE_UNKNOWN = 0,
  205. SPVC_BUILTIN_RESOURCE_TYPE_STAGE_INPUT = 1,
  206. SPVC_BUILTIN_RESOURCE_TYPE_STAGE_OUTPUT = 2,
  207. SPVC_BUILTIN_RESOURCE_TYPE_INT_MAX = 0x7fffffff
  208. } spvc_builtin_resource_type;
  209. /* Maps to spirv_cross::SPIRType::BaseType. */
  210. typedef enum spvc_basetype
  211. {
  212. SPVC_BASETYPE_UNKNOWN = 0,
  213. SPVC_BASETYPE_VOID = 1,
  214. SPVC_BASETYPE_BOOLEAN = 2,
  215. SPVC_BASETYPE_INT8 = 3,
  216. SPVC_BASETYPE_UINT8 = 4,
  217. SPVC_BASETYPE_INT16 = 5,
  218. SPVC_BASETYPE_UINT16 = 6,
  219. SPVC_BASETYPE_INT32 = 7,
  220. SPVC_BASETYPE_UINT32 = 8,
  221. SPVC_BASETYPE_INT64 = 9,
  222. SPVC_BASETYPE_UINT64 = 10,
  223. SPVC_BASETYPE_ATOMIC_COUNTER = 11,
  224. SPVC_BASETYPE_FP16 = 12,
  225. SPVC_BASETYPE_FP32 = 13,
  226. SPVC_BASETYPE_FP64 = 14,
  227. SPVC_BASETYPE_STRUCT = 15,
  228. SPVC_BASETYPE_IMAGE = 16,
  229. SPVC_BASETYPE_SAMPLED_IMAGE = 17,
  230. SPVC_BASETYPE_SAMPLER = 18,
  231. SPVC_BASETYPE_ACCELERATION_STRUCTURE = 19,
  232. SPVC_BASETYPE_INT_MAX = 0x7fffffff
  233. } spvc_basetype;
  234. #define SPVC_COMPILER_OPTION_COMMON_BIT 0x1000000
  235. #define SPVC_COMPILER_OPTION_GLSL_BIT 0x2000000
  236. #define SPVC_COMPILER_OPTION_HLSL_BIT 0x4000000
  237. #define SPVC_COMPILER_OPTION_MSL_BIT 0x8000000
  238. #define SPVC_COMPILER_OPTION_LANG_BITS 0x0f000000
  239. #define SPVC_COMPILER_OPTION_ENUM_BITS 0xffffff
  240. #define SPVC_MAKE_MSL_VERSION(major, minor, patch) ((major) * 10000 + (minor) * 100 + (patch))
  241. /* Maps to C++ API. */
  242. typedef enum spvc_msl_platform
  243. {
  244. SPVC_MSL_PLATFORM_IOS = 0,
  245. SPVC_MSL_PLATFORM_MACOS = 1,
  246. SPVC_MSL_PLATFORM_MAX_INT = 0x7fffffff
  247. } spvc_msl_platform;
  248. /* Maps to C++ API. */
  249. typedef enum spvc_msl_index_type
  250. {
  251. SPVC_MSL_INDEX_TYPE_NONE = 0,
  252. SPVC_MSL_INDEX_TYPE_UINT16 = 1,
  253. SPVC_MSL_INDEX_TYPE_UINT32 = 2,
  254. SPVC_MSL_INDEX_TYPE_MAX_INT = 0x7fffffff
  255. } spvc_msl_index_type;
  256. /* Maps to C++ API. */
  257. typedef enum spvc_msl_shader_variable_format
  258. {
  259. SPVC_MSL_SHADER_VARIABLE_FORMAT_OTHER = 0,
  260. SPVC_MSL_SHADER_VARIABLE_FORMAT_UINT8 = 1,
  261. SPVC_MSL_SHADER_VARIABLE_FORMAT_UINT16 = 2,
  262. SPVC_MSL_SHADER_VARIABLE_FORMAT_ANY16 = 3,
  263. SPVC_MSL_SHADER_VARIABLE_FORMAT_ANY32 = 4,
  264. /* Deprecated names. */
  265. SPVC_MSL_VERTEX_FORMAT_OTHER = SPVC_MSL_SHADER_VARIABLE_FORMAT_OTHER,
  266. SPVC_MSL_VERTEX_FORMAT_UINT8 = SPVC_MSL_SHADER_VARIABLE_FORMAT_UINT8,
  267. SPVC_MSL_VERTEX_FORMAT_UINT16 = SPVC_MSL_SHADER_VARIABLE_FORMAT_UINT16,
  268. SPVC_MSL_SHADER_INPUT_FORMAT_OTHER = SPVC_MSL_SHADER_VARIABLE_FORMAT_OTHER,
  269. SPVC_MSL_SHADER_INPUT_FORMAT_UINT8 = SPVC_MSL_SHADER_VARIABLE_FORMAT_UINT8,
  270. SPVC_MSL_SHADER_INPUT_FORMAT_UINT16 = SPVC_MSL_SHADER_VARIABLE_FORMAT_UINT16,
  271. SPVC_MSL_SHADER_INPUT_FORMAT_ANY16 = SPVC_MSL_SHADER_VARIABLE_FORMAT_ANY16,
  272. SPVC_MSL_SHADER_INPUT_FORMAT_ANY32 = SPVC_MSL_SHADER_VARIABLE_FORMAT_ANY32,
  273. SPVC_MSL_SHADER_INPUT_FORMAT_INT_MAX = 0x7fffffff
  274. } spvc_msl_shader_variable_format, spvc_msl_shader_input_format, spvc_msl_vertex_format;
  275. /* Maps to C++ API. Deprecated; use spvc_msl_shader_interface_var. */
  276. typedef struct spvc_msl_vertex_attribute
  277. {
  278. unsigned location;
  279. /* Obsolete, do not use. Only lingers on for ABI compatibility. */
  280. unsigned msl_buffer;
  281. /* Obsolete, do not use. Only lingers on for ABI compatibility. */
  282. unsigned msl_offset;
  283. /* Obsolete, do not use. Only lingers on for ABI compatibility. */
  284. unsigned msl_stride;
  285. /* Obsolete, do not use. Only lingers on for ABI compatibility. */
  286. spvc_bool per_instance;
  287. spvc_msl_vertex_format format;
  288. SpvBuiltIn builtin;
  289. } spvc_msl_vertex_attribute;
  290. /*
  291. * Initializes the vertex attribute struct.
  292. */
  293. SPVC_PUBLIC_API void spvc_msl_vertex_attribute_init(spvc_msl_vertex_attribute *attr);
  294. /* Maps to C++ API. Deprecated; use spvc_msl_shader_interface_var_2. */
  295. typedef struct spvc_msl_shader_interface_var
  296. {
  297. unsigned location;
  298. spvc_msl_vertex_format format;
  299. SpvBuiltIn builtin;
  300. unsigned vecsize;
  301. } spvc_msl_shader_interface_var, spvc_msl_shader_input;
  302. /*
  303. * Initializes the shader input struct.
  304. * Deprecated. Use spvc_msl_shader_interface_var_init_2().
  305. */
  306. SPVC_PUBLIC_API void spvc_msl_shader_interface_var_init(spvc_msl_shader_interface_var *var);
  307. /*
  308. * Deprecated. Use spvc_msl_shader_interface_var_init_2().
  309. */
  310. SPVC_PUBLIC_API void spvc_msl_shader_input_init(spvc_msl_shader_input *input);
  311. /* Maps to C++ API. */
  312. typedef enum spvc_msl_shader_variable_rate
  313. {
  314. SPVC_MSL_SHADER_VARIABLE_RATE_PER_VERTEX = 0,
  315. SPVC_MSL_SHADER_VARIABLE_RATE_PER_PRIMITIVE = 1,
  316. SPVC_MSL_SHADER_VARIABLE_RATE_PER_PATCH = 2,
  317. SPVC_MSL_SHADER_VARIABLE_RATE_INT_MAX = 0x7fffffff,
  318. } spvc_msl_shader_variable_rate;
  319. /* Maps to C++ API. */
  320. typedef struct spvc_msl_shader_interface_var_2
  321. {
  322. unsigned location;
  323. spvc_msl_shader_variable_format format;
  324. SpvBuiltIn builtin;
  325. unsigned vecsize;
  326. spvc_msl_shader_variable_rate rate;
  327. } spvc_msl_shader_interface_var_2;
  328. /*
  329. * Initializes the shader interface variable struct.
  330. */
  331. SPVC_PUBLIC_API void spvc_msl_shader_interface_var_init_2(spvc_msl_shader_interface_var_2 *var);
  332. /* Maps to C++ API.
  333. * Deprecated. Use spvc_msl_resource_binding_2. */
  334. typedef struct spvc_msl_resource_binding
  335. {
  336. SpvExecutionModel stage;
  337. unsigned desc_set;
  338. unsigned binding;
  339. unsigned msl_buffer;
  340. unsigned msl_texture;
  341. unsigned msl_sampler;
  342. } spvc_msl_resource_binding;
  343. typedef struct spvc_msl_resource_binding_2
  344. {
  345. SpvExecutionModel stage;
  346. unsigned desc_set;
  347. unsigned binding;
  348. unsigned count;
  349. unsigned msl_buffer;
  350. unsigned msl_texture;
  351. unsigned msl_sampler;
  352. } spvc_msl_resource_binding_2;
  353. /*
  354. * Initializes the resource binding struct.
  355. * The defaults are non-zero.
  356. * Deprecated: Use spvc_msl_resource_binding_init_2.
  357. */
  358. SPVC_PUBLIC_API void spvc_msl_resource_binding_init(spvc_msl_resource_binding *binding);
  359. SPVC_PUBLIC_API void spvc_msl_resource_binding_init_2(spvc_msl_resource_binding_2 *binding);
  360. #define SPVC_MSL_PUSH_CONSTANT_DESC_SET (~(0u))
  361. #define SPVC_MSL_PUSH_CONSTANT_BINDING (0)
  362. #define SPVC_MSL_SWIZZLE_BUFFER_BINDING (~(1u))
  363. #define SPVC_MSL_BUFFER_SIZE_BUFFER_BINDING (~(2u))
  364. #define SPVC_MSL_ARGUMENT_BUFFER_BINDING (~(3u))
  365. /* Obsolete. Sticks around for backwards compatibility. */
  366. #define SPVC_MSL_AUX_BUFFER_STRUCT_VERSION 1
  367. /* Runtime check for incompatibility. Obsolete. */
  368. SPVC_PUBLIC_API unsigned spvc_msl_get_aux_buffer_struct_version(void);
  369. /* Maps to C++ API. */
  370. typedef enum spvc_msl_sampler_coord
  371. {
  372. SPVC_MSL_SAMPLER_COORD_NORMALIZED = 0,
  373. SPVC_MSL_SAMPLER_COORD_PIXEL = 1,
  374. SPVC_MSL_SAMPLER_INT_MAX = 0x7fffffff
  375. } spvc_msl_sampler_coord;
  376. /* Maps to C++ API. */
  377. typedef enum spvc_msl_sampler_filter
  378. {
  379. SPVC_MSL_SAMPLER_FILTER_NEAREST = 0,
  380. SPVC_MSL_SAMPLER_FILTER_LINEAR = 1,
  381. SPVC_MSL_SAMPLER_FILTER_INT_MAX = 0x7fffffff
  382. } spvc_msl_sampler_filter;
  383. /* Maps to C++ API. */
  384. typedef enum spvc_msl_sampler_mip_filter
  385. {
  386. SPVC_MSL_SAMPLER_MIP_FILTER_NONE = 0,
  387. SPVC_MSL_SAMPLER_MIP_FILTER_NEAREST = 1,
  388. SPVC_MSL_SAMPLER_MIP_FILTER_LINEAR = 2,
  389. SPVC_MSL_SAMPLER_MIP_FILTER_INT_MAX = 0x7fffffff
  390. } spvc_msl_sampler_mip_filter;
  391. /* Maps to C++ API. */
  392. typedef enum spvc_msl_sampler_address
  393. {
  394. SPVC_MSL_SAMPLER_ADDRESS_CLAMP_TO_ZERO = 0,
  395. SPVC_MSL_SAMPLER_ADDRESS_CLAMP_TO_EDGE = 1,
  396. SPVC_MSL_SAMPLER_ADDRESS_CLAMP_TO_BORDER = 2,
  397. SPVC_MSL_SAMPLER_ADDRESS_REPEAT = 3,
  398. SPVC_MSL_SAMPLER_ADDRESS_MIRRORED_REPEAT = 4,
  399. SPVC_MSL_SAMPLER_ADDRESS_INT_MAX = 0x7fffffff
  400. } spvc_msl_sampler_address;
  401. /* Maps to C++ API. */
  402. typedef enum spvc_msl_sampler_compare_func
  403. {
  404. SPVC_MSL_SAMPLER_COMPARE_FUNC_NEVER = 0,
  405. SPVC_MSL_SAMPLER_COMPARE_FUNC_LESS = 1,
  406. SPVC_MSL_SAMPLER_COMPARE_FUNC_LESS_EQUAL = 2,
  407. SPVC_MSL_SAMPLER_COMPARE_FUNC_GREATER = 3,
  408. SPVC_MSL_SAMPLER_COMPARE_FUNC_GREATER_EQUAL = 4,
  409. SPVC_MSL_SAMPLER_COMPARE_FUNC_EQUAL = 5,
  410. SPVC_MSL_SAMPLER_COMPARE_FUNC_NOT_EQUAL = 6,
  411. SPVC_MSL_SAMPLER_COMPARE_FUNC_ALWAYS = 7,
  412. SPVC_MSL_SAMPLER_COMPARE_FUNC_INT_MAX = 0x7fffffff
  413. } spvc_msl_sampler_compare_func;
  414. /* Maps to C++ API. */
  415. typedef enum spvc_msl_sampler_border_color
  416. {
  417. SPVC_MSL_SAMPLER_BORDER_COLOR_TRANSPARENT_BLACK = 0,
  418. SPVC_MSL_SAMPLER_BORDER_COLOR_OPAQUE_BLACK = 1,
  419. SPVC_MSL_SAMPLER_BORDER_COLOR_OPAQUE_WHITE = 2,
  420. SPVC_MSL_SAMPLER_BORDER_COLOR_INT_MAX = 0x7fffffff
  421. } spvc_msl_sampler_border_color;
  422. /* Maps to C++ API. */
  423. typedef enum spvc_msl_format_resolution
  424. {
  425. SPVC_MSL_FORMAT_RESOLUTION_444 = 0,
  426. SPVC_MSL_FORMAT_RESOLUTION_422,
  427. SPVC_MSL_FORMAT_RESOLUTION_420,
  428. SPVC_MSL_FORMAT_RESOLUTION_INT_MAX = 0x7fffffff
  429. } spvc_msl_format_resolution;
  430. /* Maps to C++ API. */
  431. typedef enum spvc_msl_chroma_location
  432. {
  433. SPVC_MSL_CHROMA_LOCATION_COSITED_EVEN = 0,
  434. SPVC_MSL_CHROMA_LOCATION_MIDPOINT,
  435. SPVC_MSL_CHROMA_LOCATION_INT_MAX = 0x7fffffff
  436. } spvc_msl_chroma_location;
  437. /* Maps to C++ API. */
  438. typedef enum spvc_msl_component_swizzle
  439. {
  440. SPVC_MSL_COMPONENT_SWIZZLE_IDENTITY = 0,
  441. SPVC_MSL_COMPONENT_SWIZZLE_ZERO,
  442. SPVC_MSL_COMPONENT_SWIZZLE_ONE,
  443. SPVC_MSL_COMPONENT_SWIZZLE_R,
  444. SPVC_MSL_COMPONENT_SWIZZLE_G,
  445. SPVC_MSL_COMPONENT_SWIZZLE_B,
  446. SPVC_MSL_COMPONENT_SWIZZLE_A,
  447. SPVC_MSL_COMPONENT_SWIZZLE_INT_MAX = 0x7fffffff
  448. } spvc_msl_component_swizzle;
  449. /* Maps to C++ API. */
  450. typedef enum spvc_msl_sampler_ycbcr_model_conversion
  451. {
  452. SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY = 0,
  453. SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY,
  454. SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_BT_709,
  455. SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_BT_601,
  456. SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_BT_2020,
  457. SPVC_MSL_SAMPLER_YCBCR_MODEL_CONVERSION_INT_MAX = 0x7fffffff
  458. } spvc_msl_sampler_ycbcr_model_conversion;
  459. /* Maps to C+ API. */
  460. typedef enum spvc_msl_sampler_ycbcr_range
  461. {
  462. SPVC_MSL_SAMPLER_YCBCR_RANGE_ITU_FULL = 0,
  463. SPVC_MSL_SAMPLER_YCBCR_RANGE_ITU_NARROW,
  464. SPVC_MSL_SAMPLER_YCBCR_RANGE_INT_MAX = 0x7fffffff
  465. } spvc_msl_sampler_ycbcr_range;
  466. /* Maps to C++ API. */
  467. typedef struct spvc_msl_constexpr_sampler
  468. {
  469. spvc_msl_sampler_coord coord;
  470. spvc_msl_sampler_filter min_filter;
  471. spvc_msl_sampler_filter mag_filter;
  472. spvc_msl_sampler_mip_filter mip_filter;
  473. spvc_msl_sampler_address s_address;
  474. spvc_msl_sampler_address t_address;
  475. spvc_msl_sampler_address r_address;
  476. spvc_msl_sampler_compare_func compare_func;
  477. spvc_msl_sampler_border_color border_color;
  478. float lod_clamp_min;
  479. float lod_clamp_max;
  480. int max_anisotropy;
  481. spvc_bool compare_enable;
  482. spvc_bool lod_clamp_enable;
  483. spvc_bool anisotropy_enable;
  484. } spvc_msl_constexpr_sampler;
  485. /*
  486. * Initializes the constexpr sampler struct.
  487. * The defaults are non-zero.
  488. */
  489. SPVC_PUBLIC_API void spvc_msl_constexpr_sampler_init(spvc_msl_constexpr_sampler *sampler);
  490. /* Maps to the sampler Y'CbCr conversion-related portions of MSLConstexprSampler. See C++ API for defaults and details. */
  491. typedef struct spvc_msl_sampler_ycbcr_conversion
  492. {
  493. unsigned planes;
  494. spvc_msl_format_resolution resolution;
  495. spvc_msl_sampler_filter chroma_filter;
  496. spvc_msl_chroma_location x_chroma_offset;
  497. spvc_msl_chroma_location y_chroma_offset;
  498. spvc_msl_component_swizzle swizzle[4];
  499. spvc_msl_sampler_ycbcr_model_conversion ycbcr_model;
  500. spvc_msl_sampler_ycbcr_range ycbcr_range;
  501. unsigned bpc;
  502. } spvc_msl_sampler_ycbcr_conversion;
  503. /*
  504. * Initializes the constexpr sampler struct.
  505. * The defaults are non-zero.
  506. */
  507. SPVC_PUBLIC_API void spvc_msl_sampler_ycbcr_conversion_init(spvc_msl_sampler_ycbcr_conversion *conv);
  508. /* Maps to C++ API. */
  509. typedef enum spvc_hlsl_binding_flag_bits
  510. {
  511. SPVC_HLSL_BINDING_AUTO_NONE_BIT = 0,
  512. SPVC_HLSL_BINDING_AUTO_PUSH_CONSTANT_BIT = 1 << 0,
  513. SPVC_HLSL_BINDING_AUTO_CBV_BIT = 1 << 1,
  514. SPVC_HLSL_BINDING_AUTO_SRV_BIT = 1 << 2,
  515. SPVC_HLSL_BINDING_AUTO_UAV_BIT = 1 << 3,
  516. SPVC_HLSL_BINDING_AUTO_SAMPLER_BIT = 1 << 4,
  517. SPVC_HLSL_BINDING_AUTO_ALL = 0x7fffffff
  518. } spvc_hlsl_binding_flag_bits;
  519. typedef unsigned spvc_hlsl_binding_flags;
  520. #define SPVC_HLSL_PUSH_CONSTANT_DESC_SET (~(0u))
  521. #define SPVC_HLSL_PUSH_CONSTANT_BINDING (0)
  522. /* Maps to C++ API. */
  523. typedef struct spvc_hlsl_resource_binding_mapping
  524. {
  525. unsigned register_space;
  526. unsigned register_binding;
  527. } spvc_hlsl_resource_binding_mapping;
  528. typedef struct spvc_hlsl_resource_binding
  529. {
  530. SpvExecutionModel stage;
  531. unsigned desc_set;
  532. unsigned binding;
  533. spvc_hlsl_resource_binding_mapping cbv, uav, srv, sampler;
  534. } spvc_hlsl_resource_binding;
  535. /*
  536. * Initializes the resource binding struct.
  537. * The defaults are non-zero.
  538. */
  539. SPVC_PUBLIC_API void spvc_hlsl_resource_binding_init(spvc_hlsl_resource_binding *binding);
  540. /* Maps to the various spirv_cross::Compiler*::Option structures. See C++ API for defaults and details. */
  541. typedef enum spvc_compiler_option
  542. {
  543. SPVC_COMPILER_OPTION_UNKNOWN = 0,
  544. SPVC_COMPILER_OPTION_FORCE_TEMPORARY = 1 | SPVC_COMPILER_OPTION_COMMON_BIT,
  545. SPVC_COMPILER_OPTION_FLATTEN_MULTIDIMENSIONAL_ARRAYS = 2 | SPVC_COMPILER_OPTION_COMMON_BIT,
  546. SPVC_COMPILER_OPTION_FIXUP_DEPTH_CONVENTION = 3 | SPVC_COMPILER_OPTION_COMMON_BIT,
  547. SPVC_COMPILER_OPTION_FLIP_VERTEX_Y = 4 | SPVC_COMPILER_OPTION_COMMON_BIT,
  548. SPVC_COMPILER_OPTION_GLSL_SUPPORT_NONZERO_BASE_INSTANCE = 5 | SPVC_COMPILER_OPTION_GLSL_BIT,
  549. SPVC_COMPILER_OPTION_GLSL_SEPARATE_SHADER_OBJECTS = 6 | SPVC_COMPILER_OPTION_GLSL_BIT,
  550. SPVC_COMPILER_OPTION_GLSL_ENABLE_420PACK_EXTENSION = 7 | SPVC_COMPILER_OPTION_GLSL_BIT,
  551. SPVC_COMPILER_OPTION_GLSL_VERSION = 8 | SPVC_COMPILER_OPTION_GLSL_BIT,
  552. SPVC_COMPILER_OPTION_GLSL_ES = 9 | SPVC_COMPILER_OPTION_GLSL_BIT,
  553. SPVC_COMPILER_OPTION_GLSL_VULKAN_SEMANTICS = 10 | SPVC_COMPILER_OPTION_GLSL_BIT,
  554. SPVC_COMPILER_OPTION_GLSL_ES_DEFAULT_FLOAT_PRECISION_HIGHP = 11 | SPVC_COMPILER_OPTION_GLSL_BIT,
  555. SPVC_COMPILER_OPTION_GLSL_ES_DEFAULT_INT_PRECISION_HIGHP = 12 | SPVC_COMPILER_OPTION_GLSL_BIT,
  556. SPVC_COMPILER_OPTION_HLSL_SHADER_MODEL = 13 | SPVC_COMPILER_OPTION_HLSL_BIT,
  557. SPVC_COMPILER_OPTION_HLSL_POINT_SIZE_COMPAT = 14 | SPVC_COMPILER_OPTION_HLSL_BIT,
  558. SPVC_COMPILER_OPTION_HLSL_POINT_COORD_COMPAT = 15 | SPVC_COMPILER_OPTION_HLSL_BIT,
  559. SPVC_COMPILER_OPTION_HLSL_SUPPORT_NONZERO_BASE_VERTEX_BASE_INSTANCE = 16 | SPVC_COMPILER_OPTION_HLSL_BIT,
  560. SPVC_COMPILER_OPTION_MSL_VERSION = 17 | SPVC_COMPILER_OPTION_MSL_BIT,
  561. SPVC_COMPILER_OPTION_MSL_TEXEL_BUFFER_TEXTURE_WIDTH = 18 | SPVC_COMPILER_OPTION_MSL_BIT,
  562. /* Obsolete, use SWIZZLE_BUFFER_INDEX instead. */
  563. SPVC_COMPILER_OPTION_MSL_AUX_BUFFER_INDEX = 19 | SPVC_COMPILER_OPTION_MSL_BIT,
  564. SPVC_COMPILER_OPTION_MSL_SWIZZLE_BUFFER_INDEX = 19 | SPVC_COMPILER_OPTION_MSL_BIT,
  565. SPVC_COMPILER_OPTION_MSL_INDIRECT_PARAMS_BUFFER_INDEX = 20 | SPVC_COMPILER_OPTION_MSL_BIT,
  566. SPVC_COMPILER_OPTION_MSL_SHADER_OUTPUT_BUFFER_INDEX = 21 | SPVC_COMPILER_OPTION_MSL_BIT,
  567. SPVC_COMPILER_OPTION_MSL_SHADER_PATCH_OUTPUT_BUFFER_INDEX = 22 | SPVC_COMPILER_OPTION_MSL_BIT,
  568. SPVC_COMPILER_OPTION_MSL_SHADER_TESS_FACTOR_OUTPUT_BUFFER_INDEX = 23 | SPVC_COMPILER_OPTION_MSL_BIT,
  569. SPVC_COMPILER_OPTION_MSL_SHADER_INPUT_WORKGROUP_INDEX = 24 | SPVC_COMPILER_OPTION_MSL_BIT,
  570. SPVC_COMPILER_OPTION_MSL_ENABLE_POINT_SIZE_BUILTIN = 25 | SPVC_COMPILER_OPTION_MSL_BIT,
  571. SPVC_COMPILER_OPTION_MSL_DISABLE_RASTERIZATION = 26 | SPVC_COMPILER_OPTION_MSL_BIT,
  572. SPVC_COMPILER_OPTION_MSL_CAPTURE_OUTPUT_TO_BUFFER = 27 | SPVC_COMPILER_OPTION_MSL_BIT,
  573. SPVC_COMPILER_OPTION_MSL_SWIZZLE_TEXTURE_SAMPLES = 28 | SPVC_COMPILER_OPTION_MSL_BIT,
  574. SPVC_COMPILER_OPTION_MSL_PAD_FRAGMENT_OUTPUT_COMPONENTS = 29 | SPVC_COMPILER_OPTION_MSL_BIT,
  575. SPVC_COMPILER_OPTION_MSL_TESS_DOMAIN_ORIGIN_LOWER_LEFT = 30 | SPVC_COMPILER_OPTION_MSL_BIT,
  576. SPVC_COMPILER_OPTION_MSL_PLATFORM = 31 | SPVC_COMPILER_OPTION_MSL_BIT,
  577. SPVC_COMPILER_OPTION_MSL_ARGUMENT_BUFFERS = 32 | SPVC_COMPILER_OPTION_MSL_BIT,
  578. SPVC_COMPILER_OPTION_GLSL_EMIT_PUSH_CONSTANT_AS_UNIFORM_BUFFER = 33 | SPVC_COMPILER_OPTION_GLSL_BIT,
  579. SPVC_COMPILER_OPTION_MSL_TEXTURE_BUFFER_NATIVE = 34 | SPVC_COMPILER_OPTION_MSL_BIT,
  580. SPVC_COMPILER_OPTION_GLSL_EMIT_UNIFORM_BUFFER_AS_PLAIN_UNIFORMS = 35 | SPVC_COMPILER_OPTION_GLSL_BIT,
  581. SPVC_COMPILER_OPTION_MSL_BUFFER_SIZE_BUFFER_INDEX = 36 | SPVC_COMPILER_OPTION_MSL_BIT,
  582. SPVC_COMPILER_OPTION_EMIT_LINE_DIRECTIVES = 37 | SPVC_COMPILER_OPTION_COMMON_BIT,
  583. SPVC_COMPILER_OPTION_MSL_MULTIVIEW = 38 | SPVC_COMPILER_OPTION_MSL_BIT,
  584. SPVC_COMPILER_OPTION_MSL_VIEW_MASK_BUFFER_INDEX = 39 | SPVC_COMPILER_OPTION_MSL_BIT,
  585. SPVC_COMPILER_OPTION_MSL_DEVICE_INDEX = 40 | SPVC_COMPILER_OPTION_MSL_BIT,
  586. SPVC_COMPILER_OPTION_MSL_VIEW_INDEX_FROM_DEVICE_INDEX = 41 | SPVC_COMPILER_OPTION_MSL_BIT,
  587. SPVC_COMPILER_OPTION_MSL_DISPATCH_BASE = 42 | SPVC_COMPILER_OPTION_MSL_BIT,
  588. SPVC_COMPILER_OPTION_MSL_DYNAMIC_OFFSETS_BUFFER_INDEX = 43 | SPVC_COMPILER_OPTION_MSL_BIT,
  589. SPVC_COMPILER_OPTION_MSL_TEXTURE_1D_AS_2D = 44 | SPVC_COMPILER_OPTION_MSL_BIT,
  590. SPVC_COMPILER_OPTION_MSL_ENABLE_BASE_INDEX_ZERO = 45 | SPVC_COMPILER_OPTION_MSL_BIT,
  591. /* Obsolete. Use MSL_FRAMEBUFFER_FETCH_SUBPASS instead. */
  592. SPVC_COMPILER_OPTION_MSL_IOS_FRAMEBUFFER_FETCH_SUBPASS = 46 | SPVC_COMPILER_OPTION_MSL_BIT,
  593. SPVC_COMPILER_OPTION_MSL_FRAMEBUFFER_FETCH_SUBPASS = 46 | SPVC_COMPILER_OPTION_MSL_BIT,
  594. SPVC_COMPILER_OPTION_MSL_INVARIANT_FP_MATH = 47 | SPVC_COMPILER_OPTION_MSL_BIT,
  595. SPVC_COMPILER_OPTION_MSL_EMULATE_CUBEMAP_ARRAY = 48 | SPVC_COMPILER_OPTION_MSL_BIT,
  596. SPVC_COMPILER_OPTION_MSL_ENABLE_DECORATION_BINDING = 49 | SPVC_COMPILER_OPTION_MSL_BIT,
  597. SPVC_COMPILER_OPTION_MSL_FORCE_ACTIVE_ARGUMENT_BUFFER_RESOURCES = 50 | SPVC_COMPILER_OPTION_MSL_BIT,
  598. SPVC_COMPILER_OPTION_MSL_FORCE_NATIVE_ARRAYS = 51 | SPVC_COMPILER_OPTION_MSL_BIT,
  599. SPVC_COMPILER_OPTION_ENABLE_STORAGE_IMAGE_QUALIFIER_DEDUCTION = 52 | SPVC_COMPILER_OPTION_COMMON_BIT,
  600. SPVC_COMPILER_OPTION_HLSL_FORCE_STORAGE_BUFFER_AS_UAV = 53 | SPVC_COMPILER_OPTION_HLSL_BIT,
  601. SPVC_COMPILER_OPTION_FORCE_ZERO_INITIALIZED_VARIABLES = 54 | SPVC_COMPILER_OPTION_COMMON_BIT,
  602. SPVC_COMPILER_OPTION_HLSL_NONWRITABLE_UAV_TEXTURE_AS_SRV = 55 | SPVC_COMPILER_OPTION_HLSL_BIT,
  603. SPVC_COMPILER_OPTION_MSL_ENABLE_FRAG_OUTPUT_MASK = 56 | SPVC_COMPILER_OPTION_MSL_BIT,
  604. SPVC_COMPILER_OPTION_MSL_ENABLE_FRAG_DEPTH_BUILTIN = 57 | SPVC_COMPILER_OPTION_MSL_BIT,
  605. SPVC_COMPILER_OPTION_MSL_ENABLE_FRAG_STENCIL_REF_BUILTIN = 58 | SPVC_COMPILER_OPTION_MSL_BIT,
  606. SPVC_COMPILER_OPTION_MSL_ENABLE_CLIP_DISTANCE_USER_VARYING = 59 | SPVC_COMPILER_OPTION_MSL_BIT,
  607. SPVC_COMPILER_OPTION_HLSL_ENABLE_16BIT_TYPES = 60 | SPVC_COMPILER_OPTION_HLSL_BIT,
  608. SPVC_COMPILER_OPTION_MSL_MULTI_PATCH_WORKGROUP = 61 | SPVC_COMPILER_OPTION_MSL_BIT,
  609. SPVC_COMPILER_OPTION_MSL_SHADER_INPUT_BUFFER_INDEX = 62 | SPVC_COMPILER_OPTION_MSL_BIT,
  610. SPVC_COMPILER_OPTION_MSL_SHADER_INDEX_BUFFER_INDEX = 63 | SPVC_COMPILER_OPTION_MSL_BIT,
  611. SPVC_COMPILER_OPTION_MSL_VERTEX_FOR_TESSELLATION = 64 | SPVC_COMPILER_OPTION_MSL_BIT,
  612. SPVC_COMPILER_OPTION_MSL_VERTEX_INDEX_TYPE = 65 | SPVC_COMPILER_OPTION_MSL_BIT,
  613. SPVC_COMPILER_OPTION_GLSL_FORCE_FLATTENED_IO_BLOCKS = 66 | SPVC_COMPILER_OPTION_GLSL_BIT,
  614. SPVC_COMPILER_OPTION_MSL_MULTIVIEW_LAYERED_RENDERING = 67 | SPVC_COMPILER_OPTION_MSL_BIT,
  615. SPVC_COMPILER_OPTION_MSL_ARRAYED_SUBPASS_INPUT = 68 | SPVC_COMPILER_OPTION_MSL_BIT,
  616. SPVC_COMPILER_OPTION_MSL_R32UI_LINEAR_TEXTURE_ALIGNMENT = 69 | SPVC_COMPILER_OPTION_MSL_BIT,
  617. SPVC_COMPILER_OPTION_MSL_R32UI_ALIGNMENT_CONSTANT_ID = 70 | SPVC_COMPILER_OPTION_MSL_BIT,
  618. SPVC_COMPILER_OPTION_HLSL_FLATTEN_MATRIX_VERTEX_INPUT_SEMANTICS = 71 | SPVC_COMPILER_OPTION_HLSL_BIT,
  619. SPVC_COMPILER_OPTION_MSL_IOS_USE_SIMDGROUP_FUNCTIONS = 72 | SPVC_COMPILER_OPTION_MSL_BIT,
  620. SPVC_COMPILER_OPTION_MSL_EMULATE_SUBGROUPS = 73 | SPVC_COMPILER_OPTION_MSL_BIT,
  621. SPVC_COMPILER_OPTION_MSL_FIXED_SUBGROUP_SIZE = 74 | SPVC_COMPILER_OPTION_MSL_BIT,
  622. SPVC_COMPILER_OPTION_MSL_FORCE_SAMPLE_RATE_SHADING = 75 | SPVC_COMPILER_OPTION_MSL_BIT,
  623. SPVC_COMPILER_OPTION_MSL_IOS_SUPPORT_BASE_VERTEX_INSTANCE = 76 | SPVC_COMPILER_OPTION_MSL_BIT,
  624. SPVC_COMPILER_OPTION_GLSL_OVR_MULTIVIEW_VIEW_COUNT = 77 | SPVC_COMPILER_OPTION_GLSL_BIT,
  625. SPVC_COMPILER_OPTION_RELAX_NAN_CHECKS = 78 | SPVC_COMPILER_OPTION_COMMON_BIT,
  626. SPVC_COMPILER_OPTION_MSL_RAW_BUFFER_TESE_INPUT = 79 | SPVC_COMPILER_OPTION_MSL_BIT,
  627. SPVC_COMPILER_OPTION_MSL_SHADER_PATCH_INPUT_BUFFER_INDEX = 80 | SPVC_COMPILER_OPTION_MSL_BIT,
  628. SPVC_COMPILER_OPTION_MSL_MANUAL_HELPER_INVOCATION_UPDATES = 81 | SPVC_COMPILER_OPTION_MSL_BIT,
  629. SPVC_COMPILER_OPTION_MSL_CHECK_DISCARDED_FRAG_STORES = 82 | SPVC_COMPILER_OPTION_MSL_BIT,
  630. SPVC_COMPILER_OPTION_GLSL_ENABLE_ROW_MAJOR_LOAD_WORKAROUND = 83 | SPVC_COMPILER_OPTION_GLSL_BIT,
  631. SPVC_COMPILER_OPTION_MSL_ARGUMENT_BUFFERS_TIER = 84 | SPVC_COMPILER_OPTION_MSL_BIT,
  632. SPVC_COMPILER_OPTION_MSL_SAMPLE_DREF_LOD_ARRAY_AS_GRAD = 85 | SPVC_COMPILER_OPTION_MSL_BIT,
  633. SPVC_COMPILER_OPTION_MSL_READWRITE_TEXTURE_FENCES = 86 | SPVC_COMPILER_OPTION_MSL_BIT,
  634. SPVC_COMPILER_OPTION_MSL_REPLACE_RECURSIVE_INPUTS = 87 | SPVC_COMPILER_OPTION_MSL_BIT,
  635. SPVC_COMPILER_OPTION_MSL_AGX_MANUAL_CUBE_GRAD_FIXUP = 88 | SPVC_COMPILER_OPTION_MSL_BIT,
  636. SPVC_COMPILER_OPTION_MSL_FORCE_FRAGMENT_WITH_SIDE_EFFECTS_EXECUTION = 89 | SPVC_COMPILER_OPTION_MSL_BIT,
  637. SPVC_COMPILER_OPTION_HLSL_USE_ENTRY_POINT_NAME = 90 | SPVC_COMPILER_OPTION_HLSL_BIT,
  638. SPVC_COMPILER_OPTION_HLSL_PRESERVE_STRUCTURED_BUFFERS = 91 | SPVC_COMPILER_OPTION_HLSL_BIT,
  639. SPVC_COMPILER_OPTION_MSL_AUTO_DISABLE_RASTERIZATION = 92 | SPVC_COMPILER_OPTION_MSL_BIT,
  640. SPVC_COMPILER_OPTION_MSL_ENABLE_POINT_SIZE_DEFAULT = 93 | SPVC_COMPILER_OPTION_MSL_BIT,
  641. SPVC_COMPILER_OPTION_HLSL_USER_SEMANTIC = 94 | SPVC_COMPILER_OPTION_HLSL_BIT,
  642. SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff
  643. } spvc_compiler_option;
  644. /*
  645. * Context is the highest-level API construct.
  646. * The context owns all memory allocations made by its child object hierarchy, including various non-opaque structs and strings.
  647. * This means that the API user only has to care about one "destroy" call ever when using the C API.
  648. * All pointers handed out by the APIs are only valid as long as the context
  649. * is alive and spvc_context_release_allocations has not been called.
  650. */
  651. SPVC_PUBLIC_API spvc_result spvc_context_create(spvc_context *context);
  652. /* Frees all memory allocations and objects associated with the context and its child objects. */
  653. SPVC_PUBLIC_API void spvc_context_destroy(spvc_context context);
  654. /* Frees all memory allocations and objects associated with the context and its child objects, but keeps the context alive. */
  655. SPVC_PUBLIC_API void spvc_context_release_allocations(spvc_context context);
  656. /* Get the string for the last error which was logged. */
  657. SPVC_PUBLIC_API const char *spvc_context_get_last_error_string(spvc_context context);
  658. /* Get notified in a callback when an error triggers. Useful for debugging. */
  659. typedef void (*spvc_error_callback)(void *userdata, const char *error);
  660. SPVC_PUBLIC_API void spvc_context_set_error_callback(spvc_context context, spvc_error_callback cb, void *userdata);
  661. /* SPIR-V parsing interface. Maps to Parser which then creates a ParsedIR, and that IR is extracted into the handle. */
  662. SPVC_PUBLIC_API spvc_result spvc_context_parse_spirv(spvc_context context, const SpvId *spirv, size_t word_count,
  663. spvc_parsed_ir *parsed_ir);
  664. /*
  665. * Create a compiler backend. Capture mode controls if we construct by copy or move semantics.
  666. * It is always recommended to use SPVC_CAPTURE_MODE_TAKE_OWNERSHIP if you only intend to cross-compile the IR once.
  667. */
  668. SPVC_PUBLIC_API spvc_result spvc_context_create_compiler(spvc_context context, spvc_backend backend,
  669. spvc_parsed_ir parsed_ir, spvc_capture_mode mode,
  670. spvc_compiler *compiler);
  671. /* Maps directly to C++ API. */
  672. SPVC_PUBLIC_API unsigned spvc_compiler_get_current_id_bound(spvc_compiler compiler);
  673. /* Create compiler options, which will initialize defaults. */
  674. SPVC_PUBLIC_API spvc_result spvc_compiler_create_compiler_options(spvc_compiler compiler,
  675. spvc_compiler_options *options);
  676. /* Override options. Will return error if e.g. MSL options are used for the HLSL backend, etc. */
  677. SPVC_PUBLIC_API spvc_result spvc_compiler_options_set_bool(spvc_compiler_options options,
  678. spvc_compiler_option option, spvc_bool value);
  679. SPVC_PUBLIC_API spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options,
  680. spvc_compiler_option option, unsigned value);
  681. /* Set compiler options. */
  682. SPVC_PUBLIC_API spvc_result spvc_compiler_install_compiler_options(spvc_compiler compiler,
  683. spvc_compiler_options options);
  684. /* Compile IR into a string. *source is owned by the context, and caller must not free it themselves. */
  685. SPVC_PUBLIC_API spvc_result spvc_compiler_compile(spvc_compiler compiler, const char **source);
  686. /* Maps to C++ API. */
  687. SPVC_PUBLIC_API spvc_result spvc_compiler_add_header_line(spvc_compiler compiler, const char *line);
  688. SPVC_PUBLIC_API spvc_result spvc_compiler_require_extension(spvc_compiler compiler, const char *ext);
  689. SPVC_PUBLIC_API size_t spvc_compiler_get_num_required_extensions(spvc_compiler compiler);
  690. SPVC_PUBLIC_API const char *spvc_compiler_get_required_extension(spvc_compiler compiler, size_t index);
  691. SPVC_PUBLIC_API spvc_result spvc_compiler_flatten_buffer_block(spvc_compiler compiler, spvc_variable_id id);
  692. SPVC_PUBLIC_API spvc_bool spvc_compiler_variable_is_depth_or_compare(spvc_compiler compiler, spvc_variable_id id);
  693. SPVC_PUBLIC_API spvc_result spvc_compiler_mask_stage_output_by_location(spvc_compiler compiler,
  694. unsigned location, unsigned component);
  695. SPVC_PUBLIC_API spvc_result spvc_compiler_mask_stage_output_by_builtin(spvc_compiler compiler, SpvBuiltIn builtin);
  696. /*
  697. * HLSL specifics.
  698. * Maps to C++ API.
  699. */
  700. SPVC_PUBLIC_API spvc_result spvc_compiler_hlsl_set_root_constants_layout(spvc_compiler compiler,
  701. const spvc_hlsl_root_constants *constant_info,
  702. size_t count);
  703. SPVC_PUBLIC_API spvc_result spvc_compiler_hlsl_add_vertex_attribute_remap(spvc_compiler compiler,
  704. const spvc_hlsl_vertex_attribute_remap *remap,
  705. size_t remaps);
  706. SPVC_PUBLIC_API spvc_variable_id spvc_compiler_hlsl_remap_num_workgroups_builtin(spvc_compiler compiler);
  707. SPVC_PUBLIC_API spvc_result spvc_compiler_hlsl_set_resource_binding_flags(spvc_compiler compiler,
  708. spvc_hlsl_binding_flags flags);
  709. SPVC_PUBLIC_API spvc_result spvc_compiler_hlsl_add_resource_binding(spvc_compiler compiler,
  710. const spvc_hlsl_resource_binding *binding);
  711. SPVC_PUBLIC_API spvc_bool spvc_compiler_hlsl_is_resource_used(spvc_compiler compiler,
  712. SpvExecutionModel model,
  713. unsigned set,
  714. unsigned binding);
  715. /*
  716. * MSL specifics.
  717. * Maps to C++ API.
  718. */
  719. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_rasterization_disabled(spvc_compiler compiler);
  720. /* Obsolete. Renamed to needs_swizzle_buffer. */
  721. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_aux_buffer(spvc_compiler compiler);
  722. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_swizzle_buffer(spvc_compiler compiler);
  723. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_buffer_size_buffer(spvc_compiler compiler);
  724. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_output_buffer(spvc_compiler compiler);
  725. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_patch_output_buffer(spvc_compiler compiler);
  726. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_needs_input_threadgroup_mem(spvc_compiler compiler);
  727. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_vertex_attribute(spvc_compiler compiler,
  728. const spvc_msl_vertex_attribute *attrs);
  729. /* Deprecated; use spvc_compiler_msl_add_resource_binding_2(). */
  730. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_resource_binding(spvc_compiler compiler,
  731. const spvc_msl_resource_binding *binding);
  732. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_resource_binding_2(spvc_compiler compiler,
  733. const spvc_msl_resource_binding_2 *binding);
  734. /* Deprecated; use spvc_compiler_msl_add_shader_input_2(). */
  735. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_shader_input(spvc_compiler compiler,
  736. const spvc_msl_shader_interface_var *input);
  737. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_shader_input_2(spvc_compiler compiler,
  738. const spvc_msl_shader_interface_var_2 *input);
  739. /* Deprecated; use spvc_compiler_msl_add_shader_output_2(). */
  740. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_shader_output(spvc_compiler compiler,
  741. const spvc_msl_shader_interface_var *output);
  742. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_shader_output_2(spvc_compiler compiler,
  743. const spvc_msl_shader_interface_var_2 *output);
  744. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_discrete_descriptor_set(spvc_compiler compiler, unsigned desc_set);
  745. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_set_argument_buffer_device_address_space(spvc_compiler compiler, unsigned desc_set, spvc_bool device_address);
  746. /* Obsolete, use is_shader_input_used. */
  747. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_vertex_attribute_used(spvc_compiler compiler, unsigned location);
  748. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_shader_input_used(spvc_compiler compiler, unsigned location);
  749. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_shader_output_used(spvc_compiler compiler, unsigned location);
  750. SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_resource_used(spvc_compiler compiler,
  751. SpvExecutionModel model,
  752. unsigned set,
  753. unsigned binding);
  754. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler(spvc_compiler compiler, spvc_variable_id id, const spvc_msl_constexpr_sampler *sampler);
  755. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler_by_binding(spvc_compiler compiler, unsigned desc_set, unsigned binding, const spvc_msl_constexpr_sampler *sampler);
  756. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler_ycbcr(spvc_compiler compiler, spvc_variable_id id, const spvc_msl_constexpr_sampler *sampler, const spvc_msl_sampler_ycbcr_conversion *conv);
  757. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_remap_constexpr_sampler_by_binding_ycbcr(spvc_compiler compiler, unsigned desc_set, unsigned binding, const spvc_msl_constexpr_sampler *sampler, const spvc_msl_sampler_ycbcr_conversion *conv);
  758. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_set_fragment_output_components(spvc_compiler compiler, unsigned location, unsigned components);
  759. SPVC_PUBLIC_API unsigned spvc_compiler_msl_get_automatic_resource_binding(spvc_compiler compiler, spvc_variable_id id);
  760. SPVC_PUBLIC_API unsigned spvc_compiler_msl_get_automatic_resource_binding_secondary(spvc_compiler compiler, spvc_variable_id id);
  761. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_dynamic_buffer(spvc_compiler compiler, unsigned desc_set, unsigned binding, unsigned index);
  762. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_inline_uniform_block(spvc_compiler compiler, unsigned desc_set, unsigned binding);
  763. SPVC_PUBLIC_API spvc_result spvc_compiler_msl_set_combined_sampler_suffix(spvc_compiler compiler, const char *suffix);
  764. SPVC_PUBLIC_API const char *spvc_compiler_msl_get_combined_sampler_suffix(spvc_compiler compiler);
  765. /*
  766. * Reflect resources.
  767. * Maps almost 1:1 to C++ API.
  768. */
  769. SPVC_PUBLIC_API spvc_result spvc_compiler_get_active_interface_variables(spvc_compiler compiler, spvc_set *set);
  770. SPVC_PUBLIC_API spvc_result spvc_compiler_set_enabled_interface_variables(spvc_compiler compiler, spvc_set set);
  771. SPVC_PUBLIC_API spvc_result spvc_compiler_create_shader_resources(spvc_compiler compiler, spvc_resources *resources);
  772. SPVC_PUBLIC_API spvc_result spvc_compiler_create_shader_resources_for_active_variables(spvc_compiler compiler,
  773. spvc_resources *resources,
  774. spvc_set active);
  775. SPVC_PUBLIC_API spvc_result spvc_resources_get_resource_list_for_type(spvc_resources resources, spvc_resource_type type,
  776. const spvc_reflected_resource **resource_list,
  777. size_t *resource_size);
  778. SPVC_PUBLIC_API spvc_result spvc_resources_get_builtin_resource_list_for_type(
  779. spvc_resources resources, spvc_builtin_resource_type type,
  780. const spvc_reflected_builtin_resource **resource_list,
  781. size_t *resource_size);
  782. /*
  783. * Decorations.
  784. * Maps to C++ API.
  785. */
  786. SPVC_PUBLIC_API void spvc_compiler_set_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration,
  787. unsigned argument);
  788. SPVC_PUBLIC_API void spvc_compiler_set_decoration_string(spvc_compiler compiler, SpvId id, SpvDecoration decoration,
  789. const char *argument);
  790. SPVC_PUBLIC_API void spvc_compiler_set_name(spvc_compiler compiler, SpvId id, const char *argument);
  791. SPVC_PUBLIC_API void spvc_compiler_set_member_decoration(spvc_compiler compiler, spvc_type_id id, unsigned member_index,
  792. SpvDecoration decoration, unsigned argument);
  793. SPVC_PUBLIC_API void spvc_compiler_set_member_decoration_string(spvc_compiler compiler, spvc_type_id id,
  794. unsigned member_index, SpvDecoration decoration,
  795. const char *argument);
  796. SPVC_PUBLIC_API void spvc_compiler_set_member_name(spvc_compiler compiler, spvc_type_id id, unsigned member_index,
  797. const char *argument);
  798. SPVC_PUBLIC_API void spvc_compiler_unset_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration);
  799. SPVC_PUBLIC_API void spvc_compiler_unset_member_decoration(spvc_compiler compiler, spvc_type_id id,
  800. unsigned member_index, SpvDecoration decoration);
  801. SPVC_PUBLIC_API spvc_bool spvc_compiler_has_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration);
  802. SPVC_PUBLIC_API spvc_bool spvc_compiler_has_member_decoration(spvc_compiler compiler, spvc_type_id id,
  803. unsigned member_index, SpvDecoration decoration);
  804. SPVC_PUBLIC_API const char *spvc_compiler_get_name(spvc_compiler compiler, SpvId id);
  805. SPVC_PUBLIC_API unsigned spvc_compiler_get_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration);
  806. SPVC_PUBLIC_API const char *spvc_compiler_get_decoration_string(spvc_compiler compiler, SpvId id,
  807. SpvDecoration decoration);
  808. SPVC_PUBLIC_API unsigned spvc_compiler_get_member_decoration(spvc_compiler compiler, spvc_type_id id,
  809. unsigned member_index, SpvDecoration decoration);
  810. SPVC_PUBLIC_API const char *spvc_compiler_get_member_decoration_string(spvc_compiler compiler, spvc_type_id id,
  811. unsigned member_index, SpvDecoration decoration);
  812. SPVC_PUBLIC_API const char *spvc_compiler_get_member_name(spvc_compiler compiler, spvc_type_id id, unsigned member_index);
  813. /*
  814. * Entry points.
  815. * Maps to C++ API.
  816. */
  817. SPVC_PUBLIC_API spvc_result spvc_compiler_get_entry_points(spvc_compiler compiler,
  818. const spvc_entry_point **entry_points,
  819. size_t *num_entry_points);
  820. SPVC_PUBLIC_API spvc_result spvc_compiler_set_entry_point(spvc_compiler compiler, const char *name,
  821. SpvExecutionModel model);
  822. SPVC_PUBLIC_API spvc_result spvc_compiler_rename_entry_point(spvc_compiler compiler, const char *old_name,
  823. const char *new_name, SpvExecutionModel model);
  824. SPVC_PUBLIC_API const char *spvc_compiler_get_cleansed_entry_point_name(spvc_compiler compiler, const char *name,
  825. SpvExecutionModel model);
  826. SPVC_PUBLIC_API void spvc_compiler_set_execution_mode(spvc_compiler compiler, SpvExecutionMode mode);
  827. SPVC_PUBLIC_API void spvc_compiler_unset_execution_mode(spvc_compiler compiler, SpvExecutionMode mode);
  828. SPVC_PUBLIC_API void spvc_compiler_set_execution_mode_with_arguments(spvc_compiler compiler, SpvExecutionMode mode,
  829. unsigned arg0, unsigned arg1, unsigned arg2);
  830. SPVC_PUBLIC_API spvc_result spvc_compiler_get_execution_modes(spvc_compiler compiler, const SpvExecutionMode **modes,
  831. size_t *num_modes);
  832. SPVC_PUBLIC_API unsigned spvc_compiler_get_execution_mode_argument(spvc_compiler compiler, SpvExecutionMode mode);
  833. SPVC_PUBLIC_API unsigned spvc_compiler_get_execution_mode_argument_by_index(spvc_compiler compiler,
  834. SpvExecutionMode mode, unsigned index);
  835. SPVC_PUBLIC_API SpvExecutionModel spvc_compiler_get_execution_model(spvc_compiler compiler);
  836. SPVC_PUBLIC_API void spvc_compiler_update_active_builtins(spvc_compiler compiler);
  837. SPVC_PUBLIC_API spvc_bool spvc_compiler_has_active_builtin(spvc_compiler compiler, SpvBuiltIn builtin, SpvStorageClass storage);
  838. /*
  839. * Type query interface.
  840. * Maps to C++ API, except it's read-only.
  841. */
  842. SPVC_PUBLIC_API spvc_type spvc_compiler_get_type_handle(spvc_compiler compiler, spvc_type_id id);
  843. /* Pulls out SPIRType::self. This effectively gives the type ID without array or pointer qualifiers.
  844. * This is necessary when reflecting decoration/name information on members of a struct,
  845. * which are placed in the base type, not the qualified type.
  846. * This is similar to spvc_reflected_resource::base_type_id. */
  847. SPVC_PUBLIC_API spvc_type_id spvc_type_get_base_type_id(spvc_type type);
  848. SPVC_PUBLIC_API spvc_basetype spvc_type_get_basetype(spvc_type type);
  849. SPVC_PUBLIC_API unsigned spvc_type_get_bit_width(spvc_type type);
  850. SPVC_PUBLIC_API unsigned spvc_type_get_vector_size(spvc_type type);
  851. SPVC_PUBLIC_API unsigned spvc_type_get_columns(spvc_type type);
  852. SPVC_PUBLIC_API unsigned spvc_type_get_num_array_dimensions(spvc_type type);
  853. SPVC_PUBLIC_API spvc_bool spvc_type_array_dimension_is_literal(spvc_type type, unsigned dimension);
  854. SPVC_PUBLIC_API SpvId spvc_type_get_array_dimension(spvc_type type, unsigned dimension);
  855. SPVC_PUBLIC_API unsigned spvc_type_get_num_member_types(spvc_type type);
  856. SPVC_PUBLIC_API spvc_type_id spvc_type_get_member_type(spvc_type type, unsigned index);
  857. SPVC_PUBLIC_API SpvStorageClass spvc_type_get_storage_class(spvc_type type);
  858. /* Image type query. */
  859. SPVC_PUBLIC_API spvc_type_id spvc_type_get_image_sampled_type(spvc_type type);
  860. SPVC_PUBLIC_API SpvDim spvc_type_get_image_dimension(spvc_type type);
  861. SPVC_PUBLIC_API spvc_bool spvc_type_get_image_is_depth(spvc_type type);
  862. SPVC_PUBLIC_API spvc_bool spvc_type_get_image_arrayed(spvc_type type);
  863. SPVC_PUBLIC_API spvc_bool spvc_type_get_image_multisampled(spvc_type type);
  864. SPVC_PUBLIC_API spvc_bool spvc_type_get_image_is_storage(spvc_type type);
  865. SPVC_PUBLIC_API SpvImageFormat spvc_type_get_image_storage_format(spvc_type type);
  866. SPVC_PUBLIC_API SpvAccessQualifier spvc_type_get_image_access_qualifier(spvc_type type);
  867. /*
  868. * Buffer layout query.
  869. * Maps to C++ API.
  870. */
  871. SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_struct_size(spvc_compiler compiler, spvc_type struct_type, size_t *size);
  872. SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_struct_size_runtime_array(spvc_compiler compiler,
  873. spvc_type struct_type, size_t array_size, size_t *size);
  874. SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_struct_member_size(spvc_compiler compiler, spvc_type type, unsigned index, size_t *size);
  875. SPVC_PUBLIC_API spvc_result spvc_compiler_type_struct_member_offset(spvc_compiler compiler,
  876. spvc_type type, unsigned index, unsigned *offset);
  877. SPVC_PUBLIC_API spvc_result spvc_compiler_type_struct_member_array_stride(spvc_compiler compiler,
  878. spvc_type type, unsigned index, unsigned *stride);
  879. SPVC_PUBLIC_API spvc_result spvc_compiler_type_struct_member_matrix_stride(spvc_compiler compiler,
  880. spvc_type type, unsigned index, unsigned *stride);
  881. /*
  882. * Workaround helper functions.
  883. * Maps to C++ API.
  884. */
  885. SPVC_PUBLIC_API spvc_result spvc_compiler_build_dummy_sampler_for_combined_images(spvc_compiler compiler, spvc_variable_id *id);
  886. SPVC_PUBLIC_API spvc_result spvc_compiler_build_combined_image_samplers(spvc_compiler compiler);
  887. SPVC_PUBLIC_API spvc_result spvc_compiler_get_combined_image_samplers(spvc_compiler compiler,
  888. const spvc_combined_image_sampler **samplers,
  889. size_t *num_samplers);
  890. /*
  891. * Constants
  892. * Maps to C++ API.
  893. */
  894. SPVC_PUBLIC_API spvc_result spvc_compiler_get_specialization_constants(spvc_compiler compiler,
  895. const spvc_specialization_constant **constants,
  896. size_t *num_constants);
  897. SPVC_PUBLIC_API spvc_constant spvc_compiler_get_constant_handle(spvc_compiler compiler,
  898. spvc_constant_id id);
  899. SPVC_PUBLIC_API spvc_constant_id spvc_compiler_get_work_group_size_specialization_constants(spvc_compiler compiler,
  900. spvc_specialization_constant *x,
  901. spvc_specialization_constant *y,
  902. spvc_specialization_constant *z);
  903. /*
  904. * Buffer ranges
  905. * Maps to C++ API.
  906. */
  907. SPVC_PUBLIC_API spvc_result spvc_compiler_get_active_buffer_ranges(spvc_compiler compiler,
  908. spvc_variable_id id,
  909. const spvc_buffer_range **ranges,
  910. size_t *num_ranges);
  911. /*
  912. * No stdint.h until C99, sigh :(
  913. * For smaller types, the result is sign or zero-extended as appropriate.
  914. * Maps to C++ API.
  915. * TODO: The SPIRConstant query interface and modification interface is not quite complete.
  916. */
  917. SPVC_PUBLIC_API float spvc_constant_get_scalar_fp16(spvc_constant constant, unsigned column, unsigned row);
  918. SPVC_PUBLIC_API float spvc_constant_get_scalar_fp32(spvc_constant constant, unsigned column, unsigned row);
  919. SPVC_PUBLIC_API double spvc_constant_get_scalar_fp64(spvc_constant constant, unsigned column, unsigned row);
  920. SPVC_PUBLIC_API unsigned spvc_constant_get_scalar_u32(spvc_constant constant, unsigned column, unsigned row);
  921. SPVC_PUBLIC_API int spvc_constant_get_scalar_i32(spvc_constant constant, unsigned column, unsigned row);
  922. SPVC_PUBLIC_API unsigned spvc_constant_get_scalar_u16(spvc_constant constant, unsigned column, unsigned row);
  923. SPVC_PUBLIC_API int spvc_constant_get_scalar_i16(spvc_constant constant, unsigned column, unsigned row);
  924. SPVC_PUBLIC_API unsigned spvc_constant_get_scalar_u8(spvc_constant constant, unsigned column, unsigned row);
  925. SPVC_PUBLIC_API int spvc_constant_get_scalar_i8(spvc_constant constant, unsigned column, unsigned row);
  926. SPVC_PUBLIC_API void spvc_constant_get_subconstants(spvc_constant constant, const spvc_constant_id **constituents, size_t *count);
  927. SPVC_PUBLIC_API unsigned long long spvc_constant_get_scalar_u64(spvc_constant constant, unsigned column, unsigned row);
  928. SPVC_PUBLIC_API long long spvc_constant_get_scalar_i64(spvc_constant constant, unsigned column, unsigned row);
  929. SPVC_PUBLIC_API spvc_type_id spvc_constant_get_type(spvc_constant constant);
  930. /*
  931. * C implementation of the C++ api.
  932. */
  933. SPVC_PUBLIC_API void spvc_constant_set_scalar_fp16(spvc_constant constant, unsigned column, unsigned row, unsigned short value);
  934. SPVC_PUBLIC_API void spvc_constant_set_scalar_fp32(spvc_constant constant, unsigned column, unsigned row, float value);
  935. SPVC_PUBLIC_API void spvc_constant_set_scalar_fp64(spvc_constant constant, unsigned column, unsigned row, double value);
  936. SPVC_PUBLIC_API void spvc_constant_set_scalar_u32(spvc_constant constant, unsigned column, unsigned row, unsigned value);
  937. SPVC_PUBLIC_API void spvc_constant_set_scalar_i32(spvc_constant constant, unsigned column, unsigned row, int value);
  938. SPVC_PUBLIC_API void spvc_constant_set_scalar_u64(spvc_constant constant, unsigned column, unsigned row, unsigned long long value);
  939. SPVC_PUBLIC_API void spvc_constant_set_scalar_i64(spvc_constant constant, unsigned column, unsigned row, long long value);
  940. SPVC_PUBLIC_API void spvc_constant_set_scalar_u16(spvc_constant constant, unsigned column, unsigned row, unsigned short value);
  941. SPVC_PUBLIC_API void spvc_constant_set_scalar_i16(spvc_constant constant, unsigned column, unsigned row, signed short value);
  942. SPVC_PUBLIC_API void spvc_constant_set_scalar_u8(spvc_constant constant, unsigned column, unsigned row, unsigned char value);
  943. SPVC_PUBLIC_API void spvc_constant_set_scalar_i8(spvc_constant constant, unsigned column, unsigned row, signed char value);
  944. /*
  945. * Misc reflection
  946. * Maps to C++ API.
  947. */
  948. SPVC_PUBLIC_API spvc_bool spvc_compiler_get_binary_offset_for_decoration(spvc_compiler compiler,
  949. spvc_variable_id id,
  950. SpvDecoration decoration,
  951. unsigned *word_offset);
  952. SPVC_PUBLIC_API spvc_bool spvc_compiler_buffer_is_hlsl_counter_buffer(spvc_compiler compiler, spvc_variable_id id);
  953. SPVC_PUBLIC_API spvc_bool spvc_compiler_buffer_get_hlsl_counter_buffer(spvc_compiler compiler, spvc_variable_id id,
  954. spvc_variable_id *counter_id);
  955. SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_capabilities(spvc_compiler compiler,
  956. const SpvCapability **capabilities,
  957. size_t *num_capabilities);
  958. SPVC_PUBLIC_API spvc_result spvc_compiler_get_declared_extensions(spvc_compiler compiler, const char ***extensions,
  959. size_t *num_extensions);
  960. SPVC_PUBLIC_API const char *spvc_compiler_get_remapped_declared_block_name(spvc_compiler compiler, spvc_variable_id id);
  961. SPVC_PUBLIC_API spvc_result spvc_compiler_get_buffer_block_decorations(spvc_compiler compiler, spvc_variable_id id,
  962. const SpvDecoration **decorations,
  963. size_t *num_decorations);
  964. #ifdef __cplusplus
  965. }
  966. #endif
  967. #endif