[Cogl] [PATCH] framebuffer: vp change = clip change for gen6 workaround

Robert Bragg robert at sixbynine.org
Mon Mar 4 10:22:49 PST 2013


From: Robert Bragg <robert at linux.intel.com>

This makes sure that a viewport change when comparing between separate
framebuffers also implies a clip change when we are applying the Intel
gen6 workaround for broken viewport clipping. Without this then
switching between different size framebuffers could leave a scissor
matching the size of a previous framebuffer.
---
 cogl/cogl-framebuffer.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index fdd6c6f..ceb7916 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -705,7 +705,27 @@ _cogl_framebuffer_compare_viewport_state (CoglFramebuffer *a,
       /* NB: we render upside down to offscreen framebuffers and that
        * can affect how we setup the GL viewport... */
       a->type != b->type)
-    return COGL_FRAMEBUFFER_STATE_VIEWPORT;
+    {
+      unsigned long differences = COGL_FRAMEBUFFER_STATE_VIEWPORT;
+      CoglContext *context = a->context;
+
+      /* XXX: ONGOING BUG: Intel viewport scissor
+       *
+       * Intel gen6 drivers don't currently correctly handle offset
+       * viewports, since primitives aren't clipped within the bounds of
+       * the viewport.  To workaround this we push our own clip for the
+       * viewport that will use scissoring to ensure we clip as expected.
+       *
+       * This workaround implies that a change in viewport state is
+       * effectively also a change in the clipping state.
+       *
+       * TODO: file a bug upstream!
+       */
+      if (G_UNLIKELY (context->needs_viewport_scissor_workaround))
+          differences |= COGL_FRAMEBUFFER_STATE_CLIP;
+
+      return differences;
+    }
   else
     return 0;
 }
-- 
1.8.1.1



More information about the Cogl mailing list