[Mesa-dev] [PATCH 1/3] mesa: Add GL and GLSL plumbing for ARB_post_depth_coverage for i965 (gen9+).

Plamena Manolova plamena.manolova at intel.com
Thu Nov 17 20:27:28 UTC 2016


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>
---
 include/GL/glext.h                       |  4 ++++
 src/compiler/glsl/ast.h                  |  1 +
 src/compiler/glsl/ast_to_hir.cpp         |  5 +++++
 src/compiler/glsl/ast_type.cpp           |  8 +++++++-
 src/compiler/glsl/glsl_parser.yy         | 11 +++++++++++
 src/compiler/glsl/glsl_parser_extras.cpp |  3 +++
 src/compiler/glsl/glsl_parser_extras.h   |  2 ++
 src/compiler/glsl/linker.cpp             |  4 ++++
 src/mapi/glapi/gen/gl_API.xml            |  3 +++
 src/mesa/main/extensions_table.h         |  1 +
 src/mesa/main/mtypes.h                   |  2 ++
 11 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 4753575..7256fe5 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -4860,6 +4860,10 @@ GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcha
 #define GL_ARB_viewport_array 1
 #endif /* GL_ARB_viewport_array */
 
+#ifndef GL_ARB_post_depth_coverage
+#define GL_ARB_post_depth_coverage 1
+#endif /* GL_ARB_post_depth_coverage */
+
 #ifndef GL_ARB_window_pos
 #define GL_ARB_window_pos 1
 typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 55f9a6c..e7815b0 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -606,6 +606,7 @@ struct ast_type_qualifier {
          /** \{ */
          unsigned blend_support:1; /**< Are there any blend_support_ qualifiers */
          /** \} */
+         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 9b8678c..c31da86 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 2856f18..1905721 100644
--- a/src/compiler/glsl/ast_type.cpp
+++ b/src/compiler/glsl/ast_type.cpp
@@ -489,6 +489,7 @@ ast_type_qualifier::merge_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:
       create_cs_ast |=
@@ -540,6 +541,10 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc,
       state->fs_early_fragment_tests = true;
    }
 
+   if (q.flags.q.post_depth_coverage) {
+      state->fs_post_depth_coverage = true;
+   }
+
    if (this->flags.q.vertex_spacing) {
       if (q.flags.q.vertex_spacing &&
           this->vertex_spacing != q.vertex_spacing) {
@@ -671,7 +676,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 7d709c7..9a65550 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -1369,6 +1369,17 @@ 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");
+            }
+
+            $$.flags.q.post_depth_coverage = 1;
+         }
       }
 
       /* 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 0cb3c12..33c27cb 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -294,6 +294,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));
@@ -1690,6 +1691,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 +1812,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 53abbbc..87f024c 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -784,6 +784,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 cc28b26..85f1030 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -1886,6 +1886,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/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 00c9bb7..66266ce 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8361,6 +8361,9 @@
 
 </category>
 
+<category name="ARB_post_depth_coverage" number="180">
+</category>
+
 <!-- Non-ARB extensions sorted by extension number. -->
 
 <category name="GL_EXT_blend_color" number="2">
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index 036e62b..4a91422 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                ,  45,  45,  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 d2c1e58..7e369c2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2170,6 +2170,7 @@ struct gl_shader_info
    bool uses_builtin_functions;
    bool uses_gl_fragcoord;
    bool redeclares_gl_fragcoord;
+   bool PostDepthCoverage;
    bool ARB_fragment_coord_conventions_enable;
 
    /**
@@ -3797,6 +3798,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;
-- 
2.7.4



More information about the mesa-dev mailing list