Fix: Remove NV suffix from C interface
[platform/upstream/glslang.git] / glslang / Include / glslang_c_shader_types.h
1 /**
2     This code is based on the glslang_c_interface implementation by Viktor Latypov
3 **/
4
5 /**
6 BSD 2-Clause License
7
8 Copyright (c) 2019, Viktor Latypov
9 All rights reserved.
10
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are met:
13
14 1. Redistributions of source code must retain the above copyright notice, this
15    list of conditions and the following disclaimer.
16
17 2. Redistributions in binary form must reproduce the above copyright notice,
18    this list of conditions and the following disclaimer in the documentation
19    and/or other materials provided with the distribution.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 **/
32
33 #ifndef C_SHADER_TYPES_H_INCLUDED
34 #define C_SHADER_TYPES_H_INCLUDED
35
36 #define LAST_ELEMENT_MARKER(x) x
37
38 /* EShLanguage counterpart */
39 typedef enum {
40     GLSLANG_STAGE_VERTEX,
41     GLSLANG_STAGE_TESSCONTROL,
42     GLSLANG_STAGE_TESSEVALUATION,
43     GLSLANG_STAGE_GEOMETRY,
44     GLSLANG_STAGE_FRAGMENT,
45     GLSLANG_STAGE_COMPUTE,
46     GLSLANG_STAGE_RAYGEN,
47     GLSLANG_STAGE_RAYGEN_NV = GLSLANG_STAGE_RAYGEN,
48     GLSLANG_STAGE_INTERSECT,
49     GLSLANG_STAGE_INTERSECT_NV = GLSLANG_STAGE_INTERSECT,
50     GLSLANG_STAGE_ANYHIT,
51     GLSLANG_STAGE_ANYHIT_NV = GLSLANG_STAGE_ANYHIT,
52     GLSLANG_STAGE_CLOSESTHIT,
53     GLSLANG_STAGE_CLOSESTHIT_NV = GLSLANG_STAGE_CLOSESTHIT,
54     GLSLANG_STAGE_MISS,
55     GLSLANG_STAGE_MISS_NV = GLSLANG_STAGE_MISS,
56     GLSLANG_STAGE_CALLABLE,
57     GLSLANG_STAGE_CALLABLE_NV = GLSLANG_STAGE_CALLABLE,
58     GLSLANG_STAGE_TASK,
59     GLSLANG_STAGE_TASK_NV = GLSLANG_STAGE_TASK,
60     GLSLANG_STAGE_MESH,
61     GLSLANG_STAGE_MESH_NV = GLSLANG_STAGE_MESH,
62     LAST_ELEMENT_MARKER(GLSLANG_STAGE_COUNT),
63 } glslang_stage_t; // would be better as stage, but this is ancient now
64
65 /* EShLanguageMask counterpart */
66 typedef enum {
67     GLSLANG_STAGE_VERTEX_MASK = (1 << GLSLANG_STAGE_VERTEX),
68     GLSLANG_STAGE_TESSCONTROL_MASK = (1 << GLSLANG_STAGE_TESSCONTROL),
69     GLSLANG_STAGE_TESSEVALUATION_MASK = (1 << GLSLANG_STAGE_TESSEVALUATION),
70     GLSLANG_STAGE_GEOMETRY_MASK = (1 << GLSLANG_STAGE_GEOMETRY),
71     GLSLANG_STAGE_FRAGMENT_MASK = (1 << GLSLANG_STAGE_FRAGMENT),
72     GLSLANG_STAGE_COMPUTE_MASK = (1 << GLSLANG_STAGE_COMPUTE),
73     GLSLANG_STAGE_RAYGEN_MASK = (1 << GLSLANG_STAGE_RAYGEN),
74     GLSLANG_STAGE_RAYGEN_NV_MASK = GLSLANG_STAGE_RAYGEN_MASK,
75     GLSLANG_STAGE_INTERSECT_MASK = (1 << GLSLANG_STAGE_INTERSECT),
76     GLSLANG_STAGE_INTERSECT_NV_MASK = GLSLANG_STAGE_INTERSECT_MASK,
77     GLSLANG_STAGE_ANYHIT_MASK = (1 << GLSLANG_STAGE_ANYHIT),
78     GLSLANG_STAGE_ANYHIT_NV_MASK = GLSLANG_STAGE_ANYHIT_MASK,
79     GLSLANG_STAGE_CLOSESTHIT_MASK = (1 << GLSLANG_STAGE_CLOSESTHIT),
80     GLSLANG_STAGE_CLOSESTHIT_NV_MASK = GLSLANG_STAGE_CLOSESTHIT_MASK,
81     GLSLANG_STAGE_MISS_MASK = (1 << GLSLANG_STAGE_MISS),
82     GLSLANG_STAGE_MISS_NV_MASK = GLSLANG_STAGE_MISS_MASK,
83     GLSLANG_STAGE_CALLABLE_MASK = (1 << GLSLANG_STAGE_CALLABLE),
84     GLSLANG_STAGE_CALLABLE_NV_MASK = GLSLANG_STAGE_CALLABLE_MASK,
85     GLSLANG_STAGE_TASK_MASK = (1 << GLSLANG_STAGE_TASK),
86     GLSLANG_STAGE_TASK_NV_MASK = GLSLANG_STAGE_TASK_MASK,
87     GLSLANG_STAGE_MESH_MASK = (1 << GLSLANG_STAGE_MESH),
88     GLSLANG_STAGE_MESH_NV_MASK = GLSLANG_STAGE_MESH_MASK,
89     LAST_ELEMENT_MARKER(GLSLANG_STAGE_MASK_COUNT),
90 } glslang_stage_mask_t;
91
92 /* EShSource counterpart */
93 typedef enum {
94     GLSLANG_SOURCE_NONE,
95     GLSLANG_SOURCE_GLSL,
96     GLSLANG_SOURCE_HLSL,
97     LAST_ELEMENT_MARKER(GLSLANG_SOURCE_COUNT),
98 } glslang_source_t;
99
100 /* EShClient counterpart */
101 typedef enum {
102     GLSLANG_CLIENT_NONE,
103     GLSLANG_CLIENT_VULKAN,
104     GLSLANG_CLIENT_OPENGL,
105     LAST_ELEMENT_MARKER(GLSLANG_CLIENT_COUNT),
106 } glslang_client_t;
107
108 /* EShTargetLanguage counterpart */
109 typedef enum {
110     GLSLANG_TARGET_NONE,
111     GLSLANG_TARGET_SPV,
112     LAST_ELEMENT_MARKER(GLSLANG_TARGET_COUNT),
113 } glslang_target_language_t;
114
115 /* SH_TARGET_ClientVersion counterpart */
116 typedef enum {
117     GLSLANG_TARGET_VULKAN_1_0 = (1 << 22),
118     GLSLANG_TARGET_VULKAN_1_1 = (1 << 22) | (1 << 12),
119     GLSLANG_TARGET_VULKAN_1_2 = (1 << 22) | (2 << 12),
120     GLSLANG_TARGET_VULKAN_1_3 = (1 << 22) | (3 << 12),
121     GLSLANG_TARGET_OPENGL_450 = 450,
122     LAST_ELEMENT_MARKER(GLSLANG_TARGET_CLIENT_VERSION_COUNT = 5),
123 } glslang_target_client_version_t;
124
125 /* SH_TARGET_LanguageVersion counterpart */
126 typedef enum {
127     GLSLANG_TARGET_SPV_1_0 = (1 << 16),
128     GLSLANG_TARGET_SPV_1_1 = (1 << 16) | (1 << 8),
129     GLSLANG_TARGET_SPV_1_2 = (1 << 16) | (2 << 8),
130     GLSLANG_TARGET_SPV_1_3 = (1 << 16) | (3 << 8),
131     GLSLANG_TARGET_SPV_1_4 = (1 << 16) | (4 << 8),
132     GLSLANG_TARGET_SPV_1_5 = (1 << 16) | (5 << 8),
133     GLSLANG_TARGET_SPV_1_6 = (1 << 16) | (6 << 8),
134     LAST_ELEMENT_MARKER(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT = 7),
135 } glslang_target_language_version_t;
136
137 /* EShExecutable counterpart */
138 typedef enum { GLSLANG_EX_VERTEX_FRAGMENT, GLSLANG_EX_FRAGMENT } glslang_executable_t;
139
140 // EShOptimizationLevel counterpart
141 // This enum is not used in the current C interface, but could be added at a later date.
142 // GLSLANG_OPT_NONE is the current default.
143 typedef enum {
144     GLSLANG_OPT_NO_GENERATION,
145     GLSLANG_OPT_NONE,
146     GLSLANG_OPT_SIMPLE,
147     GLSLANG_OPT_FULL,
148     LAST_ELEMENT_MARKER(GLSLANG_OPT_LEVEL_COUNT),
149 } glslang_optimization_level_t;
150
151 /* EShTextureSamplerTransformMode counterpart */
152 typedef enum {
153     GLSLANG_TEX_SAMP_TRANS_KEEP,
154     GLSLANG_TEX_SAMP_TRANS_UPGRADE_TEXTURE_REMOVE_SAMPLER,
155     LAST_ELEMENT_MARKER(GLSLANG_TEX_SAMP_TRANS_COUNT),
156 } glslang_texture_sampler_transform_mode_t;
157
158 /* EShMessages counterpart */
159 typedef enum {
160     GLSLANG_MSG_DEFAULT_BIT = 0,
161     GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 << 0),
162     GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 << 1),
163     GLSLANG_MSG_AST_BIT = (1 << 2),
164     GLSLANG_MSG_SPV_RULES_BIT = (1 << 3),
165     GLSLANG_MSG_VULKAN_RULES_BIT = (1 << 4),
166     GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 << 5),
167     GLSLANG_MSG_READ_HLSL_BIT = (1 << 6),
168     GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 << 7),
169     GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 << 8),
170     GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 << 9),
171     GLSLANG_MSG_DEBUG_INFO_BIT = (1 << 10),
172     GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT = (1 << 11),
173     GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 << 12),
174     GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 << 13),
175     GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 << 14),
176     GLSLANG_MSG_ENHANCED = (1 << 15),
177     LAST_ELEMENT_MARKER(GLSLANG_MSG_COUNT),
178 } glslang_messages_t;
179
180 /* EShReflectionOptions counterpart */
181 typedef enum {
182     GLSLANG_REFLECTION_DEFAULT_BIT = 0,
183     GLSLANG_REFLECTION_STRICT_ARRAY_SUFFIX_BIT = (1 << 0),
184     GLSLANG_REFLECTION_BASIC_ARRAY_SUFFIX_BIT = (1 << 1),
185     GLSLANG_REFLECTION_INTERMEDIATE_IOO_BIT = (1 << 2),
186     GLSLANG_REFLECTION_SEPARATE_BUFFERS_BIT = (1 << 3),
187     GLSLANG_REFLECTION_ALL_BLOCK_VARIABLES_BIT = (1 << 4),
188     GLSLANG_REFLECTION_UNWRAP_IO_BLOCKS_BIT = (1 << 5),
189     GLSLANG_REFLECTION_ALL_IO_VARIABLES_BIT = (1 << 6),
190     GLSLANG_REFLECTION_SHARED_STD140_SSBO_BIT = (1 << 7),
191     GLSLANG_REFLECTION_SHARED_STD140_UBO_BIT = (1 << 8),
192     LAST_ELEMENT_MARKER(GLSLANG_REFLECTION_COUNT),
193 } glslang_reflection_options_t;
194
195 /* EProfile counterpart (from Versions.h) */
196 typedef enum {
197     GLSLANG_BAD_PROFILE = 0,
198     GLSLANG_NO_PROFILE = (1 << 0),
199     GLSLANG_CORE_PROFILE = (1 << 1),
200     GLSLANG_COMPATIBILITY_PROFILE = (1 << 2),
201     GLSLANG_ES_PROFILE = (1 << 3),
202     LAST_ELEMENT_MARKER(GLSLANG_PROFILE_COUNT),
203 } glslang_profile_t;
204
205 /* Shader options */
206 typedef enum {
207     GLSLANG_SHADER_DEFAULT_BIT = 0,
208     GLSLANG_SHADER_AUTO_MAP_BINDINGS = (1 << 0),
209     GLSLANG_SHADER_AUTO_MAP_LOCATIONS = (1 << 1),
210     GLSLANG_SHADER_VULKAN_RULES_RELAXED = (1 << 2),
211     LAST_ELEMENT_MARKER(GLSLANG_SHADER_COUNT),
212 } glslang_shader_options_t;
213
214 /* TResourceType counterpart */
215 typedef enum {
216     GLSLANG_RESOURCE_TYPE_SAMPLER,
217     GLSLANG_RESOURCE_TYPE_TEXTURE,
218     GLSLANG_RESOURCE_TYPE_IMAGE,
219     GLSLANG_RESOURCE_TYPE_UBO,
220     GLSLANG_RESOURCE_TYPE_SSBO,
221     GLSLANG_RESOURCE_TYPE_UAV,
222     LAST_ELEMENT_MARKER(GLSLANG_RESOURCE_TYPE_COUNT),
223 } glslang_resource_type_t;
224
225 #undef LAST_ELEMENT_MARKER
226
227 #endif