Having bits as a struct makes it possible to enable them all easily. This functionality is used when deserializing shaders that are using glsl types introduced by the glsl extensions.
Signed-off-by: Tapani Pälli <tapani.pa...@intel.com> --- src/glsl/ast_function.cpp | 2 +- src/glsl/ast_to_hir.cpp | 20 ++++----- src/glsl/builtin_functions.cpp | 58 +++++++++++++------------- src/glsl/builtin_types.cpp | 14 +++---- src/glsl/builtin_variables.cpp | 22 +++++----- src/glsl/glsl_lexer.ll | 44 ++++++++++---------- src/glsl/glsl_parser.yy | 32 +++++++-------- src/glsl/glsl_parser_extras.cpp | 12 +++--- src/glsl/glsl_parser_extras.h | 80 ++++++++++++++++++++---------------- src/glsl/hir_field_selection.cpp | 6 +-- src/mesa/main/ff_fragment_shader.cpp | 2 +- 11 files changed, 151 insertions(+), 141 deletions(-) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 4c5b0e4..a27acc4e 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -1694,7 +1694,7 @@ ast_aggregate_initializer::hir(exec_list *instructions, } const glsl_type *const constructor_type = this->constructor_type; - if (!state->ARB_shading_language_420pack_enable) { + if (!state->ext.ARB_shading_language_420pack_enable) { _mesa_glsl_error(&loc, state, "C-style initialization requires the " "GL_ARB_shading_language_420pack extension"); return ir_rvalue::error_value(ctx); diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index c89a26b..543605d 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1864,7 +1864,7 @@ process_array_type(YYLTYPE *loc, const glsl_type *base, * * "Only one-dimensional arrays may be declared." */ - if (!state->ARB_arrays_of_arrays_enable) { + if (!state->ext.ARB_arrays_of_arrays_enable) { _mesa_glsl_error(loc, state, "invalid array of `%s'" "GL_ARB_arrays_of_arrays " @@ -2438,7 +2438,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, * allow layout with the deprecated keywords. */ const bool relaxed_layout_qualifier_checking = - state->ARB_fragment_coord_conventions_enable; + state->ext.ARB_fragment_coord_conventions_enable; if (qual->has_layout() && uses_deprecated_qualifier) { if (relaxed_layout_qualifier_checking) { @@ -2460,8 +2460,8 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, + qual->flags.q.depth_less + qual->flags.q.depth_unchanged; if (depth_layout_count > 0 - && !state->AMD_conservative_depth_enable - && !state->ARB_conservative_depth_enable) { + && !state->ext.AMD_conservative_depth_enable + && !state->ext.ARB_conservative_depth_enable) { _mesa_glsl_error(loc, state, "extension GL_AMD_conservative_depth or " "GL_ARB_conservative_depth must be enabled " @@ -2556,7 +2556,7 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc, earlier->type = var->type; delete var; var = NULL; - } else if ((state->ARB_fragment_coord_conventions_enable || + } else if ((state->ext.ARB_fragment_coord_conventions_enable || state->is_version(150, 0)) && strcmp(var->name, "gl_FragCoord") == 0 && earlier->type == var->type @@ -2589,8 +2589,8 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc, earlier->data.interpolation = var->data.interpolation; /* Layout qualifiers for gl_FragDepth. */ - } else if ((state->AMD_conservative_depth_enable || - state->ARB_conservative_depth_enable) + } else if ((state->ext.AMD_conservative_depth_enable || + state->ext.ARB_conservative_depth_enable) && strcmp(var->name, "gl_FragDepth") == 0 && earlier->type == var->type && earlier->data.mode == var->data.mode) { @@ -2700,7 +2700,7 @@ process_initializer(ir_variable *var, ast_declaration *decl, * expressions. Const-qualified global variables must still be * initialized with constant expressions. */ - if (!state->ARB_shading_language_420pack_enable + if (!state->ext.ARB_shading_language_420pack_enable || state->current_function == NULL) { _mesa_glsl_error(& initializer_loc, state, "initializer of %s variable `%s' must be a " @@ -3082,7 +3082,7 @@ ast_declarator_list::hir(exec_list *instructions, */ if (!state->is_version(130, 300) && !state->has_explicit_attrib_location() - && !state->ARB_fragment_coord_conventions_enable) { + && !state->ext.ARB_fragment_coord_conventions_enable) { if (this->type->qualifier.flags.q.out) { _mesa_glsl_error(& loc, state, "`out' qualifier in declaration of `%s' " @@ -3966,7 +3966,7 @@ ast_jump_statement::hir(exec_list *instructions, if (state->current_function->return_type != ret_type) { YYLTYPE loc = this->get_location(); - if (state->ARB_shading_language_420pack_enable) { + if (state->ext.ARB_shading_language_420pack_enable) { if (!apply_implicit_conversion(state->current_function->return_type, ret, state)) { _mesa_glsl_error(& loc, state, diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 2162baa..dabdc2d 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -134,13 +134,13 @@ v140(const _mesa_glsl_parse_state *state) static bool texture_rectangle(const _mesa_glsl_parse_state *state) { - return state->ARB_texture_rectangle_enable; + return state->ext.ARB_texture_rectangle_enable; } static bool texture_external(const _mesa_glsl_parse_state *state) { - return state->OES_EGL_image_external_enable; + return state->ext.OES_EGL_image_external_enable; } /** True if texturing functions with explicit LOD are allowed. */ @@ -157,7 +157,7 @@ lod_exists_in_stage(const _mesa_glsl_parse_state *state) */ return state->stage == MESA_SHADER_VERTEX || state->is_version(130, 300) || - state->ARB_shader_texture_lod_enable; + state->ext.ARB_shader_texture_lod_enable; } static bool @@ -169,75 +169,75 @@ v110_lod(const _mesa_glsl_parse_state *state) static bool shader_texture_lod(const _mesa_glsl_parse_state *state) { - return state->ARB_shader_texture_lod_enable; + return state->ext.ARB_shader_texture_lod_enable; } static bool shader_texture_lod_and_rect(const _mesa_glsl_parse_state *state) { - return state->ARB_shader_texture_lod_enable && - state->ARB_texture_rectangle_enable; + return state->ext.ARB_shader_texture_lod_enable && + state->ext.ARB_texture_rectangle_enable; } static bool shader_bit_encoding(const _mesa_glsl_parse_state *state) { return state->is_version(330, 300) || - state->ARB_shader_bit_encoding_enable || - state->ARB_gpu_shader5_enable; + state->ext.ARB_shader_bit_encoding_enable || + state->ext.ARB_gpu_shader5_enable; } static bool shader_integer_mix(const _mesa_glsl_parse_state *state) { - return v130(state) && state->EXT_shader_integer_mix_enable; + return v130(state) && state->ext.EXT_shader_integer_mix_enable; } static bool shader_packing(const _mesa_glsl_parse_state *state) { - return state->ARB_shading_language_packing_enable || + return state->ext.ARB_shading_language_packing_enable || state->is_version(400, 0); } static bool shader_packing_or_es3(const _mesa_glsl_parse_state *state) { - return state->ARB_shading_language_packing_enable || + return state->ext.ARB_shading_language_packing_enable || state->is_version(400, 300); } static bool gpu_shader5(const _mesa_glsl_parse_state *state) { - return state->is_version(400, 0) || state->ARB_gpu_shader5_enable; + return state->is_version(400, 0) || state->ext.ARB_gpu_shader5_enable; } static bool texture_array_lod(const _mesa_glsl_parse_state *state) { return lod_exists_in_stage(state) && - state->EXT_texture_array_enable; + state->ext.EXT_texture_array_enable; } static bool fs_texture_array(const _mesa_glsl_parse_state *state) { return state->stage == MESA_SHADER_FRAGMENT && - state->EXT_texture_array_enable; + state->ext.EXT_texture_array_enable; } static bool texture_array(const _mesa_glsl_parse_state *state) { - return state->EXT_texture_array_enable; + return state->ext.EXT_texture_array_enable; } static bool texture_multisample(const _mesa_glsl_parse_state *state) { return state->is_version(150, 0) || - state->ARB_texture_multisample_enable; + state->ext.ARB_texture_multisample_enable; } static bool @@ -245,36 +245,36 @@ fs_texture_cube_map_array(const _mesa_glsl_parse_state *state) { return state->stage == MESA_SHADER_FRAGMENT && (state->is_version(400, 0) || - state->ARB_texture_cube_map_array_enable); + state->ext.ARB_texture_cube_map_array_enable); } static bool texture_cube_map_array(const _mesa_glsl_parse_state *state) { return state->is_version(400, 0) || - state->ARB_texture_cube_map_array_enable; + state->ext.ARB_texture_cube_map_array_enable; } static bool texture_query_levels(const _mesa_glsl_parse_state *state) { return state->is_version(430, 0) || - state->ARB_texture_query_levels_enable; + state->ext.ARB_texture_query_levels_enable; } static bool texture_query_lod(const _mesa_glsl_parse_state *state) { return state->stage == MESA_SHADER_FRAGMENT && - state->ARB_texture_query_lod_enable; + state->ext.ARB_texture_query_lod_enable; } static bool texture_gather(const _mesa_glsl_parse_state *state) { return state->is_version(400, 0) || - state->ARB_texture_gather_enable || - state->ARB_gpu_shader5_enable; + state->ext.ARB_texture_gather_enable || + state->ext.ARB_gpu_shader5_enable; } /* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5. @@ -284,8 +284,8 @@ static bool texture_gather_only(const _mesa_glsl_parse_state *state) { return !state->is_version(400, 0) && - !state->ARB_gpu_shader5_enable && - state->ARB_texture_gather_enable; + !state->ext.ARB_gpu_shader5_enable && + state->ext.ARB_texture_gather_enable; } /* Desktop GL or OES_standard_derivatives + fragment shader only */ @@ -294,7 +294,7 @@ fs_oes_derivatives(const _mesa_glsl_parse_state *state) { return state->stage == MESA_SHADER_FRAGMENT && (state->is_version(110, 300) || - state->OES_standard_derivatives_enable); + state->ext.OES_standard_derivatives_enable); } static bool @@ -311,7 +311,7 @@ tex3d(const _mesa_glsl_parse_state *state) * OES_texture_3D extension, and in GLSL ES 3.00. */ return !state->es_shader || - state->OES_texture_3D_enable || + state->ext.OES_texture_3D_enable || state->language_version >= 300; } @@ -319,7 +319,7 @@ static bool fs_tex3d(const _mesa_glsl_parse_state *state) { return state->stage == MESA_SHADER_FRAGMENT && - (!state->es_shader || state->OES_texture_3D_enable); + (!state->es_shader || state->ext.OES_texture_3D_enable); } static bool @@ -331,13 +331,13 @@ tex3d_lod(const _mesa_glsl_parse_state *state) static bool shader_atomic_counters(const _mesa_glsl_parse_state *state) { - return state->ARB_shader_atomic_counters_enable; + return state->ext.ARB_shader_atomic_counters_enable; } static bool shader_trinary_minmax(const _mesa_glsl_parse_state *state) { - return state->AMD_shader_trinary_minmax_enable; + return state->ext.AMD_shader_trinary_minmax_enable; } /** @} */ diff --git a/src/glsl/builtin_types.cpp b/src/glsl/builtin_types.cpp index 92e3860..82b4bb4 100644 --- a/src/glsl/builtin_types.cpp +++ b/src/glsl/builtin_types.cpp @@ -251,14 +251,14 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) * by the version-based loop, but attempting to add them a second time * is harmless. */ - if (state->ARB_texture_cube_map_array_enable) { + if (state->ext.ARB_texture_cube_map_array_enable) { add_type(symbols, glsl_type::samplerCubeArray_type); add_type(symbols, glsl_type::samplerCubeArrayShadow_type); add_type(symbols, glsl_type::isamplerCubeArray_type); add_type(symbols, glsl_type::usamplerCubeArray_type); } - if (state->ARB_texture_multisample_enable) { + if (state->ext.ARB_texture_multisample_enable) { add_type(symbols, glsl_type::sampler2DMS_type); add_type(symbols, glsl_type::isampler2DMS_type); add_type(symbols, glsl_type::usampler2DMS_type); @@ -267,27 +267,27 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) add_type(symbols, glsl_type::usampler2DMSArray_type); } - if (state->ARB_texture_rectangle_enable) { + if (state->ext.ARB_texture_rectangle_enable) { add_type(symbols, glsl_type::sampler2DRect_type); add_type(symbols, glsl_type::sampler2DRectShadow_type); } - if (state->EXT_texture_array_enable) { + if (state->ext.EXT_texture_array_enable) { add_type(symbols, glsl_type::sampler1DArray_type); add_type(symbols, glsl_type::sampler2DArray_type); add_type(symbols, glsl_type::sampler1DArrayShadow_type); add_type(symbols, glsl_type::sampler2DArrayShadow_type); } - if (state->OES_EGL_image_external_enable) { + if (state->ext.OES_EGL_image_external_enable) { add_type(symbols, glsl_type::samplerExternalOES_type); } - if (state->OES_texture_3D_enable) { + if (state->ext.OES_texture_3D_enable) { add_type(symbols, glsl_type::sampler3D_type); } - if (state->ARB_shader_atomic_counters_enable) { + if (state->ext.ARB_shader_atomic_counters_enable) { add_type(symbols, glsl_type::atomic_uint_type); } } diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index cc42338..2ef6a98 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -600,7 +600,7 @@ builtin_variable_generator::generate_constants() * version 4.20 and GLSL ES version 3.00. */ if ((state->is_version(130, 0) && - state->ARB_shading_language_420pack_enable) || + state->ext.ARB_shading_language_420pack_enable) || state->is_version(420, 300)) { add_const("gl_MinProgramTexelOffset", state->Const.MinProgramTexelOffset); @@ -666,7 +666,7 @@ builtin_variable_generator::generate_constants() add_const("gl_MaxTextureCoords", state->Const.MaxTextureCoords); } - if (state->ARB_shader_atomic_counters_enable) { + if (state->ext.ARB_shader_atomic_counters_enable) { add_const("gl_MaxVertexAtomicCounters", state->Const.MaxVertexAtomicCounters); add_const("gl_MaxGeometryAtomicCounters", @@ -681,7 +681,7 @@ builtin_variable_generator::generate_constants() add_const("gl_MaxTessEvaluationAtomicCounters", 0); } - if (state->is_version(430, 0) || state->ARB_compute_shader_enable) { + if (state->is_version(430, 0) || state->ext.ARB_compute_shader_enable) { add_const_ivec3("gl_MaxComputeWorkGroupCount", state->Const.MaxComputeWorkGroupCount[0], state->Const.MaxComputeWorkGroupCount[1], @@ -801,11 +801,11 @@ builtin_variable_generator::generate_vs_special_vars() { if (state->is_version(130, 300)) add_system_value(SYSTEM_VALUE_VERTEX_ID, int_t, "gl_VertexID"); - if (state->ARB_draw_instanced_enable) + if (state->ext.ARB_draw_instanced_enable) add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceIDARB"); - if (state->ARB_draw_instanced_enable || state->is_version(140, 300)) + if (state->ext.ARB_draw_instanced_enable || state->is_version(140, 300)) add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceID"); - if (state->AMD_vertex_shader_layer_enable) + if (state->ext.AMD_vertex_shader_layer_enable) add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer"); if (compatibility) { add_input(VERT_ATTRIB_POS, vec4_t, "gl_Vertex"); @@ -832,7 +832,7 @@ void builtin_variable_generator::generate_gs_special_vars() { add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer"); - if (state->ARB_viewport_array_enable) + if (state->ext.ARB_viewport_array_enable) add_output(VARYING_SLOT_VIEWPORT, int_t, "gl_ViewportIndex"); /* Although gl_PrimitiveID appears in tessellation control and tessellation @@ -886,21 +886,21 @@ builtin_variable_generator::generate_fs_special_vars() if (state->is_version(110, 300)) add_output(FRAG_RESULT_DEPTH, float_t, "gl_FragDepth"); - if (state->ARB_shader_stencil_export_enable) { + if (state->ext.ARB_shader_stencil_export_enable) { ir_variable *const var = add_output(FRAG_RESULT_STENCIL, int_t, "gl_FragStencilRefARB"); if (state->ARB_shader_stencil_export_warn) var->warn_extension = "GL_ARB_shader_stencil_export"; } - if (state->AMD_shader_stencil_export_enable) { + if (state->ext.AMD_shader_stencil_export_enable) { ir_variable *const var = add_output(FRAG_RESULT_STENCIL, int_t, "gl_FragStencilRefAMD"); if (state->AMD_shader_stencil_export_warn) var->warn_extension = "GL_AMD_shader_stencil_export"; } - if (state->ARB_sample_shading_enable) { + if (state->ext.ARB_sample_shading_enable) { add_system_value(SYSTEM_VALUE_SAMPLE_ID, int_t, "gl_SampleID"); add_system_value(SYSTEM_VALUE_SAMPLE_POS, vec2_t, "gl_SamplePosition"); /* From the ARB_sample_shading specification: @@ -913,7 +913,7 @@ builtin_variable_generator::generate_fs_special_vars() add_output(FRAG_RESULT_SAMPLE_MASK, array(int_t, 1), "gl_SampleMask"); } - if (state->ARB_gpu_shader5_enable) { + if (state->ext.ARB_gpu_shader5_enable) { add_system_value(SYSTEM_VALUE_SAMPLE_MASK_IN, array(int_t, 1), "gl_SampleMaskIn"); } } diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll index 3208b32..f206d1c 100644 --- a/src/glsl/glsl_lexer.ll +++ b/src/glsl/glsl_lexer.ll @@ -317,40 +317,40 @@ usampler2DArray KEYWORD(130, 300, 130, 300, USAMPLER2DARRAY); /* additional keywords in ARB_texture_multisample, included in GLSL 1.50 */ /* these are reserved but not defined in GLSL 3.00 */ -sampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, SAMPLER2DMS); -isampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, ISAMPLER2DMS); -usampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, USAMPLER2DMS); -sampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, SAMPLER2DMSARRAY); -isampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, ISAMPLER2DMSARRAY); -usampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, USAMPLER2DMSARRAY); +sampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ext.ARB_texture_multisample_enable, SAMPLER2DMS); +isampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ext.ARB_texture_multisample_enable, ISAMPLER2DMS); +usampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ext.ARB_texture_multisample_enable, USAMPLER2DMS); +sampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ext.ARB_texture_multisample_enable, SAMPLER2DMSARRAY); +isampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ext.ARB_texture_multisample_enable, ISAMPLER2DMSARRAY); +usampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ext.ARB_texture_multisample_enable, USAMPLER2DMSARRAY); /* keywords available with ARB_texture_cube_map_array_enable extension on desktop GLSL */ -samplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAY); -isamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, ISAMPLERCUBEARRAY); -usamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, USAMPLERCUBEARRAY); -samplerCubeArrayShadow KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAYSHADOW); +samplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ext.ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAY); +isamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ext.ARB_texture_cube_map_array_enable, ISAMPLERCUBEARRAY); +usamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ext.ARB_texture_cube_map_array_enable, USAMPLERCUBEARRAY); +samplerCubeArrayShadow KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ext.ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAYSHADOW); samplerExternalOES { - if (yyextra->OES_EGL_image_external_enable) + if (yyextra->ext.OES_EGL_image_external_enable) return SAMPLEREXTERNALOES; else return IDENTIFIER; } -atomic_uint KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_atomic_counters_enable, ATOMIC_UINT); +atomic_uint KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ext.ARB_shader_atomic_counters_enable, ATOMIC_UINT); struct return STRUCT; void return VOID_TOK; layout { if ((yyextra->is_version(140, 300)) - || yyextra->AMD_conservative_depth_enable - || yyextra->ARB_conservative_depth_enable - || yyextra->ARB_explicit_attrib_location_enable - || yyextra->ARB_uniform_buffer_object_enable - || yyextra->ARB_fragment_coord_conventions_enable - || yyextra->ARB_shading_language_420pack_enable - || yyextra->ARB_compute_shader_enable) { + || yyextra->ext.AMD_conservative_depth_enable + || yyextra->ext.ARB_conservative_depth_enable + || yyextra->ext.ARB_explicit_attrib_location_enable + || yyextra->ext.ARB_uniform_buffer_object_enable + || yyextra->ext.ARB_fragment_coord_conventions_enable + || yyextra->ext.ARB_shading_language_420pack_enable + || yyextra->ext.ARB_compute_shader_enable) { return LAYOUT_TOK; } else { yylval->identifier = strdup(yytext); @@ -430,7 +430,7 @@ enum KEYWORD(110, 100, 0, 0, ENUM); typedef KEYWORD(110, 100, 0, 0, TYPEDEF); template KEYWORD(110, 100, 0, 0, TEMPLATE); this KEYWORD(110, 100, 0, 0, THIS); -packed KEYWORD_WITH_ALT(110, 100, 140, 300, yyextra->ARB_uniform_buffer_object_enable, PACKED_TOK); +packed KEYWORD_WITH_ALT(110, 100, 140, 300, yyextra->ext.ARB_uniform_buffer_object_enable, PACKED_TOK); goto KEYWORD(110, 100, 0, 0, GOTO); switch KEYWORD(110, 100, 130, 300, SWITCH); default KEYWORD(110, 100, 130, 300, DEFAULT); @@ -506,7 +506,7 @@ image2DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE2DARRAYSHADOW); imageBuffer KEYWORD(130, 300, 0, 0, IMAGEBUFFER); iimageBuffer KEYWORD(130, 300, 0, 0, IIMAGEBUFFER); uimageBuffer KEYWORD(130, 300, 0, 0, UIMAGEBUFFER); -row_major KEYWORD_WITH_ALT(130, 0, 140, 0, yyextra->ARB_uniform_buffer_object_enable && !yyextra->es_shader, ROW_MAJOR); +row_major KEYWORD_WITH_ALT(130, 0, 140, 0, yyextra->ext.ARB_uniform_buffer_object_enable && !yyextra->es_shader, ROW_MAJOR); /* Additional reserved words in GLSL 1.40 */ isampler2DRect KEYWORD(140, 300, 140, 0, ISAMPLER2DRECT); @@ -521,7 +521,7 @@ readonly KEYWORD(0, 300, 0, 0, READONLY); writeonly KEYWORD(0, 300, 0, 0, WRITEONLY); resource KEYWORD(0, 300, 0, 0, RESOURCE); patch KEYWORD(0, 300, 0, 0, PATCH); -sample KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_gpu_shader5_enable, SAMPLE); +sample KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ext.ARB_gpu_shader5_enable, SAMPLE); subroutine KEYWORD(0, 300, 0, 0, SUBROUTINE); diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index dc35c1a..3682a58 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -930,7 +930,7 @@ parameter_qualifier: if (($1.flags.q.in || $1.flags.q.out) && ($2.flags.q.in || $2.flags.q.out)) _mesa_glsl_error(&@1, state, "duplicate in/out/inout qualifier"); - if (!state->ARB_shading_language_420pack_enable && $2.flags.q.constant) + if (!state->ext.ARB_shading_language_420pack_enable && $2.flags.q.constant) _mesa_glsl_error(&@1, state, "const must be specified before " "in/out/inout"); @@ -942,7 +942,7 @@ parameter_qualifier: if ($2.precision != ast_precision_none) _mesa_glsl_error(&@1, state, "duplicate precision qualifier"); - if (!state->ARB_shading_language_420pack_enable && $2.flags.i != 0) + if (!state->ext.ARB_shading_language_420pack_enable && $2.flags.i != 0) _mesa_glsl_error(&@1, state, "precision qualifiers must come last"); $$ = $2; @@ -1121,7 +1121,7 @@ layout_qualifier_id: memset(& $$, 0, sizeof($$)); /* Layout qualifiers for ARB_fragment_coord_conventions. */ - if (!$$.flags.i && (state->ARB_fragment_coord_conventions_enable || + if (!$$.flags.i && (state->ext.ARB_fragment_coord_conventions_enable || state->is_version(150, 0))) { if (match_layout_qualifier($1, "origin_upper_left", state) == 0) { $$.flags.q.origin_upper_left = 1; @@ -1139,8 +1139,8 @@ layout_qualifier_id: /* Layout qualifiers for AMD/ARB_conservative_depth. */ if (!$$.flags.i && - (state->AMD_conservative_depth_enable || - state->ARB_conservative_depth_enable)) { + (state->ext.AMD_conservative_depth_enable || + state->ext.ARB_conservative_depth_enable)) { if (match_layout_qualifier($1, "depth_any", state) == 0) { $$.flags.q.depth_any = 1; } else if (match_layout_qualifier($1, "depth_greater", state) == 0) { @@ -1261,14 +1261,14 @@ layout_qualifier_id: } } - if ((state->ARB_shading_language_420pack_enable || - state->ARB_shader_atomic_counters_enable) && + if ((state->ext.ARB_shading_language_420pack_enable || + state->ext.ARB_shader_atomic_counters_enable) && match_layout_qualifier("binding", $1, state) == 0) { $$.flags.q.explicit_binding = 1; $$.binding = $3; } - if (state->ARB_shader_atomic_counters_enable && + if (state->ext.ARB_shader_atomic_counters_enable && match_layout_qualifier("offset", $1, state) == 0) { $$.flags.q.explicit_offset = 1; $$.offset = $3; @@ -1305,7 +1305,7 @@ layout_qualifier_id: local_size_qualifiers[i], $3); YYERROR; } else if (!state->is_version(430, 0) && - !state->ARB_compute_shader_enable) { + !state->ext.ARB_compute_shader_enable) { _mesa_glsl_error(& @3, state, "%s qualifier requires GLSL 4.30 or " "ARB_compute_shader", @@ -1450,7 +1450,7 @@ type_qualifier: "with layout(...)"); } - if (!state->ARB_shading_language_420pack_enable && $2.flags.q.invariant) { + if (!state->ext.ARB_shading_language_420pack_enable && $2.flags.q.invariant) { _mesa_glsl_error(&@1, state, "interpolation qualifiers must come " "after \"invariant\""); } @@ -1466,7 +1466,7 @@ type_qualifier: * appear to be any text indicating that it must come before the storage * qualifier, but always seems to in examples. */ - if (!state->ARB_shading_language_420pack_enable && $2.has_layout()) + if (!state->ext.ARB_shading_language_420pack_enable && $2.has_layout()) _mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers"); if ($2.flags.q.invariant) @@ -1488,7 +1488,7 @@ type_qualifier: "duplicate auxiliary storage qualifier (centroid or sample)"); } - if (!state->ARB_shading_language_420pack_enable && + if (!state->ext.ARB_shading_language_420pack_enable && ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout())) { _mesa_glsl_error(&@1, state, "auxiliary storage qualifiers must come " "just before storage qualifiers"); @@ -1505,7 +1505,7 @@ type_qualifier: if ($2.has_storage()) _mesa_glsl_error(&@1, state, "duplicate storage qualifier"); - if (!state->ARB_shading_language_420pack_enable && + if (!state->ext.ARB_shading_language_420pack_enable && ($2.flags.q.invariant || $2.has_interpolation() || $2.has_layout() || $2.has_auxiliary_storage())) { _mesa_glsl_error(&@1, state, "storage qualifiers must come after " @@ -1521,7 +1521,7 @@ type_qualifier: if ($2.precision != ast_precision_none) _mesa_glsl_error(&@1, state, "duplicate precision qualifier"); - if (!state->ARB_shading_language_420pack_enable && $2.flags.i != 0) + if (!state->ext.ARB_shading_language_420pack_enable && $2.flags.i != 0) _mesa_glsl_error(&@1, state, "precision qualifiers must come last"); $$ = $2; @@ -1590,7 +1590,7 @@ array_specifier: { $$ = $1; - if (!state->ARB_arrays_of_arrays_enable) { + if (!state->ext.ARB_arrays_of_arrays_enable) { _mesa_glsl_error(& @1, state, "GL_ARB_arrays_of_arrays " "required for defining arrays of arrays"); @@ -1604,7 +1604,7 @@ array_specifier: { $$ = $1; - if (!state->ARB_arrays_of_arrays_enable) { + if (!state->ext.ARB_arrays_of_arrays_enable) { _mesa_glsl_error(& @1, state, "GL_ARB_arrays_of_arrays " "required for defining arrays of arrays"); diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index b822d22..779336f 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -82,13 +82,13 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this->language_version = ctx->Const.ForceGLSLVersion ? ctx->Const.ForceGLSLVersion : 110; this->es_shader = false; - this->ARB_texture_rectangle_enable = true; + this->ext.ARB_texture_rectangle_enable = true; /* OpenGL ES 2.0 has different defaults from desktop GL. */ if (ctx->API == API_OPENGLES2) { this->language_version = 100; this->es_shader = true; - this->ARB_texture_rectangle_enable = false; + this->ext.ARB_texture_rectangle_enable = false; } this->extensions = &ctx->Extensions; @@ -299,7 +299,7 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version, } if (this->es_shader) { - this->ARB_texture_rectangle_enable = false; + this->ext.ARB_texture_rectangle_enable = false; } this->language_version = version; @@ -467,7 +467,7 @@ struct _mesa_glsl_extension { * See note in _mesa_glsl_extension::supported_flag about "pointer * to member" types. */ - bool _mesa_glsl_parse_state::* enable_flag; + bool _mesa_glsl_parse_state::extension_enable_bits::* enable_flag; /** * Flag in the _mesa_glsl_parse_state struct that should be set @@ -485,7 +485,7 @@ struct _mesa_glsl_extension { #define EXT(NAME, GL, ES, SUPPORTED_FLAG) \ { "GL_" #NAME, GL, ES, &gl_extensions::SUPPORTED_FLAG, \ - &_mesa_glsl_parse_state::NAME##_enable, \ + &_mesa_glsl_parse_state::extension_enable_bits::NAME##_enable, \ &_mesa_glsl_parse_state::NAME##_warn } /** @@ -569,7 +569,7 @@ void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state, * offsets this->enable_flag and this->warn_flag. See * _mesa_glsl_extension::supported_flag for more info. */ - state->*(this->enable_flag) = (behavior != extension_disable); + state->ext.*(this->enable_flag) = (behavior != extension_disable); state->*(this->warn_flag) = (behavior == extension_warn); } diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 7d66147..e923082 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -137,12 +137,12 @@ struct _mesa_glsl_parse_state { bool has_explicit_attrib_location() const { - return ARB_explicit_attrib_location_enable || is_version(330, 300); + return ext.ARB_explicit_attrib_location_enable || is_version(330, 300); } bool has_uniform_buffer_objects() const { - return ARB_uniform_buffer_object_enable || is_version(140, 300); + return ext.ARB_uniform_buffer_object_enable || is_version(140, 300); } void process_version_directive(YYLTYPE *locp, int version, @@ -309,73 +309,83 @@ struct _mesa_glsl_parse_state { char *info_log; + struct extension_enable_bits { + + /** + * \name Enable bits for GLSL extensions + */ + /*@{*/ + bool ARB_arrays_of_arrays_enable; + bool ARB_draw_buffers_enable; + bool ARB_draw_instanced_enable; + bool ARB_explicit_attrib_location_enable; + bool ARB_fragment_coord_conventions_enable; + bool ARB_texture_rectangle_enable; + bool ARB_texture_gather_enable; + bool EXT_texture_array_enable; + bool ARB_shader_texture_lod_enable; + bool ARB_shader_stencil_export_enable; + bool AMD_conservative_depth_enable; + bool ARB_conservative_depth_enable; + bool AMD_shader_stencil_export_enable; + bool OES_texture_3D_enable; + bool OES_EGL_image_external_enable; + bool ARB_shader_bit_encoding_enable; + bool ARB_uniform_buffer_object_enable; + bool OES_standard_derivatives_enable; + bool ARB_texture_cube_map_array_enable; + bool ARB_shading_language_packing_enable; + bool ARB_texture_multisample_enable; + bool ARB_texture_query_levels_enable; + bool ARB_texture_query_lod_enable; + bool ARB_gpu_shader5_enable; + bool AMD_vertex_shader_layer_enable; + bool ARB_shading_language_420pack_enable; + bool ARB_sample_shading_enable; + bool EXT_shader_integer_mix_enable; + bool ARB_shader_atomic_counters_enable; + bool AMD_shader_trinary_minmax_enable; + bool ARB_viewport_array_enable; + bool ARB_compute_shader_enable; + /*@}*/ + + } ext; + /** - * \name Enable bits for GLSL extensions + * \name Warn bits for GLSL extensions */ /*@{*/ - bool ARB_arrays_of_arrays_enable; bool ARB_arrays_of_arrays_warn; - bool ARB_draw_buffers_enable; bool ARB_draw_buffers_warn; - bool ARB_draw_instanced_enable; bool ARB_draw_instanced_warn; - bool ARB_explicit_attrib_location_enable; bool ARB_explicit_attrib_location_warn; - bool ARB_fragment_coord_conventions_enable; bool ARB_fragment_coord_conventions_warn; - bool ARB_texture_rectangle_enable; bool ARB_texture_rectangle_warn; - bool ARB_texture_gather_enable; bool ARB_texture_gather_warn; - bool EXT_texture_array_enable; bool EXT_texture_array_warn; - bool ARB_shader_texture_lod_enable; bool ARB_shader_texture_lod_warn; - bool ARB_shader_stencil_export_enable; bool ARB_shader_stencil_export_warn; - bool AMD_conservative_depth_enable; bool AMD_conservative_depth_warn; - bool ARB_conservative_depth_enable; bool ARB_conservative_depth_warn; - bool AMD_shader_stencil_export_enable; bool AMD_shader_stencil_export_warn; - bool OES_texture_3D_enable; bool OES_texture_3D_warn; - bool OES_EGL_image_external_enable; bool OES_EGL_image_external_warn; - bool ARB_shader_bit_encoding_enable; bool ARB_shader_bit_encoding_warn; - bool ARB_uniform_buffer_object_enable; bool ARB_uniform_buffer_object_warn; - bool OES_standard_derivatives_enable; bool OES_standard_derivatives_warn; - bool ARB_texture_cube_map_array_enable; bool ARB_texture_cube_map_array_warn; - bool ARB_shading_language_packing_enable; bool ARB_shading_language_packing_warn; - bool ARB_texture_multisample_enable; bool ARB_texture_multisample_warn; - bool ARB_texture_query_levels_enable; bool ARB_texture_query_levels_warn; - bool ARB_texture_query_lod_enable; bool ARB_texture_query_lod_warn; - bool ARB_gpu_shader5_enable; bool ARB_gpu_shader5_warn; - bool AMD_vertex_shader_layer_enable; bool AMD_vertex_shader_layer_warn; - bool ARB_shading_language_420pack_enable; bool ARB_shading_language_420pack_warn; - bool ARB_sample_shading_enable; bool ARB_sample_shading_warn; - bool EXT_shader_integer_mix_enable; bool EXT_shader_integer_mix_warn; - bool ARB_shader_atomic_counters_enable; bool ARB_shader_atomic_counters_warn; - bool AMD_shader_trinary_minmax_enable; bool AMD_shader_trinary_minmax_warn; - bool ARB_viewport_array_enable; bool ARB_viewport_array_warn; - bool ARB_compute_shader_enable; bool ARB_compute_shader_warn; /*@}*/ diff --git a/src/glsl/hir_field_selection.cpp b/src/glsl/hir_field_selection.cpp index 1e92c89..f86b6e6 100644 --- a/src/glsl/hir_field_selection.cpp +++ b/src/glsl/hir_field_selection.cpp @@ -77,7 +77,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, result = new(ctx) ir_constant(op->type->array_size()); } else if (op->type->is_vector()) { - if (state->ARB_shading_language_420pack_enable) { + if (state->ext.ARB_shading_language_420pack_enable) { /* .length() returns int. */ result = new(ctx) ir_constant((int) op->type->vector_elements); } else { @@ -85,7 +85,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, "with ARB_shading_language_420pack"); } } else if (op->type->is_matrix()) { - if (state->ARB_shading_language_420pack_enable) { + if (state->ext.ARB_shading_language_420pack_enable) { /* .length() returns int. */ result = new(ctx) ir_constant((int) op->type->matrix_columns); } else { @@ -97,7 +97,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, _mesa_glsl_error(&loc, state, "unknown method: `%s'", method); } } else if (op->type->is_vector() || - (state->ARB_shading_language_420pack_enable && + (state->ext.ARB_shading_language_420pack_enable && op->type->is_scalar())) { ir_swizzle *swiz = ir_swizzle::create(op, expr->primary_expression.identifier, diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index cad67aa..25bee68 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -1315,7 +1315,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key) state->language_version = 130; state->es_shader = false; if (_mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external) - state->OES_EGL_image_external_enable = true; + state->ext.OES_EGL_image_external_enable = true; _mesa_glsl_initialize_types(state); _mesa_glsl_initialize_variables(p.instructions, state); -- 1.8.3.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev