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_NV,
47     GLSLANG_STAGE_INTERSECT_NV,
48     GLSLANG_STAGE_ANYHIT_NV,
49     GLSLANG_STAGE_CLOSESTHIT_NV,
50     GLSLANG_STAGE_MISS_NV,
51     GLSLANG_STAGE_CALLABLE_NV,
52     GLSLANG_STAGE_TASK_NV,
53     GLSLANG_STAGE_MESH_NV,
54     LAST_ELEMENT_MARKER(GLSLANG_STAGE_COUNT),
55 } glslang_stage_t; // would be better as stage, but this is ancient now
56 
57 /* EShLanguageMask counterpart */
58 typedef enum {
59     GLSLANG_STAGE_VERTEX_MASK = (1 << GLSLANG_STAGE_VERTEX),
60     GLSLANG_STAGE_TESSCONTROL_MASK = (1 << GLSLANG_STAGE_TESSCONTROL),
61     GLSLANG_STAGE_TESSEVALUATION_MASK = (1 << GLSLANG_STAGE_TESSEVALUATION),
62     GLSLANG_STAGE_GEOMETRY_MASK = (1 << GLSLANG_STAGE_GEOMETRY),
63     GLSLANG_STAGE_FRAGMENT_MASK = (1 << GLSLANG_STAGE_FRAGMENT),
64     GLSLANG_STAGE_COMPUTE_MASK = (1 << GLSLANG_STAGE_COMPUTE),
65     GLSLANG_STAGE_RAYGEN_NV_MASK = (1 << GLSLANG_STAGE_RAYGEN_NV),
66     GLSLANG_STAGE_INTERSECT_NV_MASK = (1 << GLSLANG_STAGE_INTERSECT_NV),
67     GLSLANG_STAGE_ANYHIT_NV_MASK = (1 << GLSLANG_STAGE_ANYHIT_NV),
68     GLSLANG_STAGE_CLOSESTHIT_NV_MASK = (1 << GLSLANG_STAGE_CLOSESTHIT_NV),
69     GLSLANG_STAGE_MISS_NV_MASK = (1 << GLSLANG_STAGE_MISS_NV),
70     GLSLANG_STAGE_CALLABLE_NV_MASK = (1 << GLSLANG_STAGE_CALLABLE_NV),
71     GLSLANG_STAGE_TASK_NV_MASK = (1 << GLSLANG_STAGE_TASK_NV),
72     GLSLANG_STAGE_MESH_NV_MASK = (1 << GLSLANG_STAGE_MESH_NV),
73     LAST_ELEMENT_MARKER(GLSLANG_STAGE_MASK_COUNT),
74 } glslang_stage_mask_t;
75 
76 /* EShSource counterpart */
77 typedef enum {
78     GLSLANG_SOURCE_NONE,
79     GLSLANG_SOURCE_GLSL,
80     GLSLANG_SOURCE_HLSL,
81     LAST_ELEMENT_MARKER(GLSLANG_SOURCE_COUNT),
82 } glslang_source_t;
83 
84 /* EShClient counterpart */
85 typedef enum {
86     GLSLANG_CLIENT_NONE,
87     GLSLANG_CLIENT_VULKAN,
88     GLSLANG_CLIENT_OPENGL,
89     LAST_ELEMENT_MARKER(GLSLANG_CLIENT_COUNT),
90 } glslang_client_t;
91 
92 /* EShTargetLanguage counterpart */
93 typedef enum {
94     GLSLANG_TARGET_NONE,
95     GLSLANG_TARGET_SPV,
96     LAST_ELEMENT_MARKER(GLSLANG_TARGET_COUNT),
97 } glslang_target_language_t;
98 
99 /* SH_TARGET_ClientVersion counterpart */
100 typedef enum {
101     GLSLANG_TARGET_VULKAN_1_0 = (1 << 22),
102     GLSLANG_TARGET_VULKAN_1_1 = (1 << 22) | (1 << 12),
103     GLSLANG_TARGET_VULKAN_1_2 = (1 << 22) | (2 << 12),
104     GLSLANG_TARGET_OPENGL_450 = 450,
105     LAST_ELEMENT_MARKER(GLSLANG_TARGET_CLIENT_VERSION_COUNT = 4),
106 } glslang_target_client_version_t;
107 
108 /* SH_TARGET_LanguageVersion counterpart */
109 typedef enum {
110     GLSLANG_TARGET_SPV_1_0 = (1 << 16),
111     GLSLANG_TARGET_SPV_1_1 = (1 << 16) | (1 << 8),
112     GLSLANG_TARGET_SPV_1_2 = (1 << 16) | (2 << 8),
113     GLSLANG_TARGET_SPV_1_3 = (1 << 16) | (3 << 8),
114     GLSLANG_TARGET_SPV_1_4 = (1 << 16) | (4 << 8),
115     GLSLANG_TARGET_SPV_1_5 = (1 << 16) | (5 << 8),
116     LAST_ELEMENT_MARKER(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT = 6),
117 } glslang_target_language_version_t;
118 
119 /* EShExecutable counterpart */
120 typedef enum { GLSLANG_EX_VERTEX_FRAGMENT, GLSLANG_EX_FRAGMENT } glslang_executable_t;
121 
122 /* EShOptimizationLevel counterpart  */
123 typedef enum {
124     GLSLANG_OPT_NO_GENERATION,
125     GLSLANG_OPT_NONE,
126     GLSLANG_OPT_SIMPLE,
127     GLSLANG_OPT_FULL,
128     LAST_ELEMENT_MARKER(GLSLANG_OPT_LEVEL_COUNT),
129 } glslang_optimization_level_t;
130 
131 /* EShTextureSamplerTransformMode counterpart */
132 typedef enum {
133     GLSLANG_TEX_SAMP_TRANS_KEEP,
134     GLSLANG_TEX_SAMP_TRANS_UPGRADE_TEXTURE_REMOVE_SAMPLER,
135     LAST_ELEMENT_MARKER(GLSLANG_TEX_SAMP_TRANS_COUNT),
136 } glslang_texture_sampler_transform_mode_t;
137 
138 /* EShMessages counterpart */
139 typedef enum {
140     GLSLANG_MSG_DEFAULT_BIT = 0,
141     GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 << 0),
142     GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 << 1),
143     GLSLANG_MSG_AST_BIT = (1 << 2),
144     GLSLANG_MSG_SPV_RULES_BIT = (1 << 3),
145     GLSLANG_MSG_VULKAN_RULES_BIT = (1 << 4),
146     GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 << 5),
147     GLSLANG_MSG_READ_HLSL_BIT = (1 << 6),
148     GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 << 7),
149     GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 << 8),
150     GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 << 9),
151     GLSLANG_MSG_DEBUG_INFO_BIT = (1 << 10),
152     GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT = (1 << 11),
153     GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 << 12),
154     GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 << 13),
155     GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 << 14),
156     LAST_ELEMENT_MARKER(GLSLANG_MSG_COUNT),
157 } glslang_messages_t;
158 
159 /* EShReflectionOptions counterpart */
160 typedef enum {
161     GLSLANG_REFLECTION_DEFAULT_BIT = 0,
162     GLSLANG_REFLECTION_STRICT_ARRAY_SUFFIX_BIT = (1 << 0),
163     GLSLANG_REFLECTION_BASIC_ARRAY_SUFFIX_BIT = (1 << 1),
164     GLSLANG_REFLECTION_INTERMEDIATE_IOO_BIT = (1 << 2),
165     GLSLANG_REFLECTION_SEPARATE_BUFFERS_BIT = (1 << 3),
166     GLSLANG_REFLECTION_ALL_BLOCK_VARIABLES_BIT = (1 << 4),
167     GLSLANG_REFLECTION_UNWRAP_IO_BLOCKS_BIT = (1 << 5),
168     GLSLANG_REFLECTION_ALL_IO_VARIABLES_BIT = (1 << 6),
169     GLSLANG_REFLECTION_SHARED_STD140_SSBO_BIT = (1 << 7),
170     GLSLANG_REFLECTION_SHARED_STD140_UBO_BIT = (1 << 8),
171     LAST_ELEMENT_MARKER(GLSLANG_REFLECTION_COUNT),
172 } glslang_reflection_options_t;
173 
174 /* EProfile counterpart (from Versions.h) */
175 typedef enum {
176     GLSLANG_BAD_PROFILE = 0,
177     GLSLANG_NO_PROFILE = (1 << 0),
178     GLSLANG_CORE_PROFILE = (1 << 1),
179     GLSLANG_COMPATIBILITY_PROFILE = (1 << 2),
180     GLSLANG_ES_PROFILE = (1 << 3),
181     LAST_ELEMENT_MARKER(GLSLANG_PROFILE_COUNT),
182 } glslang_profile_t;
183 
184 #undef LAST_ELEMENT_MARKER
185 
186 #endif
187