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