Mercurial > games > semicongine
annotate src/glslang/glslang_c_interface.nim @ 10:0660ba9d1930
did: make it work on windows
author | sam <sam@basx.dev> |
---|---|
date | Sat, 24 Dec 2022 22:32:46 +0700 |
parents | 213fdf8d31dd |
children |
rev | line source |
---|---|
2
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
1 import std/strformat |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
2 |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
3 when defined(linux): |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
4 const platform = "linux" |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
5 when defined(windows): |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
6 const platform = "windows" |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
7 |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
8 |
1 | 9 when defined(release): |
2
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
10 const libversion = "release" |
1 | 11 else: |
2
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
12 const libversion = "debug" |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
13 |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
14 |
213fdf8d31dd
did: hello world triangle, a bit of code organization
Sam <sam@basx.dev>
parents:
1
diff
changeset
|
15 # required to link the GLSL compiler |
10 | 16 when defined(linux): |
17 {.passl: &"-Lthirdparty/lib/glslang/{platform}_{libversion}" .} | |
18 {.passl: &"-Lthirdparty/lib/spirv-tools/{platform}_{libversion}" .} | |
19 {.passl: "-lglslang" .} | |
20 {.passl: "-lglslang-default-resource-limits" .} | |
21 {.passl: "-lHLSL" .} | |
22 {.passl: "-lMachineIndependent" .} | |
23 {.passl: "-lGenericCodeGen" .} | |
24 {.passl: "-lOSDependent" .} | |
25 {.passl: "-lOGLCompiler" .} | |
26 {.passl: "-lSPIRV" .} | |
27 {.passl: "-lSPIRV-Tools-opt" .} | |
28 {.passl: "-lSPIRV-Tools" .} | |
29 {.passl: "-lSPIRV-Tools-diff" .} | |
30 {.passl: "-lSPIRV-Tools-fuzz" .} | |
31 {.passl: "-lSPIRV-Tools-link" .} | |
32 {.passl: "-lSPIRV-Tools-lint" .} | |
33 {.passl: "-lSPIRV-Tools-opt" .} | |
34 {.passl: "-lSPIRV-Tools-reduce" .} | |
1 | 35 |
10 | 36 {.passl: "-lstdc++" .} |
37 {.passl: "-lm" .} | |
38 when defined(windows): | |
39 when libversion == "release": | |
40 const LIB_POSTFIX = ".lib" | |
41 when libversion == "debug": | |
42 const LIB_POSTFIX = "d.lib" | |
43 | |
44 {.passl: "/link" .} | |
45 {.passl: &"/LIBPATH:./thirdparty/lib/glslang/{platform}_{libversion}" .} | |
46 {.passl: &"/LIBPATH:./thirdparty/lib/spirv-tools/{platform}_{libversion}" .} | |
47 {.passl: "glslang" & LIB_POSTFIX .} | |
48 {.passl: "glslang-default-resource-limits" & LIB_POSTFIX .} | |
49 {.passl: "HLSL" & LIB_POSTFIX .} | |
50 {.passl: "MachineIndependent" & LIB_POSTFIX .} | |
51 {.passl: "GenericCodeGen" & LIB_POSTFIX .} | |
52 {.passl: "OSDependent" & LIB_POSTFIX .} | |
53 {.passl: "OGLCompiler" & LIB_POSTFIX .} | |
54 {.passl: "SPIRV" & LIB_POSTFIX .} | |
55 {.passl: "SPIRV-Tools-opt.lib" .} | |
56 {.passl: "SPIRV-Tools.lib" .} | |
57 {.passl: "SPIRV-Tools-diff.lib" .} | |
58 {.passl: "SPIRV-Tools-fuzz.lib" .} | |
59 {.passl: "SPIRV-Tools-link.lib" .} | |
60 {.passl: "SPIRV-Tools-lint.lib" .} | |
61 {.passl: "SPIRV-Tools-opt.lib" .} | |
62 {.passl: "SPIRV-Tools-reduce.lib" .} | |
1 | 63 |
10 | 64 |
1 | 65 |
0 | 66 import |
67 glslang_c_shader_types | |
68 | |
1 | 69 type |
70 glslang_shader_t* {.nodecl incompleteStruct.} = object | |
71 glslang_program_t* {.nodecl incompleteStruct.} = object | |
0 | 72 glslang_limits_t* {.bycopy.} = object |
73 non_inductive_for_loops*: bool | |
74 while_loops*: bool | |
75 do_while_loops*: bool | |
76 general_uniform_indexing*: bool | |
77 general_attribute_matrix_vector_indexing*: bool | |
78 general_varying_indexing*: bool | |
79 general_sampler_indexing*: bool | |
80 general_variable_indexing*: bool | |
81 general_constant_matrix_vector_indexing*: bool | |
82 glslang_resource_t* {.bycopy.} = object | |
83 max_lights*: cint | |
84 max_clip_planes*: cint | |
85 max_texture_units*: cint | |
86 max_texture_coords*: cint | |
87 max_vertex_attribs*: cint | |
88 max_vertex_uniform_components*: cint | |
89 max_varying_floats*: cint | |
90 max_vertex_texture_image_units*: cint | |
91 max_combined_texture_image_units*: cint | |
92 max_texture_image_units*: cint | |
93 max_fragment_uniform_components*: cint | |
94 max_draw_buffers*: cint | |
95 max_vertex_uniform_vectors*: cint | |
96 max_varying_vectors*: cint | |
97 max_fragment_uniform_vectors*: cint | |
98 max_vertex_output_vectors*: cint | |
99 max_fragment_input_vectors*: cint | |
100 min_program_texel_offset*: cint | |
101 max_program_texel_offset*: cint | |
102 max_clip_distances*: cint | |
103 max_compute_work_group_count_x*: cint | |
104 max_compute_work_group_count_y*: cint | |
105 max_compute_work_group_count_z*: cint | |
106 max_compute_work_group_size_x*: cint | |
107 max_compute_work_group_size_y*: cint | |
108 max_compute_work_group_size_z*: cint | |
109 max_compute_uniform_components*: cint | |
110 max_compute_texture_image_units*: cint | |
111 max_compute_image_uniforms*: cint | |
112 max_compute_atomic_counters*: cint | |
113 max_compute_atomic_counter_buffers*: cint | |
114 max_varying_components*: cint | |
115 max_vertex_output_components*: cint | |
116 max_geometry_input_components*: cint | |
117 max_geometry_output_components*: cint | |
118 max_fragment_input_components*: cint | |
119 max_image_units*: cint | |
120 max_combined_image_units_and_fragment_outputs*: cint | |
121 max_combined_shader_output_resources*: cint | |
122 max_image_samples*: cint | |
123 max_vertex_image_uniforms*: cint | |
124 max_tess_control_image_uniforms*: cint | |
125 max_tess_evaluation_image_uniforms*: cint | |
126 max_geometry_image_uniforms*: cint | |
127 max_fragment_image_uniforms*: cint | |
128 max_combined_image_uniforms*: cint | |
129 max_geometry_texture_image_units*: cint | |
130 max_geometry_output_vertices*: cint | |
131 max_geometry_total_output_components*: cint | |
132 max_geometry_uniform_components*: cint | |
133 max_geometry_varying_components*: cint | |
134 max_tess_control_input_components*: cint | |
135 max_tess_control_output_components*: cint | |
136 max_tess_control_texture_image_units*: cint | |
137 max_tess_control_uniform_components*: cint | |
138 max_tess_control_total_output_components*: cint | |
139 max_tess_evaluation_input_components*: cint | |
140 max_tess_evaluation_output_components*: cint | |
141 max_tess_evaluation_texture_image_units*: cint | |
142 max_tess_evaluation_uniform_components*: cint | |
143 max_tess_patch_components*: cint | |
144 max_patch_vertices*: cint | |
145 max_tess_gen_level*: cint | |
146 max_viewports*: cint | |
147 max_vertex_atomic_counters*: cint | |
148 max_tess_control_atomic_counters*: cint | |
149 max_tess_evaluation_atomic_counters*: cint | |
150 max_geometry_atomic_counters*: cint | |
151 max_fragment_atomic_counters*: cint | |
152 max_combined_atomic_counters*: cint | |
153 max_atomic_counter_bindings*: cint | |
154 max_vertex_atomic_counter_buffers*: cint | |
155 max_tess_control_atomic_counter_buffers*: cint | |
156 max_tess_evaluation_atomic_counter_buffers*: cint | |
157 max_geometry_atomic_counter_buffers*: cint | |
158 max_fragment_atomic_counter_buffers*: cint | |
159 max_combined_atomic_counter_buffers*: cint | |
160 max_atomic_counter_buffer_size*: cint | |
161 max_transform_feedback_buffers*: cint | |
162 max_transform_feedback_interleaved_components*: cint | |
163 max_cull_distances*: cint | |
164 max_combined_clip_and_cull_distances*: cint | |
165 max_samples*: cint | |
166 max_mesh_output_vertices_nv*: cint | |
167 max_mesh_output_primitives_nv*: cint | |
168 max_mesh_work_group_size_x_nv*: cint | |
169 max_mesh_work_group_size_y_nv*: cint | |
170 max_mesh_work_group_size_z_nv*: cint | |
171 max_task_work_group_size_x_nv*: cint | |
172 max_task_work_group_size_y_nv*: cint | |
173 max_task_work_group_size_z_nv*: cint | |
174 max_mesh_view_count_nv*: cint | |
175 max_mesh_output_vertices_ext*: cint | |
176 max_mesh_output_primitives_ext*: cint | |
177 max_mesh_work_group_size_x_ext*: cint | |
178 max_mesh_work_group_size_y_ext*: cint | |
179 max_mesh_work_group_size_z_ext*: cint | |
180 max_task_work_group_size_x_ext*: cint | |
181 max_task_work_group_size_y_ext*: cint | |
182 max_task_work_group_size_z_ext*: cint | |
183 max_mesh_view_count_ext*: cint | |
184 maxDualSourceDrawBuffersEXT*: cint | |
185 limits*: glslang_limits_t | |
186 glslang_input_t* {.bycopy.} = object | |
187 language*: glslang_source_t | |
188 stage*: glslang_stage_t | |
189 client*: glslang_client_t | |
190 client_version*: glslang_target_client_version_t | |
191 target_language*: glslang_target_language_t | |
192 target_language_version*: glslang_target_language_version_t | |
193 code*: cstring | |
194 default_version*: cint | |
195 default_profile*: glslang_profile_t | |
196 force_default_version_and_profile*: cint | |
197 forward_compatible*: cint | |
198 messages*: glslang_messages_t | |
199 resource*: ptr glslang_resource_t | |
200 glsl_include_result_t* {.bycopy.} = object | |
201 ## Header file name or NULL if inclusion failed | |
202 header_name*: cstring | |
203 ## Header contents or NULL | |
204 header_data*: cstring | |
205 header_length*: csize_t | |
1 | 206 glsl_include_local_func* = proc (ctx: pointer; header_name: cstring; includer_name: cstring; include_depth: csize_t): ptr glsl_include_result_t |
207 glsl_include_system_func* = proc (ctx: pointer; header_name: cstring; includer_name: cstring; include_depth: csize_t): ptr glsl_include_result_t | |
208 glsl_free_include_result_func* = proc (ctx: pointer; result: ptr glsl_include_result_t): cint | |
0 | 209 glsl_include_callbacks_t* {.bycopy.} = object |
210 include_system*: glsl_include_system_func | |
211 include_local*: glsl_include_local_func | |
212 free_include_result*: glsl_free_include_result_func | |
213 glslang_spv_options_t* {.bycopy.} = object | |
214 generate_debug_info*: bool | |
215 strip_debug_info*: bool | |
216 disable_optimizer*: bool | |
217 optimize_size*: bool | |
218 disassemble*: bool | |
219 validate*: bool | |
220 emit_nonsemantic_shader_debug_info*: bool | |
221 emit_nonsemantic_shader_debug_source*: bool | |
222 | |
223 proc glslang_initialize_process*(): cint {.importc.} | |
224 proc glslang_finalize_process*() {.importc.} | |
225 proc glslang_shader_create*(input: ptr glslang_input_t): ptr glslang_shader_t {.importc.} | |
226 proc glslang_shader_delete*(shader: ptr glslang_shader_t) {.importc.} | |
227 proc glslang_shader_set_preamble*(shader: ptr glslang_shader_t; s: cstring) {.importc.} | |
228 proc glslang_shader_shift_binding*(shader: ptr glslang_shader_t; res: glslang_resource_type_t; base: cuint) {.importc.} | |
229 proc glslang_shader_shift_binding_for_set*(shader: ptr glslang_shader_t; res: glslang_resource_type_t; base: cuint; set: cuint) {.importc.} | |
230 proc glslang_shader_set_options*(shader: ptr glslang_shader_t; options: cint) {.importc.} | |
231 | |
232 proc glslang_shader_set_glsl_version*(shader: ptr glslang_shader_t; version: cint) {.importc.} | |
233 proc glslang_shader_preprocess*(shader: ptr glslang_shader_t; input: ptr glslang_input_t): cint {.importc.} | |
234 proc glslang_shader_parse*(shader: ptr glslang_shader_t; input: ptr glslang_input_t): cint {.importc.} | |
235 proc glslang_shader_get_preprocessed_code*(shader: ptr glslang_shader_t): cstring {.importc.} | |
236 proc glslang_shader_get_info_log*(shader: ptr glslang_shader_t): cstring {.importc.} | |
237 proc glslang_shader_get_info_debug_log*(shader: ptr glslang_shader_t): cstring {.importc.} | |
238 proc glslang_program_create*(): ptr glslang_program_t {.importc.} | |
239 proc glslang_program_delete*(program: ptr glslang_program_t) {.importc.} | |
240 proc glslang_program_add_shader*(program: ptr glslang_program_t; shader: ptr glslang_shader_t) {.importc.} | |
241 proc glslang_program_link*(program: ptr glslang_program_t; messages: cint): cint {.importc.} | |
242 | |
243 proc glslang_program_add_source_text*(program: ptr glslang_program_t; stage: glslang_stage_t; text: cstring; len: csize_t) {.importc.} | |
244 proc glslang_program_set_source_file*(program: ptr glslang_program_t; stage: glslang_stage_t; file: cstring) {.importc.} | |
245 proc glslang_program_map_io*(program: ptr glslang_program_t): cint {.importc.} | |
246 proc glslang_program_SPIRV_generate*(program: ptr glslang_program_t; stage: glslang_stage_t) {.importc.} | |
247 proc glslang_program_SPIRV_generate_with_options*(program: ptr glslang_program_t; stage: glslang_stage_t; spv_options: ptr glslang_spv_options_t) {.importc.} | |
248 proc glslang_program_SPIRV_get_size*(program: ptr glslang_program_t): csize_t {.importc.} | |
249 proc glslang_program_SPIRV_get*(program: ptr glslang_program_t; a2: ptr cuint) {.importc.} | |
250 proc glslang_program_SPIRV_get_ptr*(program: ptr glslang_program_t): ptr cuint {.importc.} | |
251 proc glslang_program_SPIRV_get_messages*(program: ptr glslang_program_t): cstring {.importc.} | |
252 proc glslang_program_get_info_log*(program: ptr glslang_program_t): cstring {.importc.} | |
253 proc glslang_program_get_info_debug_log*(program: ptr glslang_program_t): cstring {.importc.} | |
254 | |
255 proc glslang_default_resource*(): ptr glslang_resource_t {.importc.} | |
256 proc glslang_default_resource_string*(): cstring {.importc.} | |
257 proc glslang_decode_resource_limits*(resources: ptr glslang_resource_t , config: cstring) {.importc.} |