intel/DRI2: add DRI2flushExtension support with invalidate hook
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 8 Jan 2010 17:35:47 +0000 (12:35 -0500)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Fri, 8 Jan 2010 17:40:58 +0000 (12:40 -0500)
Needed to support the SwapBuffers code properly.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_context.h
src/mesa/drivers/dri/intel/intel_extensions.h
src/mesa/drivers/dri/intel/intel_screen.c
src/mesa/drivers/dri/intel/intel_tex_image.c

index eccba5bd23cede9cfa0a75320b8a970672802ab3..a3c828027f88f7cd46bf31931076554908f1451f 100644 (file)
@@ -72,8 +72,6 @@ int INTEL_DEBUG = (0);
 #define DRIVER_DATE_GEM                 "GEM " DRIVER_DATE
 
 
-static void intel_flush(GLcontext *ctx, GLboolean needs_mi_flush);
-
 static const GLubyte *
 intelGetString(GLcontext * ctx, GLenum name)
 {
@@ -380,6 +378,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
        }
    }
 
+   drawable->validBuffers = GL_TRUE;
    driUpdateFramebufferSize(&intel->ctx, drawable);
 }
 
@@ -467,7 +466,7 @@ intelInvalidateState(GLcontext * ctx, GLuint new_state)
       intel->vtbl.invalidate_state( intel, new_state );
 }
 
-static void
+void
 intel_flush(GLcontext *ctx, GLboolean needs_mi_flush)
 {
    struct intel_context *intel = intel_context(ctx);
@@ -950,11 +949,7 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
         (struct intel_framebuffer *) driDrawPriv->driverPrivate;
       GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
  
-      if (driContextPriv->driScreenPriv->dri2.enabled) {     
-          intel_update_renderbuffers(driContextPriv, driDrawPriv);
-          if (driDrawPriv != driReadPriv)
-              intel_update_renderbuffers(driContextPriv, driReadPriv);
-      } else {
+      if (!driContextPriv->driScreenPriv->dri2.enabled) {     
           /* XXX FBO temporary fix-ups!  These are released in 
            * intelDextroyContext(), above.  Changes here should be
            * reflected there.
@@ -1088,6 +1083,10 @@ void LOCK_HARDWARE( struct intel_context *intel )
     if (intel->driDrawable) {
        intel_fb = intel->driDrawable->driverPrivate;
 
+       if (!intel->driDrawable->validBuffers)
+         intel_update_renderbuffers(intel->driContext,
+                                    intel->driDrawable);
+
        if (intel_fb)
          intel_rb =
             intel_get_renderbuffer(&intel_fb->Base,
index 09e8223bc7e1589377d21e504aec77ea910d609a..61d0be3a5b02848e413b3b22b312a4c1e8f75bc1 100644 (file)
@@ -447,6 +447,7 @@ extern void intelGetLock(struct intel_context *intel, GLuint flags);
 
 extern void intelFinish(GLcontext * ctx);
 extern void intelFlush(GLcontext * ctx);
+extern void intel_flush(GLcontext * ctx, GLboolean needs_mi_flush);
 
 extern void intelInitDriverFunctions(struct dd_function_table *functions);
 
index 1d1c97a4a9be23e810c03bba334b9919244e8b30..e78e07356e7e187238a5fd0466111e726b179db7 100644 (file)
@@ -32,5 +32,8 @@
 extern void
 intelInitExtensions(GLcontext *ctx);
 
+extern void
+intelFlushDrawable(__DRIdrawable *drawable);
+
 
 #endif
index a3d676741a1ac9ab2058997cc67ae1e0a844f37e..8251e91ace770dc6bb0eb1596c0f28b63d1a0ed0 100644 (file)
@@ -236,6 +236,31 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
    intelSetTexBuffer2,
 };
 
+static void
+intelDRI2Flush(__DRIdrawable *drawable)
+{
+   struct intel_context *intel = drawable->driContextPriv->driverPrivate;
+
+   if (intel->gen < 4)
+      INTEL_FIREVERTICES(intel);
+
+   if (intel->batch->map != intel->batch->ptr)
+      intel_batchbuffer_flush(intel->batch);
+}
+
+static void
+intelDRI2FlushInvalidate(__DRIdrawable *drawable)
+{
+   intelDRI2Flush(drawable);
+   drawable->validBuffers = GL_FALSE;
+}
+
+static const struct __DRI2flushExtensionRec intelFlushExtension = {
+    { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
+    intelDRI2Flush,
+    intelDRI2FlushInvalidate,
+};
+
 static const __DRIextension *intelScreenExtensions[] = {
     &driReadDrawableExtension,
     &driCopySubBufferExtension.base,
@@ -244,6 +269,7 @@ static const __DRIextension *intelScreenExtensions[] = {
     &driMediaStreamCounterExtension.base,
     &intelTexOffsetExtension.base,
     &intelTexBufferExtension.base,
+    &intelFlushExtension.base,
     NULL
 };
 
@@ -524,11 +550,9 @@ intelFillInModes(__DRIscreenPrivate *psp,
    unsigned back_buffer_factor;
    int i;
 
-   /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
-    * support pageflipping at all.
-    */
    static const GLenum back_buffer_modes[] = {
-      GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+       GLX_NONE, GLX_SWAP_UNDEFINED_OML,
+       GLX_SWAP_EXCHANGE_OML, GLX_SWAP_COPY_OML
    };
 
    uint8_t depth_bits_array[3];
@@ -711,11 +735,10 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
    intelScreenPrivate *intelScreen;
    GLenum fb_format[3];
    GLenum fb_type[3];
-   /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
-    * support pageflipping at all.
-    */
+
    static const GLenum back_buffer_modes[] = {
-      GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+       GLX_NONE, GLX_SWAP_UNDEFINED_OML,
+       GLX_SWAP_EXCHANGE_OML, GLX_SWAP_COPY_OML
    };
    uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1];
    int color;
index 66d61f93ea9d52ce685169bf007d39a4ac635661..a8f7e6c456e9dc3c622a39f09ff4f677184c9550 100644 (file)
@@ -749,7 +749,8 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
    if (!intelObj)
       return;
 
-   intel_update_renderbuffers(pDRICtx, dPriv);
+   if (!dPriv->validBuffers)
+      intel_update_renderbuffers(pDRICtx, dPriv);
 
    rb = intel_fb->color_rb[0];
    /* If the region isn't set, then intel_update_renderbuffers was unable