[cogl/wip/rib/cogl-1.12: 89/142] Fix depth testing, write enable bug



commit f7261c764e38c20679a7138a04801d86ccba5797
Author: Robert Bragg <robert linux intel com>
Date:   Sun Apr 29 22:14:43 2012 +0100

    Fix depth testing, write enable bug
    
    This fixes a bug in _cogl_pipeline_flush_color_blend_alpha_depth_state
    whereby we were only calling flush_depth_state if we knew that at least
    depth testing was enabled. This didn't take into account that enabling
    and disabling depth writing is a useful change to make even if depth
    testing is disabled. It also seemed a bit messy to flush the
    depth-testing enable separately from the other depth state.
    
    _cogl_pipeline_flush_color_blend_alpha_depth_state now simply calls
    flush_depth_state() if there is a _DEPTH_STATE difference and
    flush_depth_state() also handles flushing the depth-testing enable
    in along with all the other depth state.
    
    Reviewed-by: Neil Roberts <neil linux intel com>
    
    (cherry picked from commit 6a9dfc55b8f55d7023cb592e5bef2118d0f3d50c)

 cogl/cogl-pipeline-opengl.c |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/cogl/cogl-pipeline-opengl.c b/cogl/cogl-pipeline-opengl.c
index 5341803..a047e81 100644
--- a/cogl/cogl-pipeline-opengl.c
+++ b/cogl/cogl-pipeline-opengl.c
@@ -401,11 +401,20 @@ blend_factor_uses_constant (GLenum blend_factor)
 #endif
 
 static void
-flush_depth_state (CoglDepthState *depth_state)
+flush_depth_state (CoglContext *ctx,
+                   CoglDepthState *depth_state)
 {
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  if (ctx->depth_test_enabled_cache != depth_state->test_enabled)
+    {
+      if (depth_state->test_enabled == TRUE)
+        GE (ctx, glEnable (GL_DEPTH_TEST));
+      else
+        GE (ctx, glDisable (GL_DEPTH_TEST));
+      ctx->depth_test_enabled_cache = depth_state->test_enabled;
+    }
 
-  if (ctx->depth_test_function_cache != depth_state->test_function)
+  if (ctx->depth_test_function_cache != depth_state->test_function &&
+      depth_state->test_enabled == TRUE)
     {
       GE (ctx, glDepthFunc (depth_state->test_function));
       ctx->depth_test_function_cache = depth_state->test_function;
@@ -571,20 +580,7 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
         _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_DEPTH);
       CoglDepthState *depth_state = &authority->big_state->depth_state;
 
-      if (depth_state->test_enabled)
-        {
-          if (ctx->depth_test_enabled_cache != TRUE)
-            {
-              GE (ctx, glEnable (GL_DEPTH_TEST));
-              ctx->depth_test_enabled_cache = depth_state->test_enabled;
-            }
-          flush_depth_state (depth_state);
-        }
-      else if (ctx->depth_test_enabled_cache != FALSE)
-        {
-          GE (ctx, glDisable (GL_DEPTH_TEST));
-          ctx->depth_test_enabled_cache = depth_state->test_enabled;
-        }
+      flush_depth_state (ctx, depth_state);
     }
 
   if (pipelines_difference & COGL_PIPELINE_STATE_LOGIC_OPS)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]