Add support for GLX_SGI_make_current_read.
authorIan Romanick <idr@us.ibm.com>
Fri, 7 May 2004 22:46:37 +0000 (22:46 +0000)
committerIan Romanick <idr@us.ibm.com>
Fri, 7 May 2004 22:46:37 +0000 (22:46 +0000)
src/mesa/drivers/dri/i830/i830_context.c
src/mesa/drivers/dri/i830/i830_context.h
src/mesa/drivers/dri/i830/i830_screen.c
src/mesa/drivers/dri/i830/i830_span.c

index 1c169e1d33f1f29c807ff31b9829115d3007a47f..07a5267c29f116e99f75b6448f3619f82d72fc54 100644 (file)
@@ -506,11 +506,12 @@ GLboolean i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
       i830ContextPtr imesa = (i830ContextPtr) driContextPriv->driverPrivate;
 
       if ( imesa->driDrawable != driDrawPriv ) {
-        /* Shouldn't the readbuffer be stored also? */
         imesa->driDrawable = driDrawPriv;
         i830XMesaWindowMoved( imesa );
       }
 
+       imesa->driReadable = driReadPriv;
+
       _mesa_make_current2(imesa->glCtx,
                          (GLframebuffer *) driDrawPriv->driverPrivate,
                          (GLframebuffer *) driReadPriv->driverPrivate);
index 6dcaf1febe6fc62c67536fa56d01bc009cabc241..99d2a39c7879136f846e351398f6ea27ad85d4b3 100644 (file)
@@ -212,12 +212,26 @@ struct i830_context_t
    drm_clip_rect_t scissor_rect;
 
    drmContext hHWContext;
-   drm_hw_lock_t *driHwLock;
+   drmLock *driHwLock;
    int driFd;
 
-   __DRIdrawablePrivate *driDrawable;
+   __DRIdrawablePrivate *driDrawable;    /**< DRI drawable bound to this
+                                         * context for drawing.
+                                         */
+   __DRIdrawablePrivate *driReadable;    /**< DRI drawable bound to this
+                                         * context for reading.
+                                         */
+
+   /**
+    * Drawable used by Mesa for software fallbacks for reading and
+    * writing.  It is set by Mesa's \c SetBuffer callback, and will always be
+    * either \c i830_context_t::driDrawable or \c i830_context_t::driReadable.
+    */
+   
+   __DRIdrawablePrivate * mesa_drawable;
+
    __DRIscreenPrivate *driScreen;
-   i830ScreenPrivate *i830Screen; 
+   i830ScreenPrivate *i830Screen;
    I830SAREAPtr sarea;
 
    /**
index 18dab3d40200e9f9dc8476f399239aa994f25b46..10a1f4e5b76e97523a349e173c80636e4dd4c6f0 100644 (file)
@@ -300,6 +300,8 @@ static GLboolean i830InitDriver(__DRIscreenPrivate *sPriv)
       void * const psc = sPriv->psc->screenConfigs;
 
       if ( glx_enable_extension != NULL ) {
+        (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
+
         if ( driCompareGLXAPIVersion( 20030915 ) >= 0 ) {
            (*glx_enable_extension)( psc, "GLX_SGIX_fbconfig" );
            (*glx_enable_extension)( psc, "GLX_OML_swap_method" );
index 28610923e3f14ff1bbb6142a391c08a65d8dc35b..9076b344233e518b0b59c5388987b24dd268a7d8 100644 (file)
@@ -27,12 +27,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_span.c,v 1.4 2002/12/10 01:26:53 dawes Exp $ */
 
-/*
- * Author:
- *   Jeff Hartmann <jhartmann@2d3d.com>
+/**
+ * \file i830_span.c
+ *
+ * Heavily based on the I810 driver, which was written by Keith Whitwell.
  *
- * Heavily based on the I810 driver, which was written by:
- *   Keith Whitwell <keith@tungstengraphics.com>
+ * \author Jeff Hartmann <jhartmann@2d3d.com>
+ * \author Keith Whitwell <keith@tungstengraphics.com>
  */
 
 #include "glheader.h"
@@ -52,7 +53,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define LOCAL_VARS                                             \
    i830ContextPtr imesa = I830_CONTEXT(ctx);                    \
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;           \
+   __DRIdrawablePrivate *dPriv = imesa->mesa_drawable;         \
    i830ScreenPrivate *i830Screen = imesa->i830Screen;          \
    GLuint pitch = i830Screen->backPitch * i830Screen->cpp;     \
    GLuint height = dPriv->h;                                   \
@@ -67,7 +68,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define LOCAL_DEPTH_VARS                                       \
    i830ContextPtr imesa = I830_CONTEXT(ctx);                    \
-   __DRIdrawablePrivate *dPriv = imesa->driDrawable;           \
+   __DRIdrawablePrivate *dPriv = imesa->mesa_drawable;         \
    i830ScreenPrivate *i830Screen = imesa->i830Screen;          \
    GLuint pitch = i830Screen->backPitch * i830Screen->cpp;     \
    GLuint height = dPriv->h;                                   \
@@ -267,6 +268,13 @@ static void i830SetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
                           GLuint bufferBit)
 {
    i830ContextPtr imesa = I830_CONTEXT(ctx);
+   
+   assert( (colorBuffer == imesa->driDrawable->driverPrivate)
+          || (colorBuffer == imesa->driReadable->driverPrivate) );
+
+   imesa->mesa_drawable = (colorBuffer == imesa->driDrawable->driverPrivate)
+       ? imesa->driDrawable : imesa->driReadable;
+   
    if (bufferBit == DD_FRONT_LEFT_BIT) {
       imesa->drawMap = (char *)imesa->driScreen->pFB;
       imesa->readMap = (char *)imesa->driScreen->pFB;