• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_OPENGL_450 = 450,
104     LAST_ELEMENT_MARKER(GLSLANG_TARGET_CLIENT_VERSION_COUNT),
105 } glslang_target_client_version_t;
106 
107 /* SH_TARGET_LanguageVersion counterpart */
108 typedef enum {
109     GLSLANG_TARGET_SPV_1_0 = (1 << 16),
110     GLSLANG_TARGET_SPV_1_1 = (1 << 16) | (1 << 8),
111     GLSLANG_TARGET_SPV_1_2 = (1 << 16) | (2 << 8),
112     GLSLANG_TARGET_SPV_1_3 = (1 << 16) | (3 << 8),
113     GLSLANG_TARGET_SPV_1_4 = (1 << 16) | (4 << 8),
114     GLSLANG_TARGET_SPV_1_5 = (1 << 16) | (5 << 8),
115     LAST_ELEMENT_MARKER(GLSLANG_TARGET_LANGUAGE_VERSION_COUNT),
116 } glslang_target_language_version_t;
117 
118 /* EShExecutable counterpart */
119 typedef enum { GLSLANG_EX_VERTEX_FRAGMENT, GLSLANG_EX_FRAGMENT } glslang_executable_t;
120 
121 /* EShOptimizationLevel counterpart  */
122 typedef enum {
123     GLSLANG_OPT_NO_GENERATION,
124     GLSLANG_OPT_NONE,
125     GLSLANG_OPT_SIMPLE,
126     GLSLANG_OPT_FULL,
127     LAST_ELEMENT_MARKER(GLSLANG_OPT_LEVEL_COUNT),
128 } glslang_optimization_level_t;
129 
130 /* EShTextureSamplerTransformMode counterpart */
131 typedef enum {
132     GLSLANG_TEX_SAMP_TRANS_KEEP,
133     GLSLANG_TEX_SAMP_TRANS_UPGRADE_TEXTURE_REMOVE_SAMPLER,
134     LAST_ELEMENT_MARKER(GLSLANG_TEX_SAMP_TRANS_COUNT),
135 } glslang_texture_sampler_transform_mode_t;
136 
137 /* EShMessages counterpart */
138 typedef enum {
139     GLSLANG_MSG_DEFAULT_BIT = 0,
140     GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 << 0),
141     GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 << 1),
142     GLSLANG_MSG_AST_BIT = (1 << 2),
143     GLSLANG_MSG_SPV_RULES_BIT = (1 << 3),
144     GLSLANG_MSG_VULKAN_RULES_BIT = (1 << 4),
145     GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 << 5),
146     GLSLANG_MSG_READ_HLSL_BIT = (1 << 6),
147     GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 << 7),
148     GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 << 8),
149     GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 << 9),
150     GLSLANG_MSG_DEBUG_INFO_BIT = (1 << 10),
151     GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT = (1 << 11),
152     GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 << 12),
153     GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 << 13),
154     GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 << 14),
155     LAST_ELEMENT_MARKER(GLSLANG_MSG_COUNT),
156 } glslang_messages_t;
157 
158 /* EShReflectionOptions counterpart */
159 typedef enum {
160     GLSLANG_REFLECTION_DEFAULT_BIT = 0,
161     GLSLANG_REFLECTION_STRICT_ARRAY_SUFFIX_BIT = (1 << 0),
162     GLSLANG_REFLECTION_BASIC_ARRAY_SUFFIX_BIT = (1 << 1),
163     GLSLANG_REFLECTION_INTERMEDIATE_IOO_BIT = (1 << 2),
164     GLSLANG_REFLECTION_SEPARATE_BUFFERS_BIT = (1 << 3),
165     GLSLANG_REFLECTION_ALL_BLOCK_VARIABLES_BIT = (1 << 4),
166     GLSLANG_REFLECTION_UNWRAP_IO_BLOCKS_BIT = (1 << 5),
167     GLSLANG_REFLECTION_ALL_IO_VARIABLES_BIT = (1 << 6),
168     GLSLANG_REFLECTION_SHARED_STD140_SSBO_BIT = (1 << 7),
169     GLSLANG_REFLECTION_SHARED_STD140_UBO_BIT = (1 << 8),
170     LAST_ELEMENT_MARKER(GLSLANG_REFLECTION_COUNT),
171 } glslang_reflection_options_t;
172 
173 /* EProfile counterpart (from Versions.h) */
174 typedef enum {
175     GLSLANG_BAD_PROFILE = 0,
176     GLSLANG_NO_PROFILE = (1 << 0),
177     GLSLANG_CORE_PROFILE = (1 << 1),
178     GLSLANG_COMPATIBILITY_PROFILE = (1 << 2),
179     GLSLANG_ES_PROFILE = (1 << 3),
180     LAST_ELEMENT_MARKER(GLSLANG_PROFILE_COUNT),
181 } glslang_profile_t;
182 
183 #undef LAST_ELEMENT_MARKER
184 
185 #endif
186