-/* $Id: fb_dri.c,v 1.1 2003/08/06 18:11:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
}
+/**
+ * Called by ctx->Driver.GetBufferSize from in core Mesa to query the
+ * current framebuffer size.
+ */
static void
get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
static void
-init_core_functions( GLcontext *ctx )
+init_core_functions( struct dd_function_table *functions )
{
- ctx->Driver.GetString = get_string;
- ctx->Driver.UpdateState = update_state;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetBufferSize = get_buffer_size;
-
- ctx->Driver.Accum = _swrast_Accum;
- ctx->Driver.Bitmap = _swrast_Bitmap;
- ctx->Driver.Clear = _swrast_Clear; /* could accelerate with blits */
- ctx->Driver.CopyPixels = _swrast_CopyPixels;
- ctx->Driver.DrawPixels = _swrast_DrawPixels;
- ctx->Driver.ReadPixels = _swrast_ReadPixels;
- ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
-
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = _mesa_store_teximage2d;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
- ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
- ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
- ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
- ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
- ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
-
- ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
- ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
- ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
- ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
- ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
- ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
- ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
- ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
- ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+ functions->GetString = get_string;
+ functions->UpdateState = update_state;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetBufferSize = get_buffer_size;
+
+ functions->Clear = _swrast_Clear; /* could accelerate with blits */
}
const fbContextPtr fbdevctx = FB_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = fbdevctx->dri.drawable;
#define INIT_PIXEL_PTR(P, X, Y) \
- GLubyte *P = (char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 3
+ GLubyte *P = (GLubyte *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 3
#define INC_PIXEL_PTR(P) P += 3
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = B; P[1] = G; P[2] = R
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = B; P[1] = G; P[2] = R
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = P[2]; G = P[1]; B = P[0]; A = CHAN_MAX
const fbContextPtr fbdevctx = FB_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = fbdevctx->dri.drawable;
#define INIT_PIXEL_PTR(P, X, Y) \
- GLubyte *P = (char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 4;
+ GLubyte *P = (GLubyte *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 4;
#define INC_PIXEL_PTR(P) P += 4
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
P[0] = B; P[1] = G; P[2] = R; P[3] = 255
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
P[0] = B; P[1] = G; P[2] = R; P[3] = A
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = P[2]; G = P[1]; B = P[0]; A = P[3]
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) ((char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ( (((*P) >> 8) & 0xf8) | (((*P) >> 11) & 0x7) ); \
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) ((char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
-#define STORE_RGB_PIXEL(P, R, G, B) \
+#define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
*P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
-#define STORE_RGBA_PIXEL(P, R, G, B, A) \
+#define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
*P = ( (((R) & 0xf8) << 7) | (((G) & 0xf8) << 2) | ((B) >> 3) )
#define FETCH_RGBA_PIXEL(R, G, B, A, P) \
R = ( (((*P) >> 7) & 0xf8) | (((*P) >> 10) & 0x7) ); \
const fbContextPtr fbdevctx = FB_CONTEXT(ctx); \
__DRIdrawablePrivate *dPriv = fbdevctx->dri.drawable;
#define INIT_PIXEL_PTR(P, X, Y) \
- GLubyte *P = (char *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X)
+ GLubyte *P = (GLubyte *)dPriv->currentBuffer + (Y) * dPriv->currentPitch + (X)
#define INC_PIXEL_PTR(P) P += 1
#define STORE_CI_PIXEL(P, CI) \
P[0] = CI
#define FETCH_CI_PIXEL(CI, P) \
CI = P[0]
-#include "swrast/s_spantemp.h"
+ #include "swrast/s_spantemp.h"
{
fbContextPtr fbmesa;
GLcontext *ctx, *shareCtx;
+ struct dd_function_table functions;
assert(glVisual);
assert(driContextPriv);
if ( !fbmesa )
return GL_FALSE;
+ /* Init default driver functions then plug in our FBdev-specific functions
+ */
+ _mesa_init_driver_functions(&functions);
+ init_core_functions(&functions);
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((fbContextPtr) sharedContextPrivate)->glCtx;
shareCtx = NULL;
ctx = fbmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
- (void *) fbmesa,
- GL_TRUE);
+ &functions, (void *) fbmesa);
if (!fbmesa->glCtx) {
FREE(fbmesa);
return GL_FALSE;
driContextPriv->driverPrivate = fbmesa;
/* Create module contexts */
- init_core_functions( ctx );
_swrast_CreateContext( ctx );
_ac_CreateContext( ctx );
_tnl_CreateContext( ctx );
_swsetup_Wakeup( ctx );
-
/* swrast init -- need to verify these tests - I just plucked the
* numbers out of the air. (KW)
*/
}
-
-
static void
fbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
{
}
-
-
/*
* This is the bootstrap function for the driver.
* The __driCreateScreen name is the symbol that libGL.so fetches.
* Return: pointer to a __DRIscreenPrivate.
*/
-void *__driCreateScreen(struct DRIDriverRec *driver,
- struct DRIDriverContextRec *driverContext)
+void *
+__driCreateScreen(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext)
{
__DRIscreenPrivate *psp;
psp = __driUtilCreateScreenNoDRM(driver, driverContext, &fbAPI);
}
+
/**
* \brief Establish the set of modes available for the display.
*
.depthBits = 16, .stencilBits = 0,
.numAuxBuffers= 0, .level = 0, .pixmapMode = GL_FALSE, },
};
-static int __driInitScreenModes( const DRIDriverContext *ctx,
- int *numModes, const __GLcontextModes **modes)
+
+
+static int
+__driInitScreenModes( const DRIDriverContext *ctx,
+ int *numModes, const __GLcontextModes **modes)
{
*numModes = sizeof(__glModes)/sizeof(__GLcontextModes *);
*modes = &__glModes[0];
-static int __driValidateMode(const DRIDriverContext *ctx )
+static int
+__driValidateMode(const DRIDriverContext *ctx )
{
return 1;
}
#else
# define DRM_PAGE_SIZE 4096
#endif
-
-static int __driInitFBDev( struct DRIDriverContextRec *ctx )
+
+static int
+__driInitFBDev( struct DRIDriverContextRec *ctx )
{
int id;
ctx->shared.hFrameBuffer = ctx->FBStart;
return 1;
}
-static void __driHaltFBDev( struct DRIDriverContextRec *ctx )
+static void
+__driHaltFBDev( struct DRIDriverContextRec *ctx )
{
}