Debian Codegraph @

thirdparty/spirv-reflect/spirv_reflect.h

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