<p dir="ltr">Is this different from the arb variant?</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Dec 1, 2016 10:56 AM, "Lionel Landwerlin" <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
---<br>
 src/compiler/glsl/ast.h                  |  5 ++++<br>
 src/compiler/glsl/ast_to_hir.<wbr>cpp         |  5 ++++<br>
 src/compiler/glsl/ast_type.cpp           | 16 +++++++++++-<br>
 src/compiler/glsl/glsl_parser.<wbr>yy         | 34 ++++++++++++++++++++++----<br>
 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             |  3 +++<br>
 src/compiler/shader_info.h               |  6 +++++<br>
 src/mesa/main/api_validate.c             | 42 ++++++++++++++++++++++++++++++<wbr>++<br>
 src/mesa/main/enable.c                   | 12 +++++++++<br>
 src/mesa/main/extensions_<wbr>table.h         |  1 +<br>
 src/mesa/main/mtypes.h                   |  3 +++<br>
 src/mesa/main/shaderapi.c                |  1 +<br>
 13 files changed, 130 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h<br>
index df3a744..0e32c36 100644<br>
--- a/src/compiler/glsl/ast.h<br>
+++ b/src/compiler/glsl/ast.h<br>
@@ -610,6 +610,11 @@ struct ast_type_qualifier {<br>
           * Flag set if GL_ARB_post_depth_coverage layout qualifier is used.<br>
           */<br>
          unsigned post_depth_coverage:1;<br>
+         /**<br>
+          * Flag set if GL_INTEL_conservartive_<wbr>rasterization layout qualifier<br>
+          * is used.<br>
+          */<br>
+         unsigned inner_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>
index 2434ce5..1e14d27 100644<br>
--- a/src/compiler/glsl/ast_to_<wbr>hir.cpp<br>
+++ b/src/compiler/glsl/ast_to_<wbr>hir.cpp<br>
@@ -3633,6 +3633,11 @@ apply_layout_qualifier_to_<wbr>variable(const struct ast_type_qualifier *qual,<br>
                        "valid in fragment shader input layout declaration.");<br>
    }<br>
<br>
+   if (qual->flags.q.inner_coverage) {<br>
+      _mesa_glsl_error(loc, state, "inner_coverage 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>
diff --git a/src/compiler/glsl/ast_type.<wbr>cpp b/src/compiler/glsl/ast_type.<wbr>cpp<br>
index aa1ae7e..d68e6e2 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>
       break;<br>
    case MESA_SHADER_FRAGMENT:<br>
       valid_in_mask.flags.q.early_<wbr>fragment_tests = 1;<br>
+      valid_in_mask.flags.q.inner_<wbr>coverage = 1;<br>
       valid_in_mask.flags.q.post_<wbr>depth_coverage = 1;<br>
       break;<br>
    case MESA_SHADER_COMPUTE:<br>
@@ -634,11 +635,23 @@ 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>inner_coverage) {<br>
+      state->fs_inner_coverage = true;<br>
+      state->in_qualifier->flags.q.<wbr>inner_coverage = false;<br>
+   }<br>
+<br>
    if (state->in_qualifier->flags.q.<wbr>post_depth_coverage) {<br>
       state->fs_post_depth_coverage = true;<br>
       state->in_qualifier->flags.q.<wbr>post_depth_coverage = false;<br>
    }<br>
<br>
+   if (state->fs_inner_coverage && state->fs_post_depth_coverage) {<br>
+      _mesa_glsl_error(loc, state,<br>
+                       "inner_coverage & post_depth_coverage layout qualifiers "<br>
+                       "are mutally exclusives");<br>
+      r = 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>
@@ -707,7 +720,7 @@ ast_type_qualifier::validate_<wbr>flags(YYLTYPE *loc,<br>
                     "%s '%s':"<br>
                     "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%<wbr>s%s%s%s%s%s"<br>
                     "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%<wbr>s%s%s%s%s%s"<br>
-                    "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%<wbr>s\n",<br>
+                    "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%<wbr>s%s\n",<br>
                     message, name,<br>
                     bad.flags.q.invariant ? " invariant" : "",<br>
                     bad.flags.q.precise ? " precise" : "",<br>
@@ -768,6 +781,7 @@ ast_type_qualifier::validate_<wbr>flags(YYLTYPE *loc,<br>
                     bad.flags.q.vertices ? " vertices" : "",<br>
                     bad.flags.q.subroutine ? " subroutine" : "",<br>
                     bad.flags.q.subroutine_def ? " subroutine_def" : "",<br>
+                    bad.flags.q.inner_coverage ? " inner_coverage" : "",<br>
                     bad.flags.q.post_depth_<wbr>coverage ? " post_depth_coverage" : "");<br>
    return false;<br>
 }<br>
diff --git a/src/compiler/glsl/glsl_<wbr>parser.yy b/src/compiler/glsl/glsl_<wbr>parser.yy<br>
index 09b7e79..e3893d5 100644<br>
--- a/src/compiler/glsl/glsl_<wbr>parser.yy<br>
+++ b/src/compiler/glsl/glsl_<wbr>parser.yy<br>
@@ -1372,9 +1372,10 @@ layout_qualifier_id:<br>
                }<br>
             }<br>
          }<br>
+      }<br>
<br>
-         if (!$$.flags.i &&<br>
-             match_layout_qualifier($1, "early_fragment_tests", state) == 0) {<br>
+      if (!$$.flags.i) {<br>
+         if (match_layout_qualifier($1, "early_fragment_tests", state) == 0) {<br>
             /* From section 4.4.1.3 of the GLSL 4.50 specification<br>
              * (Fragment Shader Inputs):<br>
              *<br>
@@ -1393,15 +1394,32 @@ layout_qualifier_id:<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 (match_layout_qualifier($1, "inner_coverage", state) == 0) {<br>
+            if (state->stage != MESA_SHADER_FRAGMENT) {<br>
+               _mesa_glsl_error(& @1, state,<br>
+                                "inner_coverage layout qualifier only "<br>
+                                "valid in fragment shaders");<br>
+            }<br>
+<br>
+           if (state->INTEL_conservative_<wbr>rasterization_enable) {<br>
+              $$.flags.q.inner_coverage = 1;<br>
+           } else {<br>
+              _mesa_glsl_error(& @1, state,<br>
+                                "inner_coverage layout qualifier present, "<br>
+                                "but the INTEL_conservative_<wbr>rasterization extension "<br>
+                                "is not enabled.");<br>
+            }<br>
+         }<br>
+<br>
+         if (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>
-            if (state->ARB_post_depth_<wbr>coverage_enable) {<br>
+            if (state->ARB_post_depth_<wbr>coverage_enable ||<br>
+               state->INTEL_conservative_<wbr>rasterization_enable) {<br>
                $$.flags.q.post_depth_coverage = 1;<br>
             } else {<br>
                _mesa_glsl_error(& @1, state,<br>
@@ -1410,6 +1428,12 @@ layout_qualifier_id:<br>
                                 "is not enabled.");<br>
             }<br>
          }<br>
+<br>
+         if ($$.flags.q.post_depth_<wbr>coverage && $$.flags.q.inner_coverage) {<br>
+            _mesa_glsl_error(& @1, state,<br>
+                             "post_depth_coverage & inner_coverage layout qualifiers "<br>
+                             "are mutually exclusive");<br>
+         }<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>
index d1fc98d..14b7153 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>
    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_inner_coverage = false;<br>
    this->fs_post_depth_coverage = false;<br>
    this->fs_blend_support = 0;<br>
    memset(this->atomic_counter_<wbr>offsets, 0,<br>
@@ -687,6 +688,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_<wbr>extensions[] = {<br>
    EXT(EXT_texture_array),<br>
    EXT_AEP(EXT_texture_buffer),<br>
    EXT_AEP(EXT_texture_cube_map_<wbr>array),<br>
+   EXT(INTEL_conservative_<wbr>rasterization),<br>
    EXT(MESA_shader_integer_<wbr>functions),<br>
    EXT(NV_image_formats),<br>
 };<br>
@@ -1692,6 +1694,7 @@ set_shader_inout_layout(struct gl_shader *shader,<br>
       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_inner_<wbr>coverage);<br>
       assert(!state->fs_post_depth_<wbr>coverage);<br>
    }<br>
<br>
@@ -1813,6 +1816,7 @@ set_shader_inout_layout(struct gl_shader *shader,<br>
       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.InnerCoverage = state->fs_inner_coverage;<br>
       shader->info.PostDepthCoverage = state->fs_post_depth_coverage;<br>
       shader->info.BlendSupport = state->fs_blend_support;<br>
       break;<br>
diff --git a/src/compiler/glsl/glsl_<wbr>parser_extras.h b/src/compiler/glsl/glsl_<wbr>parser_extras.h<br>
index 4277d43..d6fc377 100644<br>
--- a/src/compiler/glsl/glsl_<wbr>parser_extras.h<br>
+++ b/src/compiler/glsl/glsl_<wbr>parser_extras.h<br>
@@ -761,6 +761,8 @@ struct _mesa_glsl_parse_state {<br>
    bool EXT_texture_buffer_warn;<br>
    bool EXT_texture_cube_map_array_<wbr>enable;<br>
    bool EXT_texture_cube_map_array_<wbr>warn;<br>
+   bool INTEL_conservative_<wbr>rasterization_enable;<br>
+   bool INTEL_conservative_<wbr>rasterization_warn;<br>
    bool MESA_shader_framebuffer_fetch_<wbr>enable;<br>
    bool MESA_shader_framebuffer_fetch_<wbr>warn;<br>
    bool MESA_shader_framebuffer_fetch_<wbr>non_coherent_enable;<br>
@@ -788,6 +790,8 @@ struct _mesa_glsl_parse_state {<br>
<br>
    bool fs_early_fragment_tests;<br>
<br>
+   bool fs_inner_coverage;<br>
+<br>
    bool fs_post_depth_coverage;<br>
<br>
    unsigned fs_blend_support;<br>
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp<br>
index 39c5e07..f43ee97 100644<br>
--- a/src/compiler/glsl/linker.cpp<br>
+++ b/src/compiler/glsl/linker.cpp<br>
@@ -1888,6 +1888,9 @@ link_fs_inout_layout_<wbr>qualifiers(struct gl_shader_program *prog,<br>
       linked_shader->info.<wbr>EarlyFragmentTests |=<br>
          shader->info.<wbr>EarlyFragmentTests;<br>
<br>
+      linked_shader->info.<wbr>InnerCoverage |=<br>
+         shader->info.InnerCoverage;<br>
+<br>
       linked_shader->info.<wbr>PostDepthCoverage |=<br>
          shader->info.<wbr>PostDepthCoverage;<br>
<br>
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h<br>
index b2830e0..768f053 100644<br>
--- a/src/compiler/shader_info.h<br>
+++ b/src/compiler/shader_info.h<br>
@@ -116,6 +116,12 @@ typedef struct shader_info {<br>
           * ARB_shader_image_load_store.<br>
           */<br>
          bool early_fragment_tests;<br>
+<br>
+         /**<br>
+          * Defined by INTEL_conservative_<wbr>rasterization.<br>
+          */<br>
+         bool inner_coverage;<br>
+<br>
          bool post_depth_coverage;<br>
<br>
          /** gl_FragDepth layout for ARB_conservative_depth. */<br>
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c<br>
index d3b4cab..95a9676 100644<br>
--- a/src/mesa/main/api_validate.c<br>
+++ b/src/mesa/main/api_validate.c<br>
@@ -555,6 +555,48 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)<br>
       }<br>
    }<br>
<br>
+   /* From GL_INTEL_conservative_<wbr>rasterization spec:<br>
+    *<br>
+    * The conservative rasterization option applies only to polygons with<br>
+    * PolygonMode state set to FILL. Draw requests for polygons with different<br>
+    * PolygonMode setting or for other primitive types (points/lines) generate<br>
+    * INVALID_OPERATION error.<br>
+    */<br>
+   if (ctx-><wbr>IntelConservativeRasterization<wbr>) {<br>
+      GLboolean pass = GL_TRUE;<br>
+<br>
+      switch (mode) {<br>
+      case GL_POINTS:<br>
+      case GL_LINES:<br>
+      case GL_LINE_LOOP:<br>
+      case GL_LINE_STRIP:<br>
+      case GL_LINES_ADJACENCY:<br>
+      case GL_LINE_STRIP_ADJACENCY:<br>
+         pass = GL_FALSE;<br>
+         break;<br>
+      case GL_TRIANGLES:<br>
+      case GL_TRIANGLE_STRIP:<br>
+      case GL_TRIANGLE_FAN:<br>
+      case GL_QUADS:<br>
+      case GL_QUAD_STRIP:<br>
+      case GL_POLYGON:<br>
+      case GL_TRIANGLES_ADJACENCY:<br>
+      case GL_TRIANGLE_STRIP_ADJACENCY:<br>
+         if (ctx->Polygon.FrontMode != GL_FILL ||<br>
+             ctx->Polygon.BackMode != GL_FILL)<br>
+            pass = GL_FALSE;<br>
+         break;<br>
+      default:<br>
+         pass = GL_FALSE;<br>
+      }<br>
+      if (!pass) {<br>
+         _mesa_error(ctx, GL_INVALID_OPERATION,<br>
+                     "mode=%s invalid with GL_INTEL_conservative_<wbr>rasterization",<br>
+                     _mesa_lookup_prim_by_nr(mode))<wbr>;<br>
+         return GL_FALSE;<br>
+      }<br>
+   }<br>
+<br>
    return GL_TRUE;<br>
 }<br>
<br>
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c<br>
index d1ab81e..c9f10ab 100644<br>
--- a/src/mesa/main/enable.c<br>
+++ b/src/mesa/main/enable.c<br>
@@ -439,6 +439,14 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)<br>
          FLUSH_VERTICES(ctx, _NEW_COLOR);<br>
          ctx->Color.IndexLogicOpEnabled = state;<br>
          break;<br>
+      case GL_CONSERVATIVE_RASTERIZATION_<wbr>INTEL:<br>
+         if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)<br>
+            goto invalid_enum_error;<br>
+         if (ctx-><wbr>IntelConservativeRasterization == state)<br>
+            return;<br>
+         FLUSH_VERTICES(ctx, _NEW_POLYGON);<br>
+         ctx-><wbr>IntelConservativeRasterization = state;<br>
+         break;<br>
       case GL_COLOR_LOGIC_OP:<br>
          if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)<br>
             goto invalid_enum_error;<br>
@@ -1631,6 +1639,10 @@ _mesa_IsEnabled( GLenum cap )<br>
          CHECK_EXTENSION(KHR_blend_<wbr>equation_advanced_coherent);<br>
          return ctx->Color.BlendCoherent;<br>
<br>
+      case GL_CONSERVATIVE_RASTERIZATION_<wbr>INTEL:<br>
+         CHECK_EXTENSION(INTEL_<wbr>conservative_rasterization);<br>
+         return ctx-><wbr>IntelConservativeRasterization<wbr>;<br>
+<br>
       default:<br>
          goto invalid_enum_error;<br>
    }<br>
diff --git a/src/mesa/main/extensions_<wbr>table.h b/src/mesa/main/extensions_<wbr>table.h<br>
index f2d3a5b..6756f7c 100644<br>
--- a/src/mesa/main/extensions_<wbr>table.h<br>
+++ b/src/mesa/main/extensions_<wbr>table.h<br>
@@ -290,6 +290,7 @@ EXT(IBM_texture_mirrored_<wbr>repeat             , dummy_true<br>
<br>
 EXT(INGR_blend_func_separate                , EXT_blend_func_separate                , GLL,  x ,  x ,  x , 1999)<br>
<br>
+EXT(INTEL_conservative_<wbr>rasterization        , INTEL_conservative_<wbr>rasterization       ,  x ,  42,  x ,  32, 2013)<br>
 EXT(INTEL_performance_query                 , INTEL_performance_query                , GLL, GLC,  x , ES2, 2013)<br>
<br>
 EXT(KHR_blend_equation_<wbr>advanced             , KHR_blend_equation_advanced            , GLL, GLC,  x , ES2, 2014)<br>
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
index dfa9a78..e91a8ac 100644<br>
--- a/src/mesa/main/mtypes.h<br>
+++ b/src/mesa/main/mtypes.h<br>
@@ -2175,6 +2175,7 @@ struct gl_shader_info<br>
    bool uses_gl_fragcoord;<br>
    bool redeclares_gl_fragcoord;<br>
    bool PostDepthCoverage;<br>
+   bool InnerCoverage;<br>
    bool ARB_fragment_coord_<wbr>conventions_enable;<br>
<br>
    /**<br>
@@ -3935,6 +3936,7 @@ struct gl_extensions<br>
    GLboolean ATI_fragment_shader;<br>
    GLboolean ATI_separate_stencil;<br>
    GLboolean GREMEDY_string_marker;<br>
+   GLboolean INTEL_conservative_<wbr>rasterization;<br>
    GLboolean INTEL_performance_query;<br>
    GLboolean KHR_blend_equation_advanced;<br>
    GLboolean KHR_blend_equation_advanced_<wbr>coherent;<br>
@@ -4618,6 +4620,7 @@ struct gl_context<br>
    GLboolean TextureFormatSupported[MESA_<wbr>FORMAT_COUNT];<br>
<br>
    GLboolean RasterDiscard;  /**< GL_RASTERIZER_DISCARD */<br>
+   GLboolean IntelConservativeRasterization<wbr>; /**< GL_INTEL_CONSERVATIVE_<wbr>RASTERIZATION */<br>
<br>
    /**<br>
     * \name Hooks for module contexts.<br>
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c<br>
index 33e4334..d8f2e79 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.inner_coverage = dst_sh->info.InnerCoverage;<br>
       dst->info.fs.post_depth_<wbr>coverage = dst_sh->info.<wbr>PostDepthCoverage;<br>
       break;<br>
    }<br>
--<br>
2.10.2<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>
</blockquote></div></div>