i965: Remove BRW_WM_LOCK dirty bit, introduced to work around lack of relocs.
[mesa.git] / src / mesa / drivers / directfb / idirectfbgl_mesa.c
index 694eeb054dfe697cb86d6cc7d1ce9dd072df0829..93593403c132052a464ef0e2ba188cb0885b3fb8 100644 (file)
 #include <direct/interface.h>
 
 #undef CLAMP
-#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 "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"
@@ -102,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;
@@ -118,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 );
@@ -503,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"
 
@@ -557,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
@@ -578,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"
@@ -706,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;
@@ -818,6 +862,15 @@ directfbgl_create_context( GLcontext        *context,
                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;
@@ -836,6 +889,15 @@ directfbgl_create_context( GLcontext        *context,
                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;