|
69 | 69 |
|
70 | 70 | {# Platform / WSI system headers: include-category types whose protection |
71 | 71 | guards were inferred at generation time from which extensions require them. |
72 | | - An empty protect list means the include is unconditional. #} |
73 | | -{%- for type in fs.types -%} |
74 | | -{% if type.category == "include" and type.raw_c -%} |
75 | | -{{ u.protect_begin(type.protect) -}} |
| 72 | + An empty protect list means the include is unconditional. |
| 73 | + Consecutive types sharing the same guard are coalesced into a single |
| 74 | + #ifdef/#endif block by the resolver. #} |
| 75 | +{%- for group in fs.include_type_groups -%} |
| 76 | +{{ u.protect_begin(group.protect) -}} |
| 77 | +{% for type in group.items -%} |
76 | 78 | {{ type.raw_c }} |
77 | | -{{ u.protect_end(type.protect) -}} |
78 | | -{% endif -%} |
79 | | -{%- endfor %} |
| 79 | +{% endfor -%} |
| 80 | +{{ u.protect_end(group.protect) -}} |
| 81 | +{% endfor %} |
80 | 82 | #ifdef __cplusplus |
81 | 83 | extern "C" { |
82 | 84 | #endif |
@@ -131,15 +133,17 @@ struct _cl_event; |
131 | 133 | #define {{ feat.full_name }} 1 |
132 | 134 | {% endfor -%} |
133 | 135 | {% endif -%} |
134 | | -{%- if not fs.is_vulkan and fs.extensions | length > 0 %} |
| 136 | +{%- if not fs.is_vulkan and fs.ext_guard_groups | length > 0 %} |
135 | 137 | /* ---- Extension compile-time guards --------------------------------------- |
136 | 138 | These mirror the definitions in standard glext.h/gl2ext.h/eglext.h so |
137 | 139 | that code guarded by e.g. #ifdef GL_ARB_draw_indirect compiles correctly |
138 | 140 | against this header. */ |
139 | | -{% for ext in fs.extensions %} |
140 | | -{{- u.protect_begin(ext.protect) -}} |
| 141 | +{% for group in fs.ext_guard_groups -%} |
| 142 | +{{- u.protect_begin(group.protect) -}} |
| 143 | +{% for ext in group.items -%} |
141 | 144 | #define {{ ext.name }} 1 |
142 | | -{{ u.protect_end(ext.protect) -}} |
| 145 | +{% endfor -%} |
| 146 | +{{ u.protect_end(group.protect) -}} |
143 | 147 | {%- endfor %} |
144 | 148 | {% endif -%} |
145 | 149 | {%- if fs.flat_enums | length > 0 -%} |
@@ -181,28 +185,41 @@ typedef enum {{ group.name }} { |
181 | 185 | {% endfor -%} |
182 | 186 | {% endif %} |
183 | 187 | /* ---- Types ---------------------------------------------------------------- |
184 | | - Emitted in topological dependency order. */ |
185 | | -{% for type in fs.types -%} |
186 | | -{%- if type.category != "include" and type.raw_c %} |
187 | | -{{ u.protect_begin(type.protect if type.protect else []) -}} |
| 188 | + Emitted in topological dependency order. Consecutive types sharing the |
| 189 | + same platform guard are coalesced into a single #ifdef/#endif block. */ |
| 190 | +{% for group in fs.type_groups -%} |
| 191 | +{% if group.protect | length > 0 -%} |
| 192 | +#if defined({{ group.protect | join(") && defined(") }}) |
| 193 | +{% endif -%} |
| 194 | +{% for type in group.items -%} |
188 | 195 | {{ type.raw_c }} |
189 | | -{{ u.protect_end(type.protect if type.protect else []) -}} |
| 196 | +{% if not loop.last %} |
| 197 | +{% endif -%} |
| 198 | +{% endfor -%} |
| 199 | +{% if group.protect | length > 0 -%} |
| 200 | +#endif |
| 201 | +{% endif -%} |
| 202 | +{% if not loop.last %} |
190 | 203 | {% endif -%} |
191 | 204 | {% endfor %} |
192 | 205 |
|
193 | 206 | /* ---- PFN typedefs -------------------------------------------------------- */ |
194 | 207 | {% if fs.is_gl_family -%} |
195 | | -{% for cmd in fs.commands -%} |
196 | | -{{ u.cmd_protect_begin(cmd) -}} |
| 208 | +{% for group in fs.cmd_pfn_groups -%} |
| 209 | +{{- u.protect_begin(group.protect) -}} |
| 210 | +{% for cmd in group.items -%} |
197 | 211 | typedef {{ cmd.return_type }} (APIENTRYP {{ cmd.pfn_type }})({{ cmd.params_str }}); |
198 | | -{{ u.cmd_protect_end(cmd) }} |
199 | | -{%- endfor %} |
| 212 | +{% endfor -%} |
| 213 | +{{ u.protect_end(group.protect) -}} |
| 214 | +{% endfor -%} |
200 | 215 | {% else %} |
201 | | -{% for cmd in fs.commands %} |
202 | | -{{ u.cmd_protect_begin(cmd) -}} |
| 216 | +{% for group in fs.cmd_pfn_groups -%} |
| 217 | +{{- u.protect_begin(group.protect) -}} |
| 218 | +{% for cmd in group.items -%} |
203 | 219 | typedef {{ cmd.return_type }} (VKAPI_PTR *{{ cmd.pfn_type }})({{ cmd.params_str }}); |
204 | | -{{- u.cmd_protect_end(cmd) }} |
205 | | -{% endfor %} |
| 220 | +{% endfor -%} |
| 221 | +{{- u.protect_end(group.protect) -}} |
| 222 | +{% endfor -%} |
206 | 223 | {% endif %} |
207 | 224 |
|
208 | 225 | /* ---- Context struct ------------------------------------------------------ |
@@ -236,15 +253,21 @@ typedef struct {{ fs.context_name }} { |
236 | 253 | union { |
237 | 254 | void *pfnArray[{{ fs.commands | length }}]; |
238 | 255 | struct { |
239 | | -{%- for cmd in fs.commands %} |
240 | | -{%- if cmd.protect %} |
241 | | -#ifdef {{ cmd.protect }} |
| 256 | +{%- for group in fs.cmd_pfn_groups %} |
| 257 | +{%- if group.protect | length > 0 %} |
| 258 | +#if defined({{ group.protect | join(") && defined(") }}) |
| 259 | +{%- for cmd in group.items %} |
242 | 260 | /* {{ cmd.index | rjust(4) }} */ {{ cmd.pfn_type }} {{ cmd.short_name }}; |
| 261 | +{%- endfor %} |
243 | 262 | #else |
| 263 | +{%- for cmd in group.items %} |
244 | 264 | /* {{ cmd.index | rjust(4) }} */ void *_pad{{ cmd.index }}; |
245 | | -#endif /* {{ cmd.protect }} */ |
246 | | -{% else %} |
| 265 | +{%- endfor %} |
| 266 | +#endif |
| 267 | +{%- else %} |
| 268 | +{%- for cmd in group.items %} |
247 | 269 | /* {{ cmd.index | rjust(4) }} */ {{ cmd.pfn_type }} {{ cmd.short_name }}; |
| 270 | +{%- endfor %} |
248 | 271 | {%- endif %} |
249 | 272 | {%- endfor %} |
250 | 273 | }; |
@@ -280,28 +303,34 @@ extern {{ fs.context_name }} gloam_{{ fs.spec_name }}_context; |
280 | 303 | {%- endfor %} |
281 | 304 |
|
282 | 305 | /* ---- Extension presence macros ------------------------------------------ */ |
283 | | -{% for ext in fs.extensions %} |
284 | | -{{- u.protect_begin(ext.protect) -}} |
| 306 | +{% for group in fs.ext_guard_groups %} |
| 307 | +{{- u.protect_begin(group.protect) -}} |
| 308 | +{% for ext in group.items -%} |
285 | 309 | #define GLOAM_{{ ext.name }} (gloam_{{ fs.spec_name }}_context.{{ ext.short_name | c_ident }}) |
286 | | -{{ u.protect_end(ext.protect) -}} |
| 310 | +{% endfor -%} |
| 311 | +{{- u.protect_end(group.protect) -}} |
287 | 312 | {%- endfor %} |
288 | 313 |
|
289 | 314 | /* ---- Dispatch macros and IntelliSense prototypes ------------------------- |
290 | 315 | Under __INTELLISENSE__ we expose real function declarations so IDEs can |
291 | 316 | provide parameter info and type checking. In normal compilation the macros |
292 | 317 | dispatch directly through the global context struct. */ |
293 | 318 | #ifdef __INTELLISENSE__ |
294 | | -{%- for cmd in fs.commands %} |
295 | | -{{ u.cmd_protect_begin(cmd) -}} |
| 319 | +{%- for group in fs.cmd_pfn_groups -%} |
| 320 | +{{- u.protect_begin(group.protect) -}} |
| 321 | +{%- for cmd in group.items -%} |
296 | 322 | {{ cmd.return_type }} {{ cmd.name }}({{ cmd.params_str }}); |
297 | | -{{- u.cmd_protect_end(cmd) }} |
298 | | -{%- endfor %} |
| 323 | +{% endfor -%} |
| 324 | +{{- u.protect_end(group.protect) }} |
| 325 | +{%- endfor -%} |
299 | 326 | #else |
300 | | -{%- for cmd in fs.commands %} |
301 | | -{{ u.cmd_protect_begin(cmd) -}} |
| 327 | +{%- for group in fs.cmd_pfn_groups -%} |
| 328 | +{{- u.protect_begin(group.protect) -}} |
| 329 | +{%- for cmd in group.items -%} |
302 | 330 | #define {{ cmd.name }} (gloam_{{ fs.spec_name }}_context.{{ cmd.short_name }}) |
303 | | -{{- u.cmd_protect_end(cmd) }} |
304 | | -{%- endfor %} |
| 331 | +{% endfor -%} |
| 332 | +{{- u.protect_end(group.protect) }} |
| 333 | +{%- endfor -%} |
305 | 334 | #endif /* __INTELLISENSE__ */ |
306 | 335 |
|
307 | 336 | /* ---- API declarations ---------------------------------------------------- */ |
@@ -405,4 +434,3 @@ void gloamLoaderResetVulkan(void); |
405 | 434 | #endif /* _WIN32 */ |
406 | 435 | {% endif %} |
407 | 436 | #endif /* GLOAM_{{ guard }} */ |
408 | | - |
|
0 commit comments