/src/glslang/glslang/MachineIndependent/Versions.cpp
Line | Count | Source |
1 | | // |
2 | | // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. |
3 | | // Copyright (C) 2012-2013 LunarG, Inc. |
4 | | // Copyright (C) 2017, 2022-2024 Arm Limited. |
5 | | // Copyright (C) 2015-2020 Google, Inc. |
6 | | // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved. |
7 | | // |
8 | | // All rights reserved. |
9 | | // |
10 | | // Redistribution and use in source and binary forms, with or without |
11 | | // modification, are permitted provided that the following conditions |
12 | | // are met: |
13 | | // |
14 | | // Redistributions of source code must retain the above copyright |
15 | | // notice, this list of conditions and the following disclaimer. |
16 | | // |
17 | | // Redistributions in binary form must reproduce the above |
18 | | // copyright notice, this list of conditions and the following |
19 | | // disclaimer in the documentation and/or other materials provided |
20 | | // with the distribution. |
21 | | // |
22 | | // Neither the name of 3Dlabs Inc. Ltd. nor the names of its |
23 | | // contributors may be used to endorse or promote products derived |
24 | | // from this software without specific prior written permission. |
25 | | // |
26 | | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
27 | | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
28 | | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
29 | | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
30 | | // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
31 | | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
32 | | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
33 | | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
34 | | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
35 | | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
36 | | // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
37 | | // POSSIBILITY OF SUCH DAMAGE. |
38 | | // |
39 | | |
40 | | // |
41 | | // Help manage multiple profiles, versions, extensions etc. |
42 | | // |
43 | | // These don't return error codes, as the presumption is parsing will |
44 | | // always continue as if the tested feature were enabled, and thus there |
45 | | // is no error recovery needed. |
46 | | // |
47 | | |
48 | | // |
49 | | // HOW TO add a feature enabled by an extension. |
50 | | // |
51 | | // To add a new hypothetical "Feature F" to the front end, where an extension |
52 | | // "XXX_extension_X" can be used to enable the feature, do the following. |
53 | | // |
54 | | // OVERVIEW: Specific features are what are error-checked for, not |
55 | | // extensions: A specific Feature F might be enabled by an extension, or a |
56 | | // particular version in a particular profile, or a stage, or combinations, etc. |
57 | | // |
58 | | // The basic mechanism is to use the following to "declare" all the things that |
59 | | // enable/disable Feature F, in a code path that implements Feature F: |
60 | | // |
61 | | // requireProfile() |
62 | | // profileRequires() |
63 | | // requireStage() |
64 | | // checkDeprecated() |
65 | | // requireNotRemoved() |
66 | | // requireExtensions() |
67 | | // extensionRequires() |
68 | | // |
69 | | // Typically, only the first two calls are needed. They go into a code path that |
70 | | // implements Feature F, and will log the proper error/warning messages. Parsing |
71 | | // will then always continue as if the tested feature was enabled. |
72 | | // |
73 | | // There is typically no if-testing or conditional parsing, just insertion of the calls above. |
74 | | // However, if symbols specific to the extension are added (step 5), they will |
75 | | // only be added under tests that the minimum version and profile are present. |
76 | | // |
77 | | // 1) Add a symbol name for the extension string at the bottom of Versions.h: |
78 | | // |
79 | | // const char* const XXX_extension_X = "XXX_extension_X"; |
80 | | // |
81 | | // 2) Add extension initialization to TParseVersions::initializeExtensionBehavior(), |
82 | | // the first function below and optionally a entry to extensionData for additional |
83 | | // error checks: |
84 | | // |
85 | | // extensionBehavior[XXX_extension_X] = EBhDisable; |
86 | | // (Optional) exts[] = {XXX_extension_X, EShTargetSpv_1_4} |
87 | | // |
88 | | // 3) Add any preprocessor directives etc. in the next function, TParseVersions::getPreamble(): |
89 | | // |
90 | | // "#define XXX_extension_X 1\n" |
91 | | // |
92 | | // The new-line is important, as that ends preprocess tokens. |
93 | | // |
94 | | // 4) Insert a profile check in the feature's path (unless all profiles support the feature, |
95 | | // for some version level). That is, call requireProfile() to constrain the profiles, e.g.: |
96 | | // |
97 | | // // ... in a path specific to Feature F... |
98 | | // requireProfile(loc, |
99 | | // ECoreProfile | ECompatibilityProfile, |
100 | | // "Feature F"); |
101 | | // |
102 | | // 5) For each profile that supports the feature, insert version/extension checks: |
103 | | // |
104 | | // The mostly likely scenario is that Feature F can only be used with a |
105 | | // particular profile if XXX_extension_X is present or the version is |
106 | | // high enough that the core specification already incorporated it. |
107 | | // |
108 | | // // following the requireProfile() call... |
109 | | // profileRequires(loc, |
110 | | // ECoreProfile | ECompatibilityProfile, |
111 | | // 420, // 0 if no version incorporated the feature into the core spec. |
112 | | // XXX_extension_X, // can be a list of extensions that all add the feature |
113 | | // "Feature F Description"); |
114 | | // |
115 | | // This allows the feature if either A) one of the extensions is enabled or |
116 | | // B) the version is high enough. If no version yet incorporates the feature |
117 | | // into core, pass in 0. |
118 | | // |
119 | | // This can be called multiple times, if different profiles support the |
120 | | // feature starting at different version numbers or with different |
121 | | // extensions. |
122 | | // |
123 | | // This must be called for each profile allowed by the initial call to requireProfile(). |
124 | | // |
125 | | // Profiles are all masks, which can be "or"-ed together. |
126 | | // |
127 | | // ENoProfile |
128 | | // ECoreProfile |
129 | | // ECompatibilityProfile |
130 | | // EEsProfile |
131 | | // |
132 | | // The ENoProfile profile is only for desktop, before profiles showed up in version 150; |
133 | | // All other #version with no profile default to either es or core, and so have profiles. |
134 | | // |
135 | | // You can select all but a particular profile using ~. The following basically means "desktop": |
136 | | // |
137 | | // ~EEsProfile |
138 | | // |
139 | | // 6) If built-in symbols are added by the extension, add them in Initialize.cpp: Their use |
140 | | // will be automatically error checked against the extensions enabled at that moment. |
141 | | // see the comment at the top of Initialize.cpp for where to put them. Establish them at |
142 | | // the earliest release that supports the extension. Then, tag them with the |
143 | | // set of extensions that both enable them and are necessary, given the version of the symbol |
144 | | // table. (There is a different symbol table for each version.) |
145 | | // |
146 | | // 7) If the extension has additional requirements like minimum SPIR-V version required, add them |
147 | | // to extensionRequires() |
148 | | |
149 | | #include "parseVersions.h" |
150 | | #include "localintermediate.h" |
151 | | |
152 | | namespace glslang { |
153 | | |
154 | | // |
155 | | // Initialize all extensions, almost always to 'disable', as once their features |
156 | | // are incorporated into a core version, their features are supported through allowing that |
157 | | // core version, not through a pseudo-enablement of the extension. |
158 | | // |
159 | | void TParseVersions::initializeExtensionBehavior() |
160 | 82 | { |
161 | 82 | typedef struct { |
162 | 82 | const char *const extensionName; |
163 | 82 | EShTargetLanguageVersion minSpvVersion; |
164 | 82 | } extensionData; |
165 | | |
166 | 82 | const extensionData exts[] = { {E_GL_EXT_ray_tracing, EShTargetSpv_1_4}, |
167 | 82 | {E_GL_NV_ray_tracing_motion_blur, EShTargetSpv_1_4}, |
168 | 82 | {E_GL_EXT_mesh_shader, EShTargetSpv_1_4}, |
169 | 82 | {E_GL_NV_cooperative_matrix2, EShTargetSpv_1_6}, |
170 | 82 | {E_GL_NV_cooperative_matrix_decode_vector, EShTargetSpv_1_6} |
171 | 82 | }; |
172 | | |
173 | 492 | for (size_t ii = 0; ii < sizeof(exts) / sizeof(exts[0]); ii++) { |
174 | | // Add only extensions which require > spv1.0 to save space in map |
175 | 410 | if (exts[ii].minSpvVersion > EShTargetSpv_1_0) { |
176 | 410 | extensionMinSpv[exts[ii].extensionName] = exts[ii].minSpvVersion; |
177 | 410 | } |
178 | 410 | } |
179 | | |
180 | 82 | extensionBehavior[E_GL_OES_texture_3D] = EBhDisable; |
181 | 82 | extensionBehavior[E_GL_OES_standard_derivatives] = EBhDisable; |
182 | 82 | extensionBehavior[E_GL_EXT_frag_depth] = EBhDisable; |
183 | 82 | extensionBehavior[E_GL_OES_EGL_image_external] = EBhDisable; |
184 | 82 | extensionBehavior[E_GL_OES_EGL_image_external_essl3] = EBhDisable; |
185 | 82 | extensionBehavior[E_GL_EXT_YUV_target] = EBhDisable; |
186 | 82 | extensionBehavior[E_GL_EXT_shader_texture_lod] = EBhDisable; |
187 | 82 | extensionBehavior[E_GL_EXT_shadow_samplers] = EBhDisable; |
188 | 82 | extensionBehavior[E_GL_ARB_texture_rectangle] = EBhDisable; |
189 | 82 | extensionBehavior[E_GL_3DL_array_objects] = EBhDisable; |
190 | 82 | extensionBehavior[E_GL_ARB_shading_language_420pack] = EBhDisable; |
191 | 82 | extensionBehavior[E_GL_ARB_texture_gather] = EBhDisable; |
192 | 82 | extensionBehavior[E_GL_ARB_gpu_shader5] = EBhDisable; |
193 | 82 | extensionBehavior[E_GL_ARB_separate_shader_objects] = EBhDisable; |
194 | 82 | extensionBehavior[E_GL_ARB_compute_shader] = EBhDisable; |
195 | 82 | extensionBehavior[E_GL_ARB_tessellation_shader] = EBhDisable; |
196 | 82 | extensionBehavior[E_GL_ARB_enhanced_layouts] = EBhDisable; |
197 | 82 | extensionBehavior[E_GL_ARB_texture_cube_map_array] = EBhDisable; |
198 | 82 | extensionBehavior[E_GL_ARB_texture_multisample] = EBhDisable; |
199 | 82 | extensionBehavior[E_GL_ARB_shader_texture_lod] = EBhDisable; |
200 | 82 | extensionBehavior[E_GL_ARB_explicit_attrib_location] = EBhDisable; |
201 | 82 | extensionBehavior[E_GL_ARB_explicit_uniform_location] = EBhDisable; |
202 | 82 | extensionBehavior[E_GL_ARB_shader_image_load_store] = EBhDisable; |
203 | 82 | extensionBehavior[E_GL_ARB_shader_atomic_counters] = EBhDisable; |
204 | 82 | extensionBehavior[E_GL_ARB_shader_atomic_counter_ops] = EBhDisable; |
205 | 82 | extensionBehavior[E_GL_ARB_shader_draw_parameters] = EBhDisable; |
206 | 82 | extensionBehavior[E_GL_ARB_shader_group_vote] = EBhDisable; |
207 | 82 | extensionBehavior[E_GL_ARB_derivative_control] = EBhDisable; |
208 | 82 | extensionBehavior[E_GL_ARB_shader_texture_image_samples] = EBhDisable; |
209 | 82 | extensionBehavior[E_GL_ARB_viewport_array] = EBhDisable; |
210 | 82 | extensionBehavior[E_GL_ARB_gpu_shader_int64] = EBhDisable; |
211 | 82 | extensionBehavior[E_GL_ARB_gpu_shader_fp64] = EBhDisable; |
212 | 82 | extensionBehavior[E_GL_ARB_shader_ballot] = EBhDisable; |
213 | 82 | extensionBehavior[E_GL_ARB_sparse_texture2] = EBhDisable; |
214 | 82 | extensionBehavior[E_GL_ARB_sparse_texture_clamp] = EBhDisable; |
215 | 82 | extensionBehavior[E_GL_ARB_shader_stencil_export] = EBhDisable; |
216 | | // extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members |
217 | 82 | extensionBehavior[E_GL_ARB_post_depth_coverage] = EBhDisable; |
218 | 82 | extensionBehavior[E_GL_ARB_shader_viewport_layer_array] = EBhDisable; |
219 | 82 | extensionBehavior[E_GL_ARB_fragment_shader_interlock] = EBhDisable; |
220 | 82 | extensionBehavior[E_GL_ARB_shader_clock] = EBhDisable; |
221 | 82 | extensionBehavior[E_GL_ARB_uniform_buffer_object] = EBhDisable; |
222 | 82 | extensionBehavior[E_GL_ARB_sample_shading] = EBhDisable; |
223 | 82 | extensionBehavior[E_GL_ARB_shader_bit_encoding] = EBhDisable; |
224 | 82 | extensionBehavior[E_GL_ARB_shader_image_size] = EBhDisable; |
225 | 82 | extensionBehavior[E_GL_ARB_shader_storage_buffer_object] = EBhDisable; |
226 | 82 | extensionBehavior[E_GL_ARB_shading_language_packing] = EBhDisable; |
227 | 82 | extensionBehavior[E_GL_ARB_texture_query_lod] = EBhDisable; |
228 | 82 | extensionBehavior[E_GL_ARB_vertex_attrib_64bit] = EBhDisable; |
229 | 82 | extensionBehavior[E_GL_NV_gpu_shader5] = EBhDisable; |
230 | 82 | extensionBehavior[E_GL_ARB_draw_instanced] = EBhDisable; |
231 | 82 | extensionBehavior[E_GL_ARB_bindless_texture] = EBhDisable; |
232 | 82 | extensionBehavior[E_GL_ARB_fragment_coord_conventions] = EBhDisable; |
233 | 82 | extensionBehavior[E_GL_ARB_conservative_depth] = EBhDisable; |
234 | | |
235 | | |
236 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable; |
237 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable; |
238 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_arithmetic] = EBhDisable; |
239 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_ballot] = EBhDisable; |
240 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_shuffle] = EBhDisable; |
241 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_shuffle_relative] = EBhDisable; |
242 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_rotate] = EBhDisable; |
243 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_clustered] = EBhDisable; |
244 | 82 | extensionBehavior[E_GL_KHR_shader_subgroup_quad] = EBhDisable; |
245 | 82 | extensionBehavior[E_GL_KHR_memory_scope_semantics] = EBhDisable; |
246 | | |
247 | 82 | extensionBehavior[E_GL_EXT_shader_atomic_int64] = EBhDisable; |
248 | | |
249 | 82 | extensionBehavior[E_GL_EXT_shader_non_constant_global_initializers] = EBhDisable; |
250 | 82 | extensionBehavior[E_GL_EXT_shader_image_load_formatted] = EBhDisable; |
251 | 82 | extensionBehavior[E_GL_EXT_post_depth_coverage] = EBhDisable; |
252 | 82 | extensionBehavior[E_GL_EXT_control_flow_attributes] = EBhDisable; |
253 | 82 | extensionBehavior[E_GL_EXT_nonuniform_qualifier] = EBhDisable; |
254 | 82 | extensionBehavior[E_GL_EXT_samplerless_texture_functions] = EBhDisable; |
255 | 82 | extensionBehavior[E_GL_EXT_scalar_block_layout] = EBhDisable; |
256 | 82 | extensionBehavior[E_GL_EXT_fragment_invocation_density] = EBhDisable; |
257 | 82 | extensionBehavior[E_GL_EXT_buffer_reference] = EBhDisable; |
258 | 82 | extensionBehavior[E_GL_EXT_buffer_reference2] = EBhDisable; |
259 | 82 | extensionBehavior[E_GL_EXT_buffer_reference_uvec2] = EBhDisable; |
260 | 82 | extensionBehavior[E_GL_EXT_demote_to_helper_invocation] = EBhDisable; |
261 | 82 | extensionBehavior[E_GL_EXT_debug_printf] = EBhDisable; |
262 | | |
263 | 82 | extensionBehavior[E_GL_EXT_shader_16bit_storage] = EBhDisable; |
264 | 82 | extensionBehavior[E_GL_EXT_shader_8bit_storage] = EBhDisable; |
265 | 82 | extensionBehavior[E_GL_EXT_subgroup_uniform_control_flow] = EBhDisable; |
266 | 82 | extensionBehavior[E_GL_EXT_maximal_reconvergence] = EBhDisable; |
267 | | |
268 | 82 | extensionBehavior[E_GL_EXT_fragment_shader_barycentric] = EBhDisable; |
269 | 82 | extensionBehavior[E_GL_EXT_expect_assume] = EBhDisable; |
270 | | |
271 | 82 | extensionBehavior[E_GL_EXT_control_flow_attributes2] = EBhDisable; |
272 | 82 | extensionBehavior[E_GL_EXT_spec_constant_composites] = EBhDisable; |
273 | 82 | extensionBehavior[E_GL_EXT_abort] = EBhDisable; |
274 | | |
275 | 82 | extensionBehavior[E_GL_KHR_cooperative_matrix] = EBhDisable; |
276 | 82 | extensionBehavior[E_GL_NV_cooperative_vector] = EBhDisable; |
277 | | |
278 | | // #line and #include |
279 | 82 | extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable; |
280 | 82 | extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable; |
281 | 82 | extensionBehavior[E_GL_ARB_shading_language_include] = EBhDisable; |
282 | | |
283 | 82 | extensionBehavior[E_GL_AMD_shader_ballot] = EBhDisable; |
284 | 82 | extensionBehavior[E_GL_AMD_shader_trinary_minmax] = EBhDisable; |
285 | 82 | extensionBehavior[E_GL_AMD_shader_explicit_vertex_parameter] = EBhDisable; |
286 | 82 | extensionBehavior[E_GL_AMD_gcn_shader] = EBhDisable; |
287 | 82 | extensionBehavior[E_GL_AMD_gpu_shader_half_float] = EBhDisable; |
288 | 82 | extensionBehavior[E_GL_AMD_texture_gather_bias_lod] = EBhDisable; |
289 | 82 | extensionBehavior[E_GL_AMD_gpu_shader_int16] = EBhDisable; |
290 | 82 | extensionBehavior[E_GL_AMD_shader_image_load_store_lod] = EBhDisable; |
291 | 82 | extensionBehavior[E_GL_AMD_shader_fragment_mask] = EBhDisable; |
292 | 82 | extensionBehavior[E_GL_AMD_gpu_shader_half_float_fetch] = EBhDisable; |
293 | 82 | extensionBehavior[E_GL_AMD_shader_early_and_late_fragment_tests] = EBhDisable; |
294 | | |
295 | 82 | extensionBehavior[E_GL_INTEL_shader_integer_functions2] = EBhDisable; |
296 | | |
297 | 82 | extensionBehavior[E_GL_NV_sample_mask_override_coverage] = EBhDisable; |
298 | 82 | extensionBehavior[E_SPV_NV_geometry_shader_passthrough] = EBhDisable; |
299 | 82 | extensionBehavior[E_GL_NV_viewport_array2] = EBhDisable; |
300 | 82 | extensionBehavior[E_GL_NV_stereo_view_rendering] = EBhDisable; |
301 | 82 | extensionBehavior[E_GL_NVX_multiview_per_view_attributes] = EBhDisable; |
302 | 82 | extensionBehavior[E_GL_NV_shader_atomic_int64] = EBhDisable; |
303 | 82 | extensionBehavior[E_GL_NV_conservative_raster_underestimation] = EBhDisable; |
304 | 82 | extensionBehavior[E_GL_NV_shader_noperspective_interpolation] = EBhDisable; |
305 | 82 | extensionBehavior[E_GL_NV_shader_subgroup_partitioned] = EBhDisable; |
306 | 82 | extensionBehavior[E_GL_NV_shading_rate_image] = EBhDisable; |
307 | 82 | extensionBehavior[E_GL_NV_ray_tracing] = EBhDisable; |
308 | 82 | extensionBehavior[E_GL_NV_ray_tracing_motion_blur] = EBhDisable; |
309 | 82 | extensionBehavior[E_GL_NV_fragment_shader_barycentric] = EBhDisable; |
310 | 82 | extensionBehavior[E_GL_KHR_compute_shader_derivatives] = EBhDisable; |
311 | 82 | extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable; |
312 | 82 | extensionBehavior[E_GL_NV_shader_texture_footprint] = EBhDisable; |
313 | 82 | extensionBehavior[E_GL_NV_mesh_shader] = EBhDisable; |
314 | 82 | extensionBehavior[E_GL_NV_cooperative_matrix] = EBhDisable; |
315 | 82 | extensionBehavior[E_GL_NV_shader_sm_builtins] = EBhDisable; |
316 | 82 | extensionBehavior[E_GL_NV_integer_cooperative_matrix] = EBhDisable; |
317 | 82 | extensionBehavior[E_GL_NV_shader_invocation_reorder] = EBhDisable; |
318 | 82 | extensionBehavior[E_GL_NV_displacement_micromap] = EBhDisable; |
319 | 82 | extensionBehavior[E_GL_NV_shader_atomic_fp16_vector] = EBhDisable; |
320 | 82 | extensionBehavior[E_GL_NV_cooperative_matrix2] = EBhDisable; |
321 | 82 | extensionBehavior[E_GL_NV_cooperative_matrix_decode_vector] = EBhDisable; |
322 | 82 | extensionBehavior[E_GL_NV_cluster_acceleration_structure] = EBhDisable; |
323 | 82 | extensionBehavior[E_GL_NV_linear_swept_spheres] = EBhDisable; |
324 | 82 | extensionBehavior[E_GL_NV_desktop_lowp_mediump] = EBhDisable; |
325 | 82 | extensionBehavior[E_GL_NV_push_constant_bank] = EBhDisable; |
326 | 82 | extensionBehavior[E_GL_NV_explicit_typecast] = EBhDisable; |
327 | | |
328 | | // ARM |
329 | 82 | extensionBehavior[E_GL_ARM_shader_core_builtins] = EBhDisable; |
330 | 82 | extensionBehavior[E_GL_ARM_tensors] = EBhDisable; |
331 | 82 | extensionBehavior[E_GL_ARM_tensors_bfloat16] = EBhDisable; |
332 | 82 | extensionBehavior[E_GL_ARM_tensors_float_e5m2] = EBhDisable; |
333 | 82 | extensionBehavior[E_GL_ARM_tensors_float_e4m3] = EBhDisable; |
334 | | |
335 | | // QCOM |
336 | 82 | extensionBehavior[E_GL_QCOM_image_processing] = EBhDisable; |
337 | 82 | extensionBehavior[E_GL_QCOM_image_processing2] = EBhDisable; |
338 | 82 | extensionBehavior[E_GL_QCOM_tile_shading] = EBhDisable; |
339 | 82 | extensionBehavior[E_GL_QCOM_cooperative_matrix_conversion] = EBhDisable; |
340 | | |
341 | | // AEP |
342 | 82 | extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisable; |
343 | 82 | extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisable; |
344 | 82 | extensionBehavior[E_GL_OES_sample_variables] = EBhDisable; |
345 | 82 | extensionBehavior[E_GL_OES_shader_image_atomic] = EBhDisable; |
346 | 82 | extensionBehavior[E_GL_OES_shader_multisample_interpolation] = EBhDisable; |
347 | 82 | extensionBehavior[E_GL_OES_texture_storage_multisample_2d_array] = EBhDisable; |
348 | 82 | extensionBehavior[E_GL_EXT_geometry_shader] = EBhDisable; |
349 | 82 | extensionBehavior[E_GL_EXT_geometry_point_size] = EBhDisable; |
350 | 82 | extensionBehavior[E_GL_EXT_gpu_shader5] = EBhDisable; |
351 | 82 | extensionBehavior[E_GL_EXT_primitive_bounding_box] = EBhDisable; |
352 | 82 | extensionBehavior[E_GL_EXT_shader_io_blocks] = EBhDisable; |
353 | 82 | extensionBehavior[E_GL_EXT_tessellation_shader] = EBhDisable; |
354 | 82 | extensionBehavior[E_GL_EXT_tessellation_point_size] = EBhDisable; |
355 | 82 | extensionBehavior[E_GL_EXT_texture_buffer] = EBhDisable; |
356 | 82 | extensionBehavior[E_GL_EXT_texture_cube_map_array] = EBhDisable; |
357 | 82 | extensionBehavior[E_GL_EXT_null_initializer] = EBhDisable; |
358 | 82 | extensionBehavior[E_GL_EXT_descriptor_heap] = EBhDisable; |
359 | | |
360 | | // OES matching AEP |
361 | 82 | extensionBehavior[E_GL_OES_geometry_shader] = EBhDisable; |
362 | 82 | extensionBehavior[E_GL_OES_geometry_point_size] = EBhDisable; |
363 | 82 | extensionBehavior[E_GL_OES_gpu_shader5] = EBhDisable; |
364 | 82 | extensionBehavior[E_GL_OES_primitive_bounding_box] = EBhDisable; |
365 | 82 | extensionBehavior[E_GL_OES_shader_io_blocks] = EBhDisable; |
366 | 82 | extensionBehavior[E_GL_OES_tessellation_shader] = EBhDisable; |
367 | 82 | extensionBehavior[E_GL_OES_tessellation_point_size] = EBhDisable; |
368 | 82 | extensionBehavior[E_GL_OES_texture_buffer] = EBhDisable; |
369 | 82 | extensionBehavior[E_GL_OES_texture_cube_map_array] = EBhDisable; |
370 | 82 | extensionBehavior[E_GL_EXT_shader_integer_mix] = EBhDisable; |
371 | | |
372 | | // EXT extensions |
373 | 82 | extensionBehavior[E_GL_EXT_device_group] = EBhDisable; |
374 | 82 | extensionBehavior[E_GL_EXT_multiview] = EBhDisable; |
375 | 82 | extensionBehavior[E_GL_EXT_shader_realtime_clock] = EBhDisable; |
376 | 82 | extensionBehavior[E_GL_EXT_ray_tracing] = EBhDisable; |
377 | 82 | extensionBehavior[E_GL_EXT_ray_query] = EBhDisable; |
378 | 82 | extensionBehavior[E_GL_EXT_ray_flags_primitive_culling] = EBhDisable; |
379 | 82 | extensionBehavior[E_GL_EXT_ray_cull_mask] = EBhDisable; |
380 | 82 | extensionBehavior[E_GL_EXT_blend_func_extended] = EBhDisable; |
381 | 82 | extensionBehavior[E_GL_EXT_shader_implicit_conversions] = EBhDisable; |
382 | 82 | extensionBehavior[E_GL_EXT_fragment_shading_rate] = EBhDisable; |
383 | 82 | extensionBehavior[E_GL_EXT_shader_image_int64] = EBhDisable; |
384 | 82 | extensionBehavior[E_GL_EXT_terminate_invocation] = EBhDisable; |
385 | 82 | extensionBehavior[E_GL_EXT_shared_memory_block] = EBhDisable; |
386 | 82 | extensionBehavior[E_GL_EXT_spirv_intrinsics] = EBhDisable; |
387 | 82 | extensionBehavior[E_GL_EXT_mesh_shader] = EBhDisable; |
388 | 82 | extensionBehavior[E_GL_EXT_opacity_micromap] = EBhDisable; |
389 | 82 | extensionBehavior[E_GL_EXT_shader_quad_control] = EBhDisable; |
390 | 82 | extensionBehavior[E_GL_EXT_ray_tracing_position_fetch] = EBhDisable; |
391 | 82 | extensionBehavior[E_GL_EXT_shader_tile_image] = EBhDisable; |
392 | 82 | extensionBehavior[E_GL_EXT_texture_shadow_lod] = EBhDisable; |
393 | 82 | extensionBehavior[E_GL_EXT_draw_instanced] = EBhDisable; |
394 | 82 | extensionBehavior[E_GL_EXT_texture_array] = EBhDisable; |
395 | 82 | extensionBehavior[E_GL_EXT_texture_offset_non_const] = EBhDisable; |
396 | 82 | extensionBehavior[E_GL_EXT_nontemporal_keyword] = EBhDisable; |
397 | 82 | extensionBehavior[E_GL_EXT_bfloat16] = EBhDisable; |
398 | 82 | extensionBehavior[E_GL_EXT_float_e4m3] = EBhDisable; |
399 | 82 | extensionBehavior[E_GL_EXT_float_e5m2] = EBhDisable; |
400 | 82 | extensionBehavior[E_GL_EXT_uniform_buffer_unsized_array] = EBhDisable; |
401 | 82 | extensionBehavior[E_GL_EXT_shader_64bit_indexing] = EBhDisable; |
402 | 82 | extensionBehavior[E_GL_EXT_conservative_depth] = EBhDisable; |
403 | 82 | extensionBehavior[E_GL_EXT_long_vector] = EBhDisable; |
404 | | |
405 | | // OVR extensions |
406 | 82 | extensionBehavior[E_GL_OVR_multiview] = EBhDisable; |
407 | 82 | extensionBehavior[E_GL_OVR_multiview2] = EBhDisable; |
408 | | |
409 | | // explicit types |
410 | 82 | extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types] = EBhDisable; |
411 | 82 | extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_int8] = EBhDisable; |
412 | 82 | extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_int16] = EBhDisable; |
413 | 82 | extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_int32] = EBhDisable; |
414 | 82 | extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_int64] = EBhDisable; |
415 | 82 | extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_float16] = EBhDisable; |
416 | 82 | extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_float32] = EBhDisable; |
417 | 82 | extensionBehavior[E_GL_EXT_shader_explicit_arithmetic_types_float64] = EBhDisable; |
418 | | |
419 | | // subgroup extended types |
420 | 82 | extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_int8] = EBhDisable; |
421 | 82 | extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_int16] = EBhDisable; |
422 | 82 | extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_int64] = EBhDisable; |
423 | 82 | extensionBehavior[E_GL_EXT_shader_subgroup_extended_types_float16] = EBhDisable; |
424 | 82 | extensionBehavior[E_GL_EXT_shader_atomic_float] = EBhDisable; |
425 | 82 | extensionBehavior[E_GL_EXT_shader_atomic_float2] = EBhDisable; |
426 | | |
427 | 82 | extensionBehavior[E_GL_EXT_integer_dot_product] = EBhDisable; |
428 | | |
429 | 82 | extensionBehavior[E_GL_EXT_shader_invocation_reorder] = EBhDisable; |
430 | | |
431 | | // Record extensions not for spv. |
432 | 82 | spvUnsupportedExt.push_back(E_GL_ARB_bindless_texture); |
433 | 82 | } |
434 | | |
435 | | // Get code that is not part of a shared symbol table, is specific to this shader, |
436 | | // or needed by the preprocessor (which does not use a shared symbol table). |
437 | | void TParseVersions::getPreamble(std::string& preamble) |
438 | 82 | { |
439 | 82 | if (isEsProfile()) { |
440 | 45 | preamble = |
441 | 45 | "#define GL_ES 1\n" |
442 | 45 | "#define GL_FRAGMENT_PRECISION_HIGH 1\n" |
443 | 45 | "#define GL_OES_texture_3D 1\n" |
444 | 45 | "#define GL_OES_standard_derivatives 1\n" |
445 | 45 | "#define GL_EXT_frag_depth 1\n" |
446 | 45 | "#define GL_OES_EGL_image_external 1\n" |
447 | 45 | "#define GL_OES_EGL_image_external_essl3 1\n" |
448 | 45 | "#define GL_EXT_YUV_target 1\n" |
449 | 45 | "#define GL_EXT_shader_texture_lod 1\n" |
450 | 45 | "#define GL_EXT_shadow_samplers 1\n" |
451 | 45 | "#define GL_EXT_fragment_shading_rate 1\n" |
452 | 45 | "#define GL_EXT_conservative_depth 1\n" |
453 | | |
454 | | // AEP |
455 | 45 | "#define GL_ANDROID_extension_pack_es31a 1\n" |
456 | 45 | "#define GL_OES_sample_variables 1\n" |
457 | 45 | "#define GL_OES_shader_image_atomic 1\n" |
458 | 45 | "#define GL_OES_shader_multisample_interpolation 1\n" |
459 | 45 | "#define GL_OES_texture_storage_multisample_2d_array 1\n" |
460 | 45 | "#define GL_EXT_geometry_shader 1\n" |
461 | 45 | "#define GL_EXT_geometry_point_size 1\n" |
462 | 45 | "#define GL_EXT_gpu_shader5 1\n" |
463 | 45 | "#define GL_EXT_primitive_bounding_box 1\n" |
464 | 45 | "#define GL_EXT_shader_io_blocks 1\n" |
465 | 45 | "#define GL_EXT_tessellation_shader 1\n" |
466 | 45 | "#define GL_EXT_tessellation_point_size 1\n" |
467 | 45 | "#define GL_EXT_texture_buffer 1\n" |
468 | 45 | "#define GL_EXT_texture_cube_map_array 1\n" |
469 | 45 | "#define GL_EXT_shader_implicit_conversions 1\n" |
470 | 45 | "#define GL_EXT_shader_integer_mix 1\n" |
471 | 45 | "#define GL_EXT_blend_func_extended 1\n" |
472 | 45 | "#define GL_EXT_descriptor_heap 1\n" |
473 | | |
474 | | // OES matching AEP |
475 | 45 | "#define GL_OES_geometry_shader 1\n" |
476 | 45 | "#define GL_OES_geometry_point_size 1\n" |
477 | 45 | "#define GL_OES_gpu_shader5 1\n" |
478 | 45 | "#define GL_OES_primitive_bounding_box 1\n" |
479 | 45 | "#define GL_OES_shader_io_blocks 1\n" |
480 | 45 | "#define GL_OES_tessellation_shader 1\n" |
481 | 45 | "#define GL_OES_tessellation_point_size 1\n" |
482 | 45 | "#define GL_OES_texture_buffer 1\n" |
483 | 45 | "#define GL_OES_texture_cube_map_array 1\n" |
484 | 45 | "#define GL_EXT_shader_non_constant_global_initializers 1\n" |
485 | | |
486 | 45 | "#define GL_QCOM_image_processing 1\n" |
487 | 45 | "#define GL_QCOM_image_processing2 1\n" |
488 | 45 | "#define GL_QCOM_tile_shading 1\n" |
489 | 45 | "#define GL_QCOM_cooperative_matrix_conversion 1\n" |
490 | 45 | ; |
491 | | |
492 | 45 | if (version >= 300) { |
493 | 0 | preamble += "#define GL_NV_shader_noperspective_interpolation 1\n"; |
494 | 0 | } |
495 | 45 | if (version >= 310) { |
496 | 0 | preamble += "#define GL_EXT_null_initializer 1\n"; |
497 | 0 | preamble += "#define GL_EXT_subgroup_uniform_control_flow 1\n"; |
498 | 0 | preamble += "#define GL_EXT_maximal_reconvergence 1\n"; |
499 | 0 | } |
500 | | |
501 | 45 | } else { // !isEsProfile() |
502 | 37 | preamble = |
503 | 37 | "#define GL_ARB_texture_rectangle 1\n" |
504 | 37 | "#define GL_ARB_shading_language_420pack 1\n" |
505 | 37 | "#define GL_ARB_texture_gather 1\n" |
506 | 37 | "#define GL_ARB_gpu_shader5 1\n" |
507 | 37 | "#define GL_ARB_separate_shader_objects 1\n" |
508 | 37 | "#define GL_ARB_compute_shader 1\n" |
509 | 37 | "#define GL_ARB_tessellation_shader 1\n" |
510 | 37 | "#define GL_ARB_enhanced_layouts 1\n" |
511 | 37 | "#define GL_ARB_texture_cube_map_array 1\n" |
512 | 37 | "#define GL_ARB_texture_multisample 1\n" |
513 | 37 | "#define GL_ARB_shader_texture_lod 1\n" |
514 | 37 | "#define GL_ARB_explicit_attrib_location 1\n" |
515 | 37 | "#define GL_ARB_explicit_uniform_location 1\n" |
516 | 37 | "#define GL_ARB_shader_image_load_store 1\n" |
517 | 37 | "#define GL_ARB_shader_atomic_counters 1\n" |
518 | 37 | "#define GL_ARB_shader_draw_parameters 1\n" |
519 | 37 | "#define GL_ARB_shader_group_vote 1\n" |
520 | 37 | "#define GL_ARB_derivative_control 1\n" |
521 | 37 | "#define GL_ARB_shader_texture_image_samples 1\n" |
522 | 37 | "#define GL_ARB_viewport_array 1\n" |
523 | 37 | "#define GL_ARB_gpu_shader_int64 1\n" |
524 | 37 | "#define GL_ARB_gpu_shader_fp64 1\n" |
525 | 37 | "#define GL_ARB_shader_ballot 1\n" |
526 | 37 | "#define GL_ARB_sparse_texture2 1\n" |
527 | 37 | "#define GL_ARB_sparse_texture_clamp 1\n" |
528 | 37 | "#define GL_ARB_shader_stencil_export 1\n" |
529 | 37 | "#define GL_ARB_sample_shading 1\n" |
530 | 37 | "#define GL_ARB_shader_image_size 1\n" |
531 | 37 | "#define GL_ARB_shading_language_packing 1\n" |
532 | | // "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members |
533 | 37 | "#define GL_ARB_post_depth_coverage 1\n" |
534 | 37 | "#define GL_ARB_fragment_shader_interlock 1\n" |
535 | 37 | "#define GL_ARB_uniform_buffer_object 1\n" |
536 | 37 | "#define GL_ARB_shader_bit_encoding 1\n" |
537 | 37 | "#define GL_ARB_shader_storage_buffer_object 1\n" |
538 | 37 | "#define GL_ARB_texture_query_lod 1\n" |
539 | 37 | "#define GL_ARB_vertex_attrib_64bit 1\n" |
540 | 37 | "#define GL_NV_gpu_shader5 1\n" |
541 | 37 | "#define GL_ARB_draw_instanced 1\n" |
542 | 37 | "#define GL_ARB_fragment_coord_conventions 1\n" |
543 | 37 | "#define GL_ARB_conservative_depth 1\n" |
544 | | |
545 | 37 | "#define GL_EXT_shader_non_constant_global_initializers 1\n" |
546 | 37 | "#define GL_EXT_shader_image_load_formatted 1\n" |
547 | 37 | "#define GL_EXT_post_depth_coverage 1\n" |
548 | 37 | "#define GL_EXT_control_flow_attributes 1\n" |
549 | 37 | "#define GL_EXT_nonuniform_qualifier 1\n" |
550 | 37 | "#define GL_EXT_shader_16bit_storage 1\n" |
551 | 37 | "#define GL_EXT_shader_8bit_storage 1\n" |
552 | 37 | "#define GL_EXT_samplerless_texture_functions 1\n" |
553 | 37 | "#define GL_EXT_scalar_block_layout 1\n" |
554 | 37 | "#define GL_EXT_fragment_invocation_density 1\n" |
555 | 37 | "#define GL_EXT_buffer_reference 1\n" |
556 | 37 | "#define GL_EXT_buffer_reference2 1\n" |
557 | 37 | "#define GL_EXT_buffer_reference_uvec2 1\n" |
558 | 37 | "#define GL_EXT_demote_to_helper_invocation 1\n" |
559 | 37 | "#define GL_EXT_debug_printf 1\n" |
560 | 37 | "#define GL_EXT_fragment_shading_rate 1\n" |
561 | 37 | "#define GL_EXT_shared_memory_block 1\n" |
562 | 37 | "#define GL_EXT_shader_integer_mix 1\n" |
563 | 37 | "#define GL_EXT_spec_constant_composites 1\n" |
564 | 37 | "#define GL_EXT_abort 1\n" |
565 | | |
566 | | // GL_KHR_shader_subgroup |
567 | 37 | "#define GL_KHR_shader_subgroup_basic 1\n" |
568 | 37 | "#define GL_KHR_shader_subgroup_vote 1\n" |
569 | 37 | "#define GL_KHR_shader_subgroup_arithmetic 1\n" |
570 | 37 | "#define GL_KHR_shader_subgroup_ballot 1\n" |
571 | 37 | "#define GL_KHR_shader_subgroup_shuffle 1\n" |
572 | 37 | "#define GL_KHR_shader_subgroup_shuffle_relative 1\n" |
573 | 37 | "#define GL_KHR_shader_subgroup_clustered 1\n" |
574 | 37 | "#define GL_KHR_shader_subgroup_quad 1\n" |
575 | | |
576 | 37 | "#define GL_KHR_cooperative_matrix 1\n" |
577 | | |
578 | 37 | "#define GL_EXT_shader_image_int64 1\n" |
579 | 37 | "#define GL_EXT_shader_atomic_int64 1\n" |
580 | 37 | "#define GL_EXT_shader_realtime_clock 1\n" |
581 | 37 | "#define GL_EXT_ray_tracing 1\n" |
582 | 37 | "#define GL_EXT_ray_query 1\n" |
583 | 37 | "#define GL_EXT_ray_flags_primitive_culling 1\n" |
584 | 37 | "#define GL_EXT_ray_cull_mask 1\n" |
585 | 37 | "#define GL_EXT_ray_tracing_position_fetch 1\n" |
586 | 37 | "#define GL_EXT_spirv_intrinsics 1\n" |
587 | 37 | "#define GL_EXT_mesh_shader 1\n" |
588 | | |
589 | 37 | "#define GL_AMD_shader_ballot 1\n" |
590 | 37 | "#define GL_AMD_shader_trinary_minmax 1\n" |
591 | 37 | "#define GL_AMD_shader_explicit_vertex_parameter 1\n" |
592 | 37 | "#define GL_AMD_gcn_shader 1\n" |
593 | 37 | "#define GL_AMD_gpu_shader_half_float 1\n" |
594 | 37 | "#define GL_AMD_texture_gather_bias_lod 1\n" |
595 | 37 | "#define GL_AMD_gpu_shader_int16 1\n" |
596 | 37 | "#define GL_AMD_shader_image_load_store_lod 1\n" |
597 | 37 | "#define GL_AMD_shader_fragment_mask 1\n" |
598 | 37 | "#define GL_AMD_gpu_shader_half_float_fetch 1\n" |
599 | | |
600 | 37 | "#define GL_INTEL_shader_integer_functions2 1\n" |
601 | | |
602 | 37 | "#define GL_NV_sample_mask_override_coverage 1\n" |
603 | 37 | "#define GL_NV_geometry_shader_passthrough 1\n" |
604 | 37 | "#define GL_NV_viewport_array2 1\n" |
605 | 37 | "#define GL_NV_shader_atomic_int64 1\n" |
606 | 37 | "#define GL_NV_conservative_raster_underestimation 1\n" |
607 | 37 | "#define GL_NV_shader_subgroup_partitioned 1\n" |
608 | 37 | "#define GL_NV_shading_rate_image 1\n" |
609 | 37 | "#define GL_NV_ray_tracing 1\n" |
610 | 37 | "#define GL_NV_ray_tracing_motion_blur 1\n" |
611 | 37 | "#define GL_NV_fragment_shader_barycentric 1\n" |
612 | 37 | "#define GL_KHR_compute_shader_derivatives 1\n" |
613 | 37 | "#define GL_NV_compute_shader_derivatives 1\n" |
614 | 37 | "#define GL_NV_shader_texture_footprint 1\n" |
615 | 37 | "#define GL_NV_mesh_shader 1\n" |
616 | 37 | "#define GL_NV_cooperative_matrix 1\n" |
617 | 37 | "#define GL_NV_integer_cooperative_matrix 1\n" |
618 | 37 | "#define GL_NV_shader_invocation_reorder 1\n" |
619 | 37 | "#define GL_NV_cooperative_matrix2 1\n" |
620 | 37 | "#define GL_NV_cooperative_matrix_decode_vector 1\n" |
621 | 37 | "#define GL_NV_desktop_lowp_mediump 1\n" |
622 | 37 | "#define GL_NV_explicit_typecast 1\n" |
623 | | |
624 | 37 | "#define GL_QCOM_image_processing 1\n" |
625 | 37 | "#define GL_QCOM_image_processing2 1\n" |
626 | 37 | "#define GL_QCOM_tile_shading 1\n" |
627 | 37 | "#define GL_QCOM_cooperative_matrix_conversion 1\n" |
628 | | |
629 | 37 | "#define GL_EXT_shader_explicit_arithmetic_types 1\n" |
630 | 37 | "#define GL_EXT_shader_explicit_arithmetic_types_int8 1\n" |
631 | 37 | "#define GL_EXT_shader_explicit_arithmetic_types_int16 1\n" |
632 | 37 | "#define GL_EXT_shader_explicit_arithmetic_types_int32 1\n" |
633 | 37 | "#define GL_EXT_shader_explicit_arithmetic_types_int64 1\n" |
634 | 37 | "#define GL_EXT_shader_explicit_arithmetic_types_float16 1\n" |
635 | 37 | "#define GL_EXT_shader_explicit_arithmetic_types_float32 1\n" |
636 | 37 | "#define GL_EXT_shader_explicit_arithmetic_types_float64 1\n" |
637 | | |
638 | 37 | "#define GL_EXT_shader_subgroup_extended_types_int8 1\n" |
639 | 37 | "#define GL_EXT_shader_subgroup_extended_types_int16 1\n" |
640 | 37 | "#define GL_EXT_shader_subgroup_extended_types_int64 1\n" |
641 | 37 | "#define GL_EXT_shader_subgroup_extended_types_float16 1\n" |
642 | | |
643 | 37 | "#define GL_EXT_shader_atomic_float 1\n" |
644 | 37 | "#define GL_EXT_shader_atomic_float2 1\n" |
645 | | |
646 | 37 | "#define GL_EXT_fragment_shader_barycentric 1\n" |
647 | 37 | "#define GL_EXT_shader_quad_control 1\n" |
648 | 37 | "#define GL_EXT_texture_array 1\n" |
649 | | |
650 | 37 | "#define GL_EXT_control_flow_attributes2 1\n" |
651 | | |
652 | 37 | "#define GL_EXT_integer_dot_product 1\n" |
653 | 37 | "#define GL_EXT_bfloat16 1\n" |
654 | 37 | "#define GL_EXT_float_e5m2 1\n" |
655 | 37 | "#define GL_EXT_float_e4m3 1\n" |
656 | 37 | "#define GL_EXT_uniform_buffer_unsized_array 1\n" |
657 | 37 | "#define GL_EXT_shader_64bit_indexing 1\n" |
658 | | |
659 | 37 | "#define GL_EXT_shader_invocation_reorder 1\n" |
660 | 37 | "#define GL_EXT_descriptor_heap 1\n" |
661 | 37 | ; |
662 | | |
663 | 37 | if (spvVersion.spv == 0) { |
664 | 37 | preamble += "#define GL_ARB_bindless_texture 1\n"; |
665 | 37 | } |
666 | | |
667 | 37 | if (version >= 150) { |
668 | | // define GL_core_profile and GL_compatibility_profile |
669 | 37 | preamble += "#define GL_core_profile 1\n"; |
670 | | |
671 | 37 | if (profile == ECompatibilityProfile) |
672 | 0 | preamble += "#define GL_compatibility_profile 1\n"; |
673 | 37 | } |
674 | 37 | if (version >= 140) { |
675 | 37 | preamble += "#define GL_EXT_null_initializer 1\n"; |
676 | 37 | preamble += "#define GL_EXT_subgroup_uniform_control_flow 1\n"; |
677 | 37 | preamble += "#define GL_EXT_maximal_reconvergence 1\n"; |
678 | 37 | } |
679 | 37 | if (version >= 130) { |
680 | 37 | preamble +="#define GL_FRAGMENT_PRECISION_HIGH 1\n"; |
681 | 37 | } |
682 | | |
683 | 37 | if (version >= 460) { |
684 | 35 | preamble += |
685 | 35 | "#define GL_ARM_tensors 1\n" |
686 | 35 | "#define GL_ARM_tensors_bfloat16 1\n" |
687 | 35 | "#define GL_ARM_tensors_float_e5m2 1\n" |
688 | 35 | "#define GL_ARM_tensors_float_e4m3 1\n" |
689 | 35 | ; |
690 | 35 | } |
691 | 37 | } |
692 | | |
693 | 82 | if ((!isEsProfile() && version >= 460) || |
694 | 47 | (isEsProfile() && version >= 320)) { |
695 | 35 | preamble += "#define GL_EXT_nontemporal_keyword 1\n"; |
696 | 35 | } |
697 | | |
698 | 82 | if ((!isEsProfile() && version >= 140) || |
699 | 45 | (isEsProfile() && version >= 310)) { |
700 | 37 | preamble += |
701 | 37 | "#define GL_EXT_device_group 1\n" |
702 | 37 | "#define GL_EXT_multiview 1\n" |
703 | 37 | "#define GL_NV_shader_sm_builtins 1\n" |
704 | 37 | ; |
705 | 37 | } |
706 | | |
707 | 82 | if ((!isEsProfile() && version >= 130) || |
708 | 45 | (isEsProfile() && version >= 300)) { |
709 | 37 | preamble += "#define GL_EXT_texture_offset_non_const 1\n"; |
710 | 37 | } |
711 | | |
712 | 82 | if (version >= 300 /* both ES and non-ES */) { |
713 | 37 | preamble += |
714 | 37 | "#define GL_OVR_multiview 1\n" |
715 | 37 | "#define GL_OVR_multiview2 1\n" |
716 | 37 | ; |
717 | 37 | } |
718 | | |
719 | | // #line and #include |
720 | 82 | preamble += |
721 | 82 | "#define GL_GOOGLE_cpp_style_line_directive 1\n" |
722 | 82 | "#define GL_GOOGLE_include_directive 1\n" |
723 | 82 | "#define GL_KHR_blend_equation_advanced 1\n" |
724 | 82 | ; |
725 | | |
726 | | // other general extensions |
727 | 82 | preamble += |
728 | 82 | "#define GL_EXT_terminate_invocation 1\n" |
729 | 82 | ; |
730 | | |
731 | | // #define VULKAN XXXX |
732 | 82 | const int numberBufSize = 12; |
733 | 82 | char numberBuf[numberBufSize]; |
734 | 82 | if (spvVersion.vulkanGlsl > 0) { |
735 | 1 | preamble += "#define VULKAN "; |
736 | 1 | snprintf(numberBuf, numberBufSize, "%d", spvVersion.vulkanGlsl); |
737 | 1 | preamble += numberBuf; |
738 | 1 | preamble += "\n"; |
739 | 1 | } |
740 | | |
741 | | // #define GL_SPIRV XXXX |
742 | 82 | if (spvVersion.openGl > 0) { |
743 | 0 | preamble += "#define GL_SPIRV "; |
744 | 0 | snprintf(numberBuf, numberBufSize, "%d", spvVersion.openGl); |
745 | 0 | preamble += numberBuf; |
746 | 0 | preamble += "\n"; |
747 | 0 | } |
748 | | |
749 | | // GL_EXT_spirv_intrinsics |
750 | 82 | if (!isEsProfile()) { |
751 | 37 | switch (language) { |
752 | 37 | case EShLangVertex: preamble += "#define GL_VERTEX_SHADER 1 \n"; break; |
753 | 0 | case EShLangTessControl: preamble += "#define GL_TESSELLATION_CONTROL_SHADER 1 \n"; break; |
754 | 0 | case EShLangTessEvaluation: preamble += "#define GL_TESSELLATION_EVALUATION_SHADER 1 \n"; break; |
755 | 0 | case EShLangGeometry: preamble += "#define GL_GEOMETRY_SHADER 1 \n"; break; |
756 | 0 | case EShLangFragment: preamble += "#define GL_FRAGMENT_SHADER 1 \n"; break; |
757 | 0 | case EShLangCompute: preamble += "#define GL_COMPUTE_SHADER 1 \n"; break; |
758 | 0 | case EShLangRayGen: preamble += "#define GL_RAY_GENERATION_SHADER_EXT 1 \n"; break; |
759 | 0 | case EShLangIntersect: preamble += "#define GL_INTERSECTION_SHADER_EXT 1 \n"; break; |
760 | 0 | case EShLangAnyHit: preamble += "#define GL_ANY_HIT_SHADER_EXT 1 \n"; break; |
761 | 0 | case EShLangClosestHit: preamble += "#define GL_CLOSEST_HIT_SHADER_EXT 1 \n"; break; |
762 | 0 | case EShLangMiss: preamble += "#define GL_MISS_SHADER_EXT 1 \n"; break; |
763 | 0 | case EShLangCallable: preamble += "#define GL_CALLABLE_SHADER_EXT 1 \n"; break; |
764 | 0 | case EShLangTask: preamble += "#define GL_TASK_SHADER_EXT 1 \n"; break; |
765 | 0 | case EShLangMesh: preamble += "#define GL_MESH_SHADER_EXT 1 \n"; break; |
766 | 0 | default: break; |
767 | 37 | } |
768 | 37 | } |
769 | 82 | } |
770 | | |
771 | | // |
772 | | // Map from stage enum to externally readable text name. |
773 | | // |
774 | | const char* StageName(EShLanguage stage) |
775 | 0 | { |
776 | 0 | switch(stage) { |
777 | 0 | case EShLangVertex: return "vertex"; |
778 | 0 | case EShLangFragment: return "fragment"; |
779 | 0 | case EShLangCompute: return "compute"; |
780 | 0 | case EShLangTessControl: return "tessellation control"; |
781 | 0 | case EShLangTessEvaluation: return "tessellation evaluation"; |
782 | 0 | case EShLangGeometry: return "geometry"; |
783 | 0 | case EShLangRayGen: return "ray-generation"; |
784 | 0 | case EShLangIntersect: return "intersection"; |
785 | 0 | case EShLangAnyHit: return "any-hit"; |
786 | 0 | case EShLangClosestHit: return "closest-hit"; |
787 | 0 | case EShLangMiss: return "miss"; |
788 | 0 | case EShLangCallable: return "callable"; |
789 | 0 | case EShLangMesh: return "mesh"; |
790 | 0 | case EShLangTask: return "task"; |
791 | 0 | default: return "unknown stage"; |
792 | 0 | } |
793 | 0 | } |
794 | | |
795 | | // |
796 | | // When to use requireStage() |
797 | | // |
798 | | // If only some stages support a feature. |
799 | | // |
800 | | // Operation: If the current stage is not present, give an error message. |
801 | | // |
802 | | void TParseVersions::requireStage(const TSourceLoc& loc, EShLanguageMask languageMask, const char* featureDesc) |
803 | 80 | { |
804 | 80 | if (((1 << language) & languageMask) == 0) |
805 | 0 | error(loc, "not supported in this stage:", featureDesc, StageName(language)); |
806 | 80 | } |
807 | | |
808 | | // If only one stage supports a feature, this can be called. But, all supporting stages |
809 | | // must be specified with one call. |
810 | | void TParseVersions::requireStage(const TSourceLoc& loc, EShLanguage stage, const char* featureDesc) |
811 | 20 | { |
812 | 20 | requireStage(loc, static_cast<EShLanguageMask>(1 << stage), featureDesc); |
813 | 20 | } |
814 | | |
815 | | // |
816 | | // When to use requireProfile(): |
817 | | // |
818 | | // Use if only some profiles support a feature. However, if within a profile the feature |
819 | | // is version or extension specific, follow this call with calls to profileRequires(). |
820 | | // |
821 | | // Operation: If the current profile is not one of the profileMask, |
822 | | // give an error message. |
823 | | // |
824 | | void TParseVersions::requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc) |
825 | 4.69k | { |
826 | 4.69k | if (! (profile & profileMask)) |
827 | 0 | error(loc, "not supported with this profile:", featureDesc, ProfileName(profile)); |
828 | 4.69k | } |
829 | | |
830 | | // |
831 | | // When to use profileRequires(): |
832 | | // |
833 | | // If a set of profiles have the same requirements for what version or extensions |
834 | | // are needed to support a feature. |
835 | | // |
836 | | // It must be called for each profile that needs protection. Use requireProfile() first |
837 | | // to reduce that set of profiles. |
838 | | // |
839 | | // Operation: Will issue warnings/errors based on the current profile, version, and extension |
840 | | // behaviors. It only checks extensions when the current profile is one of the profileMask. |
841 | | // |
842 | | // A minVersion of 0 means no version of the profileMask support this in core, |
843 | | // the extension must be present. |
844 | | // |
845 | | |
846 | | // entry point that takes multiple extensions |
847 | | void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions, |
848 | | const char* const extensions[], const char* featureDesc) |
849 | 72.4k | { |
850 | 72.4k | if (profile & profileMask) { |
851 | 1.61k | bool okay = minVersion > 0 && version >= minVersion; |
852 | 1.64k | for (int i = 0; i < numExtensions; ++i) { |
853 | 36 | switch (getExtensionBehavior(extensions[i])) { |
854 | 0 | case EBhWarn: |
855 | 0 | infoSink.info.message(EPrefixWarning, ("extension " + TString(extensions[i]) + " is being used for " + featureDesc).c_str(), loc, messages & EShMsgAbsolutePath, messages & EShMsgDisplayErrorColumn); |
856 | 0 | [[fallthrough]]; |
857 | 0 | case EBhRequire: |
858 | 0 | case EBhEnable: |
859 | 0 | okay = true; |
860 | 0 | break; |
861 | 36 | default: break; // some compilers want this |
862 | 36 | } |
863 | 36 | } |
864 | 1.61k | if (! okay) |
865 | 0 | error(loc, "not supported for this version or the enabled extensions", featureDesc, ""); |
866 | 1.61k | } |
867 | 72.4k | } |
868 | | |
869 | | // entry point for the above that takes a single extension |
870 | | void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, const char* extension, |
871 | | const char* featureDesc) |
872 | 72.4k | { |
873 | 72.4k | profileRequires(loc, profileMask, minVersion, extension ? 1 : 0, &extension, featureDesc); |
874 | 72.4k | } |
875 | | |
876 | | void TParseVersions::unimplemented(const TSourceLoc& loc, const char* featureDesc) |
877 | 0 | { |
878 | 0 | error(loc, "feature not yet implemented", featureDesc, ""); |
879 | 0 | } |
880 | | |
881 | | // |
882 | | // Within a set of profiles, see if a feature is deprecated and give an error or warning based on whether |
883 | | // a future compatibility context is being use. |
884 | | // |
885 | | void TParseVersions::checkDeprecated(const TSourceLoc& loc, int profileMask, int depVersion, const char* featureDesc) |
886 | 0 | { |
887 | 0 | if (profile & profileMask) { |
888 | 0 | if (version >= depVersion) { |
889 | 0 | if (forwardCompatible) |
890 | 0 | error(loc, "deprecated, may be removed in future release", featureDesc, ""); |
891 | 0 | else if (! suppressWarnings()) |
892 | 0 | infoSink.info.message(EPrefixWarning, (TString(featureDesc) + " deprecated in version " + |
893 | 0 | String(depVersion) + "; may be removed in future release").c_str(), |
894 | 0 | loc, messages & EShMsgAbsolutePath, messages & EShMsgDisplayErrorColumn); |
895 | 0 | } |
896 | 0 | } |
897 | 0 | } |
898 | | |
899 | | // |
900 | | // Within a set of profiles, see if a feature has now been removed and if so, give an error. |
901 | | // The version argument is the first version no longer having the feature. |
902 | | // |
903 | | void TParseVersions::requireNotRemoved(const TSourceLoc& loc, int profileMask, int removedVersion, const char* featureDesc) |
904 | 0 | { |
905 | 0 | if (profile & profileMask) { |
906 | 0 | if (version >= removedVersion) { |
907 | 0 | const int maxSize = 60; |
908 | 0 | char buf[maxSize]; |
909 | 0 | snprintf(buf, maxSize, "%s profile; removed in version %d", ProfileName(profile), removedVersion); |
910 | 0 | error(loc, "no longer supported in", featureDesc, buf); |
911 | 0 | } |
912 | 0 | } |
913 | 0 | } |
914 | | |
915 | | // Returns true if at least one of the extensions in the extensions parameter is requested. Otherwise, returns false. |
916 | | // Warns appropriately if the requested behavior of an extension is "warn". |
917 | | bool TParseVersions::checkExtensionsRequested(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc) |
918 | 20 | { |
919 | | // First, see if any of the extensions are enabled |
920 | 40 | for (int i = 0; i < numExtensions; ++i) { |
921 | 20 | TExtensionBehavior behavior = getExtensionBehavior(extensions[i]); |
922 | 20 | if (behavior == EBhEnable || behavior == EBhRequire) |
923 | 0 | return true; |
924 | 20 | } |
925 | | |
926 | | // See if any extensions want to give a warning on use; give warnings for all such extensions |
927 | 20 | bool warned = false; |
928 | 40 | for (int i = 0; i < numExtensions; ++i) { |
929 | 20 | TExtensionBehavior behavior = getExtensionBehavior(extensions[i]); |
930 | 20 | if (behavior == EBhDisable && relaxedErrors()) { |
931 | 0 | infoSink.info.message(EPrefixWarning, "The following extension must be enabled to use this feature:", loc, |
932 | 0 | messages & EShMsgAbsolutePath, messages & EShMsgDisplayErrorColumn); |
933 | 0 | behavior = EBhWarn; |
934 | 0 | } |
935 | 20 | if (behavior == EBhWarn) { |
936 | 0 | infoSink.info.message(EPrefixWarning, |
937 | 0 | ("extension " + TString(extensions[i]) + " is being used for " + featureDesc).c_str(), |
938 | 0 | loc, messages & EShMsgAbsolutePath, messages & EShMsgDisplayErrorColumn); |
939 | 0 | warned = true; |
940 | 0 | } |
941 | 20 | } |
942 | 20 | if (warned) |
943 | 0 | return true; |
944 | 20 | return false; |
945 | 20 | } |
946 | | |
947 | | // |
948 | | // Use when there are no profile/version to check, it's just an error if one of the |
949 | | // extensions is not present. |
950 | | // |
951 | | void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], |
952 | | const char* featureDesc) |
953 | 0 | { |
954 | 0 | if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc)) |
955 | 0 | return; |
956 | | |
957 | | // If we get this far, give errors explaining what extensions are needed |
958 | 0 | if (numExtensions == 1) |
959 | 0 | error(loc, "required extension not requested:", featureDesc, extensions[0]); |
960 | 0 | else { |
961 | 0 | error(loc, "required extension not requested:", featureDesc, "Possible extensions include:"); |
962 | 0 | for (int i = 0; i < numExtensions; ++i) |
963 | 0 | infoSink.info.message(EPrefixNone, extensions[i]); |
964 | 0 | } |
965 | 0 | } |
966 | | |
967 | | // |
968 | | // Use by preprocessor when there are no profile/version to check, it's just an error if one of the |
969 | | // extensions is not present. |
970 | | // |
971 | | void TParseVersions::ppRequireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], |
972 | | const char* featureDesc) |
973 | 0 | { |
974 | 0 | if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc)) |
975 | 0 | return; |
976 | | |
977 | | // If we get this far, give errors explaining what extensions are needed |
978 | 0 | if (numExtensions == 1) |
979 | 0 | ppError(loc, "required extension not requested:", featureDesc, extensions[0]); |
980 | 0 | else { |
981 | 0 | ppError(loc, "required extension not requested:", featureDesc, "Possible extensions include:"); |
982 | 0 | for (int i = 0; i < numExtensions; ++i) |
983 | 0 | infoSink.info.message(EPrefixNone, extensions[i]); |
984 | 0 | } |
985 | 0 | } |
986 | | |
987 | | TExtensionBehavior TParseVersions::getExtensionBehavior(const char* extension) |
988 | 17.7k | { |
989 | 17.7k | auto iter = extensionBehavior.find(TString(extension)); |
990 | 17.7k | if (iter == extensionBehavior.end()) |
991 | 17.7k | return EBhMissing; |
992 | 0 | else |
993 | 0 | return iter->second; |
994 | 17.7k | } |
995 | | |
996 | | // Returns true if the given extension is set to enable, require, or warn. |
997 | | bool TParseVersions::extensionTurnedOn(const char* const extension) |
998 | 17.6k | { |
999 | 17.6k | switch (getExtensionBehavior(extension)) { |
1000 | 0 | case EBhEnable: |
1001 | 0 | case EBhRequire: |
1002 | 0 | case EBhWarn: |
1003 | 0 | return true; |
1004 | 17.6k | default: |
1005 | 17.6k | break; |
1006 | 17.6k | } |
1007 | 17.6k | return false; |
1008 | 17.6k | } |
1009 | | // See if any of the extensions are set to enable, require, or warn. |
1010 | | bool TParseVersions::extensionsTurnedOn(int numExtensions, const char* const extensions[]) |
1011 | 1.59k | { |
1012 | 4.71k | for (int i = 0; i < numExtensions; ++i) { |
1013 | 3.12k | if (extensionTurnedOn(extensions[i])) |
1014 | 0 | return true; |
1015 | 3.12k | } |
1016 | 1.59k | return false; |
1017 | 1.59k | } |
1018 | | |
1019 | | // |
1020 | | // Change the current state of an extension's behavior. |
1021 | | // |
1022 | | void TParseVersions::updateExtensionBehavior(int line, const char* extension, const char* behaviorString) |
1023 | 0 | { |
1024 | | // Translate from text string of extension's behavior to an enum. |
1025 | 0 | TExtensionBehavior behavior = EBhDisable; |
1026 | 0 | if (! strcmp("require", behaviorString)) |
1027 | 0 | behavior = EBhRequire; |
1028 | 0 | else if (! strcmp("enable", behaviorString)) |
1029 | 0 | behavior = EBhEnable; |
1030 | 0 | else if (! strcmp("disable", behaviorString)) |
1031 | 0 | behavior = EBhDisable; |
1032 | 0 | else if (! strcmp("warn", behaviorString)) |
1033 | 0 | behavior = EBhWarn; |
1034 | 0 | else { |
1035 | 0 | error(getCurrentLoc(), "behavior not supported:", "#extension", behaviorString); |
1036 | 0 | return; |
1037 | 0 | } |
1038 | 0 | bool on = behavior != EBhDisable; |
1039 | | |
1040 | | // check if extension is used with correct shader stage |
1041 | 0 | checkExtensionStage(getCurrentLoc(), extension); |
1042 | | |
1043 | | // check if extension has additional requirements |
1044 | 0 | extensionRequires(getCurrentLoc(), extension, behaviorString); |
1045 | | |
1046 | | // update the requested extension |
1047 | 0 | updateExtensionBehavior(extension, behavior); |
1048 | | |
1049 | | // see if need to propagate to implicitly modified things |
1050 | 0 | if (strcmp(extension, "GL_ANDROID_extension_pack_es31a") == 0) { |
1051 | | // to everything in AEP |
1052 | 0 | updateExtensionBehavior(line, "GL_KHR_blend_equation_advanced", behaviorString); |
1053 | 0 | updateExtensionBehavior(line, "GL_OES_sample_variables", behaviorString); |
1054 | 0 | updateExtensionBehavior(line, "GL_OES_shader_image_atomic", behaviorString); |
1055 | 0 | updateExtensionBehavior(line, "GL_OES_shader_multisample_interpolation", behaviorString); |
1056 | 0 | updateExtensionBehavior(line, "GL_OES_texture_storage_multisample_2d_array", behaviorString); |
1057 | 0 | updateExtensionBehavior(line, "GL_EXT_geometry_shader", behaviorString); |
1058 | 0 | updateExtensionBehavior(line, "GL_EXT_gpu_shader5", behaviorString); |
1059 | 0 | updateExtensionBehavior(line, "GL_EXT_primitive_bounding_box", behaviorString); |
1060 | 0 | updateExtensionBehavior(line, "GL_EXT_shader_io_blocks", behaviorString); |
1061 | 0 | updateExtensionBehavior(line, "GL_EXT_tessellation_shader", behaviorString); |
1062 | 0 | updateExtensionBehavior(line, "GL_EXT_texture_buffer", behaviorString); |
1063 | 0 | updateExtensionBehavior(line, "GL_EXT_texture_cube_map_array", behaviorString); |
1064 | 0 | } |
1065 | | // geometry to io_blocks |
1066 | 0 | else if (strcmp(extension, "GL_EXT_geometry_shader") == 0) |
1067 | 0 | updateExtensionBehavior(line, "GL_EXT_shader_io_blocks", behaviorString); |
1068 | 0 | else if (strcmp(extension, "GL_OES_geometry_shader") == 0) |
1069 | 0 | updateExtensionBehavior(line, "GL_OES_shader_io_blocks", behaviorString); |
1070 | | // tessellation to io_blocks |
1071 | 0 | else if (strcmp(extension, "GL_EXT_tessellation_shader") == 0) |
1072 | 0 | updateExtensionBehavior(line, "GL_EXT_shader_io_blocks", behaviorString); |
1073 | 0 | else if (strcmp(extension, "GL_OES_tessellation_shader") == 0) |
1074 | 0 | updateExtensionBehavior(line, "GL_OES_shader_io_blocks", behaviorString); |
1075 | 0 | else if (strcmp(extension, "GL_GOOGLE_include_directive") == 0) |
1076 | 0 | updateExtensionBehavior(line, "GL_GOOGLE_cpp_style_line_directive", behaviorString); |
1077 | 0 | else if (strcmp(extension, "GL_ARB_shading_language_include") == 0) |
1078 | 0 | updateExtensionBehavior(line, "GL_GOOGLE_cpp_style_line_directive", behaviorString); |
1079 | | // subgroup_* to subgroup_basic |
1080 | 0 | else if (strcmp(extension, "GL_KHR_shader_subgroup_vote") == 0) |
1081 | 0 | updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString); |
1082 | 0 | else if (strcmp(extension, "GL_KHR_shader_subgroup_arithmetic") == 0) |
1083 | 0 | updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString); |
1084 | 0 | else if (strcmp(extension, "GL_KHR_shader_subgroup_ballot") == 0) |
1085 | 0 | updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString); |
1086 | 0 | else if (strcmp(extension, "GL_KHR_shader_subgroup_shuffle") == 0) |
1087 | 0 | updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString); |
1088 | 0 | else if (strcmp(extension, "GL_KHR_shader_subgroup_shuffle_relative") == 0) |
1089 | 0 | updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString); |
1090 | 0 | else if (strcmp(extension, "GL_KHR_shader_subgroup_clustered") == 0) |
1091 | 0 | updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString); |
1092 | 0 | else if (strcmp(extension, "GL_KHR_shader_subgroup_quad") == 0) |
1093 | 0 | updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString); |
1094 | 0 | else if (strcmp(extension, "GL_NV_shader_subgroup_partitioned") == 0) |
1095 | 0 | updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString); |
1096 | 0 | else if (strcmp(extension, "GL_EXT_buffer_reference2") == 0 || |
1097 | 0 | strcmp(extension, "GL_EXT_buffer_reference_uvec2") == 0) |
1098 | 0 | updateExtensionBehavior(line, "GL_EXT_buffer_reference", behaviorString); |
1099 | 0 | else if (strcmp(extension, "GL_NV_integer_cooperative_matrix") == 0) |
1100 | 0 | updateExtensionBehavior(line, "GL_NV_cooperative_matrix", behaviorString); |
1101 | 0 | else if (strcmp(extension, "GL_NV_cooperative_matrix2") == 0) |
1102 | 0 | updateExtensionBehavior(line, "GL_KHR_cooperative_matrix", behaviorString); |
1103 | | // subgroup extended types to explicit types |
1104 | 0 | else if (strcmp(extension, "GL_EXT_shader_subgroup_extended_types_int8") == 0) |
1105 | 0 | updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_int8", behaviorString); |
1106 | 0 | else if (strcmp(extension, "GL_EXT_shader_subgroup_extended_types_int16") == 0) |
1107 | 0 | updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_int16", behaviorString); |
1108 | 0 | else if (strcmp(extension, "GL_EXT_shader_subgroup_extended_types_int64") == 0) |
1109 | 0 | updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_int64", behaviorString); |
1110 | 0 | else if (strcmp(extension, "GL_EXT_shader_subgroup_extended_types_float16") == 0) |
1111 | 0 | updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_float16", behaviorString); |
1112 | | |
1113 | | // see if we need to update the numeric features |
1114 | 0 | else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types") == 0) |
1115 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types, on); |
1116 | 0 | else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int8") == 0) |
1117 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int8, on); |
1118 | 0 | else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int16") == 0) |
1119 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int16, on); |
1120 | 0 | else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int32") == 0) |
1121 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int32, on); |
1122 | 0 | else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int64") == 0) |
1123 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int64, on); |
1124 | 0 | else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float16") == 0) |
1125 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float16, on); |
1126 | 0 | else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float32") == 0) |
1127 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float32, on); |
1128 | 0 | else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float64") == 0) |
1129 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float64, on); |
1130 | 0 | else if (strcmp(extension, "GL_EXT_shader_implicit_conversions") == 0) |
1131 | 0 | intermediate.updateNumericFeature(TNumericFeatures::shader_implicit_conversions, on); |
1132 | 0 | else if (strcmp(extension, "GL_ARB_gpu_shader_fp64") == 0) |
1133 | 0 | intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_fp64, on); |
1134 | 0 | else if (strcmp(extension, "GL_AMD_gpu_shader_int16") == 0) |
1135 | 0 | intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_int16, on); |
1136 | 0 | else if (strcmp(extension, "GL_AMD_gpu_shader_half_float") == 0) |
1137 | 0 | intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_half_float, on); |
1138 | 0 | else if (strcmp(extension, "GL_NV_gpu_shader5") == 0) { |
1139 | 0 | intermediate.updateNumericFeature(TNumericFeatures::nv_gpu_shader5_types, on); |
1140 | 0 | } |
1141 | 0 | } |
1142 | | |
1143 | | void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBehavior behavior) |
1144 | 0 | { |
1145 | | // Update the current behavior |
1146 | 0 | if (strcmp(extension, "all") == 0) { |
1147 | | // special case for the 'all' extension; apply it to every extension present |
1148 | 0 | if (behavior == EBhRequire || behavior == EBhEnable) { |
1149 | 0 | error(getCurrentLoc(), "extension 'all' cannot have 'require' or 'enable' behavior", "#extension", ""); |
1150 | 0 | return; |
1151 | 0 | } else { |
1152 | 0 | for (auto iter = extensionBehavior.begin(); iter != extensionBehavior.end(); ++iter) |
1153 | 0 | iter->second = behavior; |
1154 | 0 | } |
1155 | 0 | } else { |
1156 | | // Do the update for this single extension |
1157 | 0 | auto iter = extensionBehavior.find(TString(extension)); |
1158 | 0 | if (iter == extensionBehavior.end()) { |
1159 | 0 | switch (behavior) { |
1160 | 0 | case EBhRequire: |
1161 | 0 | error(getCurrentLoc(), "extension not supported:", "#extension", extension); |
1162 | 0 | break; |
1163 | 0 | case EBhEnable: |
1164 | 0 | case EBhWarn: |
1165 | 0 | case EBhDisable: |
1166 | 0 | warn(getCurrentLoc(), "extension not supported:", "#extension", extension); |
1167 | 0 | break; |
1168 | 0 | default: |
1169 | 0 | assert(0 && "unexpected behavior"); |
1170 | 0 | } |
1171 | | |
1172 | 0 | return; |
1173 | 0 | } else { |
1174 | 0 | if (iter->second == EBhDisablePartial) |
1175 | 0 | warn(getCurrentLoc(), "extension is only partially supported:", "#extension", extension); |
1176 | 0 | if (behavior != EBhDisable) |
1177 | 0 | intermediate.addRequestedExtension(extension); |
1178 | 0 | iter->second = behavior; |
1179 | 0 | } |
1180 | 0 | } |
1181 | 0 | } |
1182 | | |
1183 | | // Check if extension is used with correct shader stage. |
1184 | | void TParseVersions::checkExtensionStage(const TSourceLoc& loc, const char * const extension) |
1185 | 0 | { |
1186 | | // GL_NV_mesh_shader extension is only allowed in task/mesh shaders |
1187 | 0 | if (strcmp(extension, "GL_NV_mesh_shader") == 0) { |
1188 | 0 | requireStage(loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask | EShLangFragmentMask), |
1189 | 0 | "#extension GL_NV_mesh_shader"); |
1190 | 0 | profileRequires(loc, ECoreProfile, 450, nullptr, "#extension GL_NV_mesh_shader"); |
1191 | 0 | profileRequires(loc, EEsProfile, 320, nullptr, "#extension GL_NV_mesh_shader"); |
1192 | 0 | if (extensionTurnedOn(E_GL_EXT_mesh_shader)) { |
1193 | 0 | error(loc, "GL_EXT_mesh_shader is already turned on, and not allowed with", "#extension", extension); |
1194 | 0 | } |
1195 | 0 | } |
1196 | 0 | else if (strcmp(extension, "GL_EXT_mesh_shader") == 0) { |
1197 | 0 | requireStage(loc, (EShLanguageMask)(EShLangTaskMask | EShLangMeshMask | EShLangFragmentMask), |
1198 | 0 | "#extension GL_EXT_mesh_shader"); |
1199 | 0 | profileRequires(loc, ECoreProfile, 450, nullptr, "#extension GL_EXT_mesh_shader"); |
1200 | 0 | profileRequires(loc, EEsProfile, 320, nullptr, "#extension GL_EXT_mesh_shader"); |
1201 | 0 | if (extensionTurnedOn(E_GL_NV_mesh_shader)) { |
1202 | 0 | error(loc, "GL_NV_mesh_shader is already turned on, and not allowed with", "#extension", extension); |
1203 | 0 | } |
1204 | 0 | } |
1205 | 0 | } |
1206 | | |
1207 | | // Check if extension has additional requirements |
1208 | | void TParseVersions::extensionRequires(const TSourceLoc &loc, const char * const extension, const char *behaviorString) |
1209 | 0 | { |
1210 | 0 | bool isEnabled = false; |
1211 | 0 | if (!strcmp("require", behaviorString)) |
1212 | 0 | isEnabled = true; |
1213 | 0 | else if (!strcmp("enable", behaviorString)) |
1214 | 0 | isEnabled = true; |
1215 | |
|
1216 | 0 | if (isEnabled) { |
1217 | 0 | unsigned int minSpvVersion = 0; |
1218 | 0 | auto iter = extensionMinSpv.find(TString(extension)); |
1219 | 0 | if (iter != extensionMinSpv.end()) |
1220 | 0 | minSpvVersion = iter->second; |
1221 | 0 | requireSpv(loc, extension, minSpvVersion); |
1222 | 0 | } |
1223 | |
|
1224 | 0 | if (spvVersion.spv != 0){ |
1225 | 0 | for (auto ext : spvUnsupportedExt){ |
1226 | 0 | if (strcmp(extension, ext.c_str()) == 0) |
1227 | 0 | error(loc, "not allowed when using generating SPIR-V codes", extension, ""); |
1228 | 0 | } |
1229 | 0 | } |
1230 | 0 | } |
1231 | | |
1232 | | // Call for any operation needing full GLSL integer data-type support. |
1233 | | void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op) |
1234 | 24.3k | { |
1235 | 24.3k | profileRequires(loc, ENoProfile, 130, nullptr, op); |
1236 | 24.3k | profileRequires(loc, EEsProfile, 300, nullptr, op); |
1237 | 24.3k | } |
1238 | | |
1239 | | // Call for any operation needing GLSL double data-type support. |
1240 | | void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op) |
1241 | 0 | { |
1242 | | |
1243 | | //requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); |
1244 | 0 | if (language == EShLangVertex) { |
1245 | 0 | const char* const f64_Extensions[] = {E_GL_ARB_gpu_shader_fp64, E_GL_ARB_vertex_attrib_64bit}; |
1246 | 0 | profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, 2, f64_Extensions, op); |
1247 | 0 | } else |
1248 | 0 | profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader_fp64, op); |
1249 | 0 | } |
1250 | | |
1251 | | // Call for any operation needing GLSL float16 data-type support. |
1252 | | void TParseVersions::float16Check(const TSourceLoc& loc, const char* op, bool builtIn) |
1253 | 252 | { |
1254 | 252 | if (!builtIn) { |
1255 | 0 | const char* const extensions[] = { |
1256 | 0 | E_GL_AMD_gpu_shader_half_float, |
1257 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1258 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_float16}; |
1259 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1260 | 0 | } |
1261 | 252 | } |
1262 | | |
1263 | | bool TParseVersions::float16Arithmetic() |
1264 | 0 | { |
1265 | 0 | const char* const extensions[] = { |
1266 | 0 | E_GL_AMD_gpu_shader_half_float, |
1267 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1268 | 0 | E_GL_NV_gpu_shader5, |
1269 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_float16}; |
1270 | 0 | return extensionsTurnedOn(sizeof(extensions)/sizeof(extensions[0]), extensions); |
1271 | 0 | } |
1272 | | |
1273 | | bool TParseVersions::int16Arithmetic() |
1274 | 0 | { |
1275 | 0 | const char* const extensions[] = { |
1276 | 0 | E_GL_AMD_gpu_shader_int16, |
1277 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1278 | 0 | E_GL_NV_gpu_shader5, |
1279 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int16}; |
1280 | 0 | return extensionsTurnedOn(sizeof(extensions)/sizeof(extensions[0]), extensions); |
1281 | 0 | } |
1282 | | |
1283 | | bool TParseVersions::int8Arithmetic() |
1284 | 0 | { |
1285 | 0 | const char* const extensions[] = { |
1286 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1287 | 0 | E_GL_NV_gpu_shader5, |
1288 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int8}; |
1289 | 0 | return extensionsTurnedOn(sizeof(extensions)/sizeof(extensions[0]), extensions); |
1290 | 0 | } |
1291 | | |
1292 | | void TParseVersions::requireFloat16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) |
1293 | 0 | { |
1294 | 0 | TString combined; |
1295 | 0 | combined = op; |
1296 | 0 | combined += ": "; |
1297 | 0 | combined += featureDesc; |
1298 | |
|
1299 | 0 | const char* const extensions[] = { |
1300 | 0 | E_GL_AMD_gpu_shader_half_float, |
1301 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1302 | 0 | E_GL_NV_gpu_shader5, |
1303 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_float16}; |
1304 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, combined.c_str()); |
1305 | 0 | } |
1306 | | |
1307 | | void TParseVersions::requireInt16Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) |
1308 | 0 | { |
1309 | 0 | TString combined; |
1310 | 0 | combined = op; |
1311 | 0 | combined += ": "; |
1312 | 0 | combined += featureDesc; |
1313 | |
|
1314 | 0 | const char* const extensions[] = { |
1315 | 0 | E_GL_AMD_gpu_shader_int16, |
1316 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1317 | 0 | E_GL_NV_gpu_shader5, |
1318 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int16}; |
1319 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, combined.c_str()); |
1320 | 0 | } |
1321 | | |
1322 | | void TParseVersions::requireInt8Arithmetic(const TSourceLoc& loc, const char* op, const char* featureDesc) |
1323 | 0 | { |
1324 | 0 | TString combined; |
1325 | 0 | combined = op; |
1326 | 0 | combined += ": "; |
1327 | 0 | combined += featureDesc; |
1328 | |
|
1329 | 0 | const char* const extensions[] = { |
1330 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1331 | 0 | E_GL_NV_gpu_shader5, |
1332 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int8}; |
1333 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, combined.c_str()); |
1334 | 0 | } |
1335 | | |
1336 | | void TParseVersions::float16ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1337 | 18.0k | { |
1338 | 18.0k | if (!builtIn) { |
1339 | 0 | const char* const extensions[] = { |
1340 | 0 | E_GL_AMD_gpu_shader_half_float, |
1341 | 0 | E_GL_EXT_shader_16bit_storage, |
1342 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1343 | 0 | E_GL_NV_gpu_shader5, |
1344 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_float16}; |
1345 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1346 | 0 | } |
1347 | 18.0k | } |
1348 | | |
1349 | | void TParseVersions::bfloat16ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1350 | 176 | { |
1351 | 176 | if (!builtIn) { |
1352 | 0 | const char* const extensions[] = { |
1353 | 0 | E_GL_EXT_bfloat16, |
1354 | 0 | }; |
1355 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1356 | 0 | } |
1357 | 176 | } |
1358 | | |
1359 | | void TParseVersions::floate5m2ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1360 | 128 | { |
1361 | 128 | if (!builtIn) { |
1362 | 0 | const char* const extensions[] = { |
1363 | 0 | E_GL_EXT_float_e5m2, |
1364 | 0 | }; |
1365 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1366 | 0 | } |
1367 | 128 | } |
1368 | | |
1369 | | void TParseVersions::floate4m3ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1370 | 128 | { |
1371 | 128 | if (!builtIn) { |
1372 | 0 | const char* const extensions[] = { |
1373 | 0 | E_GL_EXT_float_e4m3, |
1374 | 0 | }; |
1375 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1376 | 0 | } |
1377 | 128 | } |
1378 | | |
1379 | | // Call for any operation needing GLSL float32 data-type support. |
1380 | | void TParseVersions::explicitFloat32Check(const TSourceLoc& loc, const char* op, bool builtIn) |
1381 | 352 | { |
1382 | 352 | if (!builtIn) { |
1383 | 0 | const char* const extensions[] = {E_GL_EXT_shader_explicit_arithmetic_types, |
1384 | 0 | E_GL_NV_gpu_shader5, |
1385 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_float32}; |
1386 | 0 | requireExtensions(loc, sizeof(extensions) / sizeof(extensions[0]), extensions, op); |
1387 | 0 | } |
1388 | 352 | } |
1389 | | |
1390 | | // Call for any operation needing GLSL float64 data-type support. |
1391 | | void TParseVersions::explicitFloat64Check(const TSourceLoc& loc, const char* op, bool builtIn) |
1392 | 1.61k | { |
1393 | 1.61k | if (!builtIn) { |
1394 | 0 | const char* const extensions[] = {E_GL_EXT_shader_explicit_arithmetic_types, |
1395 | 0 | E_GL_NV_gpu_shader5, |
1396 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_float64}; |
1397 | 0 | requireExtensions(loc, sizeof(extensions) / sizeof(extensions[0]), extensions, op); |
1398 | 0 | requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); |
1399 | 0 | if(extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) && extensionTurnedOn(E_GL_NV_gpu_shader5)) |
1400 | 0 | profileRequires(loc, ECoreProfile | ECompatibilityProfile, 150, nullptr, op); |
1401 | 0 | else |
1402 | 0 | profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op); |
1403 | 0 | } |
1404 | 1.61k | } |
1405 | | |
1406 | | // Call for any operation needing GLSL explicit int8 data-type support. |
1407 | | void TParseVersions::explicitInt8Check(const TSourceLoc& loc, const char* op, bool builtIn) |
1408 | 0 | { |
1409 | 0 | if (! builtIn) { |
1410 | 0 | const char* const extensions[2] = {E_GL_EXT_shader_explicit_arithmetic_types, |
1411 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int8}; |
1412 | 0 | requireExtensions(loc, 2, extensions, op); |
1413 | 0 | } |
1414 | 0 | } |
1415 | | |
1416 | | // Call for any operation needing GLSL float16 opaque-type support |
1417 | | void TParseVersions::float16OpaqueCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1418 | 6.61k | { |
1419 | 6.61k | if (! builtIn) { |
1420 | 0 | requireExtensions(loc, 1, &E_GL_AMD_gpu_shader_half_float_fetch, op); |
1421 | 0 | requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); |
1422 | 0 | profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op); |
1423 | 0 | } |
1424 | 6.61k | } |
1425 | | |
1426 | | // Call for any operation needing GLSL explicit int16 data-type support. |
1427 | | void TParseVersions::explicitInt16Check(const TSourceLoc& loc, const char* op, bool builtIn) |
1428 | 0 | { |
1429 | 0 | if (! builtIn) { |
1430 | 0 | const char* const extensions[] = { |
1431 | 0 | E_GL_AMD_gpu_shader_int16, |
1432 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1433 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int16}; |
1434 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1435 | 0 | } |
1436 | 0 | } |
1437 | | |
1438 | | void TParseVersions::int16ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1439 | 8.86k | { |
1440 | 8.86k | if (! builtIn) { |
1441 | 0 | const char* const extensions[] = { |
1442 | 0 | E_GL_AMD_gpu_shader_int16, |
1443 | 0 | E_GL_EXT_shader_16bit_storage, |
1444 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1445 | 0 | E_GL_NV_gpu_shader5, |
1446 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int16}; |
1447 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1448 | 0 | } |
1449 | 8.86k | } |
1450 | | |
1451 | | void TParseVersions::int8ScalarVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1452 | 6.78k | { |
1453 | 6.78k | if (! builtIn) { |
1454 | 0 | const char* const extensions[] = { |
1455 | 0 | E_GL_EXT_shader_8bit_storage, |
1456 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1457 | 0 | E_GL_NV_gpu_shader5, |
1458 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int8}; |
1459 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1460 | 0 | } |
1461 | 6.78k | } |
1462 | | |
1463 | | // Call for any operation needing GLSL explicit int32 data-type support. |
1464 | | void TParseVersions::explicitInt32Check(const TSourceLoc& loc, const char* op, bool builtIn) |
1465 | 752 | { |
1466 | 752 | if (! builtIn) { |
1467 | 0 | const char* const extensions[] = {E_GL_EXT_shader_explicit_arithmetic_types, |
1468 | 0 | E_GL_NV_gpu_shader5, |
1469 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int32}; |
1470 | 0 | requireExtensions(loc, sizeof(extensions) / sizeof(extensions[0]), extensions, op); |
1471 | 0 | } |
1472 | 752 | } |
1473 | | |
1474 | | // Call for any operation needing GLSL 64-bit integer data-type support. |
1475 | | void TParseVersions::int64Check(const TSourceLoc& loc, const char* op, bool builtIn) |
1476 | 14.1k | { |
1477 | 14.1k | if (! builtIn) { |
1478 | 0 | const char* const extensions[] = {E_GL_ARB_gpu_shader_int64, |
1479 | 0 | E_GL_EXT_shader_explicit_arithmetic_types, |
1480 | 0 | E_GL_NV_gpu_shader5, |
1481 | 0 | E_GL_EXT_shader_explicit_arithmetic_types_int64}; |
1482 | 0 | requireExtensions(loc, sizeof(extensions) / sizeof(extensions[0]), extensions, op); |
1483 | 0 | requireProfile(loc, ECoreProfile | ECompatibilityProfile, op); |
1484 | 0 | if (extensionTurnedOn(E_GL_NV_gpu_shader5)) |
1485 | 0 | profileRequires(loc, ECoreProfile | ECompatibilityProfile, 150, nullptr, op); |
1486 | 0 | else |
1487 | 0 | profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, nullptr, op); |
1488 | 0 | } |
1489 | 14.1k | } |
1490 | | |
1491 | | void TParseVersions::fcoopmatCheckNV(const TSourceLoc& loc, const char* op, bool builtIn) |
1492 | 84 | { |
1493 | 84 | if (!builtIn) { |
1494 | 0 | const char* const extensions[] = {E_GL_NV_cooperative_matrix}; |
1495 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1496 | 0 | } |
1497 | 84 | } |
1498 | | |
1499 | | void TParseVersions::intcoopmatCheckNV(const TSourceLoc& loc, const char* op, bool builtIn) |
1500 | 224 | { |
1501 | 224 | if (!builtIn) { |
1502 | 0 | const char* const extensions[] = {E_GL_NV_integer_cooperative_matrix}; |
1503 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1504 | 0 | } |
1505 | 224 | } |
1506 | | |
1507 | | void TParseVersions::coopmatCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1508 | 848 | { |
1509 | 848 | if (!builtIn) { |
1510 | 0 | const char* const extensions[] = {E_GL_KHR_cooperative_matrix}; |
1511 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1512 | 0 | } |
1513 | 848 | } |
1514 | | |
1515 | | void TParseVersions::coopmatConverisonCheckQCOM(const TSourceLoc& loc, const char* op, bool builtIn) |
1516 | 0 | { |
1517 | 0 | if (!builtIn) { |
1518 | 0 | const char* const extensions[] = {E_GL_KHR_cooperative_matrix}; |
1519 | 0 | requireExtensions(loc, sizeof(extensions) / sizeof(extensions[0]), extensions, op); |
1520 | 0 | } |
1521 | 0 | } |
1522 | | |
1523 | | void TParseVersions::tensorLayoutViewCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1524 | 388 | { |
1525 | 388 | if (!builtIn) { |
1526 | 0 | const char* const extensions[] = {E_GL_NV_cooperative_matrix2}; |
1527 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1528 | 0 | } |
1529 | 388 | } |
1530 | | |
1531 | | void TParseVersions::coopvecCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1532 | 3.18k | { |
1533 | 3.18k | if (!builtIn) { |
1534 | 0 | const char* const extensions[] = {E_GL_NV_cooperative_vector}; |
1535 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1536 | 0 | } |
1537 | 3.18k | } |
1538 | | |
1539 | | void TParseVersions::intattachmentCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1540 | 0 | { |
1541 | 0 | if (!builtIn) { |
1542 | 0 | const char* const extensions[] = {E_GL_QCOM_tile_shading}; |
1543 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1544 | 0 | } |
1545 | 0 | } |
1546 | | |
1547 | | void TParseVersions::tensorCheckARM(const TSourceLoc& loc, const char* op, bool builtIn) |
1548 | 244 | { |
1549 | 244 | if (!builtIn) { |
1550 | 0 | const char* const extensions[] = {E_GL_ARM_tensors}; |
1551 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1552 | 0 | } |
1553 | 244 | } |
1554 | | |
1555 | | void TParseVersions::longVectorCheck(const TSourceLoc& loc, const char* op, bool builtIn) |
1556 | 2.35k | { |
1557 | 2.35k | if (!builtIn) { |
1558 | 0 | const char* const extensions[] = {E_GL_EXT_long_vector}; |
1559 | 0 | requireExtensions(loc, sizeof(extensions)/sizeof(extensions[0]), extensions, op); |
1560 | 0 | } |
1561 | 2.35k | } |
1562 | | |
1563 | | // Call for any operation removed because SPIR-V is in use. |
1564 | | void TParseVersions::spvRemoved(const TSourceLoc& loc, const char* op) |
1565 | 0 | { |
1566 | 0 | if (spvVersion.spv != 0) |
1567 | 0 | error(loc, "not allowed when generating SPIR-V", op, ""); |
1568 | 0 | } |
1569 | | |
1570 | | // Call for any operation removed because Vulkan SPIR-V is being generated. |
1571 | | void TParseVersions::vulkanRemoved(const TSourceLoc& loc, const char* op) |
1572 | 24 | { |
1573 | 24 | if (spvVersion.vulkan > 0 && !spvVersion.vulkanRelaxed) |
1574 | 0 | error(loc, "not allowed when using GLSL for Vulkan", op, ""); |
1575 | 24 | } |
1576 | | |
1577 | | // Call for any operation that requires Vulkan. |
1578 | | void TParseVersions::requireVulkan(const TSourceLoc& loc, const char* op) |
1579 | 0 | { |
1580 | 0 | if (spvVersion.vulkan == 0) |
1581 | 0 | error(loc, "only allowed when using GLSL for Vulkan", op, ""); |
1582 | 0 | } |
1583 | | |
1584 | | // Call for any operation that requires SPIR-V. |
1585 | | void TParseVersions::requireSpv(const TSourceLoc& loc, const char* op) |
1586 | 0 | { |
1587 | 0 | if (spvVersion.spv == 0) |
1588 | 0 | error(loc, "only allowed when generating SPIR-V", op, ""); |
1589 | 0 | } |
1590 | | void TParseVersions::requireSpv(const TSourceLoc& loc, const char *op, unsigned int version) |
1591 | 0 | { |
1592 | 0 | if (spvVersion.spv < version) |
1593 | 0 | error(loc, "not supported for current targeted SPIR-V version", op, ""); |
1594 | 0 | } |
1595 | | |
1596 | | } // end namespace glslang |