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