<div dir="ltr">This patch misses adding the #define to the GLSL preprocessor. Other than that it looks good though, so with that fixed:<div><br></div><div>Reviewed-by: Chris Forbes <<a href="mailto:chrisforbes@google.com">chrisforbes@google.com</a>></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 1, 2016 at 8:53 AM, Plamena Manolova <span dir="ltr"><<a href="mailto:plamena.manolova@intel.com" target="_blank">plamena.manolova@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">This extension allows the fragment shader to control whether values in<br>
gl_SampleMaskIn[] reflect the coverage after application of the early<br>
depth and stencil tests.<br>
<br>
Signed-off-by: Plamena Manolova <<a href="mailto:plamena.manolova@intel.com">plamena.manolova@intel.com</a>><br>
---<br>
 src/compiler/glsl/ast.h                  |  5 +++++<br>
 src/compiler/glsl/ast_to_hir.<wbr>cpp         |  5 +++++<br>
</span> src/compiler/glsl/ast_type.cpp           |  9 ++++++++-<br>
 src/compiler/glsl/glsl_parser.<wbr>yy         | 18 ++++++++++++++++++<br>
<span class=""> src/compiler/glsl/glsl_parser_<wbr>extras.cpp |  4 ++++<br>
 src/compiler/glsl/glsl_parser_<wbr>extras.h   |  4 ++++<br>
 src/compiler/glsl/linker.cpp             |  4 ++++<br>
 src/compiler/shader_info.h               |  1 +<br>
 src/mesa/main/extensions_<wbr>table.h         |  1 +<br>
 src/mesa/main/mtypes.h                   |  2 ++<br>
 src/mesa/main/shaderapi.c                |  1 +<br>
</span> 11 files changed, 53 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h<br>
index afe91ea..df3a744 100644<br>
--- a/src/compiler/glsl/ast.h<br>
+++ b/src/compiler/glsl/ast.h<br>
@@ -605,6 +605,11 @@ struct ast_type_qualifier {<br>
<span class="">          /** \{ */<br>
          unsigned blend_support:1; /**< Are there any blend_support_ qualifiers */<br>
          /** \} */<br>
+<br>
+         /**<br>
+          * Flag set if GL_ARB_post_depth_coverage layout qualifier is used.<br>
+          */<br>
+         unsigned post_depth_coverage:1;<br>
       }<br>
       /** \brief Set of flags, accessed by name. */<br>
       q;<br>
diff --git a/src/compiler/glsl/ast_to_<wbr>hir.cpp b/src/compiler/glsl/ast_to_<wbr>hir.cpp<br>
</span>index c2ce389..2434ce5 100644<br>
<span class="">--- a/src/compiler/glsl/ast_to_<wbr>hir.cpp<br>
+++ b/src/compiler/glsl/ast_to_<wbr>hir.cpp<br>
@@ -3632,6 +3632,11 @@ apply_layout_qualifier_to_<wbr>variable(const struct ast_type_qualifier *qual,<br>
       _mesa_glsl_error(loc, state, "early_fragment_tests layout qualifier only "<br>
                        "valid in fragment shader input layout declaration.");<br>
    }<br>
+<br>
+   if (qual->flags.q.post_depth_<wbr>coverage) {<br>
+      _mesa_glsl_error(loc, state, "post_depth_coverage layout qualifier only "<br>
+                       "valid in fragment shader input layout declaration.");<br>
+   }<br>
 }<br>
<br>
 static void<br>
diff --git a/src/compiler/glsl/ast_type.<wbr>cpp b/src/compiler/glsl/ast_type.<wbr>cpp<br>
</span>index 3431e24..aa1ae7e 100644<br>
--- a/src/compiler/glsl/ast_type.<wbr>cpp<br>
+++ b/src/compiler/glsl/ast_type.<wbr>cpp<br>
@@ -579,6 +579,7 @@ ast_type_qualifier::validate_<wbr>in_qualifier(YYLTYPE *loc,<br>
<span class="">       break;<br>
    case MESA_SHADER_FRAGMENT:<br>
       valid_in_mask.flags.q.early_<wbr>fragment_tests = 1;<br>
+      valid_in_mask.flags.q.post_<wbr>depth_coverage = 1;<br>
       break;<br>
    case MESA_SHADER_COMPUTE:<br>
</span>       valid_in_mask.flags.q.local_<wbr>size = 7;<br>
@@ -633,6 +634,11 @@ ast_type_qualifier::merge_<wbr>into_in_qualifier(YYLTYPE *loc,<br>
       state->in_qualifier->flags.q.<wbr>early_fragment_tests = false;<br>
    }<br>
<br>
+   if (state->in_qualifier->flags.q.<wbr>post_depth_coverage) {<br>
<span class="">+      state->fs_post_depth_coverage = true;<br>
</span>+      state->in_qualifier->flags.q.<wbr>post_depth_coverage = false;<br>
+   }<br>
+<br>
    /* We allow the creation of multiple cs_input_layout nodes. Coherence among<br>
     * all existing nodes is checked later, when the AST node is transformed<br>
     * into HIR.<br>
@@ -761,7 +767,8 @@ ast_type_qualifier::validate_<wbr>flags(YYLTYPE *loc,<br>
<span class="">                     bad.flags.q.point_mode ? " point_mode" : "",<br>
                     bad.flags.q.vertices ? " vertices" : "",<br>
                     bad.flags.q.subroutine ? " subroutine" : "",<br>
-                    bad.flags.q.subroutine_def ? " subroutine_def" : "");<br>
+                    bad.flags.q.subroutine_def ? " subroutine_def" : "",<br>
+                    bad.flags.q.post_depth_<wbr>coverage ? " post_depth_coverage" : "");<br>
    return false;<br>
 }<br>
<br>
diff --git a/src/compiler/glsl/glsl_<wbr>parser.yy b/src/compiler/glsl/glsl_<wbr>parser.yy<br>
</span>index 0c3781c..09b7e79 100644<br>
--- a/src/compiler/glsl/glsl_<wbr>parser.yy<br>
+++ b/src/compiler/glsl/glsl_<wbr>parser.yy<br>
@@ -1392,6 +1392,24 @@ layout_qualifier_id:<br>
<span class=""><br>
             $$.flags.q.early_fragment_<wbr>tests = 1;<br>
          }<br>
+<br>
+         if (!$$.flags.i &&<br>
+             match_layout_qualifier($1, "post_depth_coverage", state) == 0) {<br>
+            if (state->stage != MESA_SHADER_FRAGMENT) {<br>
+               _mesa_glsl_error(& @1, state,<br>
+                                "post_depth_coverage layout qualifier only "<br>
+                                "valid in fragment shaders");<br>
+            }<br>
+<br>
</span>+            if (state->ARB_post_depth_<wbr>coverage_enable) {<br>
+               $$.flags.q.post_depth_coverage = 1;<br>
+            } else {<br>
+               _mesa_glsl_error(& @1, state,<br>
+                                "post_depth_coverage layout qualifier present, "<br>
+                                "but the GL_ARB_post_depth_coverage extension "<br>
+                                "is not enabled.");<br>
+            }<br>
<span class="">+         }<br>
       }<br>
<br>
       /* Layout qualifiers for tessellation evaluation shaders. */<br>
diff --git a/src/compiler/glsl/glsl_<wbr>parser_extras.cpp b/src/compiler/glsl/glsl_<wbr>parser_extras.cpp<br>
</span>index 1e0298e..d1fc98d 100644<br>
--- a/src/compiler/glsl/glsl_<wbr>parser_extras.cpp<br>
+++ b/src/compiler/glsl/glsl_<wbr>parser_extras.cpp<br>
@@ -293,6 +293,7 @@ _mesa_glsl_parse_state::_mesa_<wbr>glsl_parse_state(struct gl_context *_ctx,<br>
<span class="">    this->in_qualifier = new(this) ast_type_qualifier();<br>
    this->out_qualifier = new(this) ast_type_qualifier();<br>
    this->fs_early_fragment_tests = false;<br>
+   this->fs_post_depth_coverage = false;<br>
    this->fs_blend_support = 0;<br>
    memset(this->atomic_counter_<wbr>offsets, 0,<br>
           sizeof(this->atomic_counter_<wbr>offsets));<br>
</span>@@ -606,6 +607,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_<wbr>extensions[] = {<br>
<span class="">    EXT(ARB_fragment_layer_<wbr>viewport),<br>
    EXT(ARB_gpu_shader5),<br>
    EXT(ARB_gpu_shader_fp64),<br>
+   EXT(ARB_post_depth_coverage),<br>
    EXT(ARB_sample_shading),<br>
    EXT(ARB_separate_shader_<wbr>objects),<br>
    EXT(ARB_shader_atomic_counter_<wbr>ops),<br>
</span>@@ -1690,6 +1692,7 @@ set_shader_inout_layout(struct gl_shader *shader,<br>
<span class="">       assert(!state->fs_pixel_<wbr>center_integer);<br>
       assert(!state->fs_origin_<wbr>upper_left);<br>
       assert(!state->fs_early_<wbr>fragment_tests);<br>
+      assert(!state->fs_post_depth_<wbr>coverage);<br>
    }<br>
<br>
    for (unsigned i = 0; i < MAX_FEEDBACK_BUFFERS; i++) {<br>
</span>@@ -1810,6 +1813,7 @@ set_shader_inout_layout(struct gl_shader *shader,<br>
<div><div class="h5">       shader->info.ARB_fragment_<wbr>coord_conventions_enable =<br>
          state->ARB_fragment_coord_<wbr>conventions_enable;<br>
       shader->info.<wbr>EarlyFragmentTests = state->fs_early_fragment_<wbr>tests;<br>
+      shader->info.PostDepthCoverage = state->fs_post_depth_coverage;<br>
       shader->info.BlendSupport = state->fs_blend_support;<br>
       break;<br>
<br>
diff --git a/src/compiler/glsl/glsl_<wbr>parser_extras.h b/src/compiler/glsl/glsl_<wbr>parser_extras.h<br>
index d757c1d..4277d43 100644<br>
--- a/src/compiler/glsl/glsl_<wbr>parser_extras.h<br>
+++ b/src/compiler/glsl/glsl_<wbr>parser_extras.h<br>
@@ -610,6 +610,8 @@ struct _mesa_glsl_parse_state {<br>
    bool ARB_gpu_shader5_warn;<br>
    bool ARB_gpu_shader_fp64_enable;<br>
    bool ARB_gpu_shader_fp64_warn;<br>
+   bool ARB_post_depth_coverage_<wbr>enable;<br>
+   bool ARB_post_depth_coverage_warn;<br>
    bool ARB_sample_shading_enable;<br>
    bool ARB_sample_shading_warn;<br>
    bool ARB_separate_shader_objects_<wbr>enable;<br>
@@ -786,6 +788,8 @@ struct _mesa_glsl_parse_state {<br>
<br>
    bool fs_early_fragment_tests;<br>
<br>
+   bool fs_post_depth_coverage;<br>
+<br>
    unsigned fs_blend_support;<br>
<br>
    /**<br>
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp<br>
</div></div>index 764938b..39c5e07 100644<br>
<div><div class="h5">--- a/src/compiler/glsl/linker.cpp<br>
+++ b/src/compiler/glsl/linker.cpp<br>
@@ -1887,6 +1887,10 @@ link_fs_inout_layout_<wbr>qualifiers(struct gl_shader_program *prog,<br>
<br>
       linked_shader->info.<wbr>EarlyFragmentTests |=<br>
          shader->info.<wbr>EarlyFragmentTests;<br>
+<br>
+      linked_shader->info.<wbr>PostDepthCoverage |=<br>
+         shader->info.<wbr>PostDepthCoverage;<br>
+<br>
       linked_shader->info.<wbr>BlendSupport |= shader->info.BlendSupport;<br>
    }<br>
 }<br>
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h<br>
index 7ea5d9c..b2830e0 100644<br>
--- a/src/compiler/shader_info.h<br>
+++ b/src/compiler/shader_info.h<br>
@@ -116,6 +116,7 @@ typedef struct shader_info {<br>
           * ARB_shader_image_load_store.<br>
           */<br>
          bool early_fragment_tests;<br>
+         bool post_depth_coverage;<br>
<br>
          /** gl_FragDepth layout for ARB_conservative_depth. */<br>
          enum gl_frag_depth_layout depth_layout;<br>
diff --git a/src/mesa/main/extensions_<wbr>table.h b/src/mesa/main/extensions_<wbr>table.h<br>
index d3ec551..f2d3a5b 100644<br>
--- a/src/mesa/main/extensions_<wbr>table.h<br>
+++ b/src/mesa/main/extensions_<wbr>table.h<br>
@@ -93,6 +93,7 @@ EXT(ARB_pipeline_statistics_<wbr>query           , ARB_pipeline_statistics_query<br>
 EXT(ARB_pixel_buffer_object                 , EXT_pixel_buffer_object                , GLL, GLC,  x ,  x , 2004)<br>
 EXT(ARB_point_parameters                    , EXT_point_parameters                   , GLL,  x ,  x ,  x , 1997)<br>
 EXT(ARB_point_sprite                        , ARB_point_sprite                       , GLL, GLC,  x ,  x , 2003)<br>
+EXT(ARB_post_depth_coverage                 , ARB_post_depth_coverage                ,  x ,  32,  x ,  x,  2015)<br>
 EXT(ARB_program_interface_<wbr>query             , dummy_true                             , GLL, GLC,  x ,  x , 2012)<br>
 EXT(ARB_provoking_vertex                    , EXT_provoking_vertex                   , GLL, GLC,  x ,  x , 2009)<br>
 EXT(ARB_query_buffer_object                 , ARB_query_buffer_object                , GLL, GLC,  x ,  x , 2013)<br>
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
</div></div>index 250877d..dfa9a78 100644<br>
<span class="">--- a/src/mesa/main/mtypes.h<br>
+++ b/src/mesa/main/mtypes.h<br>
@@ -2174,6 +2174,7 @@ struct gl_shader_info<br>
 {<br>
    bool uses_gl_fragcoord;<br>
    bool redeclares_gl_fragcoord;<br>
+   bool PostDepthCoverage;<br>
    bool ARB_fragment_coord_<wbr>conventions_enable;<br>
<br>
    /**<br>
</span>@@ -3818,6 +3819,7 @@ struct gl_extensions<br>
<div class="HOEnZb"><div class="h5">    GLboolean ARB_occlusion_query2;<br>
    GLboolean ARB_pipeline_statistics_query;<br>
    GLboolean ARB_point_sprite;<br>
+   GLboolean ARB_post_depth_coverage;<br>
    GLboolean ARB_query_buffer_object;<br>
    GLboolean ARB_robust_buffer_access_<wbr>behavior;<br>
    GLboolean ARB_sample_shading;<br>
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c<br>
index 83ee0d4..33e4334 100644<br>
--- a/src/mesa/main/shaderapi.c<br>
+++ b/src/mesa/main/shaderapi.c<br>
@@ -2194,6 +2194,7 @@ _mesa_copy_linked_program_<wbr>data(const struct gl_shader_program *src,<br>
    case MESA_SHADER_FRAGMENT: {<br>
       dst->info.fs.depth_layout = src->FragDepthLayout;<br>
       dst->info.fs.early_fragment_<wbr>tests = dst_sh->info.<wbr>EarlyFragmentTests;<br>
+      dst->info.fs.post_depth_<wbr>coverage = dst_sh->info.<wbr>PostDepthCoverage;<br>
       break;<br>
    }<br>
    case MESA_SHADER_COMPUTE: {<br>
--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div>