101e04c3fSmrg/* 201e04c3fSmrg * Copyright © 2010 Intel Corporation 301e04c3fSmrg * 401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 501e04c3fSmrg * copy of this software and associated documentation files (the "Software"), 601e04c3fSmrg * to deal in the Software without restriction, including without limitation 701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the 901e04c3fSmrg * Software is furnished to do so, subject to the following conditions: 1001e04c3fSmrg * 1101e04c3fSmrg * The above copyright notice and this permission notice (including the next 1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the 1301e04c3fSmrg * Software. 1401e04c3fSmrg * 1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2101e04c3fSmrg * DEALINGS IN THE SOFTWARE. 2201e04c3fSmrg */ 2301e04c3fSmrg 2401e04c3fSmrg#ifndef GLSL_PARSER_EXTRAS_H 2501e04c3fSmrg#define GLSL_PARSER_EXTRAS_H 2601e04c3fSmrg 2701e04c3fSmrg/* 2801e04c3fSmrg * Most of the definitions here only apply to C++ 2901e04c3fSmrg */ 3001e04c3fSmrg#ifdef __cplusplus 3101e04c3fSmrg 3201e04c3fSmrg 3301e04c3fSmrg#include <stdlib.h> 3401e04c3fSmrg#include "glsl_symbol_table.h" 3501e04c3fSmrg 3601e04c3fSmrg/* THIS is a macro defined somewhere deep in the Windows MSVC header files. 3701e04c3fSmrg * Undefine it here to avoid collision with the lexer's THIS token. 3801e04c3fSmrg */ 3901e04c3fSmrg#undef THIS 4001e04c3fSmrg 4101e04c3fSmrgstruct gl_context; 4201e04c3fSmrg 4301e04c3fSmrgstruct glsl_switch_state { 4401e04c3fSmrg /** Temporary variables needed for switch statement. */ 4501e04c3fSmrg ir_variable *test_var; 4601e04c3fSmrg ir_variable *is_fallthru_var; 4701e04c3fSmrg class ast_switch_statement *switch_nesting_ast; 4801e04c3fSmrg 4901e04c3fSmrg /** Used to detect if 'continue' was called inside a switch. */ 5001e04c3fSmrg ir_variable *continue_inside; 5101e04c3fSmrg 5201e04c3fSmrg /** Used to set condition if 'default' label should be chosen. */ 5301e04c3fSmrg ir_variable *run_default; 5401e04c3fSmrg 5501e04c3fSmrg /** Table of constant values already used in case labels */ 5601e04c3fSmrg struct hash_table *labels_ht; 5701e04c3fSmrg class ast_case_label *previous_default; 5801e04c3fSmrg 5901e04c3fSmrg bool is_switch_innermost; // if switch stmt is closest to break, ... 6001e04c3fSmrg}; 6101e04c3fSmrg 6201e04c3fSmrgconst char * 6301e04c3fSmrgglsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version); 6401e04c3fSmrg 6501e04c3fSmrgtypedef struct YYLTYPE { 6601e04c3fSmrg int first_line; 6701e04c3fSmrg int first_column; 6801e04c3fSmrg int last_line; 6901e04c3fSmrg int last_column; 7001e04c3fSmrg unsigned source; 717ec681f3Smrg /* Path for ARB_shading_language_include include source */ 727ec681f3Smrg char *path; 7301e04c3fSmrg} YYLTYPE; 7401e04c3fSmrg# define YYLTYPE_IS_DECLARED 1 7501e04c3fSmrg# define YYLTYPE_IS_TRIVIAL 1 7601e04c3fSmrg 7701e04c3fSmrgextern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, 7801e04c3fSmrg const char *fmt, ...); 7901e04c3fSmrg 8001e04c3fSmrg 8101e04c3fSmrgstruct _mesa_glsl_parse_state { 8201e04c3fSmrg _mesa_glsl_parse_state(struct gl_context *_ctx, gl_shader_stage stage, 8301e04c3fSmrg void *mem_ctx); 8401e04c3fSmrg 8501e04c3fSmrg DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state); 8601e04c3fSmrg 8701e04c3fSmrg /** 8801e04c3fSmrg * Generate a string representing the GLSL version currently being compiled 8901e04c3fSmrg * (useful for error messages). 9001e04c3fSmrg */ 9101e04c3fSmrg const char *get_version_string() 9201e04c3fSmrg { 9301e04c3fSmrg return glsl_compute_version_string(this, this->es_shader, 9401e04c3fSmrg this->language_version); 9501e04c3fSmrg } 9601e04c3fSmrg 9701e04c3fSmrg /** 9801e04c3fSmrg * Determine whether the current GLSL version is sufficiently high to 9901e04c3fSmrg * support a certain feature. 10001e04c3fSmrg * 10101e04c3fSmrg * \param required_glsl_version is the desktop GLSL version that is 10201e04c3fSmrg * required to support the feature, or 0 if no version of desktop GLSL 10301e04c3fSmrg * supports the feature. 10401e04c3fSmrg * 10501e04c3fSmrg * \param required_glsl_es_version is the GLSL ES version that is required 10601e04c3fSmrg * to support the feature, or 0 if no version of GLSL ES supports the 10701e04c3fSmrg * feature. 10801e04c3fSmrg */ 10901e04c3fSmrg bool is_version(unsigned required_glsl_version, 11001e04c3fSmrg unsigned required_glsl_es_version) const 11101e04c3fSmrg { 11201e04c3fSmrg unsigned required_version = this->es_shader ? 11301e04c3fSmrg required_glsl_es_version : required_glsl_version; 11401e04c3fSmrg unsigned this_version = this->forced_language_version 11501e04c3fSmrg ? this->forced_language_version : this->language_version; 11601e04c3fSmrg return required_version != 0 11701e04c3fSmrg && this_version >= required_version; 11801e04c3fSmrg } 11901e04c3fSmrg 12001e04c3fSmrg bool check_version(unsigned required_glsl_version, 12101e04c3fSmrg unsigned required_glsl_es_version, 12201e04c3fSmrg YYLTYPE *locp, const char *fmt, ...) PRINTFLIKE(5, 6); 12301e04c3fSmrg 12401e04c3fSmrg bool check_arrays_of_arrays_allowed(YYLTYPE *locp) 12501e04c3fSmrg { 12601e04c3fSmrg if (!(ARB_arrays_of_arrays_enable || is_version(430, 310))) { 12701e04c3fSmrg const char *const requirement = this->es_shader 12801e04c3fSmrg ? "GLSL ES 3.10" 12901e04c3fSmrg : "GL_ARB_arrays_of_arrays or GLSL 4.30"; 13001e04c3fSmrg _mesa_glsl_error(locp, this, 13101e04c3fSmrg "%s required for defining arrays of arrays.", 13201e04c3fSmrg requirement); 13301e04c3fSmrg return false; 13401e04c3fSmrg } 13501e04c3fSmrg return true; 13601e04c3fSmrg } 13701e04c3fSmrg 13801e04c3fSmrg bool check_precision_qualifiers_allowed(YYLTYPE *locp) 13901e04c3fSmrg { 14001e04c3fSmrg return check_version(130, 100, locp, 14101e04c3fSmrg "precision qualifiers are forbidden"); 14201e04c3fSmrg } 14301e04c3fSmrg 14401e04c3fSmrg bool check_bitwise_operations_allowed(YYLTYPE *locp) 14501e04c3fSmrg { 1467e102996Smaya return EXT_gpu_shader4_enable || 1477e102996Smaya check_version(130, 300, locp, "bit-wise operations are forbidden"); 14801e04c3fSmrg } 14901e04c3fSmrg 15001e04c3fSmrg bool check_explicit_attrib_stream_allowed(YYLTYPE *locp) 15101e04c3fSmrg { 15201e04c3fSmrg if (!this->has_explicit_attrib_stream()) { 15301e04c3fSmrg const char *const requirement = "GL_ARB_gpu_shader5 extension or GLSL 4.00"; 15401e04c3fSmrg 15501e04c3fSmrg _mesa_glsl_error(locp, this, "explicit stream requires %s", 15601e04c3fSmrg requirement); 15701e04c3fSmrg return false; 15801e04c3fSmrg } 15901e04c3fSmrg 16001e04c3fSmrg return true; 16101e04c3fSmrg } 16201e04c3fSmrg 16301e04c3fSmrg bool check_explicit_attrib_location_allowed(YYLTYPE *locp, 16401e04c3fSmrg const ir_variable *var) 16501e04c3fSmrg { 16601e04c3fSmrg if (!this->has_explicit_attrib_location()) { 16701e04c3fSmrg const char *const requirement = this->es_shader 16801e04c3fSmrg ? "GLSL ES 3.00" 16901e04c3fSmrg : "GL_ARB_explicit_attrib_location extension or GLSL 3.30"; 17001e04c3fSmrg 17101e04c3fSmrg _mesa_glsl_error(locp, this, "%s explicit location requires %s", 17201e04c3fSmrg mode_string(var), requirement); 17301e04c3fSmrg return false; 17401e04c3fSmrg } 17501e04c3fSmrg 17601e04c3fSmrg return true; 17701e04c3fSmrg } 17801e04c3fSmrg 17901e04c3fSmrg bool check_separate_shader_objects_allowed(YYLTYPE *locp, 18001e04c3fSmrg const ir_variable *var) 18101e04c3fSmrg { 18201e04c3fSmrg if (!this->has_separate_shader_objects()) { 18301e04c3fSmrg const char *const requirement = this->es_shader 18401e04c3fSmrg ? "GL_EXT_separate_shader_objects extension or GLSL ES 3.10" 18501e04c3fSmrg : "GL_ARB_separate_shader_objects extension or GLSL 4.20"; 18601e04c3fSmrg 18701e04c3fSmrg _mesa_glsl_error(locp, this, "%s explicit location requires %s", 18801e04c3fSmrg mode_string(var), requirement); 18901e04c3fSmrg return false; 19001e04c3fSmrg } 19101e04c3fSmrg 19201e04c3fSmrg return true; 19301e04c3fSmrg } 19401e04c3fSmrg 19501e04c3fSmrg bool check_explicit_uniform_location_allowed(YYLTYPE *locp, 19601e04c3fSmrg const ir_variable *) 19701e04c3fSmrg { 19801e04c3fSmrg if (!this->has_explicit_attrib_location() || 19901e04c3fSmrg !this->has_explicit_uniform_location()) { 20001e04c3fSmrg const char *const requirement = this->es_shader 20101e04c3fSmrg ? "GLSL ES 3.10" 20201e04c3fSmrg : "GL_ARB_explicit_uniform_location and either " 20301e04c3fSmrg "GL_ARB_explicit_attrib_location or GLSL 3.30."; 20401e04c3fSmrg 20501e04c3fSmrg _mesa_glsl_error(locp, this, 20601e04c3fSmrg "uniform explicit location requires %s", 20701e04c3fSmrg requirement); 20801e04c3fSmrg return false; 20901e04c3fSmrg } 21001e04c3fSmrg 21101e04c3fSmrg return true; 21201e04c3fSmrg } 21301e04c3fSmrg 21401e04c3fSmrg bool has_atomic_counters() const 21501e04c3fSmrg { 21601e04c3fSmrg return ARB_shader_atomic_counters_enable || is_version(420, 310); 21701e04c3fSmrg } 21801e04c3fSmrg 21901e04c3fSmrg bool has_enhanced_layouts() const 22001e04c3fSmrg { 22101e04c3fSmrg return ARB_enhanced_layouts_enable || is_version(440, 0); 22201e04c3fSmrg } 22301e04c3fSmrg 22401e04c3fSmrg bool has_explicit_attrib_stream() const 22501e04c3fSmrg { 22601e04c3fSmrg return ARB_gpu_shader5_enable || is_version(400, 0); 22701e04c3fSmrg } 22801e04c3fSmrg 22901e04c3fSmrg bool has_explicit_attrib_location() const 23001e04c3fSmrg { 23101e04c3fSmrg return ARB_explicit_attrib_location_enable || is_version(330, 300); 23201e04c3fSmrg } 23301e04c3fSmrg 23401e04c3fSmrg bool has_explicit_uniform_location() const 23501e04c3fSmrg { 23601e04c3fSmrg return ARB_explicit_uniform_location_enable || is_version(430, 310); 23701e04c3fSmrg } 23801e04c3fSmrg 23901e04c3fSmrg bool has_uniform_buffer_objects() const 24001e04c3fSmrg { 24101e04c3fSmrg return ARB_uniform_buffer_object_enable || is_version(140, 300); 24201e04c3fSmrg } 24301e04c3fSmrg 24401e04c3fSmrg bool has_shader_storage_buffer_objects() const 24501e04c3fSmrg { 24601e04c3fSmrg return ARB_shader_storage_buffer_object_enable || is_version(430, 310); 24701e04c3fSmrg } 24801e04c3fSmrg 24901e04c3fSmrg bool has_separate_shader_objects() const 25001e04c3fSmrg { 25101e04c3fSmrg return ARB_separate_shader_objects_enable || is_version(410, 310) 25201e04c3fSmrg || EXT_separate_shader_objects_enable; 25301e04c3fSmrg } 25401e04c3fSmrg 25501e04c3fSmrg bool has_double() const 25601e04c3fSmrg { 25701e04c3fSmrg return ARB_gpu_shader_fp64_enable || is_version(400, 0); 25801e04c3fSmrg } 25901e04c3fSmrg 26001e04c3fSmrg bool has_int64() const 26101e04c3fSmrg { 26201e04c3fSmrg return ARB_gpu_shader_int64_enable || 26301e04c3fSmrg AMD_gpu_shader_int64_enable; 26401e04c3fSmrg } 26501e04c3fSmrg 26601e04c3fSmrg bool has_420pack() const 26701e04c3fSmrg { 26801e04c3fSmrg return ARB_shading_language_420pack_enable || is_version(420, 0); 26901e04c3fSmrg } 27001e04c3fSmrg 27101e04c3fSmrg bool has_420pack_or_es31() const 27201e04c3fSmrg { 27301e04c3fSmrg return ARB_shading_language_420pack_enable || is_version(420, 310); 27401e04c3fSmrg } 27501e04c3fSmrg 27601e04c3fSmrg bool has_compute_shader() const 27701e04c3fSmrg { 27801e04c3fSmrg return ARB_compute_shader_enable || is_version(430, 310); 27901e04c3fSmrg } 28001e04c3fSmrg 28101e04c3fSmrg bool has_shader_io_blocks() const 28201e04c3fSmrg { 28301e04c3fSmrg /* The OES_geometry_shader_specification says: 28401e04c3fSmrg * 28501e04c3fSmrg * "If the OES_geometry_shader extension is enabled, the 28601e04c3fSmrg * OES_shader_io_blocks extension is also implicitly enabled." 28701e04c3fSmrg * 28801e04c3fSmrg * The OES_tessellation_shader extension has similar wording. 28901e04c3fSmrg */ 29001e04c3fSmrg return OES_shader_io_blocks_enable || 29101e04c3fSmrg EXT_shader_io_blocks_enable || 29201e04c3fSmrg OES_geometry_shader_enable || 29301e04c3fSmrg EXT_geometry_shader_enable || 29401e04c3fSmrg OES_tessellation_shader_enable || 29501e04c3fSmrg EXT_tessellation_shader_enable || 29601e04c3fSmrg 29701e04c3fSmrg is_version(150, 320); 29801e04c3fSmrg } 29901e04c3fSmrg 30001e04c3fSmrg bool has_geometry_shader() const 30101e04c3fSmrg { 30201e04c3fSmrg return OES_geometry_shader_enable || EXT_geometry_shader_enable || 30301e04c3fSmrg is_version(150, 320); 30401e04c3fSmrg } 30501e04c3fSmrg 30601e04c3fSmrg bool has_tessellation_shader() const 30701e04c3fSmrg { 30801e04c3fSmrg return ARB_tessellation_shader_enable || 30901e04c3fSmrg OES_tessellation_shader_enable || 31001e04c3fSmrg EXT_tessellation_shader_enable || 31101e04c3fSmrg is_version(400, 320); 31201e04c3fSmrg } 31301e04c3fSmrg 31401e04c3fSmrg bool has_clip_distance() const 31501e04c3fSmrg { 31601e04c3fSmrg return EXT_clip_cull_distance_enable || is_version(130, 0); 31701e04c3fSmrg } 31801e04c3fSmrg 31901e04c3fSmrg bool has_cull_distance() const 32001e04c3fSmrg { 32101e04c3fSmrg return EXT_clip_cull_distance_enable || 32201e04c3fSmrg ARB_cull_distance_enable || 32301e04c3fSmrg is_version(450, 0); 32401e04c3fSmrg } 32501e04c3fSmrg 32601e04c3fSmrg bool has_framebuffer_fetch() const 32701e04c3fSmrg { 32801e04c3fSmrg return EXT_shader_framebuffer_fetch_enable || 32901e04c3fSmrg EXT_shader_framebuffer_fetch_non_coherent_enable; 33001e04c3fSmrg } 33101e04c3fSmrg 33201e04c3fSmrg bool has_texture_cube_map_array() const 33301e04c3fSmrg { 33401e04c3fSmrg return ARB_texture_cube_map_array_enable || 33501e04c3fSmrg EXT_texture_cube_map_array_enable || 33601e04c3fSmrg OES_texture_cube_map_array_enable || 33701e04c3fSmrg is_version(400, 320); 33801e04c3fSmrg } 33901e04c3fSmrg 34001e04c3fSmrg bool has_shader_image_load_store() const 34101e04c3fSmrg { 3427ec681f3Smrg return ARB_shader_image_load_store_enable || 3437ec681f3Smrg EXT_shader_image_load_store_enable || 3447ec681f3Smrg is_version(420, 310); 34501e04c3fSmrg } 34601e04c3fSmrg 34701e04c3fSmrg bool has_bindless() const 34801e04c3fSmrg { 34901e04c3fSmrg return ARB_bindless_texture_enable; 35001e04c3fSmrg } 35101e04c3fSmrg 3527e102996Smaya bool has_image_load_formatted() const 3537e102996Smaya { 3547e102996Smaya return EXT_shader_image_load_formatted_enable; 3557e102996Smaya } 3567e102996Smaya 3577e102996Smaya bool has_implicit_conversions() const 3587e102996Smaya { 3597ec681f3Smrg return EXT_shader_implicit_conversions_enable || 3607ec681f3Smrg is_version(allow_glsl_120_subset_in_110 ? 110 : 120, 0); 3617e102996Smaya } 3627e102996Smaya 3637ec681f3Smrg bool has_implicit_int_to_uint_conversion() const 3647e102996Smaya { 3657e102996Smaya return ARB_gpu_shader5_enable || 3667e102996Smaya MESA_shader_integer_functions_enable || 3677e102996Smaya EXT_shader_implicit_conversions_enable || 3687e102996Smaya is_version(400, 0); 3697e102996Smaya } 3707e102996Smaya 3717ec681f3Smrg void set_valid_gl_and_glsl_versions(YYLTYPE *locp); 3727ec681f3Smrg 37301e04c3fSmrg void process_version_directive(YYLTYPE *locp, int version, 37401e04c3fSmrg const char *ident); 37501e04c3fSmrg 37601e04c3fSmrg struct gl_context *const ctx; 37701e04c3fSmrg void *scanner; 37801e04c3fSmrg exec_list translation_unit; 37901e04c3fSmrg glsl_symbol_table *symbols; 38001e04c3fSmrg 38101e04c3fSmrg void *linalloc; 38201e04c3fSmrg 38301e04c3fSmrg unsigned num_supported_versions; 38401e04c3fSmrg struct { 38501e04c3fSmrg unsigned ver; 38601e04c3fSmrg uint8_t gl_ver; 38701e04c3fSmrg bool es; 38801e04c3fSmrg } supported_versions[17]; 38901e04c3fSmrg 39001e04c3fSmrg bool es_shader; 39101e04c3fSmrg bool compat_shader; 39201e04c3fSmrg unsigned language_version; 39301e04c3fSmrg unsigned forced_language_version; 3947ec681f3Smrg /* Bitfield of ir_variable_mode to zero init */ 3957ec681f3Smrg uint32_t zero_init; 39601e04c3fSmrg unsigned gl_version; 39701e04c3fSmrg gl_shader_stage stage; 39801e04c3fSmrg 39901e04c3fSmrg /** 40001e04c3fSmrg * Default uniform layout qualifiers tracked during parsing. 40101e04c3fSmrg * Currently affects uniform blocks and uniform buffer variables in 40201e04c3fSmrg * those blocks. 40301e04c3fSmrg */ 40401e04c3fSmrg struct ast_type_qualifier *default_uniform_qualifier; 40501e04c3fSmrg 40601e04c3fSmrg /** 40701e04c3fSmrg * Default shader storage layout qualifiers tracked during parsing. 40801e04c3fSmrg * Currently affects shader storage blocks and shader storage buffer 40901e04c3fSmrg * variables in those blocks. 41001e04c3fSmrg */ 41101e04c3fSmrg struct ast_type_qualifier *default_shader_storage_qualifier; 41201e04c3fSmrg 41301e04c3fSmrg /** 41401e04c3fSmrg * Variables to track different cases if a fragment shader redeclares 41501e04c3fSmrg * built-in variable gl_FragCoord. 41601e04c3fSmrg * 41701e04c3fSmrg * Note: These values are computed at ast_to_hir time rather than at parse 41801e04c3fSmrg * time. 41901e04c3fSmrg */ 42001e04c3fSmrg bool fs_redeclares_gl_fragcoord; 42101e04c3fSmrg bool fs_origin_upper_left; 42201e04c3fSmrg bool fs_pixel_center_integer; 42301e04c3fSmrg bool fs_redeclares_gl_fragcoord_with_no_layout_qualifiers; 42401e04c3fSmrg 42501e04c3fSmrg /** 42601e04c3fSmrg * True if a geometry shader input primitive type or tessellation control 42701e04c3fSmrg * output vertices were specified using a layout directive. 42801e04c3fSmrg * 42901e04c3fSmrg * Note: these values are computed at ast_to_hir time rather than at parse 43001e04c3fSmrg * time. 43101e04c3fSmrg */ 43201e04c3fSmrg bool gs_input_prim_type_specified; 43301e04c3fSmrg bool tcs_output_vertices_specified; 43401e04c3fSmrg 43501e04c3fSmrg /** 43601e04c3fSmrg * Input layout qualifiers from GLSL 1.50 (geometry shader controls), 43701e04c3fSmrg * and GLSL 4.00 (tessellation evaluation shader) 43801e04c3fSmrg */ 43901e04c3fSmrg struct ast_type_qualifier *in_qualifier; 44001e04c3fSmrg 44101e04c3fSmrg /** 44201e04c3fSmrg * True if a compute shader input local size was specified using a layout 44301e04c3fSmrg * directive. 44401e04c3fSmrg * 44501e04c3fSmrg * Note: this value is computed at ast_to_hir time rather than at parse 44601e04c3fSmrg * time. 44701e04c3fSmrg */ 44801e04c3fSmrg bool cs_input_local_size_specified; 44901e04c3fSmrg 45001e04c3fSmrg /** 45101e04c3fSmrg * If cs_input_local_size_specified is true, the local size that was 45201e04c3fSmrg * specified. Otherwise ignored. 45301e04c3fSmrg */ 45401e04c3fSmrg unsigned cs_input_local_size[3]; 45501e04c3fSmrg 45601e04c3fSmrg /** 45701e04c3fSmrg * True if a compute shader input local variable size was specified using 45801e04c3fSmrg * a layout directive as specified by ARB_compute_variable_group_size. 45901e04c3fSmrg */ 46001e04c3fSmrg bool cs_input_local_size_variable_specified; 46101e04c3fSmrg 4627e102996Smaya /** 4637e102996Smaya * Arrangement of invocations used to calculate derivatives in a compute 4647e102996Smaya * shader. From NV_compute_shader_derivatives. 4657e102996Smaya */ 4667e102996Smaya enum gl_derivative_group cs_derivative_group; 4677e102996Smaya 46801e04c3fSmrg /** 46901e04c3fSmrg * True if a shader declare bindless_sampler/bindless_image, and 47001e04c3fSmrg * respectively bound_sampler/bound_image at global scope as specified by 47101e04c3fSmrg * ARB_bindless_texture. 47201e04c3fSmrg */ 47301e04c3fSmrg bool bindless_sampler_specified; 47401e04c3fSmrg bool bindless_image_specified; 47501e04c3fSmrg bool bound_sampler_specified; 47601e04c3fSmrg bool bound_image_specified; 47701e04c3fSmrg 47801e04c3fSmrg /** 47901e04c3fSmrg * Output layout qualifiers from GLSL 1.50 (geometry shader controls), 48001e04c3fSmrg * and GLSL 4.00 (tessellation control shader). 48101e04c3fSmrg */ 48201e04c3fSmrg struct ast_type_qualifier *out_qualifier; 48301e04c3fSmrg 48401e04c3fSmrg /** 48501e04c3fSmrg * Printable list of GLSL versions supported by the current context 48601e04c3fSmrg * 48701e04c3fSmrg * \note 48801e04c3fSmrg * This string should probably be generated per-context instead of per 48901e04c3fSmrg * invokation of the compiler. This should be changed when the method of 49001e04c3fSmrg * tracking supported GLSL versions changes. 49101e04c3fSmrg */ 49201e04c3fSmrg const char *supported_version_string; 49301e04c3fSmrg 49401e04c3fSmrg /** 49501e04c3fSmrg * Implementation defined limits that affect built-in variables, etc. 49601e04c3fSmrg * 49701e04c3fSmrg * \sa struct gl_constants (in mtypes.h) 49801e04c3fSmrg */ 49901e04c3fSmrg struct { 50001e04c3fSmrg /* 1.10 */ 50101e04c3fSmrg unsigned MaxLights; 50201e04c3fSmrg unsigned MaxClipPlanes; 50301e04c3fSmrg unsigned MaxTextureUnits; 50401e04c3fSmrg unsigned MaxTextureCoords; 50501e04c3fSmrg unsigned MaxVertexAttribs; 50601e04c3fSmrg unsigned MaxVertexUniformComponents; 50701e04c3fSmrg unsigned MaxVertexTextureImageUnits; 50801e04c3fSmrg unsigned MaxCombinedTextureImageUnits; 50901e04c3fSmrg unsigned MaxTextureImageUnits; 51001e04c3fSmrg unsigned MaxFragmentUniformComponents; 51101e04c3fSmrg 51201e04c3fSmrg /* ARB_draw_buffers */ 51301e04c3fSmrg unsigned MaxDrawBuffers; 51401e04c3fSmrg 51501e04c3fSmrg /* ARB_enhanced_layouts */ 51601e04c3fSmrg unsigned MaxTransformFeedbackBuffers; 51701e04c3fSmrg unsigned MaxTransformFeedbackInterleavedComponents; 51801e04c3fSmrg 51901e04c3fSmrg /* ARB_blend_func_extended */ 52001e04c3fSmrg unsigned MaxDualSourceDrawBuffers; 52101e04c3fSmrg 52201e04c3fSmrg /* 3.00 ES */ 52301e04c3fSmrg int MinProgramTexelOffset; 52401e04c3fSmrg int MaxProgramTexelOffset; 52501e04c3fSmrg 52601e04c3fSmrg /* 1.50 */ 52701e04c3fSmrg unsigned MaxVertexOutputComponents; 52801e04c3fSmrg unsigned MaxGeometryInputComponents; 52901e04c3fSmrg unsigned MaxGeometryOutputComponents; 53001e04c3fSmrg unsigned MaxGeometryShaderInvocations; 53101e04c3fSmrg unsigned MaxFragmentInputComponents; 53201e04c3fSmrg unsigned MaxGeometryTextureImageUnits; 53301e04c3fSmrg unsigned MaxGeometryOutputVertices; 53401e04c3fSmrg unsigned MaxGeometryTotalOutputComponents; 53501e04c3fSmrg unsigned MaxGeometryUniformComponents; 53601e04c3fSmrg 53701e04c3fSmrg /* ARB_shader_atomic_counters */ 53801e04c3fSmrg unsigned MaxVertexAtomicCounters; 53901e04c3fSmrg unsigned MaxTessControlAtomicCounters; 54001e04c3fSmrg unsigned MaxTessEvaluationAtomicCounters; 54101e04c3fSmrg unsigned MaxGeometryAtomicCounters; 54201e04c3fSmrg unsigned MaxFragmentAtomicCounters; 54301e04c3fSmrg unsigned MaxCombinedAtomicCounters; 54401e04c3fSmrg unsigned MaxAtomicBufferBindings; 54501e04c3fSmrg 54601e04c3fSmrg /* These are also atomic counter related, but they weren't added to 54701e04c3fSmrg * until atomic counters were added to core in GLSL 4.20 and GLSL ES 54801e04c3fSmrg * 3.10. 54901e04c3fSmrg */ 55001e04c3fSmrg unsigned MaxVertexAtomicCounterBuffers; 55101e04c3fSmrg unsigned MaxTessControlAtomicCounterBuffers; 55201e04c3fSmrg unsigned MaxTessEvaluationAtomicCounterBuffers; 55301e04c3fSmrg unsigned MaxGeometryAtomicCounterBuffers; 55401e04c3fSmrg unsigned MaxFragmentAtomicCounterBuffers; 55501e04c3fSmrg unsigned MaxCombinedAtomicCounterBuffers; 55601e04c3fSmrg unsigned MaxAtomicCounterBufferSize; 55701e04c3fSmrg 55801e04c3fSmrg /* ARB_compute_shader */ 55901e04c3fSmrg unsigned MaxComputeAtomicCounterBuffers; 56001e04c3fSmrg unsigned MaxComputeAtomicCounters; 56101e04c3fSmrg unsigned MaxComputeImageUniforms; 56201e04c3fSmrg unsigned MaxComputeTextureImageUnits; 56301e04c3fSmrg unsigned MaxComputeUniformComponents; 56401e04c3fSmrg unsigned MaxComputeWorkGroupCount[3]; 56501e04c3fSmrg unsigned MaxComputeWorkGroupSize[3]; 56601e04c3fSmrg 56701e04c3fSmrg /* ARB_shader_image_load_store */ 56801e04c3fSmrg unsigned MaxImageUnits; 56901e04c3fSmrg unsigned MaxCombinedShaderOutputResources; 57001e04c3fSmrg unsigned MaxImageSamples; 57101e04c3fSmrg unsigned MaxVertexImageUniforms; 57201e04c3fSmrg unsigned MaxTessControlImageUniforms; 57301e04c3fSmrg unsigned MaxTessEvaluationImageUniforms; 57401e04c3fSmrg unsigned MaxGeometryImageUniforms; 57501e04c3fSmrg unsigned MaxFragmentImageUniforms; 57601e04c3fSmrg unsigned MaxCombinedImageUniforms; 57701e04c3fSmrg 57801e04c3fSmrg /* ARB_viewport_array */ 57901e04c3fSmrg unsigned MaxViewports; 58001e04c3fSmrg 58101e04c3fSmrg /* ARB_tessellation_shader */ 58201e04c3fSmrg unsigned MaxPatchVertices; 58301e04c3fSmrg unsigned MaxTessGenLevel; 58401e04c3fSmrg unsigned MaxTessControlInputComponents; 58501e04c3fSmrg unsigned MaxTessControlOutputComponents; 58601e04c3fSmrg unsigned MaxTessControlTextureImageUnits; 58701e04c3fSmrg unsigned MaxTessEvaluationInputComponents; 58801e04c3fSmrg unsigned MaxTessEvaluationOutputComponents; 58901e04c3fSmrg unsigned MaxTessEvaluationTextureImageUnits; 59001e04c3fSmrg unsigned MaxTessPatchComponents; 59101e04c3fSmrg unsigned MaxTessControlTotalOutputComponents; 59201e04c3fSmrg unsigned MaxTessControlUniformComponents; 59301e04c3fSmrg unsigned MaxTessEvaluationUniformComponents; 59401e04c3fSmrg 59501e04c3fSmrg /* GL 4.5 / OES_sample_variables */ 59601e04c3fSmrg unsigned MaxSamples; 59701e04c3fSmrg } Const; 59801e04c3fSmrg 59901e04c3fSmrg /** 60001e04c3fSmrg * During AST to IR conversion, pointer to current IR function 60101e04c3fSmrg * 60201e04c3fSmrg * Will be \c NULL whenever the AST to IR conversion is not inside a 60301e04c3fSmrg * function definition. 60401e04c3fSmrg */ 60501e04c3fSmrg class ir_function_signature *current_function; 60601e04c3fSmrg 60701e04c3fSmrg /** 60801e04c3fSmrg * During AST to IR conversion, pointer to the toplevel IR 60901e04c3fSmrg * instruction list being generated. 61001e04c3fSmrg */ 61101e04c3fSmrg exec_list *toplevel_ir; 61201e04c3fSmrg 61301e04c3fSmrg /** Have we found a return statement in this function? */ 61401e04c3fSmrg bool found_return; 61501e04c3fSmrg 6167ec681f3Smrg /** Have we found the interlock builtins in this function? */ 6177ec681f3Smrg bool found_begin_interlock; 6187ec681f3Smrg bool found_end_interlock; 6197ec681f3Smrg 62001e04c3fSmrg /** Was there an error during compilation? */ 62101e04c3fSmrg bool error; 62201e04c3fSmrg 62301e04c3fSmrg /** 62401e04c3fSmrg * Are all shader inputs / outputs invariant? 62501e04c3fSmrg * 62601e04c3fSmrg * This is set when the 'STDGL invariant(all)' pragma is used. 62701e04c3fSmrg */ 62801e04c3fSmrg bool all_invariant; 62901e04c3fSmrg 63001e04c3fSmrg /** Loop or switch statement containing the current instructions. */ 63101e04c3fSmrg class ast_iteration_statement *loop_nesting_ast; 63201e04c3fSmrg 63301e04c3fSmrg struct glsl_switch_state switch_state; 63401e04c3fSmrg 63501e04c3fSmrg /** List of structures defined in user code. */ 63601e04c3fSmrg const glsl_type **user_structures; 63701e04c3fSmrg unsigned num_user_structures; 63801e04c3fSmrg 63901e04c3fSmrg char *info_log; 64001e04c3fSmrg 6417e102996Smaya /** 6427e102996Smaya * Are warnings enabled? 6437e102996Smaya * 6447e102996Smaya * Emission of warngins is controlled by '#pragma warning(...)'. 6457e102996Smaya */ 6467e102996Smaya bool warnings_enabled; 6477e102996Smaya 64801e04c3fSmrg /** 64901e04c3fSmrg * \name Enable bits for GLSL extensions 65001e04c3fSmrg */ 65101e04c3fSmrg /*@{*/ 65201e04c3fSmrg /* ARB extensions go here, sorted alphabetically. 65301e04c3fSmrg */ 65401e04c3fSmrg bool ARB_ES3_1_compatibility_enable; 65501e04c3fSmrg bool ARB_ES3_1_compatibility_warn; 65601e04c3fSmrg bool ARB_ES3_2_compatibility_enable; 65701e04c3fSmrg bool ARB_ES3_2_compatibility_warn; 65801e04c3fSmrg bool ARB_arrays_of_arrays_enable; 65901e04c3fSmrg bool ARB_arrays_of_arrays_warn; 66001e04c3fSmrg bool ARB_bindless_texture_enable; 66101e04c3fSmrg bool ARB_bindless_texture_warn; 66201e04c3fSmrg bool ARB_compatibility_enable; 66301e04c3fSmrg bool ARB_compatibility_warn; 66401e04c3fSmrg bool ARB_compute_shader_enable; 66501e04c3fSmrg bool ARB_compute_shader_warn; 66601e04c3fSmrg bool ARB_compute_variable_group_size_enable; 66701e04c3fSmrg bool ARB_compute_variable_group_size_warn; 66801e04c3fSmrg bool ARB_conservative_depth_enable; 66901e04c3fSmrg bool ARB_conservative_depth_warn; 67001e04c3fSmrg bool ARB_cull_distance_enable; 67101e04c3fSmrg bool ARB_cull_distance_warn; 67201e04c3fSmrg bool ARB_derivative_control_enable; 67301e04c3fSmrg bool ARB_derivative_control_warn; 67401e04c3fSmrg bool ARB_draw_buffers_enable; 67501e04c3fSmrg bool ARB_draw_buffers_warn; 67601e04c3fSmrg bool ARB_draw_instanced_enable; 67701e04c3fSmrg bool ARB_draw_instanced_warn; 67801e04c3fSmrg bool ARB_enhanced_layouts_enable; 67901e04c3fSmrg bool ARB_enhanced_layouts_warn; 68001e04c3fSmrg bool ARB_explicit_attrib_location_enable; 68101e04c3fSmrg bool ARB_explicit_attrib_location_warn; 68201e04c3fSmrg bool ARB_explicit_uniform_location_enable; 68301e04c3fSmrg bool ARB_explicit_uniform_location_warn; 68401e04c3fSmrg bool ARB_fragment_coord_conventions_enable; 68501e04c3fSmrg bool ARB_fragment_coord_conventions_warn; 68601e04c3fSmrg bool ARB_fragment_layer_viewport_enable; 68701e04c3fSmrg bool ARB_fragment_layer_viewport_warn; 68801e04c3fSmrg bool ARB_fragment_shader_interlock_enable; 68901e04c3fSmrg bool ARB_fragment_shader_interlock_warn; 69001e04c3fSmrg bool ARB_gpu_shader5_enable; 69101e04c3fSmrg bool ARB_gpu_shader5_warn; 69201e04c3fSmrg bool ARB_gpu_shader_fp64_enable; 69301e04c3fSmrg bool ARB_gpu_shader_fp64_warn; 69401e04c3fSmrg bool ARB_gpu_shader_int64_enable; 69501e04c3fSmrg bool ARB_gpu_shader_int64_warn; 69601e04c3fSmrg bool ARB_post_depth_coverage_enable; 69701e04c3fSmrg bool ARB_post_depth_coverage_warn; 69801e04c3fSmrg bool ARB_sample_shading_enable; 69901e04c3fSmrg bool ARB_sample_shading_warn; 70001e04c3fSmrg bool ARB_separate_shader_objects_enable; 70101e04c3fSmrg bool ARB_separate_shader_objects_warn; 70201e04c3fSmrg bool ARB_shader_atomic_counter_ops_enable; 70301e04c3fSmrg bool ARB_shader_atomic_counter_ops_warn; 70401e04c3fSmrg bool ARB_shader_atomic_counters_enable; 70501e04c3fSmrg bool ARB_shader_atomic_counters_warn; 70601e04c3fSmrg bool ARB_shader_ballot_enable; 70701e04c3fSmrg bool ARB_shader_ballot_warn; 70801e04c3fSmrg bool ARB_shader_bit_encoding_enable; 70901e04c3fSmrg bool ARB_shader_bit_encoding_warn; 71001e04c3fSmrg bool ARB_shader_clock_enable; 71101e04c3fSmrg bool ARB_shader_clock_warn; 71201e04c3fSmrg bool ARB_shader_draw_parameters_enable; 71301e04c3fSmrg bool ARB_shader_draw_parameters_warn; 71401e04c3fSmrg bool ARB_shader_group_vote_enable; 71501e04c3fSmrg bool ARB_shader_group_vote_warn; 71601e04c3fSmrg bool ARB_shader_image_load_store_enable; 71701e04c3fSmrg bool ARB_shader_image_load_store_warn; 71801e04c3fSmrg bool ARB_shader_image_size_enable; 71901e04c3fSmrg bool ARB_shader_image_size_warn; 72001e04c3fSmrg bool ARB_shader_precision_enable; 72101e04c3fSmrg bool ARB_shader_precision_warn; 72201e04c3fSmrg bool ARB_shader_stencil_export_enable; 72301e04c3fSmrg bool ARB_shader_stencil_export_warn; 72401e04c3fSmrg bool ARB_shader_storage_buffer_object_enable; 72501e04c3fSmrg bool ARB_shader_storage_buffer_object_warn; 72601e04c3fSmrg bool ARB_shader_subroutine_enable; 72701e04c3fSmrg bool ARB_shader_subroutine_warn; 72801e04c3fSmrg bool ARB_shader_texture_image_samples_enable; 72901e04c3fSmrg bool ARB_shader_texture_image_samples_warn; 73001e04c3fSmrg bool ARB_shader_texture_lod_enable; 73101e04c3fSmrg bool ARB_shader_texture_lod_warn; 73201e04c3fSmrg bool ARB_shader_viewport_layer_array_enable; 73301e04c3fSmrg bool ARB_shader_viewport_layer_array_warn; 73401e04c3fSmrg bool ARB_shading_language_420pack_enable; 73501e04c3fSmrg bool ARB_shading_language_420pack_warn; 7367ec681f3Smrg bool ARB_shading_language_include_enable; 7377ec681f3Smrg bool ARB_shading_language_include_warn; 73801e04c3fSmrg bool ARB_shading_language_packing_enable; 73901e04c3fSmrg bool ARB_shading_language_packing_warn; 74001e04c3fSmrg bool ARB_tessellation_shader_enable; 74101e04c3fSmrg bool ARB_tessellation_shader_warn; 74201e04c3fSmrg bool ARB_texture_cube_map_array_enable; 74301e04c3fSmrg bool ARB_texture_cube_map_array_warn; 74401e04c3fSmrg bool ARB_texture_gather_enable; 74501e04c3fSmrg bool ARB_texture_gather_warn; 74601e04c3fSmrg bool ARB_texture_multisample_enable; 74701e04c3fSmrg bool ARB_texture_multisample_warn; 74801e04c3fSmrg bool ARB_texture_query_levels_enable; 74901e04c3fSmrg bool ARB_texture_query_levels_warn; 75001e04c3fSmrg bool ARB_texture_query_lod_enable; 75101e04c3fSmrg bool ARB_texture_query_lod_warn; 75201e04c3fSmrg bool ARB_texture_rectangle_enable; 75301e04c3fSmrg bool ARB_texture_rectangle_warn; 75401e04c3fSmrg bool ARB_uniform_buffer_object_enable; 75501e04c3fSmrg bool ARB_uniform_buffer_object_warn; 75601e04c3fSmrg bool ARB_vertex_attrib_64bit_enable; 75701e04c3fSmrg bool ARB_vertex_attrib_64bit_warn; 75801e04c3fSmrg bool ARB_viewport_array_enable; 75901e04c3fSmrg bool ARB_viewport_array_warn; 76001e04c3fSmrg 76101e04c3fSmrg /* KHR extensions go here, sorted alphabetically. 76201e04c3fSmrg */ 76301e04c3fSmrg bool KHR_blend_equation_advanced_enable; 76401e04c3fSmrg bool KHR_blend_equation_advanced_warn; 76501e04c3fSmrg 76601e04c3fSmrg /* OES extensions go here, sorted alphabetically. 76701e04c3fSmrg */ 76801e04c3fSmrg bool OES_EGL_image_external_enable; 76901e04c3fSmrg bool OES_EGL_image_external_warn; 77001e04c3fSmrg bool OES_EGL_image_external_essl3_enable; 77101e04c3fSmrg bool OES_EGL_image_external_essl3_warn; 77201e04c3fSmrg bool OES_geometry_point_size_enable; 77301e04c3fSmrg bool OES_geometry_point_size_warn; 77401e04c3fSmrg bool OES_geometry_shader_enable; 77501e04c3fSmrg bool OES_geometry_shader_warn; 77601e04c3fSmrg bool OES_gpu_shader5_enable; 77701e04c3fSmrg bool OES_gpu_shader5_warn; 77801e04c3fSmrg bool OES_primitive_bounding_box_enable; 77901e04c3fSmrg bool OES_primitive_bounding_box_warn; 78001e04c3fSmrg bool OES_sample_variables_enable; 78101e04c3fSmrg bool OES_sample_variables_warn; 78201e04c3fSmrg bool OES_shader_image_atomic_enable; 78301e04c3fSmrg bool OES_shader_image_atomic_warn; 78401e04c3fSmrg bool OES_shader_io_blocks_enable; 78501e04c3fSmrg bool OES_shader_io_blocks_warn; 78601e04c3fSmrg bool OES_shader_multisample_interpolation_enable; 78701e04c3fSmrg bool OES_shader_multisample_interpolation_warn; 78801e04c3fSmrg bool OES_standard_derivatives_enable; 78901e04c3fSmrg bool OES_standard_derivatives_warn; 79001e04c3fSmrg bool OES_tessellation_point_size_enable; 79101e04c3fSmrg bool OES_tessellation_point_size_warn; 79201e04c3fSmrg bool OES_tessellation_shader_enable; 79301e04c3fSmrg bool OES_tessellation_shader_warn; 79401e04c3fSmrg bool OES_texture_3D_enable; 79501e04c3fSmrg bool OES_texture_3D_warn; 79601e04c3fSmrg bool OES_texture_buffer_enable; 79701e04c3fSmrg bool OES_texture_buffer_warn; 79801e04c3fSmrg bool OES_texture_cube_map_array_enable; 79901e04c3fSmrg bool OES_texture_cube_map_array_warn; 80001e04c3fSmrg bool OES_texture_storage_multisample_2d_array_enable; 80101e04c3fSmrg bool OES_texture_storage_multisample_2d_array_warn; 80201e04c3fSmrg bool OES_viewport_array_enable; 80301e04c3fSmrg bool OES_viewport_array_warn; 80401e04c3fSmrg 80501e04c3fSmrg /* All other extensions go here, sorted alphabetically. 80601e04c3fSmrg */ 80701e04c3fSmrg bool AMD_conservative_depth_enable; 80801e04c3fSmrg bool AMD_conservative_depth_warn; 80901e04c3fSmrg bool AMD_gpu_shader_int64_enable; 81001e04c3fSmrg bool AMD_gpu_shader_int64_warn; 81101e04c3fSmrg bool AMD_shader_stencil_export_enable; 81201e04c3fSmrg bool AMD_shader_stencil_export_warn; 81301e04c3fSmrg bool AMD_shader_trinary_minmax_enable; 81401e04c3fSmrg bool AMD_shader_trinary_minmax_warn; 8157e102996Smaya bool AMD_texture_texture4_enable; 8167e102996Smaya bool AMD_texture_texture4_warn; 81701e04c3fSmrg bool AMD_vertex_shader_layer_enable; 81801e04c3fSmrg bool AMD_vertex_shader_layer_warn; 81901e04c3fSmrg bool AMD_vertex_shader_viewport_index_enable; 82001e04c3fSmrg bool AMD_vertex_shader_viewport_index_warn; 82101e04c3fSmrg bool ANDROID_extension_pack_es31a_enable; 82201e04c3fSmrg bool ANDROID_extension_pack_es31a_warn; 82301e04c3fSmrg bool EXT_blend_func_extended_enable; 82401e04c3fSmrg bool EXT_blend_func_extended_warn; 82501e04c3fSmrg bool EXT_clip_cull_distance_enable; 82601e04c3fSmrg bool EXT_clip_cull_distance_warn; 8277ec681f3Smrg bool EXT_demote_to_helper_invocation_enable; 8287ec681f3Smrg bool EXT_demote_to_helper_invocation_warn; 82901e04c3fSmrg bool EXT_draw_buffers_enable; 83001e04c3fSmrg bool EXT_draw_buffers_warn; 8317ec681f3Smrg bool EXT_draw_instanced_enable; 8327ec681f3Smrg bool EXT_draw_instanced_warn; 83301e04c3fSmrg bool EXT_frag_depth_enable; 83401e04c3fSmrg bool EXT_frag_depth_warn; 83501e04c3fSmrg bool EXT_geometry_point_size_enable; 83601e04c3fSmrg bool EXT_geometry_point_size_warn; 83701e04c3fSmrg bool EXT_geometry_shader_enable; 83801e04c3fSmrg bool EXT_geometry_shader_warn; 8397e102996Smaya bool EXT_gpu_shader4_enable; 8407e102996Smaya bool EXT_gpu_shader4_warn; 84101e04c3fSmrg bool EXT_gpu_shader5_enable; 84201e04c3fSmrg bool EXT_gpu_shader5_warn; 84301e04c3fSmrg bool EXT_primitive_bounding_box_enable; 84401e04c3fSmrg bool EXT_primitive_bounding_box_warn; 84501e04c3fSmrg bool EXT_separate_shader_objects_enable; 84601e04c3fSmrg bool EXT_separate_shader_objects_warn; 84701e04c3fSmrg bool EXT_shader_framebuffer_fetch_enable; 84801e04c3fSmrg bool EXT_shader_framebuffer_fetch_warn; 84901e04c3fSmrg bool EXT_shader_framebuffer_fetch_non_coherent_enable; 85001e04c3fSmrg bool EXT_shader_framebuffer_fetch_non_coherent_warn; 8517ec681f3Smrg bool EXT_shader_group_vote_enable; 8527ec681f3Smrg bool EXT_shader_group_vote_warn; 8537e102996Smaya bool EXT_shader_image_load_formatted_enable; 8547e102996Smaya bool EXT_shader_image_load_formatted_warn; 8557ec681f3Smrg bool EXT_shader_image_load_store_enable; 8567ec681f3Smrg bool EXT_shader_image_load_store_warn; 8577e102996Smaya bool EXT_shader_implicit_conversions_enable; 8587e102996Smaya bool EXT_shader_implicit_conversions_warn; 85901e04c3fSmrg bool EXT_shader_integer_mix_enable; 86001e04c3fSmrg bool EXT_shader_integer_mix_warn; 86101e04c3fSmrg bool EXT_shader_io_blocks_enable; 86201e04c3fSmrg bool EXT_shader_io_blocks_warn; 86301e04c3fSmrg bool EXT_shader_samples_identical_enable; 86401e04c3fSmrg bool EXT_shader_samples_identical_warn; 86501e04c3fSmrg bool EXT_tessellation_point_size_enable; 86601e04c3fSmrg bool EXT_tessellation_point_size_warn; 86701e04c3fSmrg bool EXT_tessellation_shader_enable; 86801e04c3fSmrg bool EXT_tessellation_shader_warn; 86901e04c3fSmrg bool EXT_texture_array_enable; 87001e04c3fSmrg bool EXT_texture_array_warn; 87101e04c3fSmrg bool EXT_texture_buffer_enable; 87201e04c3fSmrg bool EXT_texture_buffer_warn; 87301e04c3fSmrg bool EXT_texture_cube_map_array_enable; 87401e04c3fSmrg bool EXT_texture_cube_map_array_warn; 8757e102996Smaya bool EXT_texture_query_lod_enable; 8767e102996Smaya bool EXT_texture_query_lod_warn; 8777ec681f3Smrg bool EXT_texture_shadow_lod_enable; 8787ec681f3Smrg bool EXT_texture_shadow_lod_warn; 87901e04c3fSmrg bool INTEL_conservative_rasterization_enable; 88001e04c3fSmrg bool INTEL_conservative_rasterization_warn; 88101e04c3fSmrg bool INTEL_shader_atomic_float_minmax_enable; 88201e04c3fSmrg bool INTEL_shader_atomic_float_minmax_warn; 8837ec681f3Smrg bool INTEL_shader_integer_functions2_enable; 8847ec681f3Smrg bool INTEL_shader_integer_functions2_warn; 88501e04c3fSmrg bool MESA_shader_integer_functions_enable; 88601e04c3fSmrg bool MESA_shader_integer_functions_warn; 8877e102996Smaya bool NV_compute_shader_derivatives_enable; 8887e102996Smaya bool NV_compute_shader_derivatives_warn; 88901e04c3fSmrg bool NV_fragment_shader_interlock_enable; 89001e04c3fSmrg bool NV_fragment_shader_interlock_warn; 89101e04c3fSmrg bool NV_image_formats_enable; 89201e04c3fSmrg bool NV_image_formats_warn; 89301e04c3fSmrg bool NV_shader_atomic_float_enable; 89401e04c3fSmrg bool NV_shader_atomic_float_warn; 8957ec681f3Smrg bool NV_shader_atomic_int64_enable; 8967ec681f3Smrg bool NV_shader_atomic_int64_warn; 8977ec681f3Smrg bool NV_viewport_array2_enable; 8987ec681f3Smrg bool NV_viewport_array2_warn; 89901e04c3fSmrg /*@}*/ 90001e04c3fSmrg 90101e04c3fSmrg /** Extensions supported by the OpenGL implementation. */ 90201e04c3fSmrg const struct gl_extensions *extensions; 90301e04c3fSmrg 90401e04c3fSmrg bool uses_builtin_functions; 90501e04c3fSmrg bool fs_uses_gl_fragcoord; 90601e04c3fSmrg 90701e04c3fSmrg /** 90801e04c3fSmrg * For geometry shaders, size of the most recently seen input declaration 90901e04c3fSmrg * that was a sized array, or 0 if no sized input array declarations have 91001e04c3fSmrg * been seen. 91101e04c3fSmrg * 91201e04c3fSmrg * Unused for other shader types. 91301e04c3fSmrg */ 91401e04c3fSmrg unsigned gs_input_size; 91501e04c3fSmrg 91601e04c3fSmrg bool fs_early_fragment_tests; 91701e04c3fSmrg 91801e04c3fSmrg bool fs_inner_coverage; 91901e04c3fSmrg 92001e04c3fSmrg bool fs_post_depth_coverage; 92101e04c3fSmrg 92201e04c3fSmrg bool fs_pixel_interlock_ordered; 92301e04c3fSmrg bool fs_pixel_interlock_unordered; 92401e04c3fSmrg bool fs_sample_interlock_ordered; 92501e04c3fSmrg bool fs_sample_interlock_unordered; 92601e04c3fSmrg 92701e04c3fSmrg unsigned fs_blend_support; 92801e04c3fSmrg 92901e04c3fSmrg /** 93001e04c3fSmrg * For tessellation control shaders, size of the most recently seen output 93101e04c3fSmrg * declaration that was a sized array, or 0 if no sized output array 93201e04c3fSmrg * declarations have been seen. 93301e04c3fSmrg * 93401e04c3fSmrg * Unused for other shader types. 93501e04c3fSmrg */ 93601e04c3fSmrg unsigned tcs_output_size; 93701e04c3fSmrg 93801e04c3fSmrg /** Atomic counter offsets by binding */ 93901e04c3fSmrg unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS]; 94001e04c3fSmrg 9417ec681f3Smrg /** Whether gl_Layer output is viewport-relative. */ 9427ec681f3Smrg bool redeclares_gl_layer; 9437ec681f3Smrg bool layer_viewport_relative; 9447ec681f3Smrg 94501e04c3fSmrg bool allow_extension_directive_midshader; 9467ec681f3Smrg bool allow_glsl_120_subset_in_110; 94701e04c3fSmrg bool allow_builtin_variable_redeclaration; 9487ec681f3Smrg bool ignore_write_to_readonly_var; 94901e04c3fSmrg 95001e04c3fSmrg /** 95101e04c3fSmrg * Known subroutine type declarations. 95201e04c3fSmrg */ 95301e04c3fSmrg int num_subroutine_types; 95401e04c3fSmrg ir_function **subroutine_types; 95501e04c3fSmrg 95601e04c3fSmrg /** 95701e04c3fSmrg * Functions that are associated with 95801e04c3fSmrg * subroutine types. 95901e04c3fSmrg */ 96001e04c3fSmrg int num_subroutines; 96101e04c3fSmrg ir_function **subroutines; 96201e04c3fSmrg 96301e04c3fSmrg /** 96401e04c3fSmrg * field selection temporary parser storage - 96501e04c3fSmrg * did the parser just parse a dot. 96601e04c3fSmrg */ 96701e04c3fSmrg bool is_field; 96801e04c3fSmrg 96901e04c3fSmrg /** 97001e04c3fSmrg * seen values for clip/cull distance sizes 97101e04c3fSmrg * so we can check totals aren't too large. 97201e04c3fSmrg */ 97301e04c3fSmrg unsigned clip_dist_size, cull_dist_size; 97401e04c3fSmrg}; 97501e04c3fSmrg 97601e04c3fSmrg# define YYLLOC_DEFAULT(Current, Rhs, N) \ 97701e04c3fSmrgdo { \ 97801e04c3fSmrg if (N) \ 97901e04c3fSmrg { \ 98001e04c3fSmrg (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ 98101e04c3fSmrg (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ 98201e04c3fSmrg (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ 98301e04c3fSmrg (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ 9847ec681f3Smrg (Current).path = YYRHSLOC(Rhs, N).path; \ 98501e04c3fSmrg } \ 98601e04c3fSmrg else \ 98701e04c3fSmrg { \ 98801e04c3fSmrg (Current).first_line = (Current).last_line = \ 98901e04c3fSmrg YYRHSLOC(Rhs, 0).last_line; \ 99001e04c3fSmrg (Current).first_column = (Current).last_column = \ 99101e04c3fSmrg YYRHSLOC(Rhs, 0).last_column; \ 9927ec681f3Smrg (Current).path = YYRHSLOC(Rhs, 0).path; \ 99301e04c3fSmrg } \ 99401e04c3fSmrg (Current).source = 0; \ 99501e04c3fSmrg} while (0) 99601e04c3fSmrg 99701e04c3fSmrg/** 99801e04c3fSmrg * Emit a warning to the shader log 99901e04c3fSmrg * 100001e04c3fSmrg * \sa _mesa_glsl_error 100101e04c3fSmrg */ 100201e04c3fSmrgextern void _mesa_glsl_warning(const YYLTYPE *locp, 100301e04c3fSmrg _mesa_glsl_parse_state *state, 100401e04c3fSmrg const char *fmt, ...); 100501e04c3fSmrg 100601e04c3fSmrgextern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, 100701e04c3fSmrg const char *string); 100801e04c3fSmrg 100901e04c3fSmrgextern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); 101001e04c3fSmrg 101101e04c3fSmrgunion YYSTYPE; 101201e04c3fSmrgextern int _mesa_glsl_lexer_lex(union YYSTYPE *yylval, YYLTYPE *yylloc, 101301e04c3fSmrg void *scanner); 101401e04c3fSmrg 101501e04c3fSmrgextern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); 101601e04c3fSmrg 101701e04c3fSmrg/** 101801e04c3fSmrg * Process elements of the #extension directive 101901e04c3fSmrg * 102001e04c3fSmrg * \return 102101e04c3fSmrg * If \c name and \c behavior are valid, \c true is returned. Otherwise 102201e04c3fSmrg * \c false is returned. 102301e04c3fSmrg */ 102401e04c3fSmrgextern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, 102501e04c3fSmrg const char *behavior, 102601e04c3fSmrg YYLTYPE *behavior_locp, 102701e04c3fSmrg _mesa_glsl_parse_state *state); 102801e04c3fSmrg 102901e04c3fSmrg#endif /* __cplusplus */ 103001e04c3fSmrg 103101e04c3fSmrg 103201e04c3fSmrg/* 103301e04c3fSmrg * These definitions apply to C and C++ 103401e04c3fSmrg */ 103501e04c3fSmrg#ifdef __cplusplus 103601e04c3fSmrgextern "C" { 103701e04c3fSmrg#endif 103801e04c3fSmrg 103901e04c3fSmrgstruct glcpp_parser; 10407e102996Smayastruct _mesa_glsl_parse_state; 104101e04c3fSmrg 104201e04c3fSmrgtypedef void (*glcpp_extension_iterator)( 104301e04c3fSmrg struct _mesa_glsl_parse_state *state, 104401e04c3fSmrg void (*add_builtin_define)(struct glcpp_parser *, const char *, int), 104501e04c3fSmrg struct glcpp_parser *data, 104601e04c3fSmrg unsigned version, 104701e04c3fSmrg bool es); 104801e04c3fSmrg 104901e04c3fSmrgextern int glcpp_preprocess(void *ctx, const char **shader, char **info_log, 105001e04c3fSmrg glcpp_extension_iterator extensions, 105101e04c3fSmrg struct _mesa_glsl_parse_state *state, 105201e04c3fSmrg struct gl_context *gl_ctx); 105301e04c3fSmrg 105401e04c3fSmrgextern void 105501e04c3fSmrg_mesa_glsl_copy_symbols_from_table(struct exec_list *shader_ir, 105601e04c3fSmrg struct glsl_symbol_table *src, 105701e04c3fSmrg struct glsl_symbol_table *dest); 105801e04c3fSmrg 105901e04c3fSmrg#ifdef __cplusplus 106001e04c3fSmrg} 106101e04c3fSmrg#endif 106201e04c3fSmrg 106301e04c3fSmrg 106401e04c3fSmrg#endif /* GLSL_PARSER_EXTRAS_H */ 1065