[Mesa-dev] [PATCH 05/16] glsl: process blend_support_* qualifiers

Francisco Jerez currojerez at riseup.net
Tue Aug 16 21:45:16 UTC 2016


Kenneth Graunke <kenneth at whitecape.org> writes:

> From: Ilia Mirkin <imirkin at alum.mit.edu>
>
> v2 (Ken): Add a BLEND_NONE enum value (no qualifiers in use).
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> ---
>  src/compiler/glsl/ast.h                  |  5 ++++
>  src/compiler/glsl/ast_type.cpp           |  2 ++
>  src/compiler/glsl/glsl_parser.yy         | 45 ++++++++++++++++++++++++++++++++
>  src/compiler/glsl/glsl_parser_extras.cpp |  2 ++
>  src/compiler/glsl/glsl_parser_extras.h   |  2 ++
>  src/compiler/shader_enums.h              | 26 ++++++++++++++++++
>  src/mesa/main/mtypes.h                   |  5 ++++
>  7 files changed, 87 insertions(+)
>
> diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
> index 75018a0..4c648d0 100644
> --- a/src/compiler/glsl/ast.h
> +++ b/src/compiler/glsl/ast.h
> @@ -596,6 +596,11 @@ struct ast_type_qualifier {
>           unsigned subroutine:1;  /**< Is this marked 'subroutine' */
>           unsigned subroutine_def:1; /**< Is this marked 'subroutine' with a list of types */
>  	 /** \} */
> +
> +         /** \name Qualifiers for GL_KHR_blend_equation_advanced */
> +         /** \{ */
> +         unsigned blend_support:1; /**< Are there any blend_support_ qualifiers */
> +         /** \} */
>        }
>        /** \brief Set of flags, accessed by name. */
>        q;
> diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.cpp
> index cabc698..f3f6b29 100644
> --- a/src/compiler/glsl/ast_type.cpp
> +++ b/src/compiler/glsl/ast_type.cpp
> @@ -414,6 +414,8 @@ ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
>        valid_out_mask.flags.q.xfb_buffer = 1;
>        valid_out_mask.flags.q.explicit_xfb_stride = 1;
>        valid_out_mask.flags.q.xfb_stride = 1;
> +   } else if (state->stage == MESA_SHADER_FRAGMENT) {
> +      valid_out_mask.flags.q.blend_support = 1;
>     } else {
>        _mesa_glsl_error(loc, state, "out layout qualifiers only valid in "
>                         "geometry, tessellation and vertex shaders");
> diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
> index 5aa0daa..eb1a5df 100644
> --- a/src/compiler/glsl/glsl_parser.yy
> +++ b/src/compiler/glsl/glsl_parser.yy
> @@ -1447,6 +1447,51 @@ layout_qualifier_id:
>        }
>  
>        if (!$$.flags.i) {
> +         struct {
> +            const char *s;
> +            uint32_t mask;
> +         } map[] = {
> +                 { "blend_support_multiply",       BLEND_MULTIPLY },
> +                 { "blend_support_screen",         BLEND_SCREEN },
> +                 { "blend_support_overlay",        BLEND_OVERLAY },
> +                 { "blend_support_darken",         BLEND_DARKEN },
> +                 { "blend_support_lighten",        BLEND_LIGHTEN },
> +                 { "blend_support_colordodge",     BLEND_COLORDODGE },
> +                 { "blend_support_colorburn",      BLEND_COLORBURN },
> +                 { "blend_support_hardlight",      BLEND_HARDLIGHT },
> +                 { "blend_support_softlight",      BLEND_SOFTLIGHT },
> +                 { "blend_support_difference",     BLEND_DIFFERENCE },
> +                 { "blend_support_exclusion",      BLEND_EXCLUSION },
> +                 { "blend_support_hsl_hue",        BLEND_HSL_HUE },
> +                 { "blend_support_hsl_saturation", BLEND_HSL_SATURATION },
> +                 { "blend_support_hsl_color",      BLEND_HSL_COLOR },
> +                 { "blend_support_hsl_luminosity", BLEND_HSL_LUMINOSITY },
> +                 { "blend_support_all_equations",  BLEND_ALL },
> +         };
> +         for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
> +            if (match_layout_qualifier($1, map[i].s, state) == 0) {
> +               $$.flags.q.blend_support = 1;
> +               state->fs_blend_support |= map[i].mask;
> +               break;
> +            }
> +         }
> +
> +         if ($$.flags.i &&
> +             !state->KHR_blend_equation_advanced_enable &&
> +             !state->is_version(0, 320)) {
> +            _mesa_glsl_error(& @1, state,
> +                             "advanced blending layout qualifiers require "
> +                             "ESSL 3.20 or KHR_blend_equation_advanced");
> +         }
> +
> +         if ($$.flags.i && state->stage != MESA_SHADER_FRAGMENT) {
> +            _mesa_glsl_error(& @1, state,
> +                             "advanced blending layout qualifiers only "
> +                             "valid in fragment shaders");
> +         }
> +      }
> +
> +      if (!$$.flags.i) {
>           _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
>                            "`%s'", $1);
>           YYERROR;
> diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
> index 1ca49b3..2337eae 100644
> --- a/src/compiler/glsl/glsl_parser_extras.cpp
> +++ b/src/compiler/glsl/glsl_parser_extras.cpp
> @@ -292,6 +292,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
>     this->in_qualifier = new(this) ast_type_qualifier();
>     this->out_qualifier = new(this) ast_type_qualifier();
>     this->fs_early_fragment_tests = false;
> +   this->fs_blend_support = 0;
>     memset(this->atomic_counter_offsets, 0,
>            sizeof(this->atomic_counter_offsets));
>     this->allow_extension_directive_midshader =
> @@ -1765,6 +1766,7 @@ set_shader_inout_layout(struct gl_shader *shader,
>        shader->info.ARB_fragment_coord_conventions_enable =
>           state->ARB_fragment_coord_conventions_enable;
>        shader->info.EarlyFragmentTests = state->fs_early_fragment_tests;
> +      shader->info.BlendSupport = state->fs_blend_support;
>        break;
>  
>     default:
> diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
> index ad29149..f813609 100644
> --- a/src/compiler/glsl/glsl_parser_extras.h
> +++ b/src/compiler/glsl/glsl_parser_extras.h
> @@ -746,6 +746,8 @@ struct _mesa_glsl_parse_state {
>  
>     bool fs_early_fragment_tests;
>  
> +   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
> diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
> index a69905c..7a92e7c 100644
> --- a/src/compiler/shader_enums.h
> +++ b/src/compiler/shader_enums.h
> @@ -559,6 +559,32 @@ enum gl_buffer_access_qualifier
>     ACCESS_VOLATILE = 4,
>  };
>  
> +/**
> + * \brief Blend support qualifiers
> + */
> +enum gl_blend_support_qualifier
> +{
> +   BLEND_NONE           = 0x0000,
> +
> +   BLEND_MULTIPLY       = 0x0001,
> +   BLEND_SCREEN         = 0x0002,
> +   BLEND_OVERLAY        = 0x0004,
> +   BLEND_DARKEN         = 0x0008,
> +   BLEND_LIGHTEN        = 0x0010,
> +   BLEND_COLORDODGE     = 0x0020,
> +   BLEND_COLORBURN      = 0x0040,
> +   BLEND_HARDLIGHT      = 0x0080,
> +   BLEND_SOFTLIGHT      = 0x0100,
> +   BLEND_DIFFERENCE     = 0x0200,
> +   BLEND_EXCLUSION      = 0x0400,
> +   BLEND_HSL_HUE        = 0x0800,
> +   BLEND_HSL_SATURATION = 0x1000,
> +   BLEND_HSL_COLOR      = 0x2000,
> +   BLEND_HSL_LUMINOSITY = 0x4000,
> +
> +   BLEND_ALL            = 0x7fff,
> +};
> +
>  #ifdef __cplusplus
>  } /* extern "C" */
>  #endif
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 2159ee8..6a9e729 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2319,6 +2319,11 @@ struct gl_shader_info
>     bool EarlyFragmentTests;
>  
>     /**
> +    * A bitmask of gl_blend_support_qualifier values
> +    */
> +   GLbitfield BlendSupport;
> +
> +   /**
>      * Compute shader state from ARB_compute_shader layout qualifiers.
>      */
>     struct {
> -- 
> 2.9.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160816/7ac7f2e3/attachment.sig>


More information about the mesa-dev mailing list