[Mesa-dev] [PATCH 1/2] mesa: Add GL and GLSL plumbing for ARB_post_depth_coverage for i965 (gen9+).
Chris Forbes
chrisf at ijw.co.nz
Thu Dec 1 02:10:18 UTC 2016
This patch misses adding the #define to the GLSL preprocessor. Other than
that it looks good though, so with that fixed:
Reviewed-by: Chris Forbes <chrisforbes at google.com>
On Thu, Dec 1, 2016 at 8:53 AM, Plamena Manolova <plamena.manolova at intel.com
> wrote:
> This extension allows the fragment shader to control whether values in
> gl_SampleMaskIn[] reflect the coverage after application of the early
> depth and stencil tests.
>
> Signed-off-by: Plamena Manolova <plamena.manolova at intel.com>
> ---
> src/compiler/glsl/ast.h | 5 +++++
> src/compiler/glsl/ast_to_hir.cpp | 5 +++++
> src/compiler/glsl/ast_type.cpp | 9 ++++++++-
> src/compiler/glsl/glsl_parser.yy | 18 ++++++++++++++++++
> src/compiler/glsl/glsl_parser_extras.cpp | 4 ++++
> src/compiler/glsl/glsl_parser_extras.h | 4 ++++
> src/compiler/glsl/linker.cpp | 4 ++++
> src/compiler/shader_info.h | 1 +
> src/mesa/main/extensions_table.h | 1 +
> src/mesa/main/mtypes.h | 2 ++
> src/mesa/main/shaderapi.c | 1 +
> 11 files changed, 53 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
> index afe91ea..df3a744 100644
> --- a/src/compiler/glsl/ast.h
> +++ b/src/compiler/glsl/ast.h
> @@ -605,6 +605,11 @@ struct ast_type_qualifier {
> /** \{ */
> unsigned blend_support:1; /**< Are there any blend_support_
> qualifiers */
> /** \} */
> +
> + /**
> + * Flag set if GL_ARB_post_depth_coverage layout qualifier is
> used.
> + */
> + unsigned post_depth_coverage:1;
> }
> /** \brief Set of flags, accessed by name. */
> q;
> diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_
> hir.cpp
> index c2ce389..2434ce5 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -3632,6 +3632,11 @@ apply_layout_qualifier_to_variable(const struct
> ast_type_qualifier *qual,
> _mesa_glsl_error(loc, state, "early_fragment_tests layout qualifier
> only "
> "valid in fragment shader input layout
> declaration.");
> }
> +
> + if (qual->flags.q.post_depth_coverage) {
> + _mesa_glsl_error(loc, state, "post_depth_coverage layout qualifier
> only "
> + "valid in fragment shader input layout
> declaration.");
> + }
> }
>
> static void
> diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.
> cpp
> index 3431e24..aa1ae7e 100644
> --- a/src/compiler/glsl/ast_type.cpp
> +++ b/src/compiler/glsl/ast_type.cpp
> @@ -579,6 +579,7 @@ ast_type_qualifier::validate_in_qualifier(YYLTYPE
> *loc,
> break;
> case MESA_SHADER_FRAGMENT:
> valid_in_mask.flags.q.early_fragment_tests = 1;
> + valid_in_mask.flags.q.post_depth_coverage = 1;
> break;
> case MESA_SHADER_COMPUTE:
> valid_in_mask.flags.q.local_size = 7;
> @@ -633,6 +634,11 @@ ast_type_qualifier::merge_into_in_qualifier(YYLTYPE
> *loc,
> state->in_qualifier->flags.q.early_fragment_tests = false;
> }
>
> + if (state->in_qualifier->flags.q.post_depth_coverage) {
> + state->fs_post_depth_coverage = true;
> + state->in_qualifier->flags.q.post_depth_coverage = false;
> + }
> +
> /* We allow the creation of multiple cs_input_layout nodes. Coherence
> among
> * all existing nodes is checked later, when the AST node is
> transformed
> * into HIR.
> @@ -761,7 +767,8 @@ ast_type_qualifier::validate_flags(YYLTYPE *loc,
> bad.flags.q.point_mode ? " point_mode" : "",
> bad.flags.q.vertices ? " vertices" : "",
> bad.flags.q.subroutine ? " subroutine" : "",
> - bad.flags.q.subroutine_def ? " subroutine_def" : "");
> + bad.flags.q.subroutine_def ? " subroutine_def" : "",
> + bad.flags.q.post_depth_coverage ? "
> post_depth_coverage" : "");
> return false;
> }
>
> diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_
> parser.yy
> index 0c3781c..09b7e79 100644
> --- a/src/compiler/glsl/glsl_parser.yy
> +++ b/src/compiler/glsl/glsl_parser.yy
> @@ -1392,6 +1392,24 @@ layout_qualifier_id:
>
> $$.flags.q.early_fragment_tests = 1;
> }
> +
> + if (!$$.flags.i &&
> + match_layout_qualifier($1, "post_depth_coverage", state) ==
> 0) {
> + if (state->stage != MESA_SHADER_FRAGMENT) {
> + _mesa_glsl_error(& @1, state,
> + "post_depth_coverage layout qualifier
> only "
> + "valid in fragment shaders");
> + }
> +
> + if (state->ARB_post_depth_coverage_enable) {
> + $$.flags.q.post_depth_coverage = 1;
> + } else {
> + _mesa_glsl_error(& @1, state,
> + "post_depth_coverage layout qualifier
> present, "
> + "but the GL_ARB_post_depth_coverage
> extension "
> + "is not enabled.");
> + }
> + }
> }
>
> /* Layout qualifiers for tessellation evaluation shaders. */
> diff --git a/src/compiler/glsl/glsl_parser_extras.cpp
> b/src/compiler/glsl/glsl_parser_extras.cpp
> index 1e0298e..d1fc98d 100644
> --- a/src/compiler/glsl/glsl_parser_extras.cpp
> +++ b/src/compiler/glsl/glsl_parser_extras.cpp
> @@ -293,6 +293,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_post_depth_coverage = false;
> this->fs_blend_support = 0;
> memset(this->atomic_counter_offsets, 0,
> sizeof(this->atomic_counter_offsets));
> @@ -606,6 +607,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[]
> = {
> EXT(ARB_fragment_layer_viewport),
> EXT(ARB_gpu_shader5),
> EXT(ARB_gpu_shader_fp64),
> + EXT(ARB_post_depth_coverage),
> EXT(ARB_sample_shading),
> EXT(ARB_separate_shader_objects),
> EXT(ARB_shader_atomic_counter_ops),
> @@ -1690,6 +1692,7 @@ set_shader_inout_layout(struct gl_shader *shader,
> assert(!state->fs_pixel_center_integer);
> assert(!state->fs_origin_upper_left);
> assert(!state->fs_early_fragment_tests);
> + assert(!state->fs_post_depth_coverage);
> }
>
> for (unsigned i = 0; i < MAX_FEEDBACK_BUFFERS; i++) {
> @@ -1810,6 +1813,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.PostDepthCoverage = state->fs_post_depth_coverage;
> shader->info.BlendSupport = state->fs_blend_support;
> break;
>
> diff --git a/src/compiler/glsl/glsl_parser_extras.h
> b/src/compiler/glsl/glsl_parser_extras.h
> index d757c1d..4277d43 100644
> --- a/src/compiler/glsl/glsl_parser_extras.h
> +++ b/src/compiler/glsl/glsl_parser_extras.h
> @@ -610,6 +610,8 @@ struct _mesa_glsl_parse_state {
> bool ARB_gpu_shader5_warn;
> bool ARB_gpu_shader_fp64_enable;
> bool ARB_gpu_shader_fp64_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;
> @@ -786,6 +788,8 @@ struct _mesa_glsl_parse_state {
>
> bool fs_early_fragment_tests;
>
> + bool fs_post_depth_coverage;
> +
> unsigned fs_blend_support;
>
> /**
> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
> index 764938b..39c5e07 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -1887,6 +1887,10 @@ link_fs_inout_layout_qualifiers(struct
> gl_shader_program *prog,
>
> linked_shader->info.EarlyFragmentTests |=
> shader->info.EarlyFragmentTests;
> +
> + linked_shader->info.PostDepthCoverage |=
> + shader->info.PostDepthCoverage;
> +
> linked_shader->info.BlendSupport |= shader->info.BlendSupport;
> }
> }
> diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
> index 7ea5d9c..b2830e0 100644
> --- a/src/compiler/shader_info.h
> +++ b/src/compiler/shader_info.h
> @@ -116,6 +116,7 @@ typedef struct shader_info {
> * ARB_shader_image_load_store.
> */
> bool early_fragment_tests;
> + bool post_depth_coverage;
>
> /** gl_FragDepth layout for ARB_conservative_depth. */
> enum gl_frag_depth_layout depth_layout;
> diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_
> table.h
> index d3ec551..f2d3a5b 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -93,6 +93,7 @@ EXT(ARB_pipeline_statistics_query ,
> ARB_pipeline_statistics_query
> EXT(ARB_pixel_buffer_object , EXT_pixel_buffer_object
> , GLL, GLC, x , x , 2004)
> EXT(ARB_point_parameters , EXT_point_parameters
> , GLL, x , x , x , 1997)
> EXT(ARB_point_sprite , ARB_point_sprite
> , GLL, GLC, x , x , 2003)
> +EXT(ARB_post_depth_coverage , ARB_post_depth_coverage
> , x , 32, x , x, 2015)
> EXT(ARB_program_interface_query , dummy_true
> , GLL, GLC, x , x , 2012)
> EXT(ARB_provoking_vertex , EXT_provoking_vertex
> , GLL, GLC, x , x , 2009)
> EXT(ARB_query_buffer_object , ARB_query_buffer_object
> , GLL, GLC, x , x , 2013)
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 250877d..dfa9a78 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2174,6 +2174,7 @@ struct gl_shader_info
> {
> bool uses_gl_fragcoord;
> bool redeclares_gl_fragcoord;
> + bool PostDepthCoverage;
> bool ARB_fragment_coord_conventions_enable;
>
> /**
> @@ -3818,6 +3819,7 @@ struct gl_extensions
> GLboolean ARB_occlusion_query2;
> GLboolean ARB_pipeline_statistics_query;
> GLboolean ARB_point_sprite;
> + GLboolean ARB_post_depth_coverage;
> GLboolean ARB_query_buffer_object;
> GLboolean ARB_robust_buffer_access_behavior;
> GLboolean ARB_sample_shading;
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 83ee0d4..33e4334 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -2194,6 +2194,7 @@ _mesa_copy_linked_program_data(const struct
> gl_shader_program *src,
> case MESA_SHADER_FRAGMENT: {
> dst->info.fs.depth_layout = src->FragDepthLayout;
> dst->info.fs.early_fragment_tests = dst_sh->info.
> EarlyFragmentTests;
> + dst->info.fs.post_depth_coverage = dst_sh->info.PostDepthCoverage;
> break;
> }
> case MESA_SHADER_COMPUTE: {
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161201/04976c56/attachment-0001.html>
More information about the mesa-dev
mailing list