Path: blob/21.2-virgl/src/compiler/glsl/glsl_parser_extras.h
4545 views
/*1* Copyright © 2010 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*/2223#ifndef GLSL_PARSER_EXTRAS_H24#define GLSL_PARSER_EXTRAS_H2526/*27* Most of the definitions here only apply to C++28*/29#ifdef __cplusplus303132#include <stdlib.h>33#include "glsl_symbol_table.h"3435/* THIS is a macro defined somewhere deep in the Windows MSVC header files.36* Undefine it here to avoid collision with the lexer's THIS token.37*/38#undef THIS3940struct gl_context;4142struct glsl_switch_state {43/** Temporary variables needed for switch statement. */44ir_variable *test_var;45ir_variable *is_fallthru_var;46class ast_switch_statement *switch_nesting_ast;4748/** Used to detect if 'continue' was called inside a switch. */49ir_variable *continue_inside;5051/** Used to set condition if 'default' label should be chosen. */52ir_variable *run_default;5354/** Table of constant values already used in case labels */55struct hash_table *labels_ht;56class ast_case_label *previous_default;5758bool is_switch_innermost; // if switch stmt is closest to break, ...59};6061const char *62glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version);6364typedef struct YYLTYPE {65int first_line;66int first_column;67int last_line;68int last_column;69unsigned source;70/* Path for ARB_shading_language_include include source */71char *path;72} YYLTYPE;73# define YYLTYPE_IS_DECLARED 174# define YYLTYPE_IS_TRIVIAL 17576extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,77const char *fmt, ...);787980struct _mesa_glsl_parse_state {81_mesa_glsl_parse_state(struct gl_context *_ctx, gl_shader_stage stage,82void *mem_ctx);8384DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);8586/**87* Generate a string representing the GLSL version currently being compiled88* (useful for error messages).89*/90const char *get_version_string()91{92return glsl_compute_version_string(this, this->es_shader,93this->language_version);94}9596/**97* Determine whether the current GLSL version is sufficiently high to98* support a certain feature.99*100* \param required_glsl_version is the desktop GLSL version that is101* required to support the feature, or 0 if no version of desktop GLSL102* supports the feature.103*104* \param required_glsl_es_version is the GLSL ES version that is required105* to support the feature, or 0 if no version of GLSL ES supports the106* feature.107*/108bool is_version(unsigned required_glsl_version,109unsigned required_glsl_es_version) const110{111unsigned required_version = this->es_shader ?112required_glsl_es_version : required_glsl_version;113unsigned this_version = this->forced_language_version114? this->forced_language_version : this->language_version;115return required_version != 0116&& this_version >= required_version;117}118119bool check_version(unsigned required_glsl_version,120unsigned required_glsl_es_version,121YYLTYPE *locp, const char *fmt, ...) PRINTFLIKE(5, 6);122123bool check_arrays_of_arrays_allowed(YYLTYPE *locp)124{125if (!(ARB_arrays_of_arrays_enable || is_version(430, 310))) {126const char *const requirement = this->es_shader127? "GLSL ES 3.10"128: "GL_ARB_arrays_of_arrays or GLSL 4.30";129_mesa_glsl_error(locp, this,130"%s required for defining arrays of arrays.",131requirement);132return false;133}134return true;135}136137bool check_precision_qualifiers_allowed(YYLTYPE *locp)138{139return check_version(130, 100, locp,140"precision qualifiers are forbidden");141}142143bool check_bitwise_operations_allowed(YYLTYPE *locp)144{145return EXT_gpu_shader4_enable ||146check_version(130, 300, locp, "bit-wise operations are forbidden");147}148149bool check_explicit_attrib_stream_allowed(YYLTYPE *locp)150{151if (!this->has_explicit_attrib_stream()) {152const char *const requirement = "GL_ARB_gpu_shader5 extension or GLSL 4.00";153154_mesa_glsl_error(locp, this, "explicit stream requires %s",155requirement);156return false;157}158159return true;160}161162bool check_explicit_attrib_location_allowed(YYLTYPE *locp,163const ir_variable *var)164{165if (!this->has_explicit_attrib_location()) {166const char *const requirement = this->es_shader167? "GLSL ES 3.00"168: "GL_ARB_explicit_attrib_location extension or GLSL 3.30";169170_mesa_glsl_error(locp, this, "%s explicit location requires %s",171mode_string(var), requirement);172return false;173}174175return true;176}177178bool check_separate_shader_objects_allowed(YYLTYPE *locp,179const ir_variable *var)180{181if (!this->has_separate_shader_objects()) {182const char *const requirement = this->es_shader183? "GL_EXT_separate_shader_objects extension or GLSL ES 3.10"184: "GL_ARB_separate_shader_objects extension or GLSL 4.20";185186_mesa_glsl_error(locp, this, "%s explicit location requires %s",187mode_string(var), requirement);188return false;189}190191return true;192}193194bool check_explicit_uniform_location_allowed(YYLTYPE *locp,195const ir_variable *)196{197if (!this->has_explicit_attrib_location() ||198!this->has_explicit_uniform_location()) {199const char *const requirement = this->es_shader200? "GLSL ES 3.10"201: "GL_ARB_explicit_uniform_location and either "202"GL_ARB_explicit_attrib_location or GLSL 3.30.";203204_mesa_glsl_error(locp, this,205"uniform explicit location requires %s",206requirement);207return false;208}209210return true;211}212213bool has_atomic_counters() const214{215return ARB_shader_atomic_counters_enable || is_version(420, 310);216}217218bool has_enhanced_layouts() const219{220return ARB_enhanced_layouts_enable || is_version(440, 0);221}222223bool has_explicit_attrib_stream() const224{225return ARB_gpu_shader5_enable || is_version(400, 0);226}227228bool has_explicit_attrib_location() const229{230return ARB_explicit_attrib_location_enable || is_version(330, 300);231}232233bool has_explicit_uniform_location() const234{235return ARB_explicit_uniform_location_enable || is_version(430, 310);236}237238bool has_uniform_buffer_objects() const239{240return ARB_uniform_buffer_object_enable || is_version(140, 300);241}242243bool has_shader_storage_buffer_objects() const244{245return ARB_shader_storage_buffer_object_enable || is_version(430, 310);246}247248bool has_separate_shader_objects() const249{250return ARB_separate_shader_objects_enable || is_version(410, 310)251|| EXT_separate_shader_objects_enable;252}253254bool has_double() const255{256return ARB_gpu_shader_fp64_enable || is_version(400, 0);257}258259bool has_int64() const260{261return ARB_gpu_shader_int64_enable ||262AMD_gpu_shader_int64_enable;263}264265bool has_420pack() const266{267return ARB_shading_language_420pack_enable || is_version(420, 0);268}269270bool has_420pack_or_es31() const271{272return ARB_shading_language_420pack_enable || is_version(420, 310);273}274275bool has_compute_shader() const276{277return ARB_compute_shader_enable || is_version(430, 310);278}279280bool has_shader_io_blocks() const281{282/* The OES_geometry_shader_specification says:283*284* "If the OES_geometry_shader extension is enabled, the285* OES_shader_io_blocks extension is also implicitly enabled."286*287* The OES_tessellation_shader extension has similar wording.288*/289return OES_shader_io_blocks_enable ||290EXT_shader_io_blocks_enable ||291OES_geometry_shader_enable ||292EXT_geometry_shader_enable ||293OES_tessellation_shader_enable ||294EXT_tessellation_shader_enable ||295296is_version(150, 320);297}298299bool has_geometry_shader() const300{301return OES_geometry_shader_enable || EXT_geometry_shader_enable ||302is_version(150, 320);303}304305bool has_tessellation_shader() const306{307return ARB_tessellation_shader_enable ||308OES_tessellation_shader_enable ||309EXT_tessellation_shader_enable ||310is_version(400, 320);311}312313bool has_clip_distance() const314{315return EXT_clip_cull_distance_enable || is_version(130, 0);316}317318bool has_cull_distance() const319{320return EXT_clip_cull_distance_enable ||321ARB_cull_distance_enable ||322is_version(450, 0);323}324325bool has_framebuffer_fetch() const326{327return EXT_shader_framebuffer_fetch_enable ||328EXT_shader_framebuffer_fetch_non_coherent_enable;329}330331bool has_texture_cube_map_array() const332{333return ARB_texture_cube_map_array_enable ||334EXT_texture_cube_map_array_enable ||335OES_texture_cube_map_array_enable ||336is_version(400, 320);337}338339bool has_shader_image_load_store() const340{341return ARB_shader_image_load_store_enable ||342EXT_shader_image_load_store_enable ||343is_version(420, 310);344}345346bool has_bindless() const347{348return ARB_bindless_texture_enable;349}350351bool has_image_load_formatted() const352{353return EXT_shader_image_load_formatted_enable;354}355356bool has_implicit_conversions() const357{358return EXT_shader_implicit_conversions_enable ||359is_version(allow_glsl_120_subset_in_110 ? 110 : 120, 0);360}361362bool has_implicit_int_to_uint_conversion() const363{364return ARB_gpu_shader5_enable ||365MESA_shader_integer_functions_enable ||366EXT_shader_implicit_conversions_enable ||367is_version(400, 0);368}369370void set_valid_gl_and_glsl_versions(YYLTYPE *locp);371372void process_version_directive(YYLTYPE *locp, int version,373const char *ident);374375struct gl_context *const ctx;376void *scanner;377exec_list translation_unit;378glsl_symbol_table *symbols;379380void *linalloc;381382unsigned num_supported_versions;383struct {384unsigned ver;385uint8_t gl_ver;386bool es;387} supported_versions[17];388389bool es_shader;390bool compat_shader;391unsigned language_version;392unsigned forced_language_version;393/* Bitfield of ir_variable_mode to zero init */394uint32_t zero_init;395unsigned gl_version;396gl_shader_stage stage;397398/**399* Default uniform layout qualifiers tracked during parsing.400* Currently affects uniform blocks and uniform buffer variables in401* those blocks.402*/403struct ast_type_qualifier *default_uniform_qualifier;404405/**406* Default shader storage layout qualifiers tracked during parsing.407* Currently affects shader storage blocks and shader storage buffer408* variables in those blocks.409*/410struct ast_type_qualifier *default_shader_storage_qualifier;411412/**413* Variables to track different cases if a fragment shader redeclares414* built-in variable gl_FragCoord.415*416* Note: These values are computed at ast_to_hir time rather than at parse417* time.418*/419bool fs_redeclares_gl_fragcoord;420bool fs_origin_upper_left;421bool fs_pixel_center_integer;422bool fs_redeclares_gl_fragcoord_with_no_layout_qualifiers;423424/**425* True if a geometry shader input primitive type or tessellation control426* output vertices were specified using a layout directive.427*428* Note: these values are computed at ast_to_hir time rather than at parse429* time.430*/431bool gs_input_prim_type_specified;432bool tcs_output_vertices_specified;433434/**435* Input layout qualifiers from GLSL 1.50 (geometry shader controls),436* and GLSL 4.00 (tessellation evaluation shader)437*/438struct ast_type_qualifier *in_qualifier;439440/**441* True if a compute shader input local size was specified using a layout442* directive.443*444* Note: this value is computed at ast_to_hir time rather than at parse445* time.446*/447bool cs_input_local_size_specified;448449/**450* If cs_input_local_size_specified is true, the local size that was451* specified. Otherwise ignored.452*/453unsigned cs_input_local_size[3];454455/**456* True if a compute shader input local variable size was specified using457* a layout directive as specified by ARB_compute_variable_group_size.458*/459bool cs_input_local_size_variable_specified;460461/**462* Arrangement of invocations used to calculate derivatives in a compute463* shader. From NV_compute_shader_derivatives.464*/465enum gl_derivative_group cs_derivative_group;466467/**468* True if a shader declare bindless_sampler/bindless_image, and469* respectively bound_sampler/bound_image at global scope as specified by470* ARB_bindless_texture.471*/472bool bindless_sampler_specified;473bool bindless_image_specified;474bool bound_sampler_specified;475bool bound_image_specified;476477/**478* Output layout qualifiers from GLSL 1.50 (geometry shader controls),479* and GLSL 4.00 (tessellation control shader).480*/481struct ast_type_qualifier *out_qualifier;482483/**484* Printable list of GLSL versions supported by the current context485*486* \note487* This string should probably be generated per-context instead of per488* invokation of the compiler. This should be changed when the method of489* tracking supported GLSL versions changes.490*/491const char *supported_version_string;492493/**494* Implementation defined limits that affect built-in variables, etc.495*496* \sa struct gl_constants (in mtypes.h)497*/498struct {499/* 1.10 */500unsigned MaxLights;501unsigned MaxClipPlanes;502unsigned MaxTextureUnits;503unsigned MaxTextureCoords;504unsigned MaxVertexAttribs;505unsigned MaxVertexUniformComponents;506unsigned MaxVertexTextureImageUnits;507unsigned MaxCombinedTextureImageUnits;508unsigned MaxTextureImageUnits;509unsigned MaxFragmentUniformComponents;510511/* ARB_draw_buffers */512unsigned MaxDrawBuffers;513514/* ARB_enhanced_layouts */515unsigned MaxTransformFeedbackBuffers;516unsigned MaxTransformFeedbackInterleavedComponents;517518/* ARB_blend_func_extended */519unsigned MaxDualSourceDrawBuffers;520521/* 3.00 ES */522int MinProgramTexelOffset;523int MaxProgramTexelOffset;524525/* 1.50 */526unsigned MaxVertexOutputComponents;527unsigned MaxGeometryInputComponents;528unsigned MaxGeometryOutputComponents;529unsigned MaxGeometryShaderInvocations;530unsigned MaxFragmentInputComponents;531unsigned MaxGeometryTextureImageUnits;532unsigned MaxGeometryOutputVertices;533unsigned MaxGeometryTotalOutputComponents;534unsigned MaxGeometryUniformComponents;535536/* ARB_shader_atomic_counters */537unsigned MaxVertexAtomicCounters;538unsigned MaxTessControlAtomicCounters;539unsigned MaxTessEvaluationAtomicCounters;540unsigned MaxGeometryAtomicCounters;541unsigned MaxFragmentAtomicCounters;542unsigned MaxCombinedAtomicCounters;543unsigned MaxAtomicBufferBindings;544545/* These are also atomic counter related, but they weren't added to546* until atomic counters were added to core in GLSL 4.20 and GLSL ES547* 3.10.548*/549unsigned MaxVertexAtomicCounterBuffers;550unsigned MaxTessControlAtomicCounterBuffers;551unsigned MaxTessEvaluationAtomicCounterBuffers;552unsigned MaxGeometryAtomicCounterBuffers;553unsigned MaxFragmentAtomicCounterBuffers;554unsigned MaxCombinedAtomicCounterBuffers;555unsigned MaxAtomicCounterBufferSize;556557/* ARB_compute_shader */558unsigned MaxComputeAtomicCounterBuffers;559unsigned MaxComputeAtomicCounters;560unsigned MaxComputeImageUniforms;561unsigned MaxComputeTextureImageUnits;562unsigned MaxComputeUniformComponents;563unsigned MaxComputeWorkGroupCount[3];564unsigned MaxComputeWorkGroupSize[3];565566/* ARB_shader_image_load_store */567unsigned MaxImageUnits;568unsigned MaxCombinedShaderOutputResources;569unsigned MaxImageSamples;570unsigned MaxVertexImageUniforms;571unsigned MaxTessControlImageUniforms;572unsigned MaxTessEvaluationImageUniforms;573unsigned MaxGeometryImageUniforms;574unsigned MaxFragmentImageUniforms;575unsigned MaxCombinedImageUniforms;576577/* ARB_viewport_array */578unsigned MaxViewports;579580/* ARB_tessellation_shader */581unsigned MaxPatchVertices;582unsigned MaxTessGenLevel;583unsigned MaxTessControlInputComponents;584unsigned MaxTessControlOutputComponents;585unsigned MaxTessControlTextureImageUnits;586unsigned MaxTessEvaluationInputComponents;587unsigned MaxTessEvaluationOutputComponents;588unsigned MaxTessEvaluationTextureImageUnits;589unsigned MaxTessPatchComponents;590unsigned MaxTessControlTotalOutputComponents;591unsigned MaxTessControlUniformComponents;592unsigned MaxTessEvaluationUniformComponents;593594/* GL 4.5 / OES_sample_variables */595unsigned MaxSamples;596} Const;597598/**599* During AST to IR conversion, pointer to current IR function600*601* Will be \c NULL whenever the AST to IR conversion is not inside a602* function definition.603*/604class ir_function_signature *current_function;605606/**607* During AST to IR conversion, pointer to the toplevel IR608* instruction list being generated.609*/610exec_list *toplevel_ir;611612/** Have we found a return statement in this function? */613bool found_return;614615/** Have we found the interlock builtins in this function? */616bool found_begin_interlock;617bool found_end_interlock;618619/** Was there an error during compilation? */620bool error;621622/**623* Are all shader inputs / outputs invariant?624*625* This is set when the 'STDGL invariant(all)' pragma is used.626*/627bool all_invariant;628629/** Loop or switch statement containing the current instructions. */630class ast_iteration_statement *loop_nesting_ast;631632struct glsl_switch_state switch_state;633634/** List of structures defined in user code. */635const glsl_type **user_structures;636unsigned num_user_structures;637638char *info_log;639640/**641* Are warnings enabled?642*643* Emission of warngins is controlled by '#pragma warning(...)'.644*/645bool warnings_enabled;646647/**648* \name Enable bits for GLSL extensions649*/650/*@{*/651/* ARB extensions go here, sorted alphabetically.652*/653bool ARB_ES3_1_compatibility_enable;654bool ARB_ES3_1_compatibility_warn;655bool ARB_ES3_2_compatibility_enable;656bool ARB_ES3_2_compatibility_warn;657bool ARB_arrays_of_arrays_enable;658bool ARB_arrays_of_arrays_warn;659bool ARB_bindless_texture_enable;660bool ARB_bindless_texture_warn;661bool ARB_compatibility_enable;662bool ARB_compatibility_warn;663bool ARB_compute_shader_enable;664bool ARB_compute_shader_warn;665bool ARB_compute_variable_group_size_enable;666bool ARB_compute_variable_group_size_warn;667bool ARB_conservative_depth_enable;668bool ARB_conservative_depth_warn;669bool ARB_cull_distance_enable;670bool ARB_cull_distance_warn;671bool ARB_derivative_control_enable;672bool ARB_derivative_control_warn;673bool ARB_draw_buffers_enable;674bool ARB_draw_buffers_warn;675bool ARB_draw_instanced_enable;676bool ARB_draw_instanced_warn;677bool ARB_enhanced_layouts_enable;678bool ARB_enhanced_layouts_warn;679bool ARB_explicit_attrib_location_enable;680bool ARB_explicit_attrib_location_warn;681bool ARB_explicit_uniform_location_enable;682bool ARB_explicit_uniform_location_warn;683bool ARB_fragment_coord_conventions_enable;684bool ARB_fragment_coord_conventions_warn;685bool ARB_fragment_layer_viewport_enable;686bool ARB_fragment_layer_viewport_warn;687bool ARB_fragment_shader_interlock_enable;688bool ARB_fragment_shader_interlock_warn;689bool ARB_gpu_shader5_enable;690bool ARB_gpu_shader5_warn;691bool ARB_gpu_shader_fp64_enable;692bool ARB_gpu_shader_fp64_warn;693bool ARB_gpu_shader_int64_enable;694bool ARB_gpu_shader_int64_warn;695bool ARB_post_depth_coverage_enable;696bool ARB_post_depth_coverage_warn;697bool ARB_sample_shading_enable;698bool ARB_sample_shading_warn;699bool ARB_separate_shader_objects_enable;700bool ARB_separate_shader_objects_warn;701bool ARB_shader_atomic_counter_ops_enable;702bool ARB_shader_atomic_counter_ops_warn;703bool ARB_shader_atomic_counters_enable;704bool ARB_shader_atomic_counters_warn;705bool ARB_shader_ballot_enable;706bool ARB_shader_ballot_warn;707bool ARB_shader_bit_encoding_enable;708bool ARB_shader_bit_encoding_warn;709bool ARB_shader_clock_enable;710bool ARB_shader_clock_warn;711bool ARB_shader_draw_parameters_enable;712bool ARB_shader_draw_parameters_warn;713bool ARB_shader_group_vote_enable;714bool ARB_shader_group_vote_warn;715bool ARB_shader_image_load_store_enable;716bool ARB_shader_image_load_store_warn;717bool ARB_shader_image_size_enable;718bool ARB_shader_image_size_warn;719bool ARB_shader_precision_enable;720bool ARB_shader_precision_warn;721bool ARB_shader_stencil_export_enable;722bool ARB_shader_stencil_export_warn;723bool ARB_shader_storage_buffer_object_enable;724bool ARB_shader_storage_buffer_object_warn;725bool ARB_shader_subroutine_enable;726bool ARB_shader_subroutine_warn;727bool ARB_shader_texture_image_samples_enable;728bool ARB_shader_texture_image_samples_warn;729bool ARB_shader_texture_lod_enable;730bool ARB_shader_texture_lod_warn;731bool ARB_shader_viewport_layer_array_enable;732bool ARB_shader_viewport_layer_array_warn;733bool ARB_shading_language_420pack_enable;734bool ARB_shading_language_420pack_warn;735bool ARB_shading_language_include_enable;736bool ARB_shading_language_include_warn;737bool ARB_shading_language_packing_enable;738bool ARB_shading_language_packing_warn;739bool ARB_tessellation_shader_enable;740bool ARB_tessellation_shader_warn;741bool ARB_texture_cube_map_array_enable;742bool ARB_texture_cube_map_array_warn;743bool ARB_texture_gather_enable;744bool ARB_texture_gather_warn;745bool ARB_texture_multisample_enable;746bool ARB_texture_multisample_warn;747bool ARB_texture_query_levels_enable;748bool ARB_texture_query_levels_warn;749bool ARB_texture_query_lod_enable;750bool ARB_texture_query_lod_warn;751bool ARB_texture_rectangle_enable;752bool ARB_texture_rectangle_warn;753bool ARB_uniform_buffer_object_enable;754bool ARB_uniform_buffer_object_warn;755bool ARB_vertex_attrib_64bit_enable;756bool ARB_vertex_attrib_64bit_warn;757bool ARB_viewport_array_enable;758bool ARB_viewport_array_warn;759760/* KHR extensions go here, sorted alphabetically.761*/762bool KHR_blend_equation_advanced_enable;763bool KHR_blend_equation_advanced_warn;764765/* OES extensions go here, sorted alphabetically.766*/767bool OES_EGL_image_external_enable;768bool OES_EGL_image_external_warn;769bool OES_EGL_image_external_essl3_enable;770bool OES_EGL_image_external_essl3_warn;771bool OES_geometry_point_size_enable;772bool OES_geometry_point_size_warn;773bool OES_geometry_shader_enable;774bool OES_geometry_shader_warn;775bool OES_gpu_shader5_enable;776bool OES_gpu_shader5_warn;777bool OES_primitive_bounding_box_enable;778bool OES_primitive_bounding_box_warn;779bool OES_sample_variables_enable;780bool OES_sample_variables_warn;781bool OES_shader_image_atomic_enable;782bool OES_shader_image_atomic_warn;783bool OES_shader_io_blocks_enable;784bool OES_shader_io_blocks_warn;785bool OES_shader_multisample_interpolation_enable;786bool OES_shader_multisample_interpolation_warn;787bool OES_standard_derivatives_enable;788bool OES_standard_derivatives_warn;789bool OES_tessellation_point_size_enable;790bool OES_tessellation_point_size_warn;791bool OES_tessellation_shader_enable;792bool OES_tessellation_shader_warn;793bool OES_texture_3D_enable;794bool OES_texture_3D_warn;795bool OES_texture_buffer_enable;796bool OES_texture_buffer_warn;797bool OES_texture_cube_map_array_enable;798bool OES_texture_cube_map_array_warn;799bool OES_texture_storage_multisample_2d_array_enable;800bool OES_texture_storage_multisample_2d_array_warn;801bool OES_viewport_array_enable;802bool OES_viewport_array_warn;803804/* All other extensions go here, sorted alphabetically.805*/806bool AMD_conservative_depth_enable;807bool AMD_conservative_depth_warn;808bool AMD_gpu_shader_int64_enable;809bool AMD_gpu_shader_int64_warn;810bool AMD_shader_stencil_export_enable;811bool AMD_shader_stencil_export_warn;812bool AMD_shader_trinary_minmax_enable;813bool AMD_shader_trinary_minmax_warn;814bool AMD_texture_texture4_enable;815bool AMD_texture_texture4_warn;816bool AMD_vertex_shader_layer_enable;817bool AMD_vertex_shader_layer_warn;818bool AMD_vertex_shader_viewport_index_enable;819bool AMD_vertex_shader_viewport_index_warn;820bool ANDROID_extension_pack_es31a_enable;821bool ANDROID_extension_pack_es31a_warn;822bool EXT_blend_func_extended_enable;823bool EXT_blend_func_extended_warn;824bool EXT_clip_cull_distance_enable;825bool EXT_clip_cull_distance_warn;826bool EXT_demote_to_helper_invocation_enable;827bool EXT_demote_to_helper_invocation_warn;828bool EXT_draw_buffers_enable;829bool EXT_draw_buffers_warn;830bool EXT_draw_instanced_enable;831bool EXT_draw_instanced_warn;832bool EXT_frag_depth_enable;833bool EXT_frag_depth_warn;834bool EXT_geometry_point_size_enable;835bool EXT_geometry_point_size_warn;836bool EXT_geometry_shader_enable;837bool EXT_geometry_shader_warn;838bool EXT_gpu_shader4_enable;839bool EXT_gpu_shader4_warn;840bool EXT_gpu_shader5_enable;841bool EXT_gpu_shader5_warn;842bool EXT_primitive_bounding_box_enable;843bool EXT_primitive_bounding_box_warn;844bool EXT_separate_shader_objects_enable;845bool EXT_separate_shader_objects_warn;846bool EXT_shader_framebuffer_fetch_enable;847bool EXT_shader_framebuffer_fetch_warn;848bool EXT_shader_framebuffer_fetch_non_coherent_enable;849bool EXT_shader_framebuffer_fetch_non_coherent_warn;850bool EXT_shader_group_vote_enable;851bool EXT_shader_group_vote_warn;852bool EXT_shader_image_load_formatted_enable;853bool EXT_shader_image_load_formatted_warn;854bool EXT_shader_image_load_store_enable;855bool EXT_shader_image_load_store_warn;856bool EXT_shader_implicit_conversions_enable;857bool EXT_shader_implicit_conversions_warn;858bool EXT_shader_integer_mix_enable;859bool EXT_shader_integer_mix_warn;860bool EXT_shader_io_blocks_enable;861bool EXT_shader_io_blocks_warn;862bool EXT_shader_samples_identical_enable;863bool EXT_shader_samples_identical_warn;864bool EXT_tessellation_point_size_enable;865bool EXT_tessellation_point_size_warn;866bool EXT_tessellation_shader_enable;867bool EXT_tessellation_shader_warn;868bool EXT_texture_array_enable;869bool EXT_texture_array_warn;870bool EXT_texture_buffer_enable;871bool EXT_texture_buffer_warn;872bool EXT_texture_cube_map_array_enable;873bool EXT_texture_cube_map_array_warn;874bool EXT_texture_query_lod_enable;875bool EXT_texture_query_lod_warn;876bool EXT_texture_shadow_lod_enable;877bool EXT_texture_shadow_lod_warn;878bool INTEL_conservative_rasterization_enable;879bool INTEL_conservative_rasterization_warn;880bool INTEL_shader_atomic_float_minmax_enable;881bool INTEL_shader_atomic_float_minmax_warn;882bool INTEL_shader_integer_functions2_enable;883bool INTEL_shader_integer_functions2_warn;884bool MESA_shader_integer_functions_enable;885bool MESA_shader_integer_functions_warn;886bool NV_compute_shader_derivatives_enable;887bool NV_compute_shader_derivatives_warn;888bool NV_fragment_shader_interlock_enable;889bool NV_fragment_shader_interlock_warn;890bool NV_image_formats_enable;891bool NV_image_formats_warn;892bool NV_shader_atomic_float_enable;893bool NV_shader_atomic_float_warn;894bool NV_shader_atomic_int64_enable;895bool NV_shader_atomic_int64_warn;896bool NV_viewport_array2_enable;897bool NV_viewport_array2_warn;898/*@}*/899900/** Extensions supported by the OpenGL implementation. */901const struct gl_extensions *extensions;902903bool uses_builtin_functions;904bool fs_uses_gl_fragcoord;905906/**907* For geometry shaders, size of the most recently seen input declaration908* that was a sized array, or 0 if no sized input array declarations have909* been seen.910*911* Unused for other shader types.912*/913unsigned gs_input_size;914915bool fs_early_fragment_tests;916917bool fs_inner_coverage;918919bool fs_post_depth_coverage;920921bool fs_pixel_interlock_ordered;922bool fs_pixel_interlock_unordered;923bool fs_sample_interlock_ordered;924bool fs_sample_interlock_unordered;925926unsigned fs_blend_support;927928/**929* For tessellation control shaders, size of the most recently seen output930* declaration that was a sized array, or 0 if no sized output array931* declarations have been seen.932*933* Unused for other shader types.934*/935unsigned tcs_output_size;936937/** Atomic counter offsets by binding */938unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];939940/** Whether gl_Layer output is viewport-relative. */941bool redeclares_gl_layer;942bool layer_viewport_relative;943944bool allow_extension_directive_midshader;945bool allow_glsl_120_subset_in_110;946bool allow_builtin_variable_redeclaration;947bool ignore_write_to_readonly_var;948949/**950* Known subroutine type declarations.951*/952int num_subroutine_types;953ir_function **subroutine_types;954955/**956* Functions that are associated with957* subroutine types.958*/959int num_subroutines;960ir_function **subroutines;961962/**963* field selection temporary parser storage -964* did the parser just parse a dot.965*/966bool is_field;967968/**969* seen values for clip/cull distance sizes970* so we can check totals aren't too large.971*/972unsigned clip_dist_size, cull_dist_size;973};974975# define YYLLOC_DEFAULT(Current, Rhs, N) \976do { \977if (N) \978{ \979(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \980(Current).first_column = YYRHSLOC(Rhs, 1).first_column; \981(Current).last_line = YYRHSLOC(Rhs, N).last_line; \982(Current).last_column = YYRHSLOC(Rhs, N).last_column; \983(Current).path = YYRHSLOC(Rhs, N).path; \984} \985else \986{ \987(Current).first_line = (Current).last_line = \988YYRHSLOC(Rhs, 0).last_line; \989(Current).first_column = (Current).last_column = \990YYRHSLOC(Rhs, 0).last_column; \991(Current).path = YYRHSLOC(Rhs, 0).path; \992} \993(Current).source = 0; \994} while (0)995996/**997* Emit a warning to the shader log998*999* \sa _mesa_glsl_error1000*/1001extern void _mesa_glsl_warning(const YYLTYPE *locp,1002_mesa_glsl_parse_state *state,1003const char *fmt, ...);10041005extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,1006const char *string);10071008extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state);10091010union YYSTYPE;1011extern int _mesa_glsl_lexer_lex(union YYSTYPE *yylval, YYLTYPE *yylloc,1012void *scanner);10131014extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *);10151016/**1017* Process elements of the #extension directive1018*1019* \return1020* If \c name and \c behavior are valid, \c true is returned. Otherwise1021* \c false is returned.1022*/1023extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,1024const char *behavior,1025YYLTYPE *behavior_locp,1026_mesa_glsl_parse_state *state);10271028#endif /* __cplusplus */102910301031/*1032* These definitions apply to C and C++1033*/1034#ifdef __cplusplus1035extern "C" {1036#endif10371038struct glcpp_parser;1039struct _mesa_glsl_parse_state;10401041typedef void (*glcpp_extension_iterator)(1042struct _mesa_glsl_parse_state *state,1043void (*add_builtin_define)(struct glcpp_parser *, const char *, int),1044struct glcpp_parser *data,1045unsigned version,1046bool es);10471048extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,1049glcpp_extension_iterator extensions,1050struct _mesa_glsl_parse_state *state,1051struct gl_context *gl_ctx);10521053extern void1054_mesa_glsl_copy_symbols_from_table(struct exec_list *shader_ir,1055struct glsl_symbol_table *src,1056struct glsl_symbol_table *dest);10571058#ifdef __cplusplus1059}1060#endif106110621063#endif /* GLSL_PARSER_EXTRAS_H */106410651066