[cogl/wip/virtual-framebuffer: 23/37] fix: optimize framebuffer state flush



commit fda20e5b56e38229e62f0c3757127fcfe01513d8
Author: Robert Bragg <robert linux intel com>
Date:   Tue Nov 22 21:11:35 2011 +0000

    fix: optimize framebuffer state flush

 cogl/cogl-framebuffer.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 881ccad..b204c5f 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1340,8 +1340,8 @@ bind_gl_framebuffer (CoglContext *ctx,
 }
 
 static unsigned long
-_cogl_framebuffer_compare_viewport (CoglFramebuffer *a,
-                                    CoglFramebuffer *b)
+_cogl_framebuffer_compare_viewport_state (CoglFramebuffer *a,
+                                          CoglFramebuffer *b)
 {
   if (a->viewport_x != b->viewport_x ||
       a->viewport_y != b->viewport_y ||
@@ -1356,10 +1356,10 @@ static unsigned long
 _cogl_framebuffer_compare_clip_state (CoglFramebuffer *a,
                                       CoglFramebuffer *b)
 {
-  if (((a->clip_state->stacks == NULL || b->clip_state->stacks == NULL) &&
-       a->clip_state->stacks != b->clip_state->stacks)
+  if (((a->clip_state.stacks == NULL || b->clip_state.stacks == NULL) &&
+       a->clip_state.stacks != b->clip_state.stacks)
       ||
-      a->clip_state->stacks->data != b->clip_state->stacks->data)
+      a->clip_state.stacks->data != b->clip_state.stacks->data)
     return COGL_FRAMEBUFFER_STATE_CLIP;
   else
     return 0;
@@ -1420,40 +1420,41 @@ _cogl_framebuffer_compare (CoglFramebuffer *a,
                            CoglFramebufferState state)
 {
   unsigned long differences = 0;
+  int bit;
 
   if (state & COGL_FRAMEBUFFER_STATE_BIND)
     differences |= COGL_FRAMEBUFFER_STATE_BIND;
 
-  COGL_FLAGS_FOREACH_START (differences,
-                            COGL_FRAMEBUFFER_STATE_INDEX_MAX, index)
+  COGL_FLAGS_FOREACH_START (&differences,
+                            COGL_FRAMEBUFFER_STATE_INDEX_MAX, bit)
     {
       /* XXX: We considered having an array of callbacks for each state index
        * that we'd call here but decided that this way the compiler is more
        * likely going to be able to in-line the comparison functions and use
        * the index to jump straight to the required code. */
-      switch (index)
+      switch (bit)
         {
         case COGL_FRAMEBUFFER_STATE_INDEX_VIEWPORT:
           differences |=
-            _cogl_framebuffer_compare_viewport_state (draw_buffer);
+            _cogl_framebuffer_compare_viewport_state (a, b);
           break;
         case COGL_FRAMEBUFFER_STATE_INDEX_CLIP:
-          differences |= _cogl_framebuffer_compare_clip_state (draw_buffer);
+          differences |= _cogl_framebuffer_compare_clip_state (a, b);
           break;
         case COGL_FRAMEBUFFER_STATE_INDEX_DITHER:
-          differences |= _cogl_framebuffer_compare_dither_state (draw_buffer);
+          differences |= _cogl_framebuffer_compare_dither_state (a, b);
           break;
         case COGL_FRAMEBUFFER_STATE_INDEX_MODELVIEW:
           differences |=
-            _cogl_framebuffer_compare_modelview_state (draw_buffer);
+            _cogl_framebuffer_compare_modelview_state (a, b);
           break;
         case COGL_FRAMEBUFFER_STATE_INDEX_PROJECTION:
           differences |=
-            _cogl_framebuffer_compare_projection_state (draw_buffer);
+            _cogl_framebuffer_compare_projection_state (a, b);
           break;
         case COGL_FRAMEBUFFER_STATE_INDEX_COLOR_MASK:
           differences |=
-            _cogl_framebuffer_compare_color_mask_state (draw_buffer);
+            _cogl_framebuffer_compare_color_mask_state (a, b);
           break;
         default:
           g_warn_if_reached ();
@@ -1489,7 +1490,8 @@ _cogl_framebuffer_flush_viewport_state (CoglFramebuffer *framebuffer)
              framebuffer->viewport_width,
              framebuffer->viewport_height);
 
-  GE (ctx, glViewport (framebuffer->viewport_x,
+  GE (framebuffer->context,
+      glViewport (framebuffer->viewport_x,
                   gl_viewport_y,
                   framebuffer->viewport_width,
                   framebuffer->viewport_height));



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