[Mesa-dev] [PATCH] glsl: add GL_EXT_clip_cull_distance define, add helpers

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Wed May 25 06:02:55 UTC 2016


Reviewed-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>


On 25.05.2016 01:59, Ilia Mirkin wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>
> This addresses the feedback I got after pushing the enablement patch.
>
>   docs/relnotes/11.3.0.html               |  1 +
>   src/compiler/glsl/builtin_variables.cpp | 10 ++++------
>   src/compiler/glsl/glcpp/glcpp-parse.y   |  2 ++
>   src/compiler/glsl/glsl_parser_extras.h  | 12 ++++++++++++
>   4 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/docs/relnotes/11.3.0.html b/docs/relnotes/11.3.0.html
> index 5871ec8..8d6caa2 100644
> --- a/docs/relnotes/11.3.0.html
> +++ b/docs/relnotes/11.3.0.html
> @@ -59,6 +59,7 @@ Note: some of the new features are only available with certain drivers.
>   <li>GL_ARB_shader_storage_buffer_objects on radeonsi, softpipe</li>
>   <li>GL_ATI_fragment_shader on all Gallium drivers</li>
>   <li>GL_EXT_base_instance on all drivers that support GL_ARB_base_instance</li>
> +<li>GL_EXT_clip_cull_distance on all drivers that support GL_ARB_cull_distance</li>
>   <li>GL_OES_draw_buffers_indexed and GL_EXT_draw_buffers_indexed on all drivers that support GL_ARB_draw_buffers_blend</li>
>   <li>GL_OES_sample_shading on i965, nvc0, r600, radeonsi</li>
>   <li>GL_OES_sample_variables on i965, nvc0, r600, radeonsi</li>
> diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
> index 3d34028..15d791c 100644
> --- a/src/compiler/glsl/builtin_variables.cpp
> +++ b/src/compiler/glsl/builtin_variables.cpp
> @@ -674,14 +674,13 @@ builtin_variable_generator::generate_constants()
>                   state->Const.MaxProgramTexelOffset);
>      }
>   
> -   if (state->is_version(130, 0) || state->EXT_clip_cull_distance_enable) {
> +   if (state->has_clip_distance()) {
>         add_const("gl_MaxClipDistances", state->Const.MaxClipPlanes);
>      }
>      if (state->is_version(130, 0)) {
>         add_const("gl_MaxVaryingComponents", state->ctx->Const.MaxVarying * 4);
>      }
> -   if (state->is_version(450, 0) || state->ARB_cull_distance_enable ||
> -       state->EXT_clip_cull_distance_enable) {
> +   if (state->has_cull_distance()) {
>         add_const("gl_MaxCullDistances", state->Const.MaxClipPlanes);
>         add_const("gl_MaxCombinedClipAndCullDistances",
>                   state->Const.MaxClipPlanes);
> @@ -1259,12 +1258,11 @@ builtin_variable_generator::generate_varyings()
>         }
>      }
>   
> -   if (state->is_version(130, 0) || state->EXT_clip_cull_distance_enable) {
> +   if (state->has_clip_distance()) {
>          add_varying(VARYING_SLOT_CLIP_DIST0, array(float_t, 0),
>                      "gl_ClipDistance");
>      }
> -   if (state->is_version(450, 0) || state->ARB_cull_distance_enable ||
> -       state->EXT_clip_cull_distance_enable) {
> +   if (state->has_cull_distance()) {
>         add_varying(VARYING_SLOT_CULL_DIST0, array(float_t, 0),
>                      "gl_CullDistance");
>      }
> diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y
> index 820458a..8048f8d 100644
> --- a/src/compiler/glsl/glcpp/glcpp-parse.y
> +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
> @@ -2310,6 +2310,8 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
>               add_builtin_define(parser, "GL_OES_texture_storage_multisample_2d_array", 1);
>            if (extensions->ARB_blend_func_extended)
>               add_builtin_define(parser, "GL_EXT_blend_func_extended", 1);
> +         if (extensions->ARB_cull_distance)
> +            add_builtin_define(parser, "GL_EXT_clip_cull_distance", 1);
>   
>            if (version >= 310) {
>               if (extensions->ARB_shader_image_load_store)
> diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
> index 3afc9cb..2e77b24 100644
> --- a/src/compiler/glsl/glsl_parser_extras.h
> +++ b/src/compiler/glsl/glsl_parser_extras.h
> @@ -272,6 +272,18 @@ struct _mesa_glsl_parse_state {
>                is_version(150, 320);
>      }
>   
> +   bool has_clip_distance() const
> +   {
> +      return EXT_clip_cull_distance_enable || is_version(130, 0);
> +   }
> +
> +   bool has_cull_distance() const
> +   {
> +      return EXT_clip_cull_distance_enable ||
> +             ARB_cull_distance_enable ||
> +             is_version(450, 0);
> +   }
> +
>      void process_version_directive(YYLTYPE *locp, int version,
>                                     const char *ident);
>   



More information about the mesa-dev mailing list