mesa: prefix more #includes with "main/"
[mesa.git] / src / mesa / drivers / directfb / idirectfbgl_mesa.c
index 323cdd6791383e82bfe492b421a311cfeb4355e6..93593403c132052a464ef0e2ba188cb0885b3fb8 100644 (file)
@@ -1,18 +1,19 @@
 /*
- * Copyright (C) 2004-2006 Claudio Ciccani <klan@users.sf.net>
+ * Copyright (C) 2004-2007 Claudio Ciccani <klan@directfb.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  * 
  * Based on glfbdev.c, written by Brian Paul.
 
 #include <pthread.h>
 
-#include <direct/messages.h>
-#include <direct/interface.h>
-#include <direct/mem.h>
-
 #include <directfb.h>
 #include <directfb_version.h>
 
-#define VERSION_CODE( M, m, r )  (((M) * 1000) + ((m) * 100) + ((r)))
-#define DIRECTFB_VERSION_CODE    VERSION_CODE( DIRECTFB_MAJOR_VERSION, \
-                                               DIRECTFB_MINOR_VERSION, \
-                                               DIRECTFB_MICRO_VERSION )
-
+#include <directfbgl.h>
 
-#ifdef CLAMP
-# undef CLAMP
-#endif 
+#include <direct/mem.h>
+#include <direct/messages.h>
+#include <direct/interface.h>
 
-#include "GL/directfbgl.h"
-#include "glheader.h"
-#include "buffers.h"
-#include "context.h"
-#include "extensions.h"
-#include "framebuffer.h"
-#include "renderbuffer.h"
-#include "imports.h"
-#include "texformat.h"
-#include "teximage.h"
-#include "texstore.h"
-#include "array_cache/acache.h"
+#undef CLAMP
+#include "main/glheader.h"
+#include "main/buffers.h"
+#include "main/context.h"
+#include "main/extensions.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "main/imports.h"
+#include "main/texformat.h"
+#include "main/teximage.h"
+#include "main/texstore.h"
+#include "vbo/vbo.h"
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "tnl/tnl.h"
 #include "drivers/common/driverfuncs.h"
 
 
+#define VERSION_CODE( M, m, r )  (((M) * 1000) + ((m) * 100) + ((r)))
+#define DIRECTFB_VERSION_CODE    VERSION_CODE( DIRECTFB_MAJOR_VERSION, \
+                                               DIRECTFB_MINOR_VERSION, \
+                                               DIRECTFB_MICRO_VERSION )
+
+
 static DFBResult
 Probe( void *data );
 
@@ -79,7 +78,7 @@ DIRECT_INTERFACE_IMPLEMENTATION( IDirectFBGL, Mesa )
 typedef struct {
      int                     ref;       /* reference counter */
      
-     DFBBoolean              locked;
+     int                     locked;
      
      IDirectFBSurface       *surface;
      DFBSurfacePixelFormat   format;
@@ -87,8 +86,8 @@ typedef struct {
      int                     height;
      
      struct {
-          __u8              *start;
-          __u8              *end;
+          GLubyte           *start;
+          GLubyte           *end;
           int                pitch;
      } video;
 
@@ -103,7 +102,7 @@ typedef struct {
 static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER;
 static unsigned int    global_ref  = 0;
 
-static inline int directfbgl_init( void )
+static INLINE int directfbgl_init( void )
 {
      pthread_mutexattr_t attr;
      int                 ret;
@@ -119,7 +118,7 @@ static inline int directfbgl_init( void )
      return ret;
 }
 
-static inline void directfbgl_finish( void )
+static INLINE void directfbgl_finish( void )
 {
      if (--global_ref == 0)
           pthread_mutex_destroy( &global_lock );
@@ -135,7 +134,6 @@ static bool  directfbgl_init_visual    ( GLvisual              *visual,
 static bool  directfbgl_create_context ( GLcontext             *context,
                                          GLframebuffer         *framebuffer,
                                          GLvisual              *visual,
-                                         DFBSurfacePixelFormat  format,
                                          IDirectFBGL_data      *data );
 static void  directfbgl_destroy_context( GLcontext             *context,
                                          GLframebuffer         *framebuffer );
@@ -185,12 +183,14 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz )
      IDirectFBSurface *surface;
      int               width   = 0;
      int               height  = 0;
-     DFBResult         err;
+     DFBResult         ret;
      
      DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
 
-     if (data->locked)
-          return DFB_LOCKED;
+     if (data->locked) {
+          data->locked++;
+          return DFB_OK;
+     }
 
      if (directfbgl_lock())
           return DFB_LOCKED;
@@ -198,11 +198,12 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz )
      surface = data->surface;
      surface->GetSize( surface, &width, &height );
      
-     err = surface->Lock( surface, DSLF_READ | DSLF_WRITE, 
+     ret = surface->Lock( surface, DSLF_READ | DSLF_WRITE, 
                           (void*)&data->video.start, &data->video.pitch );
-     if (err != DFB_OK) {
+     if (ret) {
           D_ERROR( "DirectFBGL/Mesa: couldn't lock surface.\n" );
-          return err;
+          directfbgl_unlock();
+          return ret;
      }
      data->video.end = data->video.start + (height-1) * data->video.pitch;
 
@@ -212,13 +213,13 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz )
                          &data->framebuffer, &data->framebuffer );
      
      if (data->width != width || data->height != height) {
+          _mesa_resize_framebuffer( &data->context, 
+                                    &data->framebuffer, width, height );
           data->width  = width;
-          data->height = height;
-          _mesa_resize_framebuffer(&data->context, 
-                                   &data->framebuffer, width, height);
+          data->height = height;                        
      }
 
-     data->locked = DFB_TRUE;
+     data->locked++;
      
      return DFB_OK;
 }
@@ -230,14 +231,14 @@ IDirectFBGL_Mesa_Unlock( IDirectFBGL *thiz )
 
      if (!data->locked)
           return DFB_OK;
-
-     _mesa_make_current( NULL, NULL, NULL );
+          
+     if (--data->locked == 0) {
+          _mesa_make_current( NULL, NULL, NULL );
      
-     data->surface->Unlock( data->surface );
-
-     directfbgl_unlock();
+          data->surface->Unlock( data->surface );
 
-     data->locked = DFB_FALSE;
+          directfbgl_unlock();
+     }
      
      return DFB_OK;
 }
@@ -270,12 +271,32 @@ IDirectFBGL_Mesa_GetAttributes( IDirectFBGL     *thiz,
      attributes->accum_green_size = visual->accumGreenBits;
      attributes->accum_blue_size  = visual->accumBlueBits;
      attributes->accum_alpha_size = visual->accumAlphaBits;
-     attributes->double_buffer    = (caps & DSCAPS_FLIPPING) ? 1 : 0;
+     attributes->double_buffer    = ((caps & DSCAPS_FLIPPING) != 0);
      attributes->stereo           = (visual->stereoMode != 0);
 
      return DFB_OK;
 }
 
+#if DIRECTFBGL_INTERFACE_VERSION >= 1
+static DFBResult
+IDirectFBGL_Mesa_GetProcAddress( IDirectFBGL  *thiz,
+                                 const char   *name,
+                                 void        **ret_address )
+{
+     DIRECT_INTERFACE_GET_DATA( IDirectFBGL );
+
+     if (!name)
+          return DFB_INVARG;
+          
+     if (!ret_address)
+          return DFB_INVARG;
+          
+     *ret_address = _glapi_get_proc_address( name );
+          
+     return (*ret_address) ? DFB_OK : DFB_UNSUPPORTED;
+}
+#endif
+
 
 /* exported symbols */
 
@@ -288,6 +309,8 @@ Probe( void *data )
 static DFBResult
 Construct( IDirectFBGL *thiz, IDirectFBSurface *surface )
 {
+     DFBResult ret;
+     
      /* Initialize global resources. */
      if (directfbgl_init())
           return DFB_INIT;
@@ -296,12 +319,17 @@ Construct( IDirectFBGL *thiz, IDirectFBSurface *surface )
      DIRECT_ALLOCATE_INTERFACE_DATA( thiz, IDirectFBGL );
  
      /* Initialize interface data. */
-     data->ref     = 1;
-     data->surface = surface;
+     data->ref = 1;
 
-     surface->AddRef( surface );
-     surface->GetPixelFormat( surface, &data->format );
-     surface->GetSize( surface, &data->width, &data->height );
+     /* Duplicate destination surface. */
+     ret = surface->GetSubSurface( surface, NULL, &data->surface );
+     if (ret) {
+          IDirectFBGL_Mesa_Destruct( thiz );
+          return ret;
+     }
+
+     data->surface->GetPixelFormat( data->surface, &data->format );
+     data->surface->GetSize( data->surface, &data->width, &data->height );
 
      /* Configure visual. */
      if (!directfbgl_init_visual( &data->visual, data->format )) {
@@ -311,19 +339,23 @@ Construct( IDirectFBGL *thiz, IDirectFBSurface *surface )
      }
      
      /* Create context. */
-     if (!directfbgl_create_context( &data->context, &data->framebuffer,
-                                     &data->visual, data->format, data )) {
+     if (!directfbgl_create_context( &data->context,
+                                     &data->framebuffer,
+                                     &data->visual, data )) {
           D_ERROR( "DirectFBGL/Mesa: failed to create context.\n" );
           IDirectFBGL_Mesa_Destruct( thiz );
           return DFB_UNSUPPORTED;
      }
 
      /* Assign interface pointers. */
-     thiz->AddRef        = IDirectFBGL_Mesa_AddRef;
-     thiz->Release       = IDirectFBGL_Mesa_Release;
-     thiz->Lock          = IDirectFBGL_Mesa_Lock;
-     thiz->Unlock        = IDirectFBGL_Mesa_Unlock;
-     thiz->GetAttributes = IDirectFBGL_Mesa_GetAttributes;
+     thiz->AddRef         = IDirectFBGL_Mesa_AddRef;
+     thiz->Release        = IDirectFBGL_Mesa_Release;
+     thiz->Lock           = IDirectFBGL_Mesa_Lock;
+     thiz->Unlock         = IDirectFBGL_Mesa_Unlock;
+     thiz->GetAttributes  = IDirectFBGL_Mesa_GetAttributes;
+#if DIRECTFBGL_INTERFACE_VERSION >= 1
+     thiz->GetProcAddress = IDirectFBGL_Mesa_GetProcAddress;
+#endif 
 
      return DFB_OK;
 }
@@ -342,7 +374,7 @@ dfbUpdateState( GLcontext *ctx, GLuint new_state )
 {
      _swrast_InvalidateState( ctx, new_state );
      _swsetup_InvalidateState( ctx, new_state );
-     _ac_InvalidateState( ctx, new_state );
+     _vbo_InvalidateState( ctx, new_state );
      _tnl_InvalidateState( ctx, new_state );
 }
 
@@ -363,71 +395,54 @@ dfbGetBufferSize( GLframebuffer *buffer, GLuint *width, GLuint *height )
 static void
 dfbSetViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h )
 {
-   GLuint newWidth, newHeight;
-   GLframebuffer *buffer = ctx->WinSysDrawBuffer;
-   dfbGetBufferSize( buffer, &newWidth, &newHeight );
-   if (buffer->Width != newWidth || buffer->Height != newHeight) {
-      _mesa_resize_framebuffer(ctx, buffer, newWidth, newHeight );
-   }
+     /* Nothing to do (the surface can't be resized while it's locked). */
+     return;
 }
 
 static void
 dfbClear( GLcontext *ctx, GLbitfield mask )
 {
      IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
-     int x = ctx->DrawBuffer->_Xmin;
-     int y = ctx->DrawBuffer->_Ymin;
-     int width = ctx->DrawBuffer->_Xmax - x;
-     int height = ctx->DrawBuffer->_Ymax - y;
-     GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height)
-     
-     if (mask & BUFFER_BIT_FRONT_LEFT &&
-         ctx->Color.ColorMask[0]      &&
-         ctx->Color.ColorMask[1]      &&
-         ctx->Color.ColorMask[2]      &&
+#define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \
+                         BUFFER_BIT_BACK_LEFT  | BUFFER_BIT_BACK_RIGHT  )
+     if (mask & BUFFER_BIT_MASK  &&
+         ctx->Color.ColorMask[0] &&
+         ctx->Color.ColorMask[1] &&
+         ctx->Color.ColorMask[2] &&
          ctx->Color.ColorMask[3])
      {
           DFBRegion clip;
-          __u8 a, r, g, b;
+          GLubyte   a, r, g, b;
           
           UNCLAMPED_FLOAT_TO_UBYTE( a, ctx->Color.ClearColor[ACOMP] );
           UNCLAMPED_FLOAT_TO_UBYTE( r, ctx->Color.ClearColor[RCOMP] );
           UNCLAMPED_FLOAT_TO_UBYTE( g, ctx->Color.ClearColor[GCOMP] );
           UNCLAMPED_FLOAT_TO_UBYTE( b, ctx->Color.ClearColor[BCOMP] );
 
-          data->surface->Unlock( data->surface );
-
-#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,25)
-          data->surface->GetClip( data->surface, &clip );
-#else
-          (void)clip;
-#endif
+          clip.x1 = ctx->DrawBuffer->_Xmin;
+          clip.y1 = ctx->DrawBuffer->_Ymin;
+          clip.x2 = ctx->DrawBuffer->_Xmax - 1;
+          clip.y2 = ctx->DrawBuffer->_Ymax - 1;
+          data->surface->SetClip( data->surface, &clip );
           
-          if (all) {
-               data->surface->SetClip( data->surface, NULL );
-          }
-          else {
-               DFBRegion reg = { x1:x, y1:y, x2:x+width-1, y2:y+height-1 };
-               data->surface->SetClip( data->surface, &reg );
-          }
+          data->surface->Unlock( data->surface );
           
           data->surface->Clear( data->surface, r, g, b, a );
-
-#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,25)
-          data->surface->SetClip( data->surface, &clip );
-#endif
           
           data->surface->Lock( data->surface, DSLF_READ | DSLF_WRITE,
                                (void*)&data->video.start, &data->video.pitch );
+          data->video.end = data->video.start + (data->height-1) * data->video.pitch;
+          data->render.Data = data->video.start;
           
-          mask &= ~BUFFER_BIT_FRONT_LEFT;
+          mask &= ~BUFFER_BIT_MASK;
      }
+#undef BUFFER_BIT_MASK
      
      if (mask)
           _swrast_Clear( ctx, mask );
-}        
-          
-     
+}
+
 
 /************************ RenderBuffer functions *****************************/
 
@@ -488,10 +503,31 @@ dfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render,
           (((S[GCOMP]) & 0xf0)     ) | \
           (((S[BCOMP]) & 0xf0) >> 4) )
 #define FETCH_PIXEL(D, P) \
-   D[RCOMP] = ((*P & 0x0f00) >> 4); \
-   D[GCOMP] = ((*P & 0x00f0)     ); \
-   D[BCOMP] = ((*P & 0x000f) << 4); \
-   D[ACOMP] = ((*P & 0xf000) >> 8)
+   D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >>  8); \
+   D[GCOMP] = ((*P & 0x00f0)     ) | ((*P & 0x00f0) >>  4); \
+   D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f)      ); \
+   D[ACOMP] = ((*P & 0xf000) >> 8) | ((*P & 0xf000) >> 12)
+
+#include "swrast/s_spantemp.h"
+
+/* RGB444 */
+#define NAME(PREFIX) PREFIX##_RGB444
+#define FORMAT GL_RGBA8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(P, X, Y, S) \
+   *P = ( (((S[RCOMP]) & 0xf0) << 4) | \
+          (((S[GCOMP]) & 0xf0)     ) | \
+          (((S[BCOMP]) & 0xf0) >> 4) )
+#define FETCH_PIXEL(D, P) \
+   D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \
+   D[GCOMP] = ((*P & 0x00f0)     ) | ((*P & 0x00f0) >> 4); \
+   D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f)     ); \
+   D[ACOMP] = 0xff
 
 #include "swrast/s_spantemp.h"
 
@@ -542,13 +578,34 @@ dfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render,
           (((S[GCOMP]) & 0xf8) <<  2) | \
           (((S[BCOMP])       ) >>  3) )
 #define FETCH_PIXEL(D, P) \
-   D[RCOMP] = ((*P & 0x7c00) >> 7); \
-   D[GCOMP] = ((*P & 0x03e0) >> 2); \
-   D[BCOMP] = ((*P & 0x001f) << 3); \
+   D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \
+   D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >>  7); \
+   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) <<  2); \
    D[ACOMP] = ((*P & 0x8000) ? 0xff : 0)
 
 #include "swrast/s_spantemp.h"
 
+/* RGB555 */
+#define NAME(PREFIX) PREFIX##_RGB555
+#define FORMAT GL_RGBA8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(P, X, Y, S) \
+   *P = ( (((S[RCOMP]) & 0xf8) <<  7) | \
+          (((S[GCOMP]) & 0xf8) <<  2) | \
+          (((S[BCOMP])       ) >>  3) )
+#define FETCH_PIXEL(D, P) \
+   D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \
+   D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >>  7); \
+   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) <<  2); \
+   D[ACOMP] = 0xff
+
+#include "swrast/s_spantemp.h"
+
 /* RGB16 */
 #define NAME(PREFIX) PREFIX##_RGB16
 #define FORMAT GL_RGBA8
@@ -563,9 +620,9 @@ dfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render,
           (((S[GCOMP]) & 0xfc) << 3) | \
           (((S[BCOMP])       ) >> 3) )
 #define FETCH_PIXEL(D, P) \
-   D[RCOMP] = ((*P & 0xf800) >> 8); \
-   D[GCOMP] = ((*P & 0x07e0) >> 3); \
-   D[BCOMP] = ((*P & 0x001f) << 3); \
+   D[RCOMP] = ((*P & 0xf800) >> 8) | ((*P & 0xf800) >> 13); \
+   D[GCOMP] = ((*P & 0x07e0) >> 3) | ((*P & 0x07e0) >>  9); \
+   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) >>  2); \
    D[ACOMP] = 0xff
 
 #include "swrast/s_spantemp.h"
@@ -691,22 +748,24 @@ directfbgl_init_visual( GLvisual              *visual,
                blueBits  = 2;
                break;
           case DSPF_ARGB4444:
+               alphaBits = 4;
+          case DSPF_RGB444:
                redBits   = 4;
                greenBits = 4;
                blueBits  = 4;
-               alphaBits = 4;
                break;
           case DSPF_ARGB2554:
+               alphaBits = 2;
                redBits   = 5;
                greenBits = 5;
                blueBits  = 4;
-               alphaBits = 2;
                break;
           case DSPF_ARGB1555:
+               alphaBits = 1;
+          case DSPF_RGB555:
                redBits   = 5;
                greenBits = 5;
                blueBits  = 5;
-               alphaBits = 1;
                break;
           case DSPF_RGB16:
                redBits   = 5;
@@ -747,11 +806,10 @@ directfbgl_init_visual( GLvisual              *visual,
 }
 
 static bool
-directfbgl_create_context( GLcontext             *context,
-                           GLframebuffer         *framebuffer,
-                           GLvisual              *visual,
-                           DFBSurfacePixelFormat  format,
-                           IDirectFBGL_data      *data )
+directfbgl_create_context( GLcontext        *context,
+                           GLframebuffer    *framebuffer,
+                           GLvisual         *visual,
+                           IDirectFBGL_data *data )
 {
      struct dd_function_table functions;
      
@@ -772,7 +830,7 @@ directfbgl_create_context( GLcontext             *context,
      }
 
      _swrast_CreateContext( context );
-     _ac_CreateContext( context );
+     _vbo_CreateContext( context );
      _tnl_CreateContext( context );
      _swsetup_CreateContext( context );
      _swsetup_Wakeup( context );
@@ -785,11 +843,12 @@ directfbgl_create_context( GLcontext             *context,
      data->render.Delete         = dfbDeleteRenderbuffer;
      data->render.AllocStorage   = dfbRenderbufferStorage;
      
-     switch (format) {
+     switch (data->format) {
           case DSPF_RGB332:
                data->render.GetRow        = get_row_RGB332;
                data->render.GetValues     = get_values_RGB332;
                data->render.PutRow        = put_row_RGB332;
+               data->render.PutRowRGB     = put_row_rgb_RGB332;
                data->render.PutMonoRow    = put_mono_row_RGB332;
                data->render.PutValues     = put_values_RGB332;
                data->render.PutMonoValues = put_mono_values_RGB332;
@@ -798,14 +857,25 @@ directfbgl_create_context( GLcontext             *context,
                data->render.GetRow        = get_row_ARGB4444;
                data->render.GetValues     = get_values_ARGB4444;
                data->render.PutRow        = put_row_ARGB4444;
+               data->render.PutRowRGB     = put_row_rgb_ARGB4444;
                data->render.PutMonoRow    = put_mono_row_ARGB4444;
                data->render.PutValues     = put_values_ARGB4444;
                data->render.PutMonoValues = put_mono_values_ARGB4444;
                break;
+          case DSPF_RGB444: 
+               data->render.GetRow        = get_row_RGB444;
+               data->render.GetValues     = get_values_RGB444;
+               data->render.PutRow        = put_row_RGB444;
+               data->render.PutRowRGB     = put_row_rgb_RGB444;
+               data->render.PutMonoRow    = put_mono_row_RGB444;
+               data->render.PutValues     = put_values_RGB444;
+               data->render.PutMonoValues = put_mono_values_RGB444;
+               break;
           case DSPF_ARGB2554: 
                data->render.GetRow        = get_row_ARGB2554;
                data->render.GetValues     = get_values_ARGB2554;
                data->render.PutRow        = put_row_ARGB2554;
+               data->render.PutRowRGB     = put_row_rgb_ARGB2554;
                data->render.PutMonoRow    = put_mono_row_ARGB2554;
                data->render.PutValues     = put_values_ARGB2554;
                data->render.PutMonoValues = put_mono_values_ARGB2554;
@@ -814,14 +884,25 @@ directfbgl_create_context( GLcontext             *context,
                data->render.GetRow        = get_row_ARGB1555;
                data->render.GetValues     = get_values_ARGB1555;
                data->render.PutRow        = put_row_ARGB1555;
+               data->render.PutRowRGB     = put_row_rgb_ARGB1555;
                data->render.PutMonoRow    = put_mono_row_ARGB1555;
                data->render.PutValues     = put_values_ARGB1555;
                data->render.PutMonoValues = put_mono_values_ARGB1555;
                break;
+          case DSPF_RGB555:
+               data->render.GetRow        = get_row_RGB555;
+               data->render.GetValues     = get_values_RGB555;
+               data->render.PutRow        = put_row_RGB555;
+               data->render.PutRowRGB     = put_row_rgb_RGB555;
+               data->render.PutMonoRow    = put_mono_row_RGB555;
+               data->render.PutValues     = put_values_RGB555;
+               data->render.PutMonoValues = put_mono_values_RGB555;
+               break;
           case DSPF_RGB16:
                data->render.GetRow        = get_row_RGB16;
                data->render.GetValues     = get_values_RGB16;
                data->render.PutRow        = put_row_RGB16;
+               data->render.PutRowRGB     = put_row_rgb_RGB16;
                data->render.PutMonoRow    = put_mono_row_RGB16;
                data->render.PutValues     = put_values_RGB16;
                data->render.PutMonoValues = put_mono_values_RGB16;
@@ -830,6 +911,7 @@ directfbgl_create_context( GLcontext             *context,
                data->render.GetRow        = get_row_RGB24;
                data->render.GetValues     = get_values_RGB24;
                data->render.PutRow        = put_row_RGB24;
+               data->render.PutRowRGB     = put_row_rgb_RGB24;
                data->render.PutMonoRow    = put_mono_row_RGB24;
                data->render.PutValues     = put_values_RGB24;
                data->render.PutMonoValues = put_mono_values_RGB24;
@@ -838,6 +920,7 @@ directfbgl_create_context( GLcontext             *context,
                data->render.GetRow        = get_row_RGB32;
                data->render.GetValues     = get_values_RGB32;
                data->render.PutRow        = put_row_RGB32;
+               data->render.PutRowRGB     = put_row_rgb_RGB32;
                data->render.PutMonoRow    = put_mono_row_RGB32;
                data->render.PutValues     = put_values_RGB32;
                data->render.PutMonoValues = put_mono_values_RGB32;
@@ -846,6 +929,7 @@ directfbgl_create_context( GLcontext             *context,
                data->render.GetRow        = get_row_ARGB;
                data->render.GetValues     = get_values_ARGB;
                data->render.PutRow        = put_row_ARGB;
+               data->render.PutRowRGB     = put_row_rgb_ARGB;
                data->render.PutMonoRow    = put_mono_row_ARGB;
                data->render.PutValues     = put_values_ARGB;
                data->render.PutMonoValues = put_mono_values_ARGB;
@@ -854,6 +938,7 @@ directfbgl_create_context( GLcontext             *context,
                data->render.GetRow        = get_row_AiRGB;
                data->render.GetValues     = get_values_AiRGB;
                data->render.PutRow        = put_row_AiRGB;
+               data->render.PutRowRGB     = put_row_rgb_AiRGB;
                data->render.PutMonoRow    = put_mono_row_AiRGB;
                data->render.PutValues     = put_values_AiRGB;
                data->render.PutMonoValues = put_mono_values_AiRGB;
@@ -863,6 +948,9 @@ directfbgl_create_context( GLcontext             *context,
                return false;
      }
 
+     data->render.Width = data->width;
+     data->render.Height = data->height;
+
      _mesa_add_renderbuffer( framebuffer, BUFFER_FRONT_LEFT, &data->render );
      
      _mesa_add_soft_renderbuffers( framebuffer,
@@ -884,8 +972,11 @@ static void
 directfbgl_destroy_context( GLcontext     *context,
                             GLframebuffer *framebuffer )
 {
-     _mesa_free_framebuffer_data( framebuffer );
-     _mesa_notifyDestroy( context );
+     _swsetup_DestroyContext( context );
+     _swrast_DestroyContext( context );
+     _tnl_DestroyContext( context );
+     _vbo_DestroyContext( context );
+     //_mesa_free_framebuffer_data( framebuffer );
      _mesa_free_context_data( context );
 }