[Mesa-dev] [PATCH 15/16] mesa: Implement GL_KHR_blend_equation_advanced_coherent.

Kenneth Graunke kenneth at whitecape.org
Sat Aug 13 03:13:07 UTC 2016


This adds the extension enable (so drivers can advertise it) and the
extra boolean state flag, GL_BLEND_ADVANCED_COHERENT_KHR, which can
be set to request coherent blending.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/main/blend.c            |  2 ++
 src/mesa/main/enable.c           | 12 ++++++++++++
 src/mesa/main/extensions_table.h |  1 +
 src/mesa/main/get.c              |  1 +
 src/mesa/main/get_hash_params.py |  3 +++
 src/mesa/main/mtypes.h           |  3 +++
 6 files changed, 22 insertions(+)

diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index e23b9cb..73fcb6a 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -1021,6 +1021,8 @@ void _mesa_init_color( struct gl_context * ctx )
     * if EGL_KHR_gl_colorspace has been used to request sRGB.
     */
    ctx->Color.sRGBEnabled = _mesa_is_gles(ctx);
+
+   ctx->Color.BlendCoherent = true;
 }
 
 /*@}*/
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 1468a45..d1ab81e 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1017,6 +1017,14 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
          ctx->Multisample.SampleMask = state;
          break;
 
+      case GL_BLEND_ADVANCED_COHERENT_KHR:
+         CHECK_EXTENSION(KHR_blend_equation_advanced_coherent, cap);
+         if (ctx->Color.BlendCoherent == state)
+            return;
+         FLUSH_VERTICES(ctx, _NEW_COLOR);
+         ctx->Color.BlendCoherent = state;
+         break;
+
       default:
          goto invalid_enum_error;
    }
@@ -1619,6 +1627,10 @@ _mesa_IsEnabled( GLenum cap )
          CHECK_EXTENSION(ARB_sample_shading);
          return ctx->Multisample.SampleShading;
 
+      case GL_BLEND_ADVANCED_COHERENT_KHR:
+         CHECK_EXTENSION(KHR_blend_equation_advanced_coherent);
+         return ctx->Color.BlendCoherent;
+
       default:
          goto invalid_enum_error;
    }
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index e8c825b..c6fdd2c 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -283,6 +283,7 @@ EXT(INGR_blend_func_separate                , EXT_blend_func_separate
 EXT(INTEL_performance_query                 , INTEL_performance_query                , GLL, GLC,  x , ES2, 2013)
 
 EXT(KHR_blend_equation_advanced             , KHR_blend_equation_advanced            , GLL, GLC,  x , ES2, 2014)
+EXT(KHR_blend_equation_advanced_coherent    , KHR_blend_equation_advanced_coherent   , GLL, GLC,  x , ES2, 2014)
 EXT(KHR_context_flush_control               , dummy_true                             , GLL, GLC,  x , ES2, 2014)
 EXT(KHR_debug                               , dummy_true                             , GLL, GLC,  11, ES2, 2012)
 EXT(KHR_robust_buffer_access_behavior       , ARB_robust_buffer_access_behavior      , GLL, GLC,  x , ES2, 2014)
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index b017827..97dfb0c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -465,6 +465,7 @@ EXTRA_EXT(ATI_meminfo);
 EXTRA_EXT(NVX_gpu_memory_info);
 EXTRA_EXT(ARB_cull_distance);
 EXTRA_EXT(EXT_window_rectangles);
+EXTRA_EXT(KHR_blend_equation_advanced_coherent);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 89d164d..3414743 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -338,6 +338,9 @@ descriptor=[
 
 # blend_func_extended
   [ "MAX_DUAL_SOURCE_DRAW_BUFFERS", "CONTEXT_INT(Const.MaxDualSourceDrawBuffers), extra_ARB_blend_func_extended" ],
+
+# GL_KHR_blend_equation_advanced_coherent
+  [ "BLEND_ADVANCED_COHERENT_KHR", "CONTEXT_BOOL(Color.BlendCoherent), extra_KHR_blend_equation_advanced_coherent" ],
 ]},
 
 # GLES3 is not a typo.
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 9e0b831..5603722 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -454,6 +454,8 @@ struct gl_colorbuffer_attrib
    GLboolean _BlendEquationPerBuffer;
    /** Per-buffer "is an advanced blending equation set?" flags. */
    GLbitfield _AdvancedBlendEnabled;
+   /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
+   bool BlendCoherent;
    /*@}*/
 
    /** 
@@ -3950,6 +3952,7 @@ struct gl_extensions
    GLboolean GREMEDY_string_marker;
    GLboolean INTEL_performance_query;
    GLboolean KHR_blend_equation_advanced;
+   GLboolean KHR_blend_equation_advanced_coherent;
    GLboolean KHR_robustness;
    GLboolean KHR_texture_compression_astc_hdr;
    GLboolean KHR_texture_compression_astc_ldr;
-- 
2.9.0



More information about the mesa-dev mailing list