X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcompiler%2Fglsl%2Fglsl_parser_extras.h;h=bd1392f7ce1a3eabc42c725899b950e9c2af57bf;hb=a3a8322dcd7aaede8dedff131c7d73bdbe3f06f9;hp=3311688aa6fe985cf3027b6c85b38265ef5616d1;hpb=d7cd7b9c49ab01b954702783493fe22cd2bb38f1;p=mesa.git diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index 3311688aa6f..bd1392f7ce1 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -21,7 +21,6 @@ * DEALINGS IN THE SOFTWARE. */ -#pragma once #ifndef GLSL_PARSER_EXTRAS_H #define GLSL_PARSER_EXTRAS_H @@ -34,6 +33,11 @@ #include #include "glsl_symbol_table.h" +/* THIS is a macro defined somewhere deep in the Windows MSVC header files. + * Undefine it here to avoid collision with the lexer's THIS token. + */ +#undef THIS + struct gl_context; struct glsl_switch_state { @@ -64,19 +68,21 @@ typedef struct YYLTYPE { int last_line; int last_column; unsigned source; + /* Path for ARB_shading_language_include include source */ + char *path; } YYLTYPE; # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, - const char *fmt, ...); + const char *fmt, ...); struct _mesa_glsl_parse_state { _mesa_glsl_parse_state(struct gl_context *_ctx, gl_shader_stage stage, - void *mem_ctx); + void *mem_ctx); - DECLARE_RALLOC_CXX_OPERATORS(_mesa_glsl_parse_state); + DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state); /** * Generate a string representing the GLSL version currently being compiled @@ -137,7 +143,8 @@ struct _mesa_glsl_parse_state { bool check_bitwise_operations_allowed(YYLTYPE *locp) { - return check_version(130, 300, locp, "bit-wise operations are forbidden"); + return EXT_gpu_shader4_enable || + check_version(130, 300, locp, "bit-wise operations are forbidden"); } bool check_explicit_attrib_stream_allowed(YYLTYPE *locp) @@ -250,6 +257,12 @@ struct _mesa_glsl_parse_state { return ARB_gpu_shader_fp64_enable || is_version(400, 0); } + bool has_int64() const + { + return ARB_gpu_shader_int64_enable || + AMD_gpu_shader_int64_enable; + } + bool has_420pack() const { return ARB_shading_language_420pack_enable || is_version(420, 0); @@ -277,6 +290,7 @@ struct _mesa_glsl_parse_state { return OES_shader_io_blocks_enable || EXT_shader_io_blocks_enable || OES_geometry_shader_enable || + EXT_geometry_shader_enable || OES_tessellation_shader_enable || EXT_tessellation_shader_enable || @@ -285,7 +299,8 @@ struct _mesa_glsl_parse_state { bool has_geometry_shader() const { - return OES_geometry_shader_enable || is_version(150, 320); + return OES_geometry_shader_enable || EXT_geometry_shader_enable || + is_version(150, 320); } bool has_tessellation_shader() const @@ -311,8 +326,46 @@ struct _mesa_glsl_parse_state { bool has_framebuffer_fetch() const { return EXT_shader_framebuffer_fetch_enable || - MESA_shader_framebuffer_fetch_enable || - MESA_shader_framebuffer_fetch_non_coherent_enable; + EXT_shader_framebuffer_fetch_non_coherent_enable; + } + + bool has_texture_cube_map_array() const + { + return ARB_texture_cube_map_array_enable || + EXT_texture_cube_map_array_enable || + OES_texture_cube_map_array_enable || + is_version(400, 320); + } + + bool has_shader_image_load_store() const + { + return ARB_shader_image_load_store_enable || + EXT_shader_image_load_store_enable || + is_version(420, 310); + } + + bool has_bindless() const + { + return ARB_bindless_texture_enable; + } + + bool has_image_load_formatted() const + { + return EXT_shader_image_load_formatted_enable; + } + + bool has_implicit_conversions() const + { + return EXT_shader_implicit_conversions_enable || + is_version(allow_glsl_120_subset_in_110 ? 110 : 120, 0); + } + + bool has_implicit_int_to_uint_conversion() const + { + return ARB_gpu_shader5_enable || + MESA_shader_integer_functions_enable || + EXT_shader_implicit_conversions_enable || + is_version(400, 0); } void process_version_directive(YYLTYPE *locp, int version, @@ -323,17 +376,21 @@ struct _mesa_glsl_parse_state { exec_list translation_unit; glsl_symbol_table *symbols; + void *linalloc; + unsigned num_supported_versions; struct { unsigned ver; uint8_t gl_ver; bool es; - } supported_versions[16]; + } supported_versions[17]; bool es_shader; + bool compat_shader; unsigned language_version; unsigned forced_language_version; - bool zero_init; + /* Bitfield of ir_variable_mode to zero init */ + uint32_t zero_init; unsigned gl_version; gl_shader_stage stage; @@ -394,6 +451,28 @@ struct _mesa_glsl_parse_state { */ unsigned cs_input_local_size[3]; + /** + * True if a compute shader input local variable size was specified using + * a layout directive as specified by ARB_compute_variable_group_size. + */ + bool cs_input_local_size_variable_specified; + + /** + * Arrangement of invocations used to calculate derivatives in a compute + * shader. From NV_compute_shader_derivatives. + */ + enum gl_derivative_group cs_derivative_group; + + /** + * True if a shader declare bindless_sampler/bindless_image, and + * respectively bound_sampler/bound_image at global scope as specified by + * ARB_bindless_texture. + */ + bool bindless_sampler_specified; + bool bindless_image_specified; + bool bound_sampler_specified; + bool bound_image_specified; + /** * Output layout qualifiers from GLSL 1.50 (geometry shader controls), * and GLSL 4.00 (tessellation control shader). @@ -446,6 +525,7 @@ struct _mesa_glsl_parse_state { unsigned MaxVertexOutputComponents; unsigned MaxGeometryInputComponents; unsigned MaxGeometryOutputComponents; + unsigned MaxGeometryShaderInvocations; unsigned MaxFragmentInputComponents; unsigned MaxGeometryTextureImageUnits; unsigned MaxGeometryOutputVertices; @@ -531,6 +611,10 @@ struct _mesa_glsl_parse_state { /** Have we found a return statement in this function? */ bool found_return; + /** Have we found the interlock builtins in this function? */ + bool found_begin_interlock; + bool found_end_interlock; + /** Was there an error during compilation? */ bool error; @@ -552,6 +636,13 @@ struct _mesa_glsl_parse_state { char *info_log; + /** + * Are warnings enabled? + * + * Emission of warngins is controlled by '#pragma warning(...)'. + */ + bool warnings_enabled; + /** * \name Enable bits for GLSL extensions */ @@ -564,8 +655,14 @@ struct _mesa_glsl_parse_state { bool ARB_ES3_2_compatibility_warn; bool ARB_arrays_of_arrays_enable; bool ARB_arrays_of_arrays_warn; + bool ARB_bindless_texture_enable; + bool ARB_bindless_texture_warn; + bool ARB_compatibility_enable; + bool ARB_compatibility_warn; bool ARB_compute_shader_enable; bool ARB_compute_shader_warn; + bool ARB_compute_variable_group_size_enable; + bool ARB_compute_variable_group_size_warn; bool ARB_conservative_depth_enable; bool ARB_conservative_depth_warn; bool ARB_cull_distance_enable; @@ -586,10 +683,16 @@ struct _mesa_glsl_parse_state { bool ARB_fragment_coord_conventions_warn; bool ARB_fragment_layer_viewport_enable; bool ARB_fragment_layer_viewport_warn; + bool ARB_fragment_shader_interlock_enable; + bool ARB_fragment_shader_interlock_warn; bool ARB_gpu_shader5_enable; bool ARB_gpu_shader5_warn; bool ARB_gpu_shader_fp64_enable; bool ARB_gpu_shader_fp64_warn; + bool ARB_gpu_shader_int64_enable; + bool ARB_gpu_shader_int64_warn; + bool ARB_post_depth_coverage_enable; + bool ARB_post_depth_coverage_warn; bool ARB_sample_shading_enable; bool ARB_sample_shading_warn; bool ARB_separate_shader_objects_enable; @@ -598,6 +701,8 @@ struct _mesa_glsl_parse_state { bool ARB_shader_atomic_counter_ops_warn; bool ARB_shader_atomic_counters_enable; bool ARB_shader_atomic_counters_warn; + bool ARB_shader_ballot_enable; + bool ARB_shader_ballot_warn; bool ARB_shader_bit_encoding_enable; bool ARB_shader_bit_encoding_warn; bool ARB_shader_clock_enable; @@ -622,8 +727,12 @@ struct _mesa_glsl_parse_state { bool ARB_shader_texture_image_samples_warn; bool ARB_shader_texture_lod_enable; bool ARB_shader_texture_lod_warn; + bool ARB_shader_viewport_layer_array_enable; + bool ARB_shader_viewport_layer_array_warn; bool ARB_shading_language_420pack_enable; bool ARB_shading_language_420pack_warn; + bool ARB_shading_language_include_enable; + bool ARB_shading_language_include_warn; bool ARB_shading_language_packing_enable; bool ARB_shading_language_packing_warn; bool ARB_tessellation_shader_enable; @@ -649,17 +758,23 @@ struct _mesa_glsl_parse_state { /* KHR extensions go here, sorted alphabetically. */ + bool KHR_blend_equation_advanced_enable; + bool KHR_blend_equation_advanced_warn; /* OES extensions go here, sorted alphabetically. */ bool OES_EGL_image_external_enable; bool OES_EGL_image_external_warn; + bool OES_EGL_image_external_essl3_enable; + bool OES_EGL_image_external_essl3_warn; bool OES_geometry_point_size_enable; bool OES_geometry_point_size_warn; bool OES_geometry_shader_enable; bool OES_geometry_shader_warn; bool OES_gpu_shader5_enable; bool OES_gpu_shader5_warn; + bool OES_primitive_bounding_box_enable; + bool OES_primitive_bounding_box_warn; bool OES_sample_variables_enable; bool OES_sample_variables_warn; bool OES_shader_image_atomic_enable; @@ -678,33 +793,67 @@ struct _mesa_glsl_parse_state { bool OES_texture_3D_warn; bool OES_texture_buffer_enable; bool OES_texture_buffer_warn; + bool OES_texture_cube_map_array_enable; + bool OES_texture_cube_map_array_warn; bool OES_texture_storage_multisample_2d_array_enable; bool OES_texture_storage_multisample_2d_array_warn; + bool OES_viewport_array_enable; + bool OES_viewport_array_warn; /* All other extensions go here, sorted alphabetically. */ bool AMD_conservative_depth_enable; bool AMD_conservative_depth_warn; + bool AMD_gpu_shader_int64_enable; + bool AMD_gpu_shader_int64_warn; bool AMD_shader_stencil_export_enable; bool AMD_shader_stencil_export_warn; bool AMD_shader_trinary_minmax_enable; bool AMD_shader_trinary_minmax_warn; + bool AMD_texture_texture4_enable; + bool AMD_texture_texture4_warn; bool AMD_vertex_shader_layer_enable; bool AMD_vertex_shader_layer_warn; bool AMD_vertex_shader_viewport_index_enable; bool AMD_vertex_shader_viewport_index_warn; + bool ANDROID_extension_pack_es31a_enable; + bool ANDROID_extension_pack_es31a_warn; bool EXT_blend_func_extended_enable; bool EXT_blend_func_extended_warn; bool EXT_clip_cull_distance_enable; bool EXT_clip_cull_distance_warn; + bool EXT_demote_to_helper_invocation_enable; + bool EXT_demote_to_helper_invocation_warn; bool EXT_draw_buffers_enable; bool EXT_draw_buffers_warn; + bool EXT_draw_instanced_enable; + bool EXT_draw_instanced_warn; + bool EXT_frag_depth_enable; + bool EXT_frag_depth_warn; + bool EXT_geometry_point_size_enable; + bool EXT_geometry_point_size_warn; + bool EXT_geometry_shader_enable; + bool EXT_geometry_shader_warn; + bool EXT_gpu_shader4_enable; + bool EXT_gpu_shader4_warn; bool EXT_gpu_shader5_enable; bool EXT_gpu_shader5_warn; + bool EXT_primitive_bounding_box_enable; + bool EXT_primitive_bounding_box_warn; bool EXT_separate_shader_objects_enable; bool EXT_separate_shader_objects_warn; bool EXT_shader_framebuffer_fetch_enable; bool EXT_shader_framebuffer_fetch_warn; + bool EXT_shader_framebuffer_fetch_non_coherent_enable; + bool EXT_shader_framebuffer_fetch_non_coherent_warn; + bool EXT_shader_group_vote_enable; + bool EXT_shader_group_vote_warn; + bool EXT_shader_image_load_formatted_enable; + bool EXT_shader_image_load_formatted_warn; + bool EXT_shader_image_load_store_enable; + bool EXT_shader_image_load_store_warn; + bool EXT_shader_implicit_conversions_enable; + bool EXT_shader_implicit_conversions_warn; bool EXT_shader_integer_mix_enable; bool EXT_shader_integer_mix_warn; bool EXT_shader_io_blocks_enable; @@ -719,12 +868,30 @@ struct _mesa_glsl_parse_state { bool EXT_texture_array_warn; bool EXT_texture_buffer_enable; bool EXT_texture_buffer_warn; - bool MESA_shader_framebuffer_fetch_enable; - bool MESA_shader_framebuffer_fetch_warn; - bool MESA_shader_framebuffer_fetch_non_coherent_enable; - bool MESA_shader_framebuffer_fetch_non_coherent_warn; + bool EXT_texture_cube_map_array_enable; + bool EXT_texture_cube_map_array_warn; + bool EXT_texture_query_lod_enable; + bool EXT_texture_query_lod_warn; + bool EXT_texture_shadow_lod_enable; + bool EXT_texture_shadow_lod_warn; + bool INTEL_conservative_rasterization_enable; + bool INTEL_conservative_rasterization_warn; + bool INTEL_shader_atomic_float_minmax_enable; + bool INTEL_shader_atomic_float_minmax_warn; + bool INTEL_shader_integer_functions2_enable; + bool INTEL_shader_integer_functions2_warn; bool MESA_shader_integer_functions_enable; bool MESA_shader_integer_functions_warn; + bool NV_compute_shader_derivatives_enable; + bool NV_compute_shader_derivatives_warn; + bool NV_fragment_shader_interlock_enable; + bool NV_fragment_shader_interlock_warn; + bool NV_image_formats_enable; + bool NV_image_formats_warn; + bool NV_shader_atomic_float_enable; + bool NV_shader_atomic_float_warn; + bool NV_viewport_array2_enable; + bool NV_viewport_array2_warn; /*@}*/ /** Extensions supported by the OpenGL implementation. */ @@ -744,6 +911,17 @@ struct _mesa_glsl_parse_state { bool fs_early_fragment_tests; + bool fs_inner_coverage; + + bool fs_post_depth_coverage; + + bool fs_pixel_interlock_ordered; + bool fs_pixel_interlock_unordered; + bool fs_sample_interlock_ordered; + bool fs_sample_interlock_unordered; + + unsigned fs_blend_support; + /** * For tessellation control shaders, size of the most recently seen output * declaration that was a sized array, or 0 if no sized output array @@ -756,7 +934,14 @@ struct _mesa_glsl_parse_state { /** Atomic counter offsets by binding */ unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS]; + /** Whether gl_Layer output is viewport-relative. */ + bool redeclares_gl_layer; + bool layer_viewport_relative; + bool allow_extension_directive_midshader; + bool allow_glsl_120_subset_in_110; + bool allow_builtin_variable_redeclaration; + bool allow_layout_qualifier_on_function_parameter; /** * Known subroutine type declarations. @@ -784,23 +969,25 @@ struct _mesa_glsl_parse_state { unsigned clip_dist_size, cull_dist_size; }; -# define YYLLOC_DEFAULT(Current, Rhs, N) \ -do { \ - if (N) \ - { \ - (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC(Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC(Rhs, 0).last_column; \ - } \ - (Current).source = 0; \ +# define YYLLOC_DEFAULT(Current, Rhs, N) \ +do { \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC(Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC(Rhs, N).last_column; \ + (Current).path = YYRHSLOC(Rhs, N).path; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC(Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC(Rhs, 0).last_column; \ + (Current).path = YYRHSLOC(Rhs, 0).path; \ + } \ + (Current).source = 0; \ } while (0) /** @@ -809,11 +996,11 @@ do { \ * \sa _mesa_glsl_error */ extern void _mesa_glsl_warning(const YYLTYPE *locp, - _mesa_glsl_parse_state *state, - const char *fmt, ...); + _mesa_glsl_parse_state *state, + const char *fmt, ...); extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, - const char *string); + const char *string); extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state); @@ -831,9 +1018,9 @@ extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *); * \c false is returned. */ extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, - const char *behavior, - YYLTYPE *behavior_locp, - _mesa_glsl_parse_state *state); + const char *behavior, + YYLTYPE *behavior_locp, + _mesa_glsl_parse_state *state); #endif /* __cplusplus */ @@ -846,21 +1033,24 @@ extern "C" { #endif struct glcpp_parser; +struct _mesa_glsl_parse_state; typedef void (*glcpp_extension_iterator)( - struct _mesa_glsl_parse_state *state, - void (*add_builtin_define)(struct glcpp_parser *, const char *, int), - struct glcpp_parser *data, - unsigned version, - bool es); + struct _mesa_glsl_parse_state *state, + void (*add_builtin_define)(struct glcpp_parser *, const char *, int), + struct glcpp_parser *data, + unsigned version, + bool es); extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log, glcpp_extension_iterator extensions, struct _mesa_glsl_parse_state *state, struct gl_context *gl_ctx); -extern void _mesa_destroy_shader_compiler(void); -extern void _mesa_destroy_shader_compiler_caches(void); +extern void +_mesa_glsl_copy_symbols_from_table(struct exec_list *shader_ir, + struct glsl_symbol_table *src, + struct glsl_symbol_table *dest); #ifdef __cplusplus }