1b8e80941Smrg/*
2b8e80941Smrg * Copyright © 2010 Intel Corporation
3b8e80941Smrg *
4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
6b8e80941Smrg * to deal in the Software without restriction, including without limitation
7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
9b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
10b8e80941Smrg *
11b8e80941Smrg * The above copyright notice and this permission notice (including the next
12b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the
13b8e80941Smrg * Software.
14b8e80941Smrg *
15b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21b8e80941Smrg * DEALINGS IN THE SOFTWARE.
22b8e80941Smrg */
23b8e80941Smrg
24b8e80941Smrg#ifndef GLSL_PARSER_EXTRAS_H
25b8e80941Smrg#define GLSL_PARSER_EXTRAS_H
26b8e80941Smrg
27b8e80941Smrg/*
28b8e80941Smrg * Most of the definitions here only apply to C++
29b8e80941Smrg */
30b8e80941Smrg#ifdef __cplusplus
31b8e80941Smrg
32b8e80941Smrg
33b8e80941Smrg#include <stdlib.h>
34b8e80941Smrg#include "glsl_symbol_table.h"
35b8e80941Smrg
36b8e80941Smrg/* THIS is a macro defined somewhere deep in the Windows MSVC header files.
37b8e80941Smrg * Undefine it here to avoid collision with the lexer's THIS token.
38b8e80941Smrg */
39b8e80941Smrg#undef THIS
40b8e80941Smrg
41b8e80941Smrgstruct gl_context;
42b8e80941Smrg
43b8e80941Smrgstruct glsl_switch_state {
44b8e80941Smrg   /** Temporary variables needed for switch statement. */
45b8e80941Smrg   ir_variable *test_var;
46b8e80941Smrg   ir_variable *is_fallthru_var;
47b8e80941Smrg   class ast_switch_statement *switch_nesting_ast;
48b8e80941Smrg
49b8e80941Smrg   /** Used to detect if 'continue' was called inside a switch. */
50b8e80941Smrg   ir_variable *continue_inside;
51b8e80941Smrg
52b8e80941Smrg   /** Used to set condition if 'default' label should be chosen. */
53b8e80941Smrg   ir_variable *run_default;
54b8e80941Smrg
55b8e80941Smrg   /** Table of constant values already used in case labels */
56b8e80941Smrg   struct hash_table *labels_ht;
57b8e80941Smrg   class ast_case_label *previous_default;
58b8e80941Smrg
59b8e80941Smrg   bool is_switch_innermost; // if switch stmt is closest to break, ...
60b8e80941Smrg};
61b8e80941Smrg
62b8e80941Smrgconst char *
63b8e80941Smrgglsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version);
64b8e80941Smrg
65b8e80941Smrgtypedef struct YYLTYPE {
66b8e80941Smrg   int first_line;
67b8e80941Smrg   int first_column;
68b8e80941Smrg   int last_line;
69b8e80941Smrg   int last_column;
70b8e80941Smrg   unsigned source;
71b8e80941Smrg} YYLTYPE;
72b8e80941Smrg# define YYLTYPE_IS_DECLARED 1
73b8e80941Smrg# define YYLTYPE_IS_TRIVIAL 1
74b8e80941Smrg
75b8e80941Smrgextern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
76b8e80941Smrg                             const char *fmt, ...);
77b8e80941Smrg
78b8e80941Smrg
79b8e80941Smrgstruct _mesa_glsl_parse_state {
80b8e80941Smrg   _mesa_glsl_parse_state(struct gl_context *_ctx, gl_shader_stage stage,
81b8e80941Smrg                          void *mem_ctx);
82b8e80941Smrg
83b8e80941Smrg   DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);
84b8e80941Smrg
85b8e80941Smrg   /**
86b8e80941Smrg    * Generate a string representing the GLSL version currently being compiled
87b8e80941Smrg    * (useful for error messages).
88b8e80941Smrg    */
89b8e80941Smrg   const char *get_version_string()
90b8e80941Smrg   {
91b8e80941Smrg      return glsl_compute_version_string(this, this->es_shader,
92b8e80941Smrg                                         this->language_version);
93b8e80941Smrg   }
94b8e80941Smrg
95b8e80941Smrg   /**
96b8e80941Smrg    * Determine whether the current GLSL version is sufficiently high to
97b8e80941Smrg    * support a certain feature.
98b8e80941Smrg    *
99b8e80941Smrg    * \param required_glsl_version is the desktop GLSL version that is
100b8e80941Smrg    * required to support the feature, or 0 if no version of desktop GLSL
101b8e80941Smrg    * supports the feature.
102b8e80941Smrg    *
103b8e80941Smrg    * \param required_glsl_es_version is the GLSL ES version that is required
104b8e80941Smrg    * to support the feature, or 0 if no version of GLSL ES supports the
105b8e80941Smrg    * feature.
106b8e80941Smrg    */
107b8e80941Smrg   bool is_version(unsigned required_glsl_version,
108b8e80941Smrg                   unsigned required_glsl_es_version) const
109b8e80941Smrg   {
110b8e80941Smrg      unsigned required_version = this->es_shader ?
111b8e80941Smrg         required_glsl_es_version : required_glsl_version;
112b8e80941Smrg      unsigned this_version = this->forced_language_version
113b8e80941Smrg         ? this->forced_language_version : this->language_version;
114b8e80941Smrg      return required_version != 0
115b8e80941Smrg         && this_version >= required_version;
116b8e80941Smrg   }
117b8e80941Smrg
118b8e80941Smrg   bool check_version(unsigned required_glsl_version,
119b8e80941Smrg                      unsigned required_glsl_es_version,
120b8e80941Smrg                      YYLTYPE *locp, const char *fmt, ...) PRINTFLIKE(5, 6);
121b8e80941Smrg
122b8e80941Smrg   bool check_arrays_of_arrays_allowed(YYLTYPE *locp)
123b8e80941Smrg   {
124b8e80941Smrg      if (!(ARB_arrays_of_arrays_enable || is_version(430, 310))) {
125b8e80941Smrg         const char *const requirement = this->es_shader
126b8e80941Smrg            ? "GLSL ES 3.10"
127b8e80941Smrg            : "GL_ARB_arrays_of_arrays or GLSL 4.30";
128b8e80941Smrg         _mesa_glsl_error(locp, this,
129b8e80941Smrg                          "%s required for defining arrays of arrays.",
130b8e80941Smrg                          requirement);
131b8e80941Smrg         return false;
132b8e80941Smrg      }
133b8e80941Smrg      return true;
134b8e80941Smrg   }
135b8e80941Smrg
136b8e80941Smrg   bool check_precision_qualifiers_allowed(YYLTYPE *locp)
137b8e80941Smrg   {
138b8e80941Smrg      return check_version(130, 100, locp,
139b8e80941Smrg                           "precision qualifiers are forbidden");
140b8e80941Smrg   }
141b8e80941Smrg
142b8e80941Smrg   bool check_bitwise_operations_allowed(YYLTYPE *locp)
143b8e80941Smrg   {
144b8e80941Smrg      return EXT_gpu_shader4_enable ||
145b8e80941Smrg             check_version(130, 300, locp, "bit-wise operations are forbidden");
146b8e80941Smrg   }
147b8e80941Smrg
148b8e80941Smrg   bool check_explicit_attrib_stream_allowed(YYLTYPE *locp)
149b8e80941Smrg   {
150b8e80941Smrg      if (!this->has_explicit_attrib_stream()) {
151b8e80941Smrg         const char *const requirement = "GL_ARB_gpu_shader5 extension or GLSL 4.00";
152b8e80941Smrg
153b8e80941Smrg         _mesa_glsl_error(locp, this, "explicit stream requires %s",
154b8e80941Smrg                          requirement);
155b8e80941Smrg         return false;
156b8e80941Smrg      }
157b8e80941Smrg
158b8e80941Smrg      return true;
159b8e80941Smrg   }
160b8e80941Smrg
161b8e80941Smrg   bool check_explicit_attrib_location_allowed(YYLTYPE *locp,
162b8e80941Smrg                                               const ir_variable *var)
163b8e80941Smrg   {
164b8e80941Smrg      if (!this->has_explicit_attrib_location()) {
165b8e80941Smrg         const char *const requirement = this->es_shader
166b8e80941Smrg            ? "GLSL ES 3.00"
167b8e80941Smrg            : "GL_ARB_explicit_attrib_location extension or GLSL 3.30";
168b8e80941Smrg
169b8e80941Smrg         _mesa_glsl_error(locp, this, "%s explicit location requires %s",
170b8e80941Smrg                          mode_string(var), requirement);
171b8e80941Smrg         return false;
172b8e80941Smrg      }
173b8e80941Smrg
174b8e80941Smrg      return true;
175b8e80941Smrg   }
176b8e80941Smrg
177b8e80941Smrg   bool check_separate_shader_objects_allowed(YYLTYPE *locp,
178b8e80941Smrg                                              const ir_variable *var)
179b8e80941Smrg   {
180b8e80941Smrg      if (!this->has_separate_shader_objects()) {
181b8e80941Smrg         const char *const requirement = this->es_shader
182b8e80941Smrg            ? "GL_EXT_separate_shader_objects extension or GLSL ES 3.10"
183b8e80941Smrg            : "GL_ARB_separate_shader_objects extension or GLSL 4.20";
184b8e80941Smrg
185b8e80941Smrg         _mesa_glsl_error(locp, this, "%s explicit location requires %s",
186b8e80941Smrg                          mode_string(var), requirement);
187b8e80941Smrg         return false;
188b8e80941Smrg      }
189b8e80941Smrg
190b8e80941Smrg      return true;
191b8e80941Smrg   }
192b8e80941Smrg
193b8e80941Smrg   bool check_explicit_uniform_location_allowed(YYLTYPE *locp,
194b8e80941Smrg                                                const ir_variable *)
195b8e80941Smrg   {
196b8e80941Smrg      if (!this->has_explicit_attrib_location() ||
197b8e80941Smrg          !this->has_explicit_uniform_location()) {
198b8e80941Smrg         const char *const requirement = this->es_shader
199b8e80941Smrg            ? "GLSL ES 3.10"
200b8e80941Smrg            : "GL_ARB_explicit_uniform_location and either "
201b8e80941Smrg              "GL_ARB_explicit_attrib_location or GLSL 3.30.";
202b8e80941Smrg
203b8e80941Smrg         _mesa_glsl_error(locp, this,
204b8e80941Smrg                          "uniform explicit location requires %s",
205b8e80941Smrg                          requirement);
206b8e80941Smrg         return false;
207b8e80941Smrg      }
208b8e80941Smrg
209b8e80941Smrg      return true;
210b8e80941Smrg   }
211b8e80941Smrg
212b8e80941Smrg   bool has_atomic_counters() const
213b8e80941Smrg   {
214b8e80941Smrg      return ARB_shader_atomic_counters_enable || is_version(420, 310);
215b8e80941Smrg   }
216b8e80941Smrg
217b8e80941Smrg   bool has_enhanced_layouts() const
218b8e80941Smrg   {
219b8e80941Smrg      return ARB_enhanced_layouts_enable || is_version(440, 0);
220b8e80941Smrg   }
221b8e80941Smrg
222b8e80941Smrg   bool has_explicit_attrib_stream() const
223b8e80941Smrg   {
224b8e80941Smrg      return ARB_gpu_shader5_enable || is_version(400, 0);
225b8e80941Smrg   }
226b8e80941Smrg
227b8e80941Smrg   bool has_explicit_attrib_location() const
228b8e80941Smrg   {
229b8e80941Smrg      return ARB_explicit_attrib_location_enable || is_version(330, 300);
230b8e80941Smrg   }
231b8e80941Smrg
232b8e80941Smrg   bool has_explicit_uniform_location() const
233b8e80941Smrg   {
234b8e80941Smrg      return ARB_explicit_uniform_location_enable || is_version(430, 310);
235b8e80941Smrg   }
236b8e80941Smrg
237b8e80941Smrg   bool has_uniform_buffer_objects() const
238b8e80941Smrg   {
239b8e80941Smrg      return ARB_uniform_buffer_object_enable || is_version(140, 300);
240b8e80941Smrg   }
241b8e80941Smrg
242b8e80941Smrg   bool has_shader_storage_buffer_objects() const
243b8e80941Smrg   {
244b8e80941Smrg      return ARB_shader_storage_buffer_object_enable || is_version(430, 310);
245b8e80941Smrg   }
246b8e80941Smrg
247b8e80941Smrg   bool has_separate_shader_objects() const
248b8e80941Smrg   {
249b8e80941Smrg      return ARB_separate_shader_objects_enable || is_version(410, 310)
250b8e80941Smrg         || EXT_separate_shader_objects_enable;
251b8e80941Smrg   }
252b8e80941Smrg
253b8e80941Smrg   bool has_double() const
254b8e80941Smrg   {
255b8e80941Smrg      return ARB_gpu_shader_fp64_enable || is_version(400, 0);
256b8e80941Smrg   }
257b8e80941Smrg
258b8e80941Smrg   bool has_int64() const
259b8e80941Smrg   {
260b8e80941Smrg      return ARB_gpu_shader_int64_enable ||
261b8e80941Smrg             AMD_gpu_shader_int64_enable;
262b8e80941Smrg   }
263b8e80941Smrg
264b8e80941Smrg   bool has_420pack() const
265b8e80941Smrg   {
266b8e80941Smrg      return ARB_shading_language_420pack_enable || is_version(420, 0);
267b8e80941Smrg   }
268b8e80941Smrg
269b8e80941Smrg   bool has_420pack_or_es31() const
270b8e80941Smrg   {
271b8e80941Smrg      return ARB_shading_language_420pack_enable || is_version(420, 310);
272b8e80941Smrg   }
273b8e80941Smrg
274b8e80941Smrg   bool has_compute_shader() const
275b8e80941Smrg   {
276b8e80941Smrg      return ARB_compute_shader_enable || is_version(430, 310);
277b8e80941Smrg   }
278b8e80941Smrg
279b8e80941Smrg   bool has_shader_io_blocks() const
280b8e80941Smrg   {
281b8e80941Smrg      /* The OES_geometry_shader_specification says:
282b8e80941Smrg       *
283b8e80941Smrg       *    "If the OES_geometry_shader extension is enabled, the
284b8e80941Smrg       *     OES_shader_io_blocks extension is also implicitly enabled."
285b8e80941Smrg       *
286b8e80941Smrg       * The OES_tessellation_shader extension has similar wording.
287b8e80941Smrg       */
288b8e80941Smrg      return OES_shader_io_blocks_enable ||
289b8e80941Smrg             EXT_shader_io_blocks_enable ||
290b8e80941Smrg             OES_geometry_shader_enable ||
291b8e80941Smrg             EXT_geometry_shader_enable ||
292b8e80941Smrg             OES_tessellation_shader_enable ||
293b8e80941Smrg             EXT_tessellation_shader_enable ||
294b8e80941Smrg
295b8e80941Smrg             is_version(150, 320);
296b8e80941Smrg   }
297b8e80941Smrg
298b8e80941Smrg   bool has_geometry_shader() const
299b8e80941Smrg   {
300b8e80941Smrg      return OES_geometry_shader_enable || EXT_geometry_shader_enable ||
301b8e80941Smrg             is_version(150, 320);
302b8e80941Smrg   }
303b8e80941Smrg
304b8e80941Smrg   bool has_tessellation_shader() const
305b8e80941Smrg   {
306b8e80941Smrg      return ARB_tessellation_shader_enable ||
307b8e80941Smrg             OES_tessellation_shader_enable ||
308b8e80941Smrg             EXT_tessellation_shader_enable ||
309b8e80941Smrg             is_version(400, 320);
310b8e80941Smrg   }
311b8e80941Smrg
312b8e80941Smrg   bool has_clip_distance() const
313b8e80941Smrg   {
314b8e80941Smrg      return EXT_clip_cull_distance_enable || is_version(130, 0);
315b8e80941Smrg   }
316b8e80941Smrg
317b8e80941Smrg   bool has_cull_distance() const
318b8e80941Smrg   {
319b8e80941Smrg      return EXT_clip_cull_distance_enable ||
320b8e80941Smrg             ARB_cull_distance_enable ||
321b8e80941Smrg             is_version(450, 0);
322b8e80941Smrg   }
323b8e80941Smrg
324b8e80941Smrg   bool has_framebuffer_fetch() const
325b8e80941Smrg   {
326b8e80941Smrg      return EXT_shader_framebuffer_fetch_enable ||
327b8e80941Smrg             EXT_shader_framebuffer_fetch_non_coherent_enable;
328b8e80941Smrg   }
329b8e80941Smrg
330b8e80941Smrg   bool has_texture_cube_map_array() const
331b8e80941Smrg   {
332b8e80941Smrg      return ARB_texture_cube_map_array_enable ||
333b8e80941Smrg             EXT_texture_cube_map_array_enable ||
334b8e80941Smrg             OES_texture_cube_map_array_enable ||
335b8e80941Smrg             is_version(400, 320);
336b8e80941Smrg   }
337b8e80941Smrg
338b8e80941Smrg   bool has_shader_image_load_store() const
339b8e80941Smrg   {
340b8e80941Smrg      return ARB_shader_image_load_store_enable || is_version(420, 310);
341b8e80941Smrg   }
342b8e80941Smrg
343b8e80941Smrg   bool has_bindless() const
344b8e80941Smrg   {
345b8e80941Smrg      return ARB_bindless_texture_enable;
346b8e80941Smrg   }
347b8e80941Smrg
348b8e80941Smrg   bool has_image_load_formatted() const
349b8e80941Smrg   {
350b8e80941Smrg      return EXT_shader_image_load_formatted_enable;
351b8e80941Smrg   }
352b8e80941Smrg
353b8e80941Smrg   bool has_implicit_conversions() const
354b8e80941Smrg   {
355b8e80941Smrg      return EXT_shader_implicit_conversions_enable || is_version(120, 0);
356b8e80941Smrg   }
357b8e80941Smrg
358b8e80941Smrg   bool has_implicit_uint_to_int_conversion() const
359b8e80941Smrg   {
360b8e80941Smrg      return ARB_gpu_shader5_enable ||
361b8e80941Smrg             MESA_shader_integer_functions_enable ||
362b8e80941Smrg             EXT_shader_implicit_conversions_enable ||
363b8e80941Smrg             is_version(400, 0);
364b8e80941Smrg   }
365b8e80941Smrg
366b8e80941Smrg   void process_version_directive(YYLTYPE *locp, int version,
367b8e80941Smrg                                  const char *ident);
368b8e80941Smrg
369b8e80941Smrg   struct gl_context *const ctx;
370b8e80941Smrg   void *scanner;
371b8e80941Smrg   exec_list translation_unit;
372b8e80941Smrg   glsl_symbol_table *symbols;
373b8e80941Smrg
374b8e80941Smrg   void *linalloc;
375b8e80941Smrg
376b8e80941Smrg   unsigned num_supported_versions;
377b8e80941Smrg   struct {
378b8e80941Smrg      unsigned ver;
379b8e80941Smrg      uint8_t gl_ver;
380b8e80941Smrg      bool es;
381b8e80941Smrg   } supported_versions[17];
382b8e80941Smrg
383b8e80941Smrg   bool es_shader;
384b8e80941Smrg   bool compat_shader;
385b8e80941Smrg   unsigned language_version;
386b8e80941Smrg   unsigned forced_language_version;
387b8e80941Smrg   bool zero_init;
388b8e80941Smrg   unsigned gl_version;
389b8e80941Smrg   gl_shader_stage stage;
390b8e80941Smrg
391b8e80941Smrg   /**
392b8e80941Smrg    * Default uniform layout qualifiers tracked during parsing.
393b8e80941Smrg    * Currently affects uniform blocks and uniform buffer variables in
394b8e80941Smrg    * those blocks.
395b8e80941Smrg    */
396b8e80941Smrg   struct ast_type_qualifier *default_uniform_qualifier;
397b8e80941Smrg
398b8e80941Smrg   /**
399b8e80941Smrg    * Default shader storage layout qualifiers tracked during parsing.
400b8e80941Smrg    * Currently affects shader storage blocks and shader storage buffer
401b8e80941Smrg    * variables in those blocks.
402b8e80941Smrg    */
403b8e80941Smrg   struct ast_type_qualifier *default_shader_storage_qualifier;
404b8e80941Smrg
405b8e80941Smrg   /**
406b8e80941Smrg    * Variables to track different cases if a fragment shader redeclares
407b8e80941Smrg    * built-in variable gl_FragCoord.
408b8e80941Smrg    *
409b8e80941Smrg    * Note: These values are computed at ast_to_hir time rather than at parse
410b8e80941Smrg    * time.
411b8e80941Smrg    */
412b8e80941Smrg   bool fs_redeclares_gl_fragcoord;
413b8e80941Smrg   bool fs_origin_upper_left;
414b8e80941Smrg   bool fs_pixel_center_integer;
415b8e80941Smrg   bool fs_redeclares_gl_fragcoord_with_no_layout_qualifiers;
416b8e80941Smrg
417b8e80941Smrg   /**
418b8e80941Smrg    * True if a geometry shader input primitive type or tessellation control
419b8e80941Smrg    * output vertices were specified using a layout directive.
420b8e80941Smrg    *
421b8e80941Smrg    * Note: these values are computed at ast_to_hir time rather than at parse
422b8e80941Smrg    * time.
423b8e80941Smrg    */
424b8e80941Smrg   bool gs_input_prim_type_specified;
425b8e80941Smrg   bool tcs_output_vertices_specified;
426b8e80941Smrg
427b8e80941Smrg   /**
428b8e80941Smrg    * Input layout qualifiers from GLSL 1.50 (geometry shader controls),
429b8e80941Smrg    * and GLSL 4.00 (tessellation evaluation shader)
430b8e80941Smrg    */
431b8e80941Smrg   struct ast_type_qualifier *in_qualifier;
432b8e80941Smrg
433b8e80941Smrg   /**
434b8e80941Smrg    * True if a compute shader input local size was specified using a layout
435b8e80941Smrg    * directive.
436b8e80941Smrg    *
437b8e80941Smrg    * Note: this value is computed at ast_to_hir time rather than at parse
438b8e80941Smrg    * time.
439b8e80941Smrg    */
440b8e80941Smrg   bool cs_input_local_size_specified;
441b8e80941Smrg
442b8e80941Smrg   /**
443b8e80941Smrg    * If cs_input_local_size_specified is true, the local size that was
444b8e80941Smrg    * specified.  Otherwise ignored.
445b8e80941Smrg    */
446b8e80941Smrg   unsigned cs_input_local_size[3];
447b8e80941Smrg
448b8e80941Smrg   /**
449b8e80941Smrg    * True if a compute shader input local variable size was specified using
450b8e80941Smrg    * a layout directive as specified by ARB_compute_variable_group_size.
451b8e80941Smrg    */
452b8e80941Smrg   bool cs_input_local_size_variable_specified;
453b8e80941Smrg
454b8e80941Smrg   /**
455b8e80941Smrg    * Arrangement of invocations used to calculate derivatives in a compute
456b8e80941Smrg    * shader.  From NV_compute_shader_derivatives.
457b8e80941Smrg    */
458b8e80941Smrg   enum gl_derivative_group cs_derivative_group;
459b8e80941Smrg
460b8e80941Smrg   /**
461b8e80941Smrg    * True if a shader declare bindless_sampler/bindless_image, and
462b8e80941Smrg    * respectively bound_sampler/bound_image at global scope as specified by
463b8e80941Smrg    * ARB_bindless_texture.
464b8e80941Smrg    */
465b8e80941Smrg   bool bindless_sampler_specified;
466b8e80941Smrg   bool bindless_image_specified;
467b8e80941Smrg   bool bound_sampler_specified;
468b8e80941Smrg   bool bound_image_specified;
469b8e80941Smrg
470b8e80941Smrg   /**
471b8e80941Smrg    * Output layout qualifiers from GLSL 1.50 (geometry shader controls),
472b8e80941Smrg    * and GLSL 4.00 (tessellation control shader).
473b8e80941Smrg    */
474b8e80941Smrg   struct ast_type_qualifier *out_qualifier;
475b8e80941Smrg
476b8e80941Smrg   /**
477b8e80941Smrg    * Printable list of GLSL versions supported by the current context
478b8e80941Smrg    *
479b8e80941Smrg    * \note
480b8e80941Smrg    * This string should probably be generated per-context instead of per
481b8e80941Smrg    * invokation of the compiler.  This should be changed when the method of
482b8e80941Smrg    * tracking supported GLSL versions changes.
483b8e80941Smrg    */
484b8e80941Smrg   const char *supported_version_string;
485b8e80941Smrg
486b8e80941Smrg   /**
487b8e80941Smrg    * Implementation defined limits that affect built-in variables, etc.
488b8e80941Smrg    *
489b8e80941Smrg    * \sa struct gl_constants (in mtypes.h)
490b8e80941Smrg    */
491b8e80941Smrg   struct {
492b8e80941Smrg      /* 1.10 */
493b8e80941Smrg      unsigned MaxLights;
494b8e80941Smrg      unsigned MaxClipPlanes;
495b8e80941Smrg      unsigned MaxTextureUnits;
496b8e80941Smrg      unsigned MaxTextureCoords;
497b8e80941Smrg      unsigned MaxVertexAttribs;
498b8e80941Smrg      unsigned MaxVertexUniformComponents;
499b8e80941Smrg      unsigned MaxVertexTextureImageUnits;
500b8e80941Smrg      unsigned MaxCombinedTextureImageUnits;
501b8e80941Smrg      unsigned MaxTextureImageUnits;
502b8e80941Smrg      unsigned MaxFragmentUniformComponents;
503b8e80941Smrg
504b8e80941Smrg      /* ARB_draw_buffers */
505b8e80941Smrg      unsigned MaxDrawBuffers;
506b8e80941Smrg
507b8e80941Smrg      /* ARB_enhanced_layouts */
508b8e80941Smrg      unsigned MaxTransformFeedbackBuffers;
509b8e80941Smrg      unsigned MaxTransformFeedbackInterleavedComponents;
510b8e80941Smrg
511b8e80941Smrg      /* ARB_blend_func_extended */
512b8e80941Smrg      unsigned MaxDualSourceDrawBuffers;
513b8e80941Smrg
514b8e80941Smrg      /* 3.00 ES */
515b8e80941Smrg      int MinProgramTexelOffset;
516b8e80941Smrg      int MaxProgramTexelOffset;
517b8e80941Smrg
518b8e80941Smrg      /* 1.50 */
519b8e80941Smrg      unsigned MaxVertexOutputComponents;
520b8e80941Smrg      unsigned MaxGeometryInputComponents;
521b8e80941Smrg      unsigned MaxGeometryOutputComponents;
522b8e80941Smrg      unsigned MaxGeometryShaderInvocations;
523b8e80941Smrg      unsigned MaxFragmentInputComponents;
524b8e80941Smrg      unsigned MaxGeometryTextureImageUnits;
525b8e80941Smrg      unsigned MaxGeometryOutputVertices;
526b8e80941Smrg      unsigned MaxGeometryTotalOutputComponents;
527b8e80941Smrg      unsigned MaxGeometryUniformComponents;
528b8e80941Smrg
529b8e80941Smrg      /* ARB_shader_atomic_counters */
530b8e80941Smrg      unsigned MaxVertexAtomicCounters;
531b8e80941Smrg      unsigned MaxTessControlAtomicCounters;
532b8e80941Smrg      unsigned MaxTessEvaluationAtomicCounters;
533b8e80941Smrg      unsigned MaxGeometryAtomicCounters;
534b8e80941Smrg      unsigned MaxFragmentAtomicCounters;
535b8e80941Smrg      unsigned MaxCombinedAtomicCounters;
536b8e80941Smrg      unsigned MaxAtomicBufferBindings;
537b8e80941Smrg
538b8e80941Smrg      /* These are also atomic counter related, but they weren't added to
539b8e80941Smrg       * until atomic counters were added to core in GLSL 4.20 and GLSL ES
540b8e80941Smrg       * 3.10.
541b8e80941Smrg       */
542b8e80941Smrg      unsigned MaxVertexAtomicCounterBuffers;
543b8e80941Smrg      unsigned MaxTessControlAtomicCounterBuffers;
544b8e80941Smrg      unsigned MaxTessEvaluationAtomicCounterBuffers;
545b8e80941Smrg      unsigned MaxGeometryAtomicCounterBuffers;
546b8e80941Smrg      unsigned MaxFragmentAtomicCounterBuffers;
547b8e80941Smrg      unsigned MaxCombinedAtomicCounterBuffers;
548b8e80941Smrg      unsigned MaxAtomicCounterBufferSize;
549b8e80941Smrg
550b8e80941Smrg      /* ARB_compute_shader */
551b8e80941Smrg      unsigned MaxComputeAtomicCounterBuffers;
552b8e80941Smrg      unsigned MaxComputeAtomicCounters;
553b8e80941Smrg      unsigned MaxComputeImageUniforms;
554b8e80941Smrg      unsigned MaxComputeTextureImageUnits;
555b8e80941Smrg      unsigned MaxComputeUniformComponents;
556b8e80941Smrg      unsigned MaxComputeWorkGroupCount[3];
557b8e80941Smrg      unsigned MaxComputeWorkGroupSize[3];
558b8e80941Smrg
559b8e80941Smrg      /* ARB_shader_image_load_store */
560b8e80941Smrg      unsigned MaxImageUnits;
561b8e80941Smrg      unsigned MaxCombinedShaderOutputResources;
562b8e80941Smrg      unsigned MaxImageSamples;
563b8e80941Smrg      unsigned MaxVertexImageUniforms;
564b8e80941Smrg      unsigned MaxTessControlImageUniforms;
565b8e80941Smrg      unsigned MaxTessEvaluationImageUniforms;
566b8e80941Smrg      unsigned MaxGeometryImageUniforms;
567b8e80941Smrg      unsigned MaxFragmentImageUniforms;
568b8e80941Smrg      unsigned MaxCombinedImageUniforms;
569b8e80941Smrg
570b8e80941Smrg      /* ARB_viewport_array */
571b8e80941Smrg      unsigned MaxViewports;
572b8e80941Smrg
573b8e80941Smrg      /* ARB_tessellation_shader */
574b8e80941Smrg      unsigned MaxPatchVertices;
575b8e80941Smrg      unsigned MaxTessGenLevel;
576b8e80941Smrg      unsigned MaxTessControlInputComponents;
577b8e80941Smrg      unsigned MaxTessControlOutputComponents;
578b8e80941Smrg      unsigned MaxTessControlTextureImageUnits;
579b8e80941Smrg      unsigned MaxTessEvaluationInputComponents;
580b8e80941Smrg      unsigned MaxTessEvaluationOutputComponents;
581b8e80941Smrg      unsigned MaxTessEvaluationTextureImageUnits;
582b8e80941Smrg      unsigned MaxTessPatchComponents;
583b8e80941Smrg      unsigned MaxTessControlTotalOutputComponents;
584b8e80941Smrg      unsigned MaxTessControlUniformComponents;
585b8e80941Smrg      unsigned MaxTessEvaluationUniformComponents;
586b8e80941Smrg
587b8e80941Smrg      /* GL 4.5 / OES_sample_variables */
588b8e80941Smrg      unsigned MaxSamples;
589b8e80941Smrg   } Const;
590b8e80941Smrg
591b8e80941Smrg   /**
592b8e80941Smrg    * During AST to IR conversion, pointer to current IR function
593b8e80941Smrg    *
594b8e80941Smrg    * Will be \c NULL whenever the AST to IR conversion is not inside a
595b8e80941Smrg    * function definition.
596b8e80941Smrg    */
597b8e80941Smrg   class ir_function_signature *current_function;
598b8e80941Smrg
599b8e80941Smrg   /**
600b8e80941Smrg    * During AST to IR conversion, pointer to the toplevel IR
601b8e80941Smrg    * instruction list being generated.
602b8e80941Smrg    */
603b8e80941Smrg   exec_list *toplevel_ir;
604b8e80941Smrg
605b8e80941Smrg   /** Have we found a return statement in this function? */
606b8e80941Smrg   bool found_return;
607b8e80941Smrg
608b8e80941Smrg   /** Was there an error during compilation? */
609b8e80941Smrg   bool error;
610b8e80941Smrg
611b8e80941Smrg   /**
612b8e80941Smrg    * Are all shader inputs / outputs invariant?
613b8e80941Smrg    *
614b8e80941Smrg    * This is set when the 'STDGL invariant(all)' pragma is used.
615b8e80941Smrg    */
616b8e80941Smrg   bool all_invariant;
617b8e80941Smrg
618b8e80941Smrg   /** Loop or switch statement containing the current instructions. */
619b8e80941Smrg   class ast_iteration_statement *loop_nesting_ast;
620b8e80941Smrg
621b8e80941Smrg   struct glsl_switch_state switch_state;
622b8e80941Smrg
623b8e80941Smrg   /** List of structures defined in user code. */
624b8e80941Smrg   const glsl_type **user_structures;
625b8e80941Smrg   unsigned num_user_structures;
626b8e80941Smrg
627b8e80941Smrg   char *info_log;
628b8e80941Smrg
629b8e80941Smrg   /**
630b8e80941Smrg    * Are warnings enabled?
631b8e80941Smrg    *
632b8e80941Smrg    * Emission of warngins is controlled by '#pragma warning(...)'.
633b8e80941Smrg    */
634b8e80941Smrg   bool warnings_enabled;
635b8e80941Smrg
636b8e80941Smrg   /**
637b8e80941Smrg    * \name Enable bits for GLSL extensions
638b8e80941Smrg    */
639b8e80941Smrg   /*@{*/
640b8e80941Smrg   /* ARB extensions go here, sorted alphabetically.
641b8e80941Smrg    */
642b8e80941Smrg   bool ARB_ES3_1_compatibility_enable;
643b8e80941Smrg   bool ARB_ES3_1_compatibility_warn;
644b8e80941Smrg   bool ARB_ES3_2_compatibility_enable;
645b8e80941Smrg   bool ARB_ES3_2_compatibility_warn;
646b8e80941Smrg   bool ARB_arrays_of_arrays_enable;
647b8e80941Smrg   bool ARB_arrays_of_arrays_warn;
648b8e80941Smrg   bool ARB_bindless_texture_enable;
649b8e80941Smrg   bool ARB_bindless_texture_warn;
650b8e80941Smrg   bool ARB_compatibility_enable;
651b8e80941Smrg   bool ARB_compatibility_warn;
652b8e80941Smrg   bool ARB_compute_shader_enable;
653b8e80941Smrg   bool ARB_compute_shader_warn;
654b8e80941Smrg   bool ARB_compute_variable_group_size_enable;
655b8e80941Smrg   bool ARB_compute_variable_group_size_warn;
656b8e80941Smrg   bool ARB_conservative_depth_enable;
657b8e80941Smrg   bool ARB_conservative_depth_warn;
658b8e80941Smrg   bool ARB_cull_distance_enable;
659b8e80941Smrg   bool ARB_cull_distance_warn;
660b8e80941Smrg   bool ARB_derivative_control_enable;
661b8e80941Smrg   bool ARB_derivative_control_warn;
662b8e80941Smrg   bool ARB_draw_buffers_enable;
663b8e80941Smrg   bool ARB_draw_buffers_warn;
664b8e80941Smrg   bool ARB_draw_instanced_enable;
665b8e80941Smrg   bool ARB_draw_instanced_warn;
666b8e80941Smrg   bool ARB_enhanced_layouts_enable;
667b8e80941Smrg   bool ARB_enhanced_layouts_warn;
668b8e80941Smrg   bool ARB_explicit_attrib_location_enable;
669b8e80941Smrg   bool ARB_explicit_attrib_location_warn;
670b8e80941Smrg   bool ARB_explicit_uniform_location_enable;
671b8e80941Smrg   bool ARB_explicit_uniform_location_warn;
672b8e80941Smrg   bool ARB_fragment_coord_conventions_enable;
673b8e80941Smrg   bool ARB_fragment_coord_conventions_warn;
674b8e80941Smrg   bool ARB_fragment_layer_viewport_enable;
675b8e80941Smrg   bool ARB_fragment_layer_viewport_warn;
676b8e80941Smrg   bool ARB_fragment_shader_interlock_enable;
677b8e80941Smrg   bool ARB_fragment_shader_interlock_warn;
678b8e80941Smrg   bool ARB_gpu_shader5_enable;
679b8e80941Smrg   bool ARB_gpu_shader5_warn;
680b8e80941Smrg   bool ARB_gpu_shader_fp64_enable;
681b8e80941Smrg   bool ARB_gpu_shader_fp64_warn;
682b8e80941Smrg   bool ARB_gpu_shader_int64_enable;
683b8e80941Smrg   bool ARB_gpu_shader_int64_warn;
684b8e80941Smrg   bool ARB_post_depth_coverage_enable;
685b8e80941Smrg   bool ARB_post_depth_coverage_warn;
686b8e80941Smrg   bool ARB_sample_shading_enable;
687b8e80941Smrg   bool ARB_sample_shading_warn;
688b8e80941Smrg   bool ARB_separate_shader_objects_enable;
689b8e80941Smrg   bool ARB_separate_shader_objects_warn;
690b8e80941Smrg   bool ARB_shader_atomic_counter_ops_enable;
691b8e80941Smrg   bool ARB_shader_atomic_counter_ops_warn;
692b8e80941Smrg   bool ARB_shader_atomic_counters_enable;
693b8e80941Smrg   bool ARB_shader_atomic_counters_warn;
694b8e80941Smrg   bool ARB_shader_ballot_enable;
695b8e80941Smrg   bool ARB_shader_ballot_warn;
696b8e80941Smrg   bool ARB_shader_bit_encoding_enable;
697b8e80941Smrg   bool ARB_shader_bit_encoding_warn;
698b8e80941Smrg   bool ARB_shader_clock_enable;
699b8e80941Smrg   bool ARB_shader_clock_warn;
700b8e80941Smrg   bool ARB_shader_draw_parameters_enable;
701b8e80941Smrg   bool ARB_shader_draw_parameters_warn;
702b8e80941Smrg   bool ARB_shader_group_vote_enable;
703b8e80941Smrg   bool ARB_shader_group_vote_warn;
704b8e80941Smrg   bool ARB_shader_image_load_store_enable;
705b8e80941Smrg   bool ARB_shader_image_load_store_warn;
706b8e80941Smrg   bool ARB_shader_image_size_enable;
707b8e80941Smrg   bool ARB_shader_image_size_warn;
708b8e80941Smrg   bool ARB_shader_precision_enable;
709b8e80941Smrg   bool ARB_shader_precision_warn;
710b8e80941Smrg   bool ARB_shader_stencil_export_enable;
711b8e80941Smrg   bool ARB_shader_stencil_export_warn;
712b8e80941Smrg   bool ARB_shader_storage_buffer_object_enable;
713b8e80941Smrg   bool ARB_shader_storage_buffer_object_warn;
714b8e80941Smrg   bool ARB_shader_subroutine_enable;
715b8e80941Smrg   bool ARB_shader_subroutine_warn;
716b8e80941Smrg   bool ARB_shader_texture_image_samples_enable;
717b8e80941Smrg   bool ARB_shader_texture_image_samples_warn;
718b8e80941Smrg   bool ARB_shader_texture_lod_enable;
719b8e80941Smrg   bool ARB_shader_texture_lod_warn;
720b8e80941Smrg   bool ARB_shader_viewport_layer_array_enable;
721b8e80941Smrg   bool ARB_shader_viewport_layer_array_warn;
722b8e80941Smrg   bool ARB_shading_language_420pack_enable;
723b8e80941Smrg   bool ARB_shading_language_420pack_warn;
724b8e80941Smrg   bool ARB_shading_language_packing_enable;
725b8e80941Smrg   bool ARB_shading_language_packing_warn;
726b8e80941Smrg   bool ARB_tessellation_shader_enable;
727b8e80941Smrg   bool ARB_tessellation_shader_warn;
728b8e80941Smrg   bool ARB_texture_cube_map_array_enable;
729b8e80941Smrg   bool ARB_texture_cube_map_array_warn;
730b8e80941Smrg   bool ARB_texture_gather_enable;
731b8e80941Smrg   bool ARB_texture_gather_warn;
732b8e80941Smrg   bool ARB_texture_multisample_enable;
733b8e80941Smrg   bool ARB_texture_multisample_warn;
734b8e80941Smrg   bool ARB_texture_query_levels_enable;
735b8e80941Smrg   bool ARB_texture_query_levels_warn;
736b8e80941Smrg   bool ARB_texture_query_lod_enable;
737b8e80941Smrg   bool ARB_texture_query_lod_warn;
738b8e80941Smrg   bool ARB_texture_rectangle_enable;
739b8e80941Smrg   bool ARB_texture_rectangle_warn;
740b8e80941Smrg   bool ARB_uniform_buffer_object_enable;
741b8e80941Smrg   bool ARB_uniform_buffer_object_warn;
742b8e80941Smrg   bool ARB_vertex_attrib_64bit_enable;
743b8e80941Smrg   bool ARB_vertex_attrib_64bit_warn;
744b8e80941Smrg   bool ARB_viewport_array_enable;
745b8e80941Smrg   bool ARB_viewport_array_warn;
746b8e80941Smrg
747b8e80941Smrg   /* KHR extensions go here, sorted alphabetically.
748b8e80941Smrg    */
749b8e80941Smrg   bool KHR_blend_equation_advanced_enable;
750b8e80941Smrg   bool KHR_blend_equation_advanced_warn;
751b8e80941Smrg
752b8e80941Smrg   /* OES extensions go here, sorted alphabetically.
753b8e80941Smrg    */
754b8e80941Smrg   bool OES_EGL_image_external_enable;
755b8e80941Smrg   bool OES_EGL_image_external_warn;
756b8e80941Smrg   bool OES_EGL_image_external_essl3_enable;
757b8e80941Smrg   bool OES_EGL_image_external_essl3_warn;
758b8e80941Smrg   bool OES_geometry_point_size_enable;
759b8e80941Smrg   bool OES_geometry_point_size_warn;
760b8e80941Smrg   bool OES_geometry_shader_enable;
761b8e80941Smrg   bool OES_geometry_shader_warn;
762b8e80941Smrg   bool OES_gpu_shader5_enable;
763b8e80941Smrg   bool OES_gpu_shader5_warn;
764b8e80941Smrg   bool OES_primitive_bounding_box_enable;
765b8e80941Smrg   bool OES_primitive_bounding_box_warn;
766b8e80941Smrg   bool OES_sample_variables_enable;
767b8e80941Smrg   bool OES_sample_variables_warn;
768b8e80941Smrg   bool OES_shader_image_atomic_enable;
769b8e80941Smrg   bool OES_shader_image_atomic_warn;
770b8e80941Smrg   bool OES_shader_io_blocks_enable;
771b8e80941Smrg   bool OES_shader_io_blocks_warn;
772b8e80941Smrg   bool OES_shader_multisample_interpolation_enable;
773b8e80941Smrg   bool OES_shader_multisample_interpolation_warn;
774b8e80941Smrg   bool OES_standard_derivatives_enable;
775b8e80941Smrg   bool OES_standard_derivatives_warn;
776b8e80941Smrg   bool OES_tessellation_point_size_enable;
777b8e80941Smrg   bool OES_tessellation_point_size_warn;
778b8e80941Smrg   bool OES_tessellation_shader_enable;
779b8e80941Smrg   bool OES_tessellation_shader_warn;
780b8e80941Smrg   bool OES_texture_3D_enable;
781b8e80941Smrg   bool OES_texture_3D_warn;
782b8e80941Smrg   bool OES_texture_buffer_enable;
783b8e80941Smrg   bool OES_texture_buffer_warn;
784b8e80941Smrg   bool OES_texture_cube_map_array_enable;
785b8e80941Smrg   bool OES_texture_cube_map_array_warn;
786b8e80941Smrg   bool OES_texture_storage_multisample_2d_array_enable;
787b8e80941Smrg   bool OES_texture_storage_multisample_2d_array_warn;
788b8e80941Smrg   bool OES_viewport_array_enable;
789b8e80941Smrg   bool OES_viewport_array_warn;
790b8e80941Smrg
791b8e80941Smrg   /* All other extensions go here, sorted alphabetically.
792b8e80941Smrg    */
793b8e80941Smrg   bool AMD_conservative_depth_enable;
794b8e80941Smrg   bool AMD_conservative_depth_warn;
795b8e80941Smrg   bool AMD_gpu_shader_int64_enable;
796b8e80941Smrg   bool AMD_gpu_shader_int64_warn;
797b8e80941Smrg   bool AMD_shader_stencil_export_enable;
798b8e80941Smrg   bool AMD_shader_stencil_export_warn;
799b8e80941Smrg   bool AMD_shader_trinary_minmax_enable;
800b8e80941Smrg   bool AMD_shader_trinary_minmax_warn;
801b8e80941Smrg   bool AMD_texture_texture4_enable;
802b8e80941Smrg   bool AMD_texture_texture4_warn;
803b8e80941Smrg   bool AMD_vertex_shader_layer_enable;
804b8e80941Smrg   bool AMD_vertex_shader_layer_warn;
805b8e80941Smrg   bool AMD_vertex_shader_viewport_index_enable;
806b8e80941Smrg   bool AMD_vertex_shader_viewport_index_warn;
807b8e80941Smrg   bool ANDROID_extension_pack_es31a_enable;
808b8e80941Smrg   bool ANDROID_extension_pack_es31a_warn;
809b8e80941Smrg   bool EXT_blend_func_extended_enable;
810b8e80941Smrg   bool EXT_blend_func_extended_warn;
811b8e80941Smrg   bool EXT_clip_cull_distance_enable;
812b8e80941Smrg   bool EXT_clip_cull_distance_warn;
813b8e80941Smrg   bool EXT_draw_buffers_enable;
814b8e80941Smrg   bool EXT_draw_buffers_warn;
815b8e80941Smrg   bool EXT_frag_depth_enable;
816b8e80941Smrg   bool EXT_frag_depth_warn;
817b8e80941Smrg   bool EXT_geometry_point_size_enable;
818b8e80941Smrg   bool EXT_geometry_point_size_warn;
819b8e80941Smrg   bool EXT_geometry_shader_enable;
820b8e80941Smrg   bool EXT_geometry_shader_warn;
821b8e80941Smrg   bool EXT_gpu_shader4_enable;
822b8e80941Smrg   bool EXT_gpu_shader4_warn;
823b8e80941Smrg   bool EXT_gpu_shader5_enable;
824b8e80941Smrg   bool EXT_gpu_shader5_warn;
825b8e80941Smrg   bool EXT_primitive_bounding_box_enable;
826b8e80941Smrg   bool EXT_primitive_bounding_box_warn;
827b8e80941Smrg   bool EXT_separate_shader_objects_enable;
828b8e80941Smrg   bool EXT_separate_shader_objects_warn;
829b8e80941Smrg   bool EXT_shader_framebuffer_fetch_enable;
830b8e80941Smrg   bool EXT_shader_framebuffer_fetch_warn;
831b8e80941Smrg   bool EXT_shader_framebuffer_fetch_non_coherent_enable;
832b8e80941Smrg   bool EXT_shader_framebuffer_fetch_non_coherent_warn;
833b8e80941Smrg   bool EXT_shader_image_load_formatted_enable;
834b8e80941Smrg   bool EXT_shader_image_load_formatted_warn;
835b8e80941Smrg   bool EXT_shader_implicit_conversions_enable;
836b8e80941Smrg   bool EXT_shader_implicit_conversions_warn;
837b8e80941Smrg   bool EXT_shader_integer_mix_enable;
838b8e80941Smrg   bool EXT_shader_integer_mix_warn;
839b8e80941Smrg   bool EXT_shader_io_blocks_enable;
840b8e80941Smrg   bool EXT_shader_io_blocks_warn;
841b8e80941Smrg   bool EXT_shader_samples_identical_enable;
842b8e80941Smrg   bool EXT_shader_samples_identical_warn;
843b8e80941Smrg   bool EXT_tessellation_point_size_enable;
844b8e80941Smrg   bool EXT_tessellation_point_size_warn;
845b8e80941Smrg   bool EXT_tessellation_shader_enable;
846b8e80941Smrg   bool EXT_tessellation_shader_warn;
847b8e80941Smrg   bool EXT_texture_array_enable;
848b8e80941Smrg   bool EXT_texture_array_warn;
849b8e80941Smrg   bool EXT_texture_buffer_enable;
850b8e80941Smrg   bool EXT_texture_buffer_warn;
851b8e80941Smrg   bool EXT_texture_cube_map_array_enable;
852b8e80941Smrg   bool EXT_texture_cube_map_array_warn;
853b8e80941Smrg   bool EXT_texture_query_lod_enable;
854b8e80941Smrg   bool EXT_texture_query_lod_warn;
855b8e80941Smrg   bool INTEL_conservative_rasterization_enable;
856b8e80941Smrg   bool INTEL_conservative_rasterization_warn;
857b8e80941Smrg   bool INTEL_shader_atomic_float_minmax_enable;
858b8e80941Smrg   bool INTEL_shader_atomic_float_minmax_warn;
859b8e80941Smrg   bool MESA_shader_integer_functions_enable;
860b8e80941Smrg   bool MESA_shader_integer_functions_warn;
861b8e80941Smrg   bool NV_compute_shader_derivatives_enable;
862b8e80941Smrg   bool NV_compute_shader_derivatives_warn;
863b8e80941Smrg   bool NV_fragment_shader_interlock_enable;
864b8e80941Smrg   bool NV_fragment_shader_interlock_warn;
865b8e80941Smrg   bool NV_image_formats_enable;
866b8e80941Smrg   bool NV_image_formats_warn;
867b8e80941Smrg   bool NV_shader_atomic_float_enable;
868b8e80941Smrg   bool NV_shader_atomic_float_warn;
869b8e80941Smrg   /*@}*/
870b8e80941Smrg
871b8e80941Smrg   /** Extensions supported by the OpenGL implementation. */
872b8e80941Smrg   const struct gl_extensions *extensions;
873b8e80941Smrg
874b8e80941Smrg   bool uses_builtin_functions;
875b8e80941Smrg   bool fs_uses_gl_fragcoord;
876b8e80941Smrg
877b8e80941Smrg   /**
878b8e80941Smrg    * For geometry shaders, size of the most recently seen input declaration
879b8e80941Smrg    * that was a sized array, or 0 if no sized input array declarations have
880b8e80941Smrg    * been seen.
881b8e80941Smrg    *
882b8e80941Smrg    * Unused for other shader types.
883b8e80941Smrg    */
884b8e80941Smrg   unsigned gs_input_size;
885b8e80941Smrg
886b8e80941Smrg   bool fs_early_fragment_tests;
887b8e80941Smrg
888b8e80941Smrg   bool fs_inner_coverage;
889b8e80941Smrg
890b8e80941Smrg   bool fs_post_depth_coverage;
891b8e80941Smrg
892b8e80941Smrg   bool fs_pixel_interlock_ordered;
893b8e80941Smrg   bool fs_pixel_interlock_unordered;
894b8e80941Smrg   bool fs_sample_interlock_ordered;
895b8e80941Smrg   bool fs_sample_interlock_unordered;
896b8e80941Smrg
897b8e80941Smrg   unsigned fs_blend_support;
898b8e80941Smrg
899b8e80941Smrg   /**
900b8e80941Smrg    * For tessellation control shaders, size of the most recently seen output
901b8e80941Smrg    * declaration that was a sized array, or 0 if no sized output array
902b8e80941Smrg    * declarations have been seen.
903b8e80941Smrg    *
904b8e80941Smrg    * Unused for other shader types.
905b8e80941Smrg    */
906b8e80941Smrg   unsigned tcs_output_size;
907b8e80941Smrg
908b8e80941Smrg   /** Atomic counter offsets by binding */
909b8e80941Smrg   unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
910b8e80941Smrg
911b8e80941Smrg   bool allow_extension_directive_midshader;
912b8e80941Smrg   bool allow_builtin_variable_redeclaration;
913b8e80941Smrg   bool allow_layout_qualifier_on_function_parameter;
914b8e80941Smrg
915b8e80941Smrg   /**
916b8e80941Smrg    * Known subroutine type declarations.
917b8e80941Smrg    */
918b8e80941Smrg   int num_subroutine_types;
919b8e80941Smrg   ir_function **subroutine_types;
920b8e80941Smrg
921b8e80941Smrg   /**
922b8e80941Smrg    * Functions that are associated with
923b8e80941Smrg    * subroutine types.
924b8e80941Smrg    */
925b8e80941Smrg   int num_subroutines;
926b8e80941Smrg   ir_function **subroutines;
927b8e80941Smrg
928b8e80941Smrg   /**
929b8e80941Smrg    * field selection temporary parser storage -
930b8e80941Smrg    * did the parser just parse a dot.
931b8e80941Smrg    */
932b8e80941Smrg   bool is_field;
933b8e80941Smrg
934b8e80941Smrg   /**
935b8e80941Smrg    * seen values for clip/cull distance sizes
936b8e80941Smrg    * so we can check totals aren't too large.
937b8e80941Smrg    */
938b8e80941Smrg   unsigned clip_dist_size, cull_dist_size;
939b8e80941Smrg};
940b8e80941Smrg
941b8e80941Smrg# define YYLLOC_DEFAULT(Current, Rhs, N)                        \
942b8e80941Smrgdo {                                                            \
943b8e80941Smrg   if (N)                                                       \
944b8e80941Smrg   {                                                            \
945b8e80941Smrg      (Current).first_line   = YYRHSLOC(Rhs, 1).first_line;     \
946b8e80941Smrg      (Current).first_column = YYRHSLOC(Rhs, 1).first_column;   \
947b8e80941Smrg      (Current).last_line    = YYRHSLOC(Rhs, N).last_line;      \
948b8e80941Smrg      (Current).last_column  = YYRHSLOC(Rhs, N).last_column;    \
949b8e80941Smrg   }                                                            \
950b8e80941Smrg   else                                                         \
951b8e80941Smrg   {                                                            \
952b8e80941Smrg      (Current).first_line   = (Current).last_line =            \
953b8e80941Smrg         YYRHSLOC(Rhs, 0).last_line;                            \
954b8e80941Smrg      (Current).first_column = (Current).last_column =          \
955b8e80941Smrg         YYRHSLOC(Rhs, 0).last_column;                          \
956b8e80941Smrg   }                                                            \
957b8e80941Smrg   (Current).source = 0;                                        \
958b8e80941Smrg} while (0)
959b8e80941Smrg
960b8e80941Smrg/**
961b8e80941Smrg * Emit a warning to the shader log
962b8e80941Smrg *
963b8e80941Smrg * \sa _mesa_glsl_error
964b8e80941Smrg */
965b8e80941Smrgextern void _mesa_glsl_warning(const YYLTYPE *locp,
966b8e80941Smrg                               _mesa_glsl_parse_state *state,
967b8e80941Smrg                               const char *fmt, ...);
968b8e80941Smrg
969b8e80941Smrgextern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
970b8e80941Smrg                                  const char *string);
971b8e80941Smrg
972b8e80941Smrgextern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state);
973b8e80941Smrg
974b8e80941Smrgunion YYSTYPE;
975b8e80941Smrgextern int _mesa_glsl_lexer_lex(union YYSTYPE *yylval, YYLTYPE *yylloc,
976b8e80941Smrg                                void *scanner);
977b8e80941Smrg
978b8e80941Smrgextern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *);
979b8e80941Smrg
980b8e80941Smrg/**
981b8e80941Smrg * Process elements of the #extension directive
982b8e80941Smrg *
983b8e80941Smrg * \return
984b8e80941Smrg * If \c name and \c behavior are valid, \c true is returned.  Otherwise
985b8e80941Smrg * \c false is returned.
986b8e80941Smrg */
987b8e80941Smrgextern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
988b8e80941Smrg                                         const char *behavior,
989b8e80941Smrg                                         YYLTYPE *behavior_locp,
990b8e80941Smrg                                         _mesa_glsl_parse_state *state);
991b8e80941Smrg
992b8e80941Smrg#endif /* __cplusplus */
993b8e80941Smrg
994b8e80941Smrg
995b8e80941Smrg/*
996b8e80941Smrg * These definitions apply to C and C++
997b8e80941Smrg */
998b8e80941Smrg#ifdef __cplusplus
999b8e80941Smrgextern "C" {
1000b8e80941Smrg#endif
1001b8e80941Smrg
1002b8e80941Smrgstruct glcpp_parser;
1003b8e80941Smrgstruct _mesa_glsl_parse_state;
1004b8e80941Smrg
1005b8e80941Smrgtypedef void (*glcpp_extension_iterator)(
1006b8e80941Smrg              struct _mesa_glsl_parse_state *state,
1007b8e80941Smrg              void (*add_builtin_define)(struct glcpp_parser *, const char *, int),
1008b8e80941Smrg              struct glcpp_parser *data,
1009b8e80941Smrg              unsigned version,
1010b8e80941Smrg              bool es);
1011b8e80941Smrg
1012b8e80941Smrgextern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,
1013b8e80941Smrg                            glcpp_extension_iterator extensions,
1014b8e80941Smrg                            struct _mesa_glsl_parse_state *state,
1015b8e80941Smrg                            struct gl_context *gl_ctx);
1016b8e80941Smrg
1017b8e80941Smrgextern void _mesa_init_shader_compiler_types(void);
1018b8e80941Smrgextern void _mesa_destroy_shader_compiler_types(void);
1019b8e80941Smrgextern void _mesa_destroy_shader_compiler(void);
1020b8e80941Smrgextern void _mesa_destroy_shader_compiler_caches(void);
1021b8e80941Smrg
1022b8e80941Smrgextern void
1023b8e80941Smrg_mesa_glsl_copy_symbols_from_table(struct exec_list *shader_ir,
1024b8e80941Smrg                                   struct glsl_symbol_table *src,
1025b8e80941Smrg                                   struct glsl_symbol_table *dest);
1026b8e80941Smrg
1027b8e80941Smrg#ifdef __cplusplus
1028b8e80941Smrg}
1029b8e80941Smrg#endif
1030b8e80941Smrg
1031b8e80941Smrg
1032b8e80941Smrg#endif /* GLSL_PARSER_EXTRAS_H */
1033