summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordok666 <dok666>2003-05-06 00:01:36 +0000
committerdok666 <dok666>2003-05-06 00:01:36 +0000
commit7f20382be4bd0c2ad602e46ef72fec9156bddf04 (patch)
tree8034808e09c20d6019b8e2d25b13fa20c6cd9845
parent7fe70b51e82516b8acc0ebdfc4fd2bdfefecac2c (diff)
This is the first checkin to the embedded-2-branch.
Architectural changes --------------------- Moved global (and static) front/back buffer offset/pitch/cpp to the drawables for dynamic allocation of multiple buffers. Made driverContext.shared.fbOrigin the amount of video memory that won't be used by the driver for local textures etc. The windowing system will allocate front/back buffers below this origin. Removed front/back buffer offset, pitch, width, height and cpp from mgaScreen and mgaDMAInit. Added them to mga_context_regs_t. Unlock hardware in mgaUnbindContext() and radeonUnbindContext(). Removed nearly all MiniGLX dependencies from DRI Util, it can now be used without allocating any MiniGLXDisplayRec, GLXDrawable, XVisualInfo etc. Fixes to the Matrox driver -------------------------- Proper deinitialization (buffer unmapping etc). Fixed mip mapping by implementing mgaChooseTextureFormat() the supposed way and removing the texture conversion code. Otherwise the texture is marked to be incomplete because the formats don't match. Fixed multi texturing by fixing the texture unit swapping in mgaUpdateTextureState(). Fixed fogging. Fixed mgaClearColor(). Fixed register masking in mgaSetTexFilter(). Fixed mgaDDTexParameter() for texture objects that aren't currently bound to the TMU but to the GL context. Other changes ------------- Disabled src/drv/fb until it's working again. Some signed/unsigned and other warnings fixes (gcc-3.3 -Wall). Major TODOs ----------- Update radeon_dri and fb_dri for the architectural changes. Cleanup/update MiniGLX according to the changes (it already works again on mga). Regain backward compatibility in the mga drm module (already have a complete solution in mind). Cleanup DRI Util code.
-rw-r--r--src/glut/mini/bitmap.c5
-rw-r--r--src/glut/mini/models.c4
-rw-r--r--src/glut/mini/teapot.c4
-rw-r--r--src/glut/mini/window.c2
-rw-r--r--src/mesa/drivers/common/depthtmp.h4
-rw-r--r--src/mesa/drivers/common/spantmp.h6
-rw-r--r--src/mesa/drivers/common/stenciltmp.h4
-rw-r--r--src/mesa/drivers/dri/common/depthtmp.h4
-rw-r--r--src/mesa/drivers/dri/common/spantmp.h6
-rw-r--r--src/mesa/drivers/dri/common/stenciltmp.h4
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.c60
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.h10
-rw-r--r--src/mesa/drivers/dri/mga/mgabuffers.c204
-rw-r--r--src/mesa/drivers/dri/mga/mgacontext.h4
-rw-r--r--src/mesa/drivers/dri/mga/mgaioctl.c4
-rw-r--r--src/mesa/drivers/dri/mga/mgaioctl.h4
-rw-r--r--src/mesa/drivers/dri/mga/mgapixel.c20
-rw-r--r--src/mesa/drivers/dri/mga/mgaspan.c13
-rw-r--r--src/mesa/drivers/dri/mga/mgastate.c67
-rw-r--r--src/mesa/drivers/dri/mga/mgatex.c144
-rw-r--r--src/mesa/drivers/dri/mga/mgatex.h3
-rw-r--r--src/mesa/drivers/dri/mga/mgatexcnv.c213
-rw-r--r--src/mesa/drivers/dri/mga/mgatexmem.c14
-rw-r--r--src/mesa/drivers/dri/mga/mgavb.c2
-rw-r--r--src/mesa/drivers/dri/mga/server/mga.h7
-rw-r--r--src/mesa/drivers/dri/mga/server/mga_common.h8
-rw-r--r--src/mesa/drivers/dri/mga/server/mga_dri.c140
-rw-r--r--src/mesa/drivers/dri/mga/server/mga_dri.h9
-rw-r--r--src/mesa/drivers/dri/mga/server/mga_sarea.h11
-rw-r--r--src/mesa/drivers/dri/r200/r200_screen.c8
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c15
-rw-r--r--src/mesa/drivers/dri/radeon/server/radeon_dri.c1
-rw-r--r--src/mesa/main/texstore.c6
-rw-r--r--src/mesa/tnl/t_vb_texgen.c14
-rw-r--r--src/mesa/tnl/t_vb_vertex.c4
-rw-r--r--src/miniglx/dri_util.c186
-rw-r--r--src/miniglx/dri_util.h38
-rw-r--r--src/miniglx/miniglx.c98
-rw-r--r--src/miniglx/miniglxP.h56
-rw-r--r--src/miniglx/sarea.h10
-rw-r--r--src/miniglx/xf86drm.c2
41 files changed, 649 insertions, 769 deletions
diff --git a/src/glut/mini/bitmap.c b/src/glut/mini/bitmap.c
index 55a031af0a5..aa2a34a57ef 100644
--- a/src/glut/mini/bitmap.c
+++ b/src/glut/mini/bitmap.c
@@ -12,8 +12,9 @@ glutBitmapCharacter(GLUTbitmapFont font, int c)
{
const BitmapCharRec *ch;
BitmapFontPtr fontinfo;
- GLfloat swapbytes, lsbfirst, rowlength;
- GLfloat skiprows, skippixels, alignment;
+/* GLfloat swapbytes, lsbfirst, rowlength;*/
+/* GLfloat skiprows, skippixels;*/
+ GLfloat alignment;
#if defined(_WIN32)
fontinfo = (BitmapFontPtr) __glutFont(font);
diff --git a/src/glut/mini/models.c b/src/glut/mini/models.c
index 12bb770d812..7dcd3d91e15 100644
--- a/src/glut/mini/models.c
+++ b/src/glut/mini/models.c
@@ -122,7 +122,7 @@ glutSolidCone(GLdouble base, GLdouble height,
static void
drawBox(GLfloat size, GLenum type)
{
- static GLfloat n[6][3] =
+/* static GLfloat n[6][3] =
{
{-1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
@@ -130,7 +130,7 @@ drawBox(GLfloat size, GLenum type)
{0.0, -1.0, 0.0},
{0.0, 0.0, 1.0},
{0.0, 0.0, -1.0}
- };
+ };*/
static GLint faces[6][4] =
{
{0, 1, 2, 3},
diff --git a/src/glut/mini/teapot.c b/src/glut/mini/teapot.c
index ec2a207763e..60aa09628ab 100644
--- a/src/glut/mini/teapot.c
+++ b/src/glut/mini/teapot.c
@@ -48,6 +48,7 @@ OpenGL(TM) is a trademark of Silicon Graphics, Inc.
#include <GL/glu.h>
#include "GL/glut.h"
+#if 0
/* Rim, body, lid, and bottom data must be reflected in x and
y; handle and spout data across the y axis only. */
@@ -134,16 +135,17 @@ static float tex[2][2][2] =
{ {0, 1},
{1, 1}}
};
+#endif
/* *INDENT-ON* */
static void
teapot(GLint grid, GLdouble scale, GLenum type)
{
+#if 0
float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
long i, j, k, l;
-#if 0
glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
diff --git a/src/glut/mini/window.c b/src/glut/mini/window.c
index 73266769c53..e85a0fb08f1 100644
--- a/src/glut/mini/window.c
+++ b/src/glut/mini/window.c
@@ -41,7 +41,7 @@
-static GLXContext context = 0;
+/*static GLXContext context = 0;*/
static Window win;
static XVisualInfo *visinfo = 0;
static Display *dpy = 0;
diff --git a/src/mesa/drivers/common/depthtmp.h b/src/mesa/drivers/common/depthtmp.h
index f3da61e5199..b3f989940a2 100644
--- a/src/mesa/drivers/common/depthtmp.h
+++ b/src/mesa/drivers/common/depthtmp.h
@@ -73,7 +73,7 @@ static void TAG(WriteDepthPixels)( GLcontext *ctx,
{
HW_WRITE_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_DEPTH_VARS;
if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" );
@@ -139,7 +139,7 @@ static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
{
HW_READ_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_DEPTH_VARS;
if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" );
diff --git a/src/mesa/drivers/common/spantmp.h b/src/mesa/drivers/common/spantmp.h
index 888be0465e5..c6ec7aa1ee6 100644
--- a/src/mesa/drivers/common/spantmp.h
+++ b/src/mesa/drivers/common/spantmp.h
@@ -116,7 +116,7 @@ static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
{
HW_WRITE_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_VARS;
if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
@@ -178,7 +178,7 @@ static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
{
HW_WRITE_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_VARS;
INIT_MONO_PIXEL(p, color);
@@ -231,7 +231,7 @@ static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
{
HW_READ_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_VARS;
if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
diff --git a/src/mesa/drivers/common/stenciltmp.h b/src/mesa/drivers/common/stenciltmp.h
index 365e9811ac3..bbdd3391947 100644
--- a/src/mesa/drivers/common/stenciltmp.h
+++ b/src/mesa/drivers/common/stenciltmp.h
@@ -66,7 +66,7 @@ static void TAG(WriteStencilPixels)( GLcontext *ctx,
{
HW_WRITE_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_STENCIL_VARS;
if (DBG) fprintf(stderr, "WriteStencilPixels\n");
@@ -121,7 +121,7 @@ static void TAG(ReadStencilPixels)( GLcontext *ctx, GLuint n,
{
HW_READ_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_STENCIL_VARS;
if (DBG) fprintf(stderr, "ReadStencilPixels\n");
diff --git a/src/mesa/drivers/dri/common/depthtmp.h b/src/mesa/drivers/dri/common/depthtmp.h
index f3da61e5199..b3f989940a2 100644
--- a/src/mesa/drivers/dri/common/depthtmp.h
+++ b/src/mesa/drivers/dri/common/depthtmp.h
@@ -73,7 +73,7 @@ static void TAG(WriteDepthPixels)( GLcontext *ctx,
{
HW_WRITE_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_DEPTH_VARS;
if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" );
@@ -139,7 +139,7 @@ static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
{
HW_READ_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_DEPTH_VARS;
if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" );
diff --git a/src/mesa/drivers/dri/common/spantmp.h b/src/mesa/drivers/dri/common/spantmp.h
index 888be0465e5..c6ec7aa1ee6 100644
--- a/src/mesa/drivers/dri/common/spantmp.h
+++ b/src/mesa/drivers/dri/common/spantmp.h
@@ -116,7 +116,7 @@ static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
{
HW_WRITE_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_VARS;
if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
@@ -178,7 +178,7 @@ static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
{
HW_WRITE_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_VARS;
INIT_MONO_PIXEL(p, color);
@@ -231,7 +231,7 @@ static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
{
HW_READ_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_VARS;
if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
diff --git a/src/mesa/drivers/dri/common/stenciltmp.h b/src/mesa/drivers/dri/common/stenciltmp.h
index 365e9811ac3..bbdd3391947 100644
--- a/src/mesa/drivers/dri/common/stenciltmp.h
+++ b/src/mesa/drivers/dri/common/stenciltmp.h
@@ -66,7 +66,7 @@ static void TAG(WriteStencilPixels)( GLcontext *ctx,
{
HW_WRITE_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_STENCIL_VARS;
if (DBG) fprintf(stderr, "WriteStencilPixels\n");
@@ -121,7 +121,7 @@ static void TAG(ReadStencilPixels)( GLcontext *ctx, GLuint n,
{
HW_READ_LOCK()
{
- GLint i;
+ GLuint i;
LOCAL_STENCIL_VARS;
if (DBG) fprintf(stderr, "ReadStencilPixels\n");
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c
index 01d60005620..e62c07330ae 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.c
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -125,17 +125,10 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
mgaScreen->chipset = serverInfo->chipset;
- mgaScreen->width = serverInfo->width;
- mgaScreen->height = serverInfo->height;
mgaScreen->mem = serverInfo->mem;
- mgaScreen->cpp = serverInfo->cpp;
mgaScreen->agpMode = serverInfo->agpMode;
- mgaScreen->frontPitch = serverInfo->frontPitch;
- mgaScreen->frontOffset = serverInfo->frontOffset;
- mgaScreen->backOffset = serverInfo->backOffset;
- mgaScreen->backPitch = serverInfo->backPitch;
mgaScreen->depthOffset = serverInfo->depthOffset;
mgaScreen->depthPitch = serverInfo->depthPitch;
@@ -201,7 +194,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
serverInfo->agpTextureOffset);
#endif
- mgaScreen->mAccess = serverInfo->mAccess;
+ //mgaScreen->mAccess = serverInfo->mAccess;
/* For calculating setupdma addresses.
*/
@@ -224,11 +217,20 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
static void
mgaDestroyScreen(__DRIscreenPrivate *sPriv)
{
- mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private;
+ mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private;
+ MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv;
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
fprintf(stderr, "mgaDestroyScreen\n");
+ if ( mgaScreen->texVirtual[MGA_AGP_HEAP] ) {
+ drmUnmap( mgaScreen->texVirtual[MGA_AGP_HEAP],
+ serverInfo->agpTextureSize );
+ }
+ if (mgaScreen->bufs)
+ drmUnmapBufs( mgaScreen->bufs );
+ drmUnmap( mgaScreen->mmio.map, mgaScreen->mmio.size );
+
/*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/
free(mgaScreen);
sPriv->private = NULL;
@@ -313,7 +315,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
*/
ctx = mmesa->glCtx;
{
- int nr = 2;
+ unsigned int nr = 2;
if (mgaScreen->chipset == MGA_CARD_TYPE_G200)
nr = 1;
@@ -375,15 +377,16 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( ctx );
+
_ac_CreateContext( ctx );
_tnl_CreateContext( ctx );
-
- _swsetup_CreateContext( ctx );
/* Install the customized pipeline:
*/
_tnl_destroy_pipeline( ctx );
_tnl_install_pipeline( ctx, mga_pipeline );
+
+ _swsetup_CreateContext( ctx );
/* Configure swrast to match hardware characteristics:
*/
@@ -399,7 +402,6 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
mgaDDInitStateFuncs( ctx );
mgaDDInitTextureFuncs( ctx );
- mgaDDInitSpanFuncs( ctx );
mgaDDInitDriverFuncs( ctx );
mgaDDInitIoctlFuncs( ctx );
mgaDDInitPixelFuncs( ctx );
@@ -478,6 +480,8 @@ mgaUnbindContext(__DRIcontextPrivate *driContextPriv)
if (mmesa)
mmesa->dirty = ~0;
+ UNLOCK_HARDWARE( mmesa );
+
return GL_TRUE;
}
@@ -505,7 +509,7 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv)
{
- fprintf(stderr, "%s\n", __FUNCTION__);
+/* fprintf(stderr, "%s\n", __FUNCTION__);*/
if (driContextPriv) {
mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
@@ -524,6 +528,7 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_set_viewport(mmesa->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
+ mgaDDInitSpanFuncs( mmesa->glCtx );
}
else {
_mesa_make_current(NULL, NULL);
@@ -539,15 +544,15 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
int me = mmesa->hHWContext;
int i;
- fprintf(stderr, "%s\n", __FUNCTION__);
+/* fprintf(stderr, "%s\n", __FUNCTION__);*/
drmGetLock(mmesa->driFd, mmesa->hHWContext, flags);
- fprintf(stderr,
+/* fprintf(stderr,
"mmesa->lastStamp %d dpriv->lastStamp %d *(dpriv->pStamp) %d\n",
mmesa->lastStamp,
dPriv->lastStamp,
- *(dPriv->pStamp));
+ *(dPriv->pStamp));*/
/* The window might have moved, so we might need to get new clip
* rects.
@@ -564,23 +569,26 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
mmesa->lastStamp = dPriv->lastStamp;
mmesa->SetupNewInputs |= VERT_BIT_CLIP;
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
+
mgaUpdateRects( mmesa, (MGA_FRONT|MGA_BACK) );
}
mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS;
+ memcpy( &sarea->ContextState, &mmesa->setup, sizeof(mmesa->setup));
mmesa->sarea->dirty |= MGA_UPLOAD_CONTEXT;
if (sarea->ctxOwner != me) {
+ sarea->ctxOwner=me;
+
mmesa->dirty |= (MGA_UPLOAD_CONTEXT | MGA_UPLOAD_TEX0 |
MGA_UPLOAD_TEX1 | MGA_UPLOAD_PIPE);
- sarea->ctxOwner=me;
+
+ for (i = 0 ; i < mmesa->lastTexHeap ; i++)
+ if (sarea->texAge[i] != mmesa->texAge[i])
+ mgaAgeTextures( mmesa, i );
}
- for (i = 0 ; i < mmesa->lastTexHeap ; i++)
- if (sarea->texAge[i] != mmesa->texAge[i])
- mgaAgeTextures( mmesa, i );
-
sarea->last_quiescent = -1; /* just kill it for now */
}
@@ -607,10 +615,12 @@ static const struct __DriverAPIRec mgaAPI = {
* The __driCreateScreen name is the symbol that libGL.so fetches.
* Return: pointer to a __DRIscreenPrivate.
*/
-void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config)
+void *__driCreateScreen(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc)
{
__DRIscreenPrivate *psp;
- psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &mgaAPI);
+ psp = __driUtilCreateScreen(driver, driverContext, psc, &mgaAPI);
return (void *) psp;
}
+
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.h b/src/mesa/drivers/dri/mga/mga_xmesa.h
index ae9d4f47647..f28ba5cbc6d 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.h
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.h
@@ -38,21 +38,11 @@
typedef struct mga_screen_private_s {
int chipset;
- int width;
- int height;
int mem;
- int cpp; /* for front and back buffers */
GLint agpMode;
unsigned int irq; /* IRQ number (0 means none) */
- unsigned int mAccess;
-
- unsigned int frontOffset;
- unsigned int frontPitch;
- unsigned int backOffset;
- unsigned int backPitch;
-
unsigned int depthOffset;
unsigned int depthPitch;
int depthCpp;
diff --git a/src/mesa/drivers/dri/mga/mgabuffers.c b/src/mesa/drivers/dri/mga/mgabuffers.c
index aad8b574724..585bff5ba79 100644
--- a/src/mesa/drivers/dri/mga/mgabuffers.c
+++ b/src/mesa/drivers/dri/mga/mgabuffers.c
@@ -40,18 +40,18 @@ static void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa )
/* fprintf( stderr, "%s\n", __FUNCTION__ );*/
if (driDrawable->numClipRects == 0) {
- static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0};
- mmesa->numClipRects = 1;
- mmesa->pClipRects = &zeroareacliprect;
- } else {
- mmesa->numClipRects = driDrawable->numClipRects;
- mmesa->pClipRects = driDrawable->pClipRects;
+ static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0};
+ mmesa->numClipRects = 1;
+ mmesa->pClipRects = &zeroareacliprect;
+ }
+ else {
+ mmesa->numClipRects = driDrawable->numClipRects;
+ mmesa->pClipRects = driDrawable->pClipRects;
}
mmesa->drawX = driDrawable->x;
mmesa->drawY = driDrawable->y;
- mmesa->setup.dstorg = mmesa->drawOffset;
- mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS;
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
}
@@ -61,27 +61,27 @@ static void mgaXMesaSetBackClipRects( mgaContextPtr mmesa )
/* fprintf( stderr, "%s\n", __FUNCTION__ );*/
- if (driDrawable->numBackClipRects == 0)
- {
+ if (driDrawable->numBackClipRects == 0) {
if (driDrawable->numClipRects == 0) {
- static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0};
- mmesa->numClipRects = 1;
- mmesa->pClipRects = &zeroareacliprect;
- } else {
- mmesa->numClipRects = driDrawable->numClipRects;
- mmesa->pClipRects = driDrawable->pClipRects;
+ static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0};
+ mmesa->numClipRects = 1;
+ mmesa->pClipRects = &zeroareacliprect;
+ }
+ else {
+ mmesa->numClipRects = driDrawable->numClipRects;
+ mmesa->pClipRects = driDrawable->pClipRects;
}
mmesa->drawX = driDrawable->x;
mmesa->drawY = driDrawable->y;
- } else {
+ }
+ else {
mmesa->numClipRects = driDrawable->numBackClipRects;
mmesa->pClipRects = driDrawable->pBackClipRects;
mmesa->drawX = driDrawable->backX;
mmesa->drawY = driDrawable->backY;
}
- mmesa->setup.dstorg = mmesa->drawOffset;
- mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS;
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
}
@@ -102,13 +102,12 @@ static void mgaUpdateRectsFromSarea( mgaContextPtr mmesa )
top = sarea->exported_nback;
for (i = 0 ; i < top ; i++)
- driDrawable->pBackClipRects[i] =
- *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
+ driDrawable->pBackClipRects[i] =
+ *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
}
- if (sarea->exported_buffers & MGA_FRONT)
- {
+ if (sarea->exported_buffers & MGA_FRONT) {
int start = top;
driDrawable->numClipRects = sarea->exported_nfront;
@@ -116,8 +115,8 @@ static void mgaUpdateRectsFromSarea( mgaContextPtr mmesa )
top += sarea->exported_nfront;
for ( ; i < top ; i++)
- driDrawable->pClipRects[i-start] =
- *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
+ driDrawable->pClipRects[i-start] =
+ *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
}
@@ -132,7 +131,7 @@ static void mgaUpdateRectsFromSarea( mgaContextPtr mmesa )
driDrawable->w = sarea->exported_w;
driDrawable->h = sarea->exported_h;
driDrawable->pStamp =
- &(driScreen->pSAREA->drawableTable[driDrawable->index].stamp);
+ &(driScreen->pSAREA->drawableTable[driDrawable->index].stamp);
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK) & ~(sarea->exported_buffers);
}
@@ -161,23 +160,23 @@ static void printSareaRects( mgaContextPtr mmesa )
i = 0;
if (sarea->exported_buffers & MGA_BACK)
for ( ; i < sarea->exported_nback ; i++)
- fprintf(stderr, "back %d: %d,%d-%d,%d\n", i,
- sarea->exported_boxes[i].x1, sarea->exported_boxes[i].y1,
- sarea->exported_boxes[i].x2, sarea->exported_boxes[i].y2);
+ fprintf(stderr, "back %d: %d,%d-%d,%d\n", i,
+ sarea->exported_boxes[i].x1, sarea->exported_boxes[i].y1,
+ sarea->exported_boxes[i].x2, sarea->exported_boxes[i].y2);
if (sarea->exported_buffers & MGA_FRONT) {
int start = i;
int top = i + sarea->exported_nfront;
for ( ; i < top ; i++)
- fprintf(stderr, "front %d: %d,%d-%d,%d\n",
- i - start,
- sarea->exported_boxes[i].x1, sarea->exported_boxes[i].y1,
- sarea->exported_boxes[i].x2, sarea->exported_boxes[i].y2);
+ fprintf(stderr, "front %d: %d,%d-%d,%d\n",
+ i - start,
+ sarea->exported_boxes[i].x1, sarea->exported_boxes[i].y1,
+ sarea->exported_boxes[i].x2, sarea->exported_boxes[i].y2);
}
fprintf(stderr, "drawableTable[%d].stamp: %d\n",
- sarea->exported_index,
- driScreen->pSAREA->drawableTable[sarea->exported_index].stamp);
+ sarea->exported_index,
+ driScreen->pSAREA->drawableTable[sarea->exported_index].stamp);
}
static void printMmesaRects( mgaContextPtr mmesa )
@@ -197,17 +196,84 @@ static void printMmesaRects( mgaContextPtr mmesa )
for (i = 0 ; i < nr ; i++)
fprintf(stderr, "box %d: %d,%d-%d,%d\n", i,
- mmesa->pClipRects[i].x1, mmesa->pClipRects[i].y1,
- mmesa->pClipRects[i].x2, mmesa->pClipRects[i].y2);
+ mmesa->pClipRects[i].x1, mmesa->pClipRects[i].y1,
+ mmesa->pClipRects[i].x2, mmesa->pClipRects[i].y2);
fprintf(stderr, "mmesa->draw_buffer: %d\n", mmesa->draw_buffer);
fprintf(stderr, "drawableTable[%d].stamp: %d\n",
- driDrawable->index,
- driScreen->pSAREA->drawableTable[driDrawable->index].stamp);
+ driDrawable->index,
+ driScreen->pSAREA->drawableTable[driDrawable->index].stamp);
}
#endif
+static void mgaUpdateDrawBuffer(mgaContextPtr mmesa)
+{
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+
+ mmesa->setup.fb_cpp = driDrawable->cpp;
+
+ mmesa->setup.front_pitch = driDrawable->frontPitch / driDrawable->cpp;
+ mmesa->setup.front_offset = driDrawable->frontOffset;
+
+ mmesa->setup.back_pitch = driDrawable->backPitch / driDrawable->cpp;
+ mmesa->setup.back_offset = driDrawable->backOffset;
+
+ switch (mmesa->draw_buffer) {
+ case MGA_FRONT:
+ mmesa->drawOffset = driDrawable->frontOffset;
+ mmesa->readOffset = driDrawable->frontOffset;
+
+ mmesa->setup.draw_pitch = mmesa->setup.front_pitch;
+ mmesa->setup.draw_offset = mmesa->setup.front_offset;
+ break;
+ case MGA_BACK:
+ mmesa->drawOffset = driDrawable->backOffset;
+ mmesa->readOffset = driDrawable->backOffset;
+
+ mmesa->setup.draw_pitch = mmesa->setup.back_pitch;
+ mmesa->setup.draw_offset = mmesa->setup.back_offset;
+ break;
+ default:
+ break;
+ }
+
+ mmesa->setup.maccess = (MA_memreset_disable |
+ MA_fogen_disable |
+ MA_tlutload_disable |
+ MA_nodither_disable |
+ MA_dit555_disable);
+
+ switch (driDrawable->cpp) {
+ case 2:
+ mmesa->setup.maccess |= MA_pwidth_16;
+ break;
+ case 4:
+ mmesa->setup.maccess |= MA_pwidth_32;
+ break;
+ default:
+ fprintf( stderr, "Error: unknown cpp %d, exiting...\n",
+ driDrawable->cpp );
+ }
+
+ switch (mmesa->glCtx->Visual.depthBits) {
+ case 16:
+ mmesa->setup.maccess |= MA_zwidth_16;
+ break;
+ case 24:
+ mmesa->setup.maccess |= MA_zwidth_24;
+ break;
+ case 32:
+ mmesa->setup.maccess |= MA_pwidth_32;
+ break;
+ }
+
+ if (mmesa->glCtx->Fog.Enabled)
+ mmesa->setup.maccess |= MA_fogen_enable;
+
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+}
+
void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
{
@@ -217,7 +283,9 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
/* fprintf(stderr, "%s\n", __FUNCTION__);*/
DRI_VALIDATE_DRAWABLE_INFO(driScreen, driDrawable);
- mmesa->dirty_cliprects = 0;
+ mmesa->dirty_cliprects = 0;
+
+ mgaUpdateDrawBuffer( mmesa );
if (mmesa->draw_buffer == MGA_FRONT)
mgaXMesaSetFrontClipRects( mmesa );
@@ -228,7 +296,7 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
printMmesaRects(mmesa);
#endif
- sarea->req_drawable = driDrawable->draw;
+ sarea->req_drawable = (unsigned int)driDrawable;/* dok ->draw; */
sarea->req_draw_buffer = mmesa->draw_buffer;
mgaUpdateClipping( mmesa->glCtx );
@@ -240,16 +308,15 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
void mgaDDSetReadBuffer(GLcontext *ctx, GLenum mode )
{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
- if (mode == GL_FRONT_LEFT)
- {
- mmesa->readOffset = mmesa->mgaScreen->frontOffset;
+ if (mode == GL_FRONT_LEFT) {
+ mmesa->readOffset = driDrawable->frontOffset;
mmesa->read_buffer = MGA_FRONT;
- }
- else
- {
- mmesa->readOffset = mmesa->mgaScreen->backOffset;
+ }
+ else {
+ mmesa->readOffset = driDrawable->backOffset;
mmesa->read_buffer = MGA_BACK;
}
}
@@ -266,27 +333,24 @@ void mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode )
* _DrawDestMask is easier to cope with than <mode>.
*/
switch ( ctx->Color._DrawDestMask ) {
- case FRONT_LEFT_BIT:
- mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
- mmesa->readOffset = mmesa->mgaScreen->frontOffset;
- mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset;
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
- mmesa->draw_buffer = MGA_FRONT;
- mgaXMesaSetFrontClipRects( mmesa );
- FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
- break;
- case BACK_LEFT_BIT:
- mmesa->drawOffset = mmesa->mgaScreen->backOffset;
- mmesa->readOffset = mmesa->mgaScreen->backOffset;
- mmesa->setup.dstorg = mmesa->mgaScreen->backOffset;
- mmesa->draw_buffer = MGA_BACK;
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
- mgaXMesaSetBackClipRects( mmesa );
- FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
- break;
- default:
- FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE );
- break;
+ case FRONT_LEFT_BIT:
+ mmesa->draw_buffer = MGA_FRONT;
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ case BACK_LEFT_BIT:
+ mmesa->draw_buffer = MGA_BACK;
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ default:
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ break;
}
+
+ mgaUpdateDrawBuffer( mmesa );
+
+ if (mmesa->draw_buffer == MGA_FRONT)
+ mgaXMesaSetFrontClipRects( mmesa );
+ else
+ mgaXMesaSetBackClipRects( mmesa );
}
diff --git a/src/mesa/drivers/dri/mga/mgacontext.h b/src/mesa/drivers/dri/mga/mgacontext.h
index 52f2dfaf410..7a5f3134701 100644
--- a/src/mesa/drivers/dri/mga/mgacontext.h
+++ b/src/mesa/drivers/dri/mga/mgacontext.h
@@ -108,7 +108,7 @@ typedef struct mga_texture_object_s
GLuint offsets[MGA_TEX_MAXLEVELS];
int lastLevel;
GLuint dirty_images;
- GLuint totalSize;
+ GLint totalSize;
int texelBytes;
GLuint age;
int bound;
@@ -215,7 +215,7 @@ struct mga_context_t {
int readOffset;
int drawX, drawY; /* origin of drawable in draw buffer */
int lastX, lastY; /* detect DSTORG bug */
- GLuint numClipRects; /* cliprects for the draw buffer */
+ GLint numClipRects; /* cliprects for the draw buffer */
XF86DRIClipRectPtr pClipRects;
XF86DRIClipRectRec draw_rect;
XF86DRIClipRectRec scissor_rect;
diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c
index f88c8780607..4a67b985049 100644
--- a/src/mesa/drivers/dri/mga/mgaioctl.c
+++ b/src/mesa/drivers/dri/mga/mgaioctl.c
@@ -422,7 +422,7 @@ void mgaDDFinish( GLcontext *ctx )
}
}
-void mgaWaitAgeLocked( mgaContextPtr mmesa, int age )
+void mgaWaitAgeLocked( mgaContextPtr mmesa, unsigned int age )
{
if (GET_DISPATCH_AGE(mmesa) < age) {
UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH );
@@ -430,7 +430,7 @@ void mgaWaitAgeLocked( mgaContextPtr mmesa, int age )
}
-void mgaWaitAge( mgaContextPtr mmesa, int age )
+void mgaWaitAge( mgaContextPtr mmesa, unsigned int age )
{
if (GET_DISPATCH_AGE(mmesa) < age) {
LOCK_HARDWARE(mmesa);
diff --git a/src/mesa/drivers/dri/mga/mgaioctl.h b/src/mesa/drivers/dri/mga/mgaioctl.h
index b7cf44d6ff9..ca258fb41e0 100644
--- a/src/mesa/drivers/dri/mga/mgaioctl.h
+++ b/src/mesa/drivers/dri/mga/mgaioctl.h
@@ -46,8 +46,8 @@ void mgaWaitForVBlank( mgaContextPtr mmesa );
void mgaFireILoadLocked( mgaContextPtr mmesa,
GLuint offset, GLuint length );
-void mgaWaitAgeLocked( mgaContextPtr mmesa, int age );
-void mgaWaitAge( mgaContextPtr mmesa, int age );
+void mgaWaitAgeLocked( mgaContextPtr mmesa, unsigned int age );
+void mgaWaitAge( mgaContextPtr mmesa, unsigned int age );
void mgaFlushVertices( mgaContextPtr mmesa );
void mgaFlushVerticesLocked( mgaContextPtr mmesa );
diff --git a/src/mesa/drivers/dri/mga/mgapixel.c b/src/mesa/drivers/dri/mga/mgapixel.c
index 0bc4b3fac5f..f520e936069 100644
--- a/src/mesa/drivers/dri/mga/mgapixel.c
+++ b/src/mesa/drivers/dri/mga/mgapixel.c
@@ -84,8 +84,8 @@ check_depth( const GLcontext *ctx, GLenum type,
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
if ( IS_AGP_MEM( mmesa, pixels ) &&
- !( ( type == GL_UNSIGNED_INT && mmesa->mgaScreen->cpp == 4 ) ||
- ( type == GL_UNSIGNED_SHORT && mmesa->mgaScreen->cpp == 2 ) ) )
+ !( ( type == GL_UNSIGNED_INT && mmesa->driDrawable->cpp == 4 ) ||
+ ( type == GL_UNSIGNED_SHORT && mmesa->driDrawable->cpp == 2 ) ) )
return GL_FALSE;
return ( ctx->Pixel.DepthBias == 0.0 &&
@@ -102,7 +102,7 @@ check_color( const GLcontext *ctx, GLenum type, GLenum format,
const void *pixels, GLint sz, GLint pitch )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- GLuint cpp = mmesa->mgaScreen->cpp;
+ GLuint cpp = mmesa->driDrawable->cpp;
/* Can't do conversions on agp reads/draws.
*/
@@ -206,8 +206,8 @@ clip_pixelrect( const GLcontext *ctx,
if (*height <= 0)
return GL_FALSE;
- *size = ((*y + *height - 1) * mmesa->mgaScreen->frontPitch +
- (*x + *width - 1) * mmesa->mgaScreen->cpp);
+ *size = ((*y + *height - 1) * mmesa->driDrawable->frontPitch +
+ (*x + *width - 1) * mmesa->driDrawable->cpp);
return GL_TRUE;
}
@@ -278,8 +278,8 @@ mgaTryReadPixels( GLcontext *ctx,
ok = check_color(ctx, type, format, pack, pixels, size, pitch);
planemask = ~0;
source = (mmesa->draw_buffer == MGA_FRONT ?
- mmesa->mgaScreen->frontOffset :
- mmesa->mgaScreen->backOffset);
+ mmesa->driDrawable->frontOffset :
+ mmesa->driDrawable->backOffset);
break;
default:
@@ -480,7 +480,7 @@ mgaTryDrawPixels( GLcontext *ctx,
GLint size, skipPixels, skipRows;
GLint pitch = unpack->RowLength ? unpack->RowLength : width;
GLuint dest, planemask;
- GLuint cpp = mmesa->mgaScreen->cpp;
+ GLuint cpp = mmesa->driDrawable->cpp;
if (!clip_pixelrect(ctx, ctx->DrawBuffer,
&x, &y, &width, &height,
@@ -517,8 +517,8 @@ mgaTryDrawPixels( GLcontext *ctx,
case GL_RGB:
case GL_BGRA:
dest = (mmesa->draw_buffer == MGA_FRONT ?
- mmesa->mgaScreen->frontOffset :
- mmesa->mgaScreen->backOffset);
+ mmesa->driDrawable->frontOffset :
+ mmesa->driDrawable->backOffset);
planemask = mgaPackColor(cpp,
ctx->Color.ColorMask[RCOMP],
diff --git a/src/mesa/drivers/dri/mga/mgaspan.c b/src/mesa/drivers/dri/mga/mgaspan.c
index 8dc971cfc57..9333e22aff0 100644
--- a/src/mesa/drivers/dri/mga/mgaspan.c
+++ b/src/mesa/drivers/dri/mga/mgaspan.c
@@ -38,17 +38,16 @@
#define LOCAL_VARS \
__DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
- mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
- GLuint pitch = mgaScreen->frontPitch; \
+ GLuint pitch = dPriv->frontPitch; \
GLuint height = dPriv->h; \
char *read_buf = (char *)(sPriv->pFB + \
mmesa->readOffset + \
- dPriv->x * mgaScreen->cpp + \
+ dPriv->x * dPriv->cpp + \
dPriv->y * pitch); \
char *buf = (char *)(sPriv->pFB + \
mmesa->drawOffset + \
- dPriv->x * mgaScreen->cpp + \
+ dPriv->x * dPriv->cpp + \
dPriv->y * pitch); \
GLuint p; \
(void) read_buf; (void) buf; (void) p
@@ -59,11 +58,11 @@
__DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
- GLuint pitch = mgaScreen->frontPitch; \
+ GLuint pitch = mgaScreen->depthPitch; \
GLuint height = dPriv->h; \
char *buf = (char *)(sPriv->pFB + \
mgaScreen->depthOffset + \
- dPriv->x * mgaScreen->cpp + \
+ dPriv->x * mgaScreen->depthCpp + \
dPriv->y * pitch)
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
@@ -238,7 +237,7 @@ void mgaDDInitSpanFuncs( GLcontext *ctx )
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
- switch (mmesa->mgaScreen->cpp) {
+ switch (mmesa->driDrawable->cpp) {
case 2:
swdd->WriteRGBASpan = mgaWriteRGBASpan_565;
swdd->WriteRGBSpan = mgaWriteRGBSpan_565;
diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c
index 02b98fdb766..b3f91e042d7 100644
--- a/src/mesa/drivers/dri/mga/mgastate.c
+++ b/src/mesa/drivers/dri/mga/mgastate.c
@@ -376,7 +376,8 @@ static void mgaDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
static void mgaUpdateAlphaMode(GLcontext *ctx)
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+// mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
int a = 0;
/* determine source of alpha for blending and testing */
@@ -464,13 +465,13 @@ static void mgaUpdateAlphaMode(GLcontext *ctx)
case GL_ONE_MINUS_SRC_ALPHA:
a |= AC_src_om_src_alpha; break;
case GL_DST_ALPHA:
- if (mgaScreen->cpp == 4)
+ if (driDrawable->cpp == 4)
a |= AC_src_dst_alpha;
else
a |= AC_src_one;
break;
case GL_ONE_MINUS_DST_ALPHA:
- if (mgaScreen->cpp == 4)
+ if (driDrawable->cpp == 4)
a |= AC_src_om_dst_alpha;
else
a |= AC_src_zero;
@@ -499,13 +500,13 @@ static void mgaUpdateAlphaMode(GLcontext *ctx)
case GL_ONE_MINUS_SRC_COLOR:
a |= AC_dst_om_src_color; break;
case GL_DST_ALPHA:
- if (mgaScreen->cpp == 4)
+ if (driDrawable->cpp == 4)
a |= AC_dst_dst_alpha;
else
a |= AC_dst_one;
break;
case GL_ONE_MINUS_DST_ALPHA:
- if (mgaScreen->cpp == 4)
+ if (driDrawable->cpp == 4)
a |= AC_dst_om_dst_alpha;
else
a |= AC_dst_zero;
@@ -579,9 +580,9 @@ static void mgaDDClearColor(GLcontext *ctx,
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->cpp,
- color[0], color[1],
- color[2], color[3]);
+ mmesa->ClearColor = mgaPackColor( mmesa->driDrawable->cpp,
+ color[0] * 0xff, color[1] * 0xff,
+ color[2] * 0xff, color[3] * 0xff);
}
@@ -636,21 +637,21 @@ static void mgaDDColorMask(GLcontext *ctx,
GLboolean b, GLboolean a )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
- GLuint mask = mgaPackColor(mgaScreen->cpp,
+ GLuint mask = mgaPackColor(driDrawable->cpp,
ctx->Color.ColorMask[RCOMP],
ctx->Color.ColorMask[GCOMP],
ctx->Color.ColorMask[BCOMP],
ctx->Color.ColorMask[ACOMP]);
- if (mgaScreen->cpp == 2)
+ if (driDrawable->cpp == 2)
mask = mask | (mask << 16);
if (mmesa->setup.plnwt != mask) {
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
- mmesa->setup.plnwt = mask;
+ mmesa->setup.plnwt = mask;
}
}
@@ -663,7 +664,7 @@ static void mgaDDColorMask(GLcontext *ctx,
* Note: the fully opaque pattern (0xffff) has been disabled in order
* to work around a conformance issue.
*/
-static int mgaStipples[16] = {
+static unsigned int mgaStipples[16] = {
0xffff1, /* See above note */
0xa5a5,
0x5a5a,
@@ -999,54 +1000,16 @@ static void mgaDDInvalidateState( GLcontext *ctx, GLuint new_state )
void mgaInitState( mgaContextPtr mmesa )
{
- mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
GLcontext *ctx = mmesa->glCtx;
if (ctx->Color._DrawDestMask == BACK_LEFT_BIT) {
mmesa->draw_buffer = MGA_BACK;
mmesa->read_buffer = MGA_BACK;
- mmesa->drawOffset = mmesa->mgaScreen->backOffset;
- mmesa->readOffset = mmesa->mgaScreen->backOffset;
- mmesa->setup.dstorg = mgaScreen->backOffset;
} else {
mmesa->draw_buffer = MGA_FRONT;
mmesa->read_buffer = MGA_FRONT;
- mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
- mmesa->readOffset = mmesa->mgaScreen->frontOffset;
- mmesa->setup.dstorg = mgaScreen->frontOffset;
}
-
- mmesa->setup.maccess = (MA_memreset_disable |
- MA_fogen_disable |
- MA_tlutload_disable |
- MA_nodither_disable |
- MA_dit555_disable);
-
- switch (mmesa->mgaScreen->cpp) {
- case 2:
- mmesa->setup.maccess |= MA_pwidth_16;
- break;
- case 4:
- mmesa->setup.maccess |= MA_pwidth_32;
- break;
- default:
- fprintf( stderr, "Error: unknown cpp %d, exiting...\n",
- mmesa->mgaScreen->cpp );
- exit( 1 );
- }
-
- switch (mmesa->glCtx->Visual.depthBits) {
- case 16:
- mmesa->setup.maccess |= MA_zwidth_16;
- break;
- case 24:
- mmesa->setup.maccess |= MA_zwidth_24;
- break;
- case 32:
- mmesa->setup.maccess |= MA_pwidth_32;
- break;
- }
-
+
mmesa->setup.dwgctl = (DC_opcod_trap |
DC_atype_i |
DC_linear_xy |
diff --git a/src/mesa/drivers/dri/mga/mgatex.c b/src/mesa/drivers/dri/mga/mgatex.c
index 6571587eca2..df826367c3e 100644
--- a/src/mesa/drivers/dri/mga/mgatex.c
+++ b/src/mesa/drivers/dri/mga/mgatex.c
@@ -135,8 +135,8 @@ static void mgaSetTexFilter(mgaTextureObjectPtr t, GLenum minf, GLenum magf)
}
- t->setup.texfilter &= (TF_minfilter_MASK |
- TF_magfilter_MASK |
+ t->setup.texfilter &= (TF_minfilter_MASK &
+ TF_magfilter_MASK &
TF_fthres_MASK);
t->setup.texfilter |= val;
}
@@ -151,40 +151,28 @@ static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4])
}
-static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
- struct gl_texture_image *texImage,
- GLenum format, GLenum type )
+static const struct gl_texture_format *
+mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
const GLboolean do32bpt = mmesa->default32BitTextures;
- const struct gl_texture_format *texFormat;
- GLint ret;
-
- if ( 0 )
- fprintf( stderr, "internal=%s format=%s type=%s\n",
- texImage->IntFormat == 3 ? "GL_RGB (3)" :
- texImage->IntFormat == 4 ? "GL_RGBA (4)" :
- _mesa_lookup_enum_by_nr( texImage->IntFormat ),
- _mesa_lookup_enum_by_nr( format ),
- _mesa_lookup_enum_by_nr( type ) );
-
-#define SET_FORMAT( r, gl ) \
+
+#define SET_FORMAT( gl ) \
do { \
- ret = (r); \
- texFormat = &(gl); \
+ return &(gl); \
} while (0)
-#define SET_FORMAT_32BPT( r32, gl32, r16, gl16 ) \
+#define SET_FORMAT_32BPT( gl32, gl16 ) \
do { \
if ( do32bpt ) { \
- ret = (r32); \
- texFormat = &(gl32); \
+ return &(gl32); \
} else { \
- ret = (r16); \
- texFormat = &(gl16); \
+ return &(gl16); \
} \
} while (0)
- switch ( texImage->IntFormat ) {
+ switch (internalFormat) {
/* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has
* got to be better than sticking them way down the end of this
* huge list.
@@ -194,29 +182,29 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
case GL_COMPRESSED_RGBA:
if ( format == GL_BGRA ) {
if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
- SET_FORMAT( TMC_tformat_tw32, _mesa_texformat_argb8888 );
+ SET_FORMAT( _mesa_texformat_argb8888 );
break;
} else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
- SET_FORMAT( TMC_tformat_tw12, _mesa_texformat_argb4444 );
+ SET_FORMAT( _mesa_texformat_argb4444 );
break;
} else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
- SET_FORMAT( TMC_tformat_tw15, _mesa_texformat_argb1555 );
+ SET_FORMAT( _mesa_texformat_argb1555 );
break;
}
}
- SET_FORMAT_32BPT( TMC_tformat_tw32, _mesa_texformat_argb8888,
- TMC_tformat_tw12, _mesa_texformat_argb4444 );
+ SET_FORMAT_32BPT( _mesa_texformat_argb8888,
+ _mesa_texformat_argb4444 );
break;
case 3:
case GL_RGB:
case GL_COMPRESSED_RGB:
if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
- SET_FORMAT( TMC_tformat_tw16, _mesa_texformat_rgb565 );
+ SET_FORMAT( _mesa_texformat_rgb565 );
break;
}
- SET_FORMAT_32BPT( TMC_tformat_tw32, _mesa_texformat_argb8888,
- TMC_tformat_tw16, _mesa_texformat_rgb565 );
+ SET_FORMAT_32BPT( _mesa_texformat_argb8888,
+ _mesa_texformat_rgb565 );
break;
/* GH: Okay, keep checking as normal. Still test for GL_RGB,
@@ -226,31 +214,31 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- SET_FORMAT_32BPT( TMC_tformat_tw32, _mesa_texformat_argb8888,
- TMC_tformat_tw12, _mesa_texformat_argb4444 );
+ SET_FORMAT_32BPT( _mesa_texformat_argb8888,
+ _mesa_texformat_argb4444 );
break;
case GL_RGBA4:
case GL_RGBA2:
- SET_FORMAT( TMC_tformat_tw12, _mesa_texformat_argb4444 );
+ SET_FORMAT( _mesa_texformat_argb4444 );
break;
case GL_RGB5_A1:
- SET_FORMAT( TMC_tformat_tw15, _mesa_texformat_argb1555 );
+ SET_FORMAT( _mesa_texformat_argb1555 );
break;
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- SET_FORMAT_32BPT( TMC_tformat_tw32, _mesa_texformat_argb8888,
- TMC_tformat_tw16, _mesa_texformat_rgb565 );
+ SET_FORMAT_32BPT( _mesa_texformat_argb8888,
+ _mesa_texformat_rgb565 );
break;
case GL_RGB5:
case GL_RGB4:
case GL_R3_G3_B2:
- SET_FORMAT( TMC_tformat_tw16, _mesa_texformat_rgb565 );
+ SET_FORMAT( _mesa_texformat_rgb565 );
break;
case GL_ALPHA:
@@ -260,7 +248,7 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
/* FIXME: This will report incorrect component sizes... */
- SET_FORMAT( TMC_tformat_tw12, _mesa_texformat_argb4444 );
+ SET_FORMAT( _mesa_texformat_argb4444 );
break;
case 1:
@@ -271,7 +259,7 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
/* FIXME: This will report incorrect component sizes... */
- SET_FORMAT( TMC_tformat_tw16, _mesa_texformat_rgb565 );
+ SET_FORMAT( _mesa_texformat_rgb565 );
break;
case 2:
@@ -284,7 +272,7 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
/* FIXME: This will report incorrect component sizes... */
- SET_FORMAT( TMC_tformat_tw12, _mesa_texformat_argb4444 );
+ SET_FORMAT( _mesa_texformat_argb4444 );
break;
case GL_INTENSITY:
@@ -294,7 +282,7 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
/* FIXME: This will report incorrect component sizes... */
- SET_FORMAT( TMC_tformat_tw12, _mesa_texformat_argb4444 );
+ SET_FORMAT( _mesa_texformat_argb4444 );
break;
case GL_COLOR_INDEX:
@@ -304,18 +292,16 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
case GL_COLOR_INDEX8_EXT:
case GL_COLOR_INDEX12_EXT:
case GL_COLOR_INDEX16_EXT:
- SET_FORMAT( TMC_tformat_tw8, _mesa_texformat_ci8 );
+ SET_FORMAT( _mesa_texformat_ci8 );
break;
default:
- fprintf( stderr, "bad texture format in mgaChooseTexFormat() %d",
- texImage->IntFormat );
- return -1;
+ break;
}
- texImage->TexFormat = texFormat;
-
- return ret;
+ fprintf( stderr, "bad texture format in mgaChooseTexFormat() %d",
+ internalFormat );
+ return NULL;
}
@@ -330,11 +316,12 @@ static void mgaCreateTexObj(mgaContextPtr mmesa,
{
const GLint baseLevel = tObj->BaseLevel;
struct gl_texture_image *image = tObj->Image[baseLevel];
+ const struct gl_texture_format *texFormat = image->TexFormat;
mgaTextureObjectPtr t;
int i, ofs;
int LastLevel;
int s, s2;
- int tformat;
+ int tformat = 0;
if (!image) return;
@@ -344,11 +331,31 @@ static void mgaCreateTexObj(mgaContextPtr mmesa,
return;
}
- /* FIXME: Use the real DD interface...
- */
- tformat = mgaChooseTexFormat( mmesa, image, image->Format,
- GL_UNSIGNED_BYTE );
- t->texelBytes = image->TexFormat->TexelBytes;
+ switch (texFormat->RedBits + texFormat->GreenBits + texFormat->BlueBits) {
+ case 12:
+ tformat = TMC_tformat_tw12;
+ break;
+ case 15:
+ tformat = TMC_tformat_tw15;
+ break;
+ case 16:
+ tformat = TMC_tformat_tw16;
+ break;
+ case 24:
+ tformat = TMC_tformat_tw32;
+ break;
+ case 0:
+ if (texFormat->IndexBits == 8) {
+ tformat = TMC_tformat_tw8;
+ break;
+ }
+ /* fall through */
+ default:
+ fprintf(stderr, "mgaCreateTexObj: Invalid texFormat\n" );
+ break;
+ }
+
+ t->texelBytes = texFormat->TexelBytes;
/* We are going to upload all levels that are present, even if
* later levels wouldn't be used by the current filtering mode. This
@@ -704,8 +711,8 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int hw_unit )
mmesa->CurrentTexObj[hw_unit] = t;
t->bound |= hw_unit+1;
-/* if (t->MemBlock) */
-/* mgaUpdateTexLRU( mmesa, t ); */
+/* if (t->MemBlock)*/
+/* mgaUpdateTexLRU( mmesa, t );*/
t->setup.texctl2 &= ~TMC_dualtex_enable;
if ((ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT) &&
@@ -739,7 +746,8 @@ void mgaUpdateTextureState( GLcontext *ctx )
mmesa->CurrentTexObj[1] = 0;
}
- if (ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT) {
+ if (ctx->Texture.Unit[0]._ReallyEnabled != TEXTURE_2D_BIT &&
+ ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT) {
mmesa->tmu_source[0] = 1;
} else {
mmesa->tmu_source[0] = 0;
@@ -765,7 +773,8 @@ void mgaUpdateTextureState( GLcontext *ctx )
mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_TEX0;
mmesa->setup.dwgctl &= DC_opcod_MASK;
- mmesa->setup.dwgctl |= (ctx->Texture.Unit[0]._ReallyEnabled
+ mmesa->setup.dwgctl |= ((ctx->Texture.Unit[0]._ReallyEnabled ||
+ ctx->Texture.Unit[1]._ReallyEnabled)
? DC_opcod_texture_trap
: DC_opcod_trap);
}
@@ -794,7 +803,7 @@ static void mgaDDTexEnv( GLcontext *ctx, GLenum target,
GLuint col;
COPY_4V(c, fc);
- col = mgaPackColor( mmesa->mgaScreen->cpp, c[0], c[1], c[2], c[3] );
+ col = mgaPackColor( mmesa->driDrawable->cpp, c[0], c[1], c[2], c[3] );
mmesa->envcolor = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]);
if (mmesa->setup.fcol != col) {
@@ -878,7 +887,7 @@ mgaDDTexParameter( GLcontext *ctx, GLenum target,
/* if we don't have a hardware texture, it will be automatically
created with current state before it is used, so we don't have
to do anything now */
- if ( !t || !t->bound || target != GL_TEXTURE_2D ) {
+ if ( !t || /*!t->bound ||*/ target != GL_TEXTURE_2D ) {
return;
}
@@ -912,15 +921,18 @@ static void
mgaDDBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+/* mgaContextPtr mmesa = MGA_CONTEXT( ctx );
int unit = ctx->Texture.CurrentUnit;
+ mgaTextureObjectPtr t;
+
+ t = (mgaTextureObjectPtr) tObj->DriverData;
FLUSH_BATCH(mmesa);
if (mmesa->CurrentTexObj[unit]) {
mmesa->CurrentTexObj[unit]->bound &= ~(unit+1);
mmesa->CurrentTexObj[unit] = 0;
- }
+ }*/
/* force the texture state to be updated
*/
@@ -962,7 +974,7 @@ mgaDDInitTextureFuncs( GLcontext *ctx )
{
ctx->Driver.TexEnv = mgaDDTexEnv;
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
+ ctx->Driver.ChooseTextureFormat = mgaChooseTextureFormat;
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
ctx->Driver.TexImage2D = mgaTexImage2D;
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
diff --git a/src/mesa/drivers/dri/mga/mgatex.h b/src/mesa/drivers/dri/mga/mgatex.h
index c9f87d997e2..867443ce472 100644
--- a/src/mesa/drivers/dri/mga/mgatex.h
+++ b/src/mesa/drivers/dri/mga/mgatex.h
@@ -40,7 +40,7 @@ typedef struct mga_texture_object_s *mgaTextureObjectPtr;
*/
void mgaUpdateTextureState( GLcontext *ctx );
-void mgaConvertTexture( GLuint *dest, int texelBytes,
+void mgaConvertTexture( GLubyte *dest, int texelBytes,
struct gl_texture_image *image,
int x, int y, int width, int height );
@@ -58,5 +58,6 @@ void mgaAgeTextures( mgaContextPtr mmesa, int heap );
void mgaDDInitTextureFuncs( GLcontext *ctx );
+void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t );
#endif
diff --git a/src/mesa/drivers/dri/mga/mgatexcnv.c b/src/mesa/drivers/dri/mga/mgatexcnv.c
index d561df37c5e..503a9120aab 100644
--- a/src/mesa/drivers/dri/mga/mgatexcnv.c
+++ b/src/mesa/drivers/dri/mga/mgatexcnv.c
@@ -43,13 +43,14 @@
* for an 8x8 texture. This happens when we have to crutch the pitch
* limits of the mga by uploading a block of texels as a single line.
*/
-void mgaConvertTexture( GLuint *destPtr, int texelBytes,
+void mgaConvertTexture( GLubyte *dst, int texelBytes,
struct gl_texture_image *image,
int x, int y, int width, int height )
{
- register int i, j;
- GLubyte *src;
- int stride;
+ int i;
+ GLubyte *src;
+ int src_pitch;
+ int dst_pitch;
if (0)
fprintf(stderr, "texture image %p\n", image->Data);
@@ -57,200 +58,14 @@ void mgaConvertTexture( GLuint *destPtr, int texelBytes,
if (image->Data == 0)
return;
- /* FIXME: g400 luminance_alpha internal format */
- switch (texelBytes) {
- case 1:
- switch (image->Format) {
- case GL_COLOR_INDEX:
- case GL_INTENSITY:
- case GL_LUMINANCE:
- case GL_ALPHA:
- src = (GLubyte *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 2 ; j ; j-- ) {
-
- *destPtr++ = src[0] | ( src[1] << 8 ) | ( src[2] << 16 ) | ( src[3] << 24 );
- src += 4;
- }
- src += stride;
- }
- break;
- default:
- goto format_error;
- }
- break;
- case 2:
- switch (image->Format) {
- case GL_RGB:
- src = (GLubyte *)image->Data + ( y * image->Width + x ) * 3;
- stride = (image->Width - width) * 3;
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR565(src[0],src[1],src[2]) |
- ( MGAPACKCOLOR565(src[3],src[4],src[5]) << 16 );
- src += 6;
- }
- src += stride;
- }
- break;
- case GL_RGBA:
- src = (GLubyte *)image->Data + ( y * image->Width + x ) * 4;
- stride = (image->Width - width) * 4;
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR4444(src[0],src[1],src[2],src[3]) |
- ( MGAPACKCOLOR4444(src[4],src[5],src[6],src[7]) << 16 );
- src += 8;
- }
- src += stride;
- }
- break;
- case GL_LUMINANCE:
- src = (GLubyte *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
- /* FIXME: should probably use 555 texture to get true grey */
- *destPtr++ = MGAPACKCOLOR565(src[0],src[0],src[0]) |
- ( MGAPACKCOLOR565(src[1],src[1],src[1]) << 16 );
- src += 2;
- }
- src += stride;
- }
- break;
- case GL_INTENSITY:
- src = (GLubyte *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[0]) |
- ( MGAPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16 );
- src += 2;
- }
- src += stride;
- }
- break;
- case GL_ALPHA:
- src = (GLubyte *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR4444(255,255,255,src[0]) |
- ( MGAPACKCOLOR4444(255,255,255,src[1]) << 16 );
- src += 2;
- }
- src += stride;
- }
- break;
- case GL_LUMINANCE_ALPHA:
- src = (GLubyte *)image->Data + ( y * image->Width + x ) * 2;
- stride = (image->Width - width) * 2;
- for ( i = height ; i ; i-- ) {
- for ( j = width >> 1 ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[1]) |
- ( MGAPACKCOLOR4444(src[2],src[2],src[2],src[3]) << 16 );
- src += 4;
- }
- src += stride;
- }
- break;
- default:
- goto format_error;
- }
- break;
- case 4:
- switch (image->Format) {
- case GL_RGB:
- src = (GLubyte *)image->Data + ( y * image->Width + x ) * 3;
- stride = (image->Width - width) * 3;
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2], 255);
- src += 3;
- }
- src += stride;
- }
- break;
- case GL_RGBA:
- src = (GLubyte *)image->Data + ( y * image->Width + x ) * 4;
- stride = (image->Width - width) * 4;
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2],src[3]);
- src += 4;
- }
- src += stride;
- }
- break;
- case GL_LUMINANCE:
- src = (GLubyte *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0], 255);
- src += 1;
- }
- src += stride;
- }
- break;
- case GL_INTENSITY:
- src = (GLubyte *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0],src[0]);
- src += 1;
- }
- src += stride;
- }
- break;
- case GL_ALPHA:
- src = (GLubyte *)image->Data + ( y * image->Width + x );
- stride = (image->Width - width);
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR8888(255,255,255,src[0]);
- src += 1;
- }
- src += stride;
- }
- break;
- case GL_LUMINANCE_ALPHA:
- src = (GLubyte *)image->Data + ( y * image->Width + x ) * 2;
- stride = (image->Width - width) * 2;
- for ( i = height ; i ; i-- ) {
- for ( j = width ; j ; j-- ) {
-
- *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],
- src[0],src[1]);
- src += 2;
- }
- src += stride;
- }
- break;
- default:
- goto format_error;
- }
- break;
- default:
- goto format_error;
+ src = (GLubyte *)image->Data + (y * image->RowStride + x) * texelBytes;
+
+ src_pitch = image->RowStride * texelBytes;
+ dst_pitch = width * texelBytes;
+
+ for (i = height; i; i--) {
+ memcpy( dst, src, dst_pitch );
+ dst += dst_pitch;
+ src += src_pitch;
}
-
- return;
-
- format_error:
-
- fprintf(stderr, "Unsupported texelBytes %i, image->Format %i\n",
- (int)texelBytes, (int)image->Format );
}
diff --git a/src/mesa/drivers/dri/mga/mgatexmem.c b/src/mesa/drivers/dri/mga/mgatexmem.c
index 34a3fbeaee9..1d6bb29fadd 100644
--- a/src/mesa/drivers/dri/mga/mgatexmem.c
+++ b/src/mesa/drivers/dri/mga/mgatexmem.c
@@ -108,7 +108,7 @@ mgaPrintGlobalLRU( mgaContextPtr mmesa, int heap )
static void mgaResetGlobalLRU( mgaContextPtr mmesa, GLuint heap )
{
drmTextureRegion *list = mmesa->sarea->texList[heap];
- int sz = 1 << mmesa->mgaScreen->logTextureGranularity[heap];
+ unsigned int sz = 1 << mmesa->mgaScreen->logTextureGranularity[heap];
int i;
mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap];
@@ -137,7 +137,7 @@ static void mgaResetGlobalLRU( mgaContextPtr mmesa, GLuint heap )
}
-static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t )
{
int i;
int heap = t->heap;
@@ -197,8 +197,8 @@ static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t )
*/
static void mgaTexturesGone( mgaContextPtr mmesa,
GLuint heap,
- GLuint offset,
- GLuint size,
+ GLint offset,
+ GLint size,
GLuint in_use )
{
mgaTextureObjectPtr t, tmp;
@@ -244,7 +244,7 @@ static void mgaTexturesGone( mgaContextPtr mmesa,
void mgaAgeTextures( mgaContextPtr mmesa, int heap )
{
MGASAREAPrivPtr sarea = mmesa->sarea;
- int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]);
+ unsigned int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]);
int idx, nr = 0;
/* Have to go right round from the back to ensure stuff ends up
@@ -390,7 +390,7 @@ void mgaUploadSubImageLocked( mgaContextPtr mmesa,
/* FIXME: the sync for direct copy reduces speed.. */
if(t->heap == MGA_CARD_HEAP ) {
mgaGetILoadBufferLocked( mmesa );
- mgaConvertTexture( (GLuint *)mmesa->iload_buffer->address,
+ mgaConvertTexture( (GLubyte *)mmesa->iload_buffer->address,
texelBytes, image, x, y, width, height );
if(length < 64) length = 64;
@@ -413,7 +413,7 @@ void mgaUploadSubImageLocked( mgaContextPtr mmesa,
*/
UPDATE_LOCK(mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT);
- mgaConvertTexture( (GLuint *)
+ mgaConvertTexture( (GLubyte *)
(mmesa->mgaScreen->texVirtual[t->heap] +
offset +
y * width * 4/texelsPerDword),
diff --git a/src/mesa/drivers/dri/mga/mgavb.c b/src/mesa/drivers/dri/mga/mgavb.c
index 976610f8a7e..2706db29f86 100644
--- a/src/mesa/drivers/dri/mga/mgavb.c
+++ b/src/mesa/drivers/dri/mga/mgavb.c
@@ -89,7 +89,7 @@ static struct {
#define VERTEX mgaVertex
#define VERTEX_COLOR mga_color_t
-#define LOCALVARS mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+#define LOCALVARS mgaContextPtr mmesa = MGA_CONTEXT(ctx); (void) mmesa;
#define GET_VIEWPORT_MAT() mmesa->hw_viewport
#define GET_TEXSOURCE(n) mmesa->tmu_source[n]
#define GET_VERTEX_FORMAT() mmesa->vertex_format
diff --git a/src/mesa/drivers/dri/mga/server/mga.h b/src/mesa/drivers/dri/mga/server/mga.h
index 3fca53dc2fb..bcec03a1eee 100644
--- a/src/mesa/drivers/dri/mga/server/mga.h
+++ b/src/mesa/drivers/dri/mga/server/mga.h
@@ -59,11 +59,6 @@ typedef struct {
int irq; /**< \brief IRQ number */
-
- int frontOffset; /**< \brief Front color buffer offset */
- int frontPitch; /**< \brief Front color buffer pitch */
- int backOffset; /**< \brief Back color buffer offset */
- int backPitch; /**< \brief Back color buffer pitch */
int depthOffset; /**< \brief Depth buffer offset */
int depthPitch; /**< \brief Depth buffer pitch */
int textureOffset; /**< \brief Texture area offset */
@@ -93,7 +88,7 @@ typedef struct {
drmBufMapPtr drmBuffers;
unsigned long IOAddress;
- unsigned char *IOBase;
+ volatile void *IOBase;
int HasSDRAM;
__u32 reg_ien;
diff --git a/src/mesa/drivers/dri/mga/server/mga_common.h b/src/mesa/drivers/dri/mga/server/mga_common.h
index 90f6b37f4e6..7924434f636 100644
--- a/src/mesa/drivers/dri/mga/server/mga_common.h
+++ b/src/mesa/drivers/dri/mga/server/mga_common.h
@@ -71,11 +71,11 @@ typedef struct {
int chipset;
int sgram;
- unsigned int maccess;
+// unsigned int maccess;
- unsigned int fb_cpp;
- unsigned int front_offset, front_pitch;
- unsigned int back_offset, back_pitch;
+// unsigned int fb_cpp;
+// unsigned int front_offset, front_pitch;
+// unsigned int back_offset, back_pitch;
unsigned int depth_cpp;
unsigned int depth_offset, depth_pitch;
diff --git a/src/mesa/drivers/dri/mga/server/mga_dri.c b/src/mesa/drivers/dri/mga/server/mga_dri.c
index f6ff32f1317..e056ef140f3 100644
--- a/src/mesa/drivers/dri/mga/server/mga_dri.c
+++ b/src/mesa/drivers/dri/mga/server/mga_dri.c
@@ -383,27 +383,6 @@ static int MGADRIKernelInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
init.sgram = 0; /* FIXME !pMga->HasSDRAM; */
-
- switch (ctx->bpp)
- {
- case 16:
- init.maccess = MGA_MACCESS_PW16;
- break;
- case 32:
- init.maccess = MGA_MACCESS_PW32;
- break;
- default:
- fprintf( stderr, "[mga] invalid bpp (%d)\n", ctx->bpp );
- return 0;
- }
-
-
- init.fb_cpp = ctx->bpp / 8;
- init.front_offset = pMga->frontOffset;
- init.front_pitch = pMga->frontPitch / init.fb_cpp;
- init.back_offset = pMga->backOffset;
- init.back_pitch = pMga->backPitch / init.fb_cpp;
-
init.depth_cpp = ctx->bpp / 8;
init.depth_offset = pMga->depthOffset;
init.depth_pitch = pMga->depthPitch / init.depth_cpp;
@@ -483,17 +462,11 @@ static int MGADRIBuffersInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
static int MGAMemoryInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
{
int width_bytes = ctx->shared.virtualWidth * ctx->cpp;
- int bufferSize = ((ctx->shared.virtualHeight * width_bytes
- + MGA_BUFFER_ALIGN)
- & ~MGA_BUFFER_ALIGN);
int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes
+ MGA_BUFFER_ALIGN)
& ~MGA_BUFFER_ALIGN);
int l;
- pMga->frontOffset = 0;
- pMga->frontPitch = ctx->shared.virtualWidth * ctx->cpp;
-
fprintf(stderr,
"Using %d MB AGP aperture\n", pMga->agpSize);
fprintf(stderr,
@@ -503,7 +476,7 @@ static int MGAMemoryInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
/* Front, back and depth buffers - everything else texture??
*/
- pMga->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize;
+ pMga->textureSize = ctx->shared.fbSize - depthSize;
if (pMga->textureSize < 0)
return 0;
@@ -528,33 +501,27 @@ static int MGAMemoryInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
}
/* Reserve space for textures */
- pMga->textureOffset = ((ctx->shared.fbSize - pMga->textureSize +
+ pMga->textureOffset = ((ctx->FBSize - pMga->textureSize +
MGA_BUFFER_ALIGN) &
~MGA_BUFFER_ALIGN);
/* Reserve space for the shared depth
* buffer.
*/
- pMga->depthOffset = ((pMga->textureOffset - depthSize +
+ pMga->depthOffset = ((ctx->shared.fbOrigin +
MGA_BUFFER_ALIGN) &
~MGA_BUFFER_ALIGN);
pMga->depthPitch = ctx->shared.virtualWidth * ctx->cpp;
- pMga->backOffset = ((pMga->depthOffset - bufferSize +
- MGA_BUFFER_ALIGN) &
- ~MGA_BUFFER_ALIGN);
- pMga->backPitch = ctx->shared.virtualWidth * ctx->cpp;
fprintf(stderr,
- "Will use back buffer at offset 0x%x\n",
- pMga->backOffset);
+ "Will use depth buffer at offset %d.%d MB\n",
+ pMga->depthOffset>>20, (pMga->depthOffset&0xfffff) * 1000 / 0x100000);
fprintf(stderr,
- "Will use depth buffer at offset 0x%x\n",
- pMga->depthOffset);
- fprintf(stderr,
- "Will use %d kb for textures at offset 0x%x\n",
- pMga->textureSize/1024, pMga->textureOffset);
+ "Will use %d kb for textures at offset %d.%d MB\n",
+ pMga->textureSize/1024, pMga->textureOffset>>20,
+ (pMga->textureOffset&0xfffff) * 1000 / 0x100000);
return 1;
}
@@ -589,19 +556,10 @@ static void print_client_msg( MGADRIPtr pMGADRI )
{
fprintf( stderr, "chipset: %d\n", pMGADRI->chipset );
- fprintf( stderr, "width: %d\n", pMGADRI->width );
- fprintf( stderr, "height: %d\n", pMGADRI->height );
fprintf( stderr, "mem: %d\n", pMGADRI->mem );
- fprintf( stderr, "cpp: %d\n", pMGADRI->cpp );
fprintf( stderr, "agpMode: %d\n", pMGADRI->agpMode );
- fprintf( stderr, "frontOffset: %d\n", pMGADRI->frontOffset );
- fprintf( stderr, "frontPitch: %d\n", pMGADRI->frontPitch );
-
- fprintf( stderr, "backOffset: %d\n", pMGADRI->backOffset );
- fprintf( stderr, "backPitch: %d\n", pMGADRI->backPitch );
-
fprintf( stderr, "depthOffset: %d\n", pMGADRI->depthOffset );
fprintf( stderr, "depthPitch: %d\n", pMGADRI->depthPitch );
@@ -636,6 +594,17 @@ static int MGAScreenInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
usleep(100);
//assert(!ctx->IsClient);
+ switch (ctx->bpp)
+ {
+ case 16:
+ case 32:
+ break;
+ default:
+ fprintf(stderr, "[drm] Direct rendering only supported for RGB16 and RGB32 yet\n");
+ return 0;
+ }
+
+
{
int width_bytes = (ctx->shared.virtualWidth * ctx->cpp);
int maxy = ctx->shared.fbSize / width_bytes;
@@ -804,6 +773,7 @@ static int MGAScreenInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
}
+#if 0
/* Quick hack to clear the front & back buffers. Could also use
* the clear ioctl to do this, but would need to setup hw state
* first.
@@ -815,6 +785,7 @@ static int MGAScreenInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
memset(ctx->FBAddress + pMga->backOffset,
0,
pMga->backPitch * ctx->shared.virtualHeight );
+#endif
/* Can release the lock now */
/* DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);*/
@@ -838,17 +809,10 @@ static int MGAScreenInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
default:
return 0;
}
- pMGADRI->width = ctx->shared.virtualWidth;
- pMGADRI->height = ctx->shared.virtualHeight;
pMGADRI->mem = ctx->shared.fbSize;
- pMGADRI->cpp = ctx->bpp / 8;
pMGADRI->agpMode = pMga->agpMode;
- pMGADRI->frontOffset = pMga->frontOffset;
- pMGADRI->frontPitch = pMga->frontPitch;
- pMGADRI->backOffset = pMga->backOffset;
- pMGADRI->backPitch = pMga->backPitch;
pMGADRI->depthOffset = pMga->depthOffset;
pMGADRI->depthPitch = pMga->depthPitch;
pMGADRI->textureOffset = pMga->textureOffset;
@@ -1036,8 +1000,6 @@ static int mgaInitFBDev( struct DRIDriverContextRec *ctx )
pMga->IOAddress = ctx->MMIOStart;
pMga->IOBase = ctx->MMIOAddress;
- pMga->frontPitch = ctx->shared.virtualWidth * ctx->cpp;
-
if (!MGAScreenInit( ctx, pMga ))
return 0;
@@ -1056,8 +1018,56 @@ static int mgaInitFBDev( struct DRIDriverContextRec *ctx )
*/
static void mgaHaltFBDev( struct DRIDriverContextRec *ctx )
{
- drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
- drmClose(ctx->drmFD);
+ MGAPtr pMga = ctx->driverPrivate;
+ drmMGAInit init;
+
+ if ( pMga->drmBuffers ) {
+ drmUnmapBufs( pMga->drmBuffers );
+ pMga->drmBuffers = NULL;
+ }
+
+ if (pMga->irq) {
+ drmCtlUninstHandler(ctx->drmFD);
+ pMga->irq = 0;
+ }
+
+ /* Cleanup DMA */
+ memset( &init, 0, sizeof(drmMGAInit) );
+ init.func = MGA_CLEANUP_DMA;
+ drmCommandWrite( ctx->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit) );
+
+ if ( pMga->status.map ) {
+ drmUnmap( pMga->status.map, pMga->status.size );
+ pMga->status.map = NULL;
+ }
+ if ( pMga->buffers.map ) {
+ drmUnmap( pMga->buffers.map, pMga->buffers.size );
+ pMga->buffers.map = NULL;
+ }
+ if ( pMga->primary.map ) {
+ drmUnmap( pMga->primary.map, pMga->primary.size );
+ pMga->primary.map = NULL;
+ }
+ if ( pMga->warp.map ) {
+ drmUnmap( pMga->warp.map, pMga->warp.size );
+ pMga->warp.map = NULL;
+ }
+
+ if ( pMga->agpTextures.map ) {
+ drmUnmap( pMga->agpTextures.map, pMga->agpTextures.size );
+ pMga->agpTextures.map = NULL;
+ }
+
+ if ( pMga->agp.handle ) {
+ drmAgpUnbind( ctx->drmFD, pMga->agp.handle );
+ drmAgpFree( ctx->drmFD, pMga->agp.handle );
+ pMga->agp.handle = 0;
+ drmAgpRelease( ctx->drmFD );
+ }
+
+ drmUnlock( ctx->drmFD, ctx->serverContext );
+ drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
+ drmClose(ctx->drmFD);
if (ctx->driverPrivate) {
free(ctx->driverPrivate);
@@ -1080,6 +1090,13 @@ static int mgaEngineRestore( struct DRIDriverContextRec *ctx )
return 1;
}
+static int mgaEngineIdle( struct DRIDriverContextRec *ctx )
+{
+ MGAWaitForIdleDMA( ctx, ctx->driverPrivate );
+
+ return 1;
+}
+
/**
* \brief Exported driver interface for Mini GLX.
*
@@ -1093,6 +1110,7 @@ struct DRIDriverRec __driDriver = {
mgaHaltFBDev,
mgaEngineShutdown,
mgaEngineRestore,
+ mgaEngineIdle,
0
};
diff --git a/src/mesa/drivers/dri/mga/server/mga_dri.h b/src/mesa/drivers/dri/mga/server/mga_dri.h
index c6a3e23f41b..d124747d681 100644
--- a/src/mesa/drivers/dri/mga/server/mga_dri.h
+++ b/src/mesa/drivers/dri/mga/server/mga_dri.h
@@ -44,19 +44,10 @@
typedef struct {
int chipset;
- int width;
- int height;
int mem;
- int cpp;
int agpMode;
- int frontOffset;
- int frontPitch;
-
- int backOffset;
- int backPitch;
-
int depthOffset;
int depthPitch;
diff --git a/src/mesa/drivers/dri/mga/server/mga_sarea.h b/src/mesa/drivers/dri/mga/server/mga_sarea.h
index 40058ebde80..3d37cf4f73a 100644
--- a/src/mesa/drivers/dri/mga/server/mga_sarea.h
+++ b/src/mesa/drivers/dri/mga/server/mga_sarea.h
@@ -116,7 +116,14 @@
/* Setup registers for 3D context
*/
typedef struct {
- unsigned int dstorg;
+ unsigned int fb_cpp;
+ unsigned int front_offset;
+ unsigned int front_pitch;
+ unsigned int back_offset;
+ unsigned int back_pitch;
+ unsigned int draw_offset;
+ unsigned int draw_pitch;
+
unsigned int maccess;
unsigned int plnwt;
unsigned int dwgctl;
@@ -186,7 +193,7 @@ typedef struct {
* The client clears the exported_drawable field before
* clobbering the boxes data.
*/
- GLXDrawable req_drawable; /* the X drawable id */
+ unsigned int req_drawable; /* the X drawable id */
unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
unsigned int exported_drawable;
diff --git a/src/mesa/drivers/dri/r200/r200_screen.c b/src/mesa/drivers/dri/r200/r200_screen.c
index 2562e72353b..7f71243c6a1 100644
--- a/src/mesa/drivers/dri/r200/r200_screen.c
+++ b/src/mesa/drivers/dri/r200/r200_screen.c
@@ -379,11 +379,13 @@ static struct __DriverAPIRec r200API = {
* Return: pointer to a __DRIscreenPrivate.
*
*/
-void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config)
+void *
+__driCreateScreen(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc)
{
__DRIscreenPrivate *psp;
- psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &r200API);
+ psp = __driUtilCreateScreen(driver, driverContext, psc, &r200API);
return (void *) psp;
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index 7ea650d42c7..bd707d89bd3 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -280,7 +280,8 @@ radeonCreateContext( const __GLcontextModes *glVisual,
rmesa->dri.hwLock = &sPriv->pSAREA->lock;
rmesa->dri.fd = sPriv->fd;
- rmesa->glCtx->_RotateMode = radeonScreen->driScreen->display->rotateMode;
+ /* remove X dependency -- dok, 2003-04-27
+ * rmesa->glCtx->_RotateMode = radeonScreen->driScreen->display->rotateMode; */
/* If we don't have 1.3, fallback to the 1.1 interfaces.
*/
@@ -716,6 +717,9 @@ radeonUnbindContext( __DRIcontextPrivate *driContextPriv )
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, rmesa->glCtx);
radeonVtxfmtUnbindContext( rmesa->glCtx );
+
+ UNLOCK_HARDWARE( rmesa );
+
return GL_TRUE;
}
@@ -845,10 +849,13 @@ static struct __DriverAPIRec radeonAPI = {
*
* Calls __driUtilCreateScreen() with ::radeonAPI.
*/
-void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config)
+void *
+__driCreateScreen(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc)
{
__DRIscreenPrivate *psp;
- psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &radeonAPI);
+ psp = __driUtilCreateScreen(driver, driverContext, psc, &radeonAPI);
return (void *) psp;
}
+
diff --git a/src/mesa/drivers/dri/radeon/server/radeon_dri.c b/src/mesa/drivers/dri/radeon/server/radeon_dri.c
index 298f646773a..8efac506d90 100644
--- a/src/mesa/drivers/dri/radeon/server/radeon_dri.c
+++ b/src/mesa/drivers/dri/radeon/server/radeon_dri.c
@@ -1243,6 +1243,7 @@ struct DRIDriverRec __driDriver = {
radeonHaltFBDev,
RADEONEngineShutdown,
RADEONEngineRestore,
+ 0,
#if _HAVE_FULL_GL
0,
#else
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 700c916b645..927659652e9 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1,4 +1,4 @@
-/* $Id: texstore.c,v 1.47.4.2 2003/03/09 10:52:21 jrfonseca Exp $ */
+/* $Id: texstore.c,v 1.47.4.2.4.1 2003/05/06 00:01:36 dok666 Exp $ */
/*
* Mesa 3-D graphics library
@@ -1894,8 +1894,8 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
{
const struct gl_texture_image *srcImage;
const struct gl_texture_format *convertFormat;
- const GLubyte *srcData;
- GLubyte *dstData;
+ const GLubyte *srcData = NULL;
+ GLubyte *dstData = NULL;
GLint level, maxLevels;
ASSERT(texObj);
diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c
index 4cf198bbac4..ef571efddeb 100644
--- a/src/mesa/tnl/t_vb_texgen.c
+++ b/src/mesa/tnl/t_vb_texgen.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_texgen.c,v 1.15 2002/10/29 20:29:04 brianp Exp $ */
+/* $Id: t_vb_texgen.c,v 1.15.8.1 2003/05/06 00:01:40 dok666 Exp $ */
/*
* Mesa 3-D graphics library
@@ -322,9 +322,15 @@ static void texgen_sphere_map( GLcontext *ctx,
GLfloat (*f)[3] = store->tmp_f;
GLfloat *m = store->tmp_m;
-/* _mesa_debug(NULL, "%s normstride %d eyestride %d\n", */
-/* __FUNCTION__, VB->NormalPtr->stride, */
-/* VB->EyePtr->stride); */
+ //printf("0, %p, %p\n", VB->NormalPtr, VB->EyePtr);
+
+ if (!VB->EyePtr) {
+ return;
+ }
+
+/* _mesa_debug(NULL, "%s normstride %d eyestride %d\n",
+ __FUNCTION__, VB->NormalPtr->stride,
+ VB->EyePtr->stride);*/
(build_m_tab[VB->EyePtr->size])( store->tmp_f,
store->tmp_m,
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
index 9e9e1a9362e..10d781145e5 100644
--- a/src/mesa/tnl/t_vb_vertex.c
+++ b/src/mesa/tnl/t_vb_vertex.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_vertex.c,v 1.17 2002/10/31 17:14:37 brianp Exp $ */
+/* $Id: t_vb_vertex.c,v 1.17.8.1 2003/05/06 00:01:41 dok666 Exp $ */
/*
* Mesa 3-D graphics library
@@ -141,7 +141,7 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
if (stage->changed_inputs) {
- if (ctx->_NeedEyeCoords) {
+ if (1||ctx->_NeedEyeCoords) {
/* Separate modelview transformation:
* Use combined ModelProject to avoid some depth artifacts
*/
diff --git a/src/miniglx/dri_util.c b/src/miniglx/dri_util.c
index f67a2a31375..af48d0086c8 100644
--- a/src/miniglx/dri_util.c
+++ b/src/miniglx/dri_util.c
@@ -77,13 +77,9 @@ __driUtilMessage(const char *f, ...)
* MiniGLXDisplayRec::configs until finding one with a matching visual ID.
*/
static __GLXvisualConfig *
-__driFindGlxConfig(Display *dpy, int scrn, VisualID vid)
+__driFindGlxConfig(__GLXvisualConfig *glxConfigs, int numConfigs, VisualID vid)
{
- __GLXvisualConfig *glxConfigs;
- int numConfigs, i;
-
- numConfigs = dpy->numConfigs;
- glxConfigs = dpy->configs;
+ int i;
for (i = 0; i < numConfigs; i++) {
if (glxConfigs[i].vid == vid) {
@@ -174,30 +170,23 @@ __glXFormatGLModes(__GLcontextModes *modes, const __GLXvisualConfig *config)
* While casting the opaque private pointers associated with the parameters into their
* respective real types it also assures they are not null.
*/
-static Bool driUnbindContext(Display *dpy, int scrn,
- GLXDrawable draw, GLXContext gc,
- int will_rebind)
+static Bool driUnbindContext(__DRIscreen *pDRIScreen,
+ __DRIdrawable *drawable,
+ __DRIcontext *context,
+ int will_rebind)
{
- __DRIscreen *pDRIScreen;
- __DRIdrawable *pdraw;
__DRIcontextPrivate *pcp;
__DRIscreenPrivate *psp;
__DRIdrawablePrivate *pdp;
- if (gc == NULL || draw == None)
- return GL_FALSE;
-
- if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn)))
+ if (drawable == NULL || context == None)
return GL_FALSE;
if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private))
return GL_FALSE;
- if (!(pdraw = &draw->driDrawable))
- return GL_FALSE;
-
- pcp = (__DRIcontextPrivate *)gc->driContext.private;
- pdp = (__DRIdrawablePrivate *)pdraw->private;
+ pcp = (__DRIcontextPrivate *) context->private;
+ pdp = (__DRIdrawablePrivate *) drawable->private;
/* Let driver unbind drawable from context */
(*psp->DriverAPI.UnbindContext)(pcp);
@@ -226,12 +215,10 @@ static Bool driUnbindContext(Display *dpy, int scrn,
* While casting the opaque private pointers into their
* respective real types it also assures they are not null.
*/
-static Bool driBindContext(Display *dpy, int scrn,
- GLXDrawable draw,
- GLXContext gc)
+static Bool driBindContext(__DRIscreen *pDRIScreen,
+ __DRIdrawable *drawable,
+ __DRIcontext *context)
{
- __DRIscreen *pDRIScreen;
- __DRIdrawable *pdraw;
__DRIdrawablePrivate *pdp;
__DRIscreenPrivate *psp;
__DRIcontextPrivate *pcp;
@@ -240,21 +227,17 @@ static Bool driBindContext(Display *dpy, int scrn,
* Assume error checking is done properly in glXMakeCurrent before
* calling driBindContext.
*/
- if (gc == NULL || draw == None)
- return GL_FALSE;
-
- if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn)))
+ if (drawable == NULL || context == None)
return GL_FALSE;
if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private))
return GL_FALSE;
- pdraw = &draw->driDrawable;
- pdp = (__DRIdrawablePrivate *) pdraw->private;
+ pdp = (__DRIdrawablePrivate *) drawable->private;
/* Bind the drawable to the context */
- pcp = (__DRIcontextPrivate *)gc->driContext.private;
+ pcp = (__DRIcontextPrivate *)context->private;
pcp->driDrawablePriv = pdp;
pdp->driContextPriv = pcp;
pdp->refcount++;
@@ -303,11 +286,10 @@ void __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
*
* Is called directly from glXSwapBuffers().
*/
-static void driSwapBuffers( Display *dpy, void *drawablePrivate )
+static void driSwapBuffers( __DRIscreen *pDRIscreen, void *drawablePrivate )
{
__DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
dPriv->swapBuffers(dPriv);
- (void) dpy;
}
@@ -321,7 +303,7 @@ static void driSwapBuffers( Display *dpy, void *drawablePrivate )
* This function calls __DriverAPIRec::DestroyBuffer on \p drawablePrivate,
* frees the clip rects if any, and finally frees \p drawablePrivate itself.
*/
-static void driDestroyDrawable(Display *dpy, void *drawablePrivate)
+static void driDestroyDrawable(__DRIscreen *pDRIscreen, void *drawablePrivate)
{
__DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *) drawablePrivate;
__DRIscreenPrivate *psp = pdp->driScreenPriv;
@@ -352,11 +334,10 @@ static void driDestroyDrawable(Display *dpy, void *drawablePrivate)
* visual config, converts it into a __GLcontextModesRec and passes it to
* __DriverAPIRec::CreateBuffer to create a buffer.
*/
-static void *driCreateDrawable(Display *dpy, int scrn,
- GLXDrawable draw,
- VisualID vid, __DRIdrawable *pdraw)
+static void *driCreateDrawable(__DRIscreen *pDRIScreen,
+ int width, int height, int index,
+ VisualID vid, __DRIdrawable *pdraw)
{
- __DRIscreen *pDRIScreen;
__DRIscreenPrivate *psp;
__DRIdrawablePrivate *pdp;
__GLXvisualConfig *config;
@@ -367,39 +348,36 @@ static void *driCreateDrawable(Display *dpy, int scrn,
return NULL;
}
- pdp->index = dpy->clientID;
- pdp->draw = draw;
+ pdp->index = index;
+ //pdp->draw = draw;
pdp->refcount = 0;
pdp->lastStamp = -1;
pdp->numBackClipRects = 0;
pdp->pBackClipRects = NULL;
- pdp->display = dpy;
- pdp->screen = scrn;
+ //pdp->display = dpy;
+ //pdp->screen = scrn;
/* Initialize with the invariant window dimensions and clip rects here.
*/
pdp->x = 0;
pdp->y = 0;
- pdp->w = pdp->draw->w;
- pdp->h = pdp->draw->h;
+ pdp->w = width;
+ pdp->h = height;
pdp->numClipRects = 0;
pdp->pClipRects = (XF86DRIClipRectPtr) malloc(sizeof(XF86DRIClipRectRec));
(pdp->pClipRects)[0].x1 = 0;
(pdp->pClipRects)[0].y1 = 0;
- (pdp->pClipRects)[0].x2 = pdp->draw->w;
- (pdp->pClipRects)[0].y2 = pdp->draw->h;
+ (pdp->pClipRects)[0].x2 = width;
+ (pdp->pClipRects)[0].y2 = height;
- if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
- free(pdp);
- return NULL;
- } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
free(pdp);
return NULL;
}
pdp->driScreenPriv = psp;
pdp->driContextPriv = 0;
- config = __driFindGlxConfig(dpy, scrn, vid);
+ config = __driFindGlxConfig(psp->configs, psp->numConfigs, vid);
if (!config)
return NULL;
@@ -430,8 +408,9 @@ static void *driCreateDrawable(Display *dpy, int scrn,
* \internal
* This function returns the MiniGLXwindowRec::driDrawable attribute.
*/
-static __DRIdrawable *driGetDrawable(Display *dpy, GLXDrawable draw,
- void *screenPrivate)
+static __DRIdrawable *driGetDrawable(__DRIscreen *pDRIscreen,
+ GLXDrawable draw,
+ void *screenPrivate)
{
return &draw->driDrawable;
}
@@ -456,7 +435,7 @@ static __DRIdrawable *driGetDrawable(Display *dpy, GLXDrawable draw,
* This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls
* drmDestroyContext(), and finally frees \p contextPrivate.
*/
-static void driDestroyContext(Display *dpy, int scrn, void *contextPrivate)
+static void driDestroyContext(__DRIscreen *pDRIscreen, void *contextPrivate)
{
__DRIcontextPrivate *pcp = (__DRIcontextPrivate *) contextPrivate;
__DRIscreenPrivate *psp = NULL;
@@ -489,11 +468,11 @@ static void driDestroyContext(Display *dpy, int scrn, void *contextPrivate)
* gets the visual, converts it into a __GLcontextModesRec and passes it
* to __DriverAPIRec::CreateContext to create the context.
*/
-static void *driCreateContext(Display *dpy, XVisualInfo *vis,
+static void *driCreateContext(__DRIscreen *pDRIScreen,
+ VisualID vid,
void *sharedPrivate,
__DRIcontext *pctx)
{
- __DRIscreen *pDRIScreen;
__DRIcontextPrivate *pcp;
__DRIcontextPrivate *pshare = (__DRIcontextPrivate *) sharedPrivate;
__DRIscreenPrivate *psp;
@@ -501,9 +480,6 @@ static void *driCreateContext(Display *dpy, XVisualInfo *vis,
__GLcontextModes modes;
void *shareCtx;
- if (!(pDRIScreen = __glXFindDRIScreen(dpy, 0)))
- return NULL;
-
if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private))
return NULL;
@@ -512,7 +488,7 @@ static void *driCreateContext(Display *dpy, XVisualInfo *vis,
return NULL;
}
- pcp->display = dpy;
+ //pcp->display = dpy;
pcp->driScreenPriv = psp;
pcp->driDrawablePriv = NULL;
@@ -528,7 +504,7 @@ static void *driCreateContext(Display *dpy, XVisualInfo *vis,
/* Setup a __GLcontextModes struct corresponding to vis->visualid
* and create the rendering context.
*/
- config = __driFindGlxConfig(dpy, 0, vis->visualid);
+ config = __driFindGlxConfig(psp->configs, psp->numConfigs, vid);
if (!config)
return NULL;
@@ -568,7 +544,7 @@ static void *driCreateContext(Display *dpy, XVisualInfo *vis,
* This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls
* drmClose(), and finally frees \p screenPrivate.
*/
-static void driDestroyScreen(Display *dpy, int scrn, void *screenPrivate)
+static void driDestroyScreen(__DRIscreen *pDRIscreen, void *screenPrivate)
{
__DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
@@ -601,8 +577,9 @@ static void driDestroyScreen(Display *dpy, int scrn, void *screenPrivate)
* __DriverAPIRec::InitDriver.
*/
__DRIscreenPrivate *
-__driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config,
+__driUtilCreateScreen(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc,
const struct __DriverAPIRec *driverAPI)
{
__DRIscreenPrivate *psp;
@@ -612,10 +589,14 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
return NULL;
}
- psp->display = dpy;
- psp->myNum = scrn;
-
- psp->fd = drmOpen(NULL,dpy->driverContext.pciBusID);
+ //psp->display = dpy;
+ psp->myNum = 0;//scrn;
+
+ /* Ask the driver for a list of supported configs:
+ */
+ driver->initScreenConfigs( driverContext, &psp->numConfigs, &psp->configs );
+
+ psp->fd = drmOpen(NULL,driverContext->pciBusID);
if (psp->fd < 0) {
fprintf(stderr, "libGL error: failed to open DRM: %s\n",
strerror(-psp->fd));
@@ -658,20 +639,20 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
* that has information about the screen size, depth, pitch,
* ancilliary buffers, DRM mmap handles, etc.
*/
- psp->fbOrigin = 0;
- psp->fbSize = dpy->driverContext.shared.fbSize;
- psp->fbStride = dpy->driverContext.shared.fbStride;
- psp->devPrivSize = dpy->driverContext.driverClientMsgSize;
- psp->pDevPriv = dpy->driverContext.driverClientMsg;
- psp->fbWidth = dpy->driverContext.shared.virtualWidth;
- psp->fbHeight = dpy->driverContext.shared.virtualHeight;
- psp->fbBPP = dpy->driverContext.bpp;
-
- if (dpy->IsClient) {
+ psp->fbOrigin = driverContext->shared.fbOrigin;
+ psp->fbSize = driverContext->shared.fbSize;
+ //psp->fbStride = driverContext->shared.fbStride;
+ psp->devPrivSize = driverContext->driverClientMsgSize;
+ psp->pDevPriv = driverContext->driverClientMsg;
+ psp->fbWidth = driverContext->shared.virtualWidth;
+ psp->fbHeight = driverContext->shared.virtualHeight;
+ psp->fbBPP = driverContext->bpp;
+
+ if (driverContext->IsClient) {
/*
* Map the framebuffer region.
*/
- if (drmMap(psp->fd, dpy->driverContext.shared.hFrameBuffer, psp->fbSize,
+ if (drmMap(psp->fd, driverContext->shared.hFrameBuffer, psp->fbSize + psp->fbOrigin,
(drmAddressPtr)&psp->pFB)) {
fprintf(stderr, "libGL error: drmMap of framebuffer failed\n");
(void)drmClose(psp->fd);
@@ -683,23 +664,23 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
* Map the SAREA region. Further mmap regions may be setup in
* each DRI driver's "createScreen" function.
*/
- if (drmMap(psp->fd, dpy->driverContext.shared.hSAREA,
- dpy->driverContext.shared.SAREASize,
+ if (drmMap(psp->fd, driverContext->shared.hSAREA,
+ driverContext->shared.SAREASize,
(drmAddressPtr)&psp->pSAREA)) {
fprintf(stderr, "libGL error: drmMap of sarea failed\n");
- (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
+ (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize + psp->fbOrigin);
(void)drmClose(psp->fd);
free(psp);
return NULL;
}
#if !_HAVE_FULL_GL
- mprotect(psp->pSAREA, dpy->driverContext.shared.SAREASize, PROT_READ);
+ mprotect(psp->pSAREA, driverContext->shared.SAREASize, PROT_READ);
#endif
} else {
- psp->pFB = dpy->driverContext.FBAddress;
- psp->pSAREA = dpy->driverContext.pSAREA;
+ psp->pFB = driverContext->FBAddress;
+ psp->pSAREA = driverContext->pSAREA;
}
@@ -731,8 +712,9 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
* Same as __driUtilCreateScreen() but without opening the DRM device.
*/
__DRIscreenPrivate *
-__driUtilCreateScreenNoDRM(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config,
+__driUtilCreateScreenNoDRM(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc,
const struct __DriverAPIRec *driverAPI)
{
__DRIscreenPrivate *psp;
@@ -741,26 +723,30 @@ __driUtilCreateScreenNoDRM(Display *dpy, int scrn, __DRIscreen *psc,
if (!psp)
return NULL;
+ /* Ask the driver for a list of supported configs:
+ */
+ driver->initScreenConfigs( driverContext, &psp->numConfigs, &psp->configs );
+
psp->ddxMajor = 4;
psp->ddxMinor = 0;
psp->ddxPatch = 1;
psp->driMajor = 4;
psp->driMinor = 1;
psp->driPatch = 0;
- psp->display = dpy;
- psp->myNum = scrn;
+ //psp->display = dpy;
+ psp->myNum = 0;//scrn;
psp->fd = 0;
- psp->fbOrigin = 0;
- psp->fbSize = dpy->driverContext.shared.fbSize;
- psp->fbStride = dpy->driverContext.shared.fbStride;
- psp->devPrivSize = dpy->driverContext.driverClientMsgSize;
- psp->pDevPriv = dpy->driverContext.driverClientMsg;
- psp->fbWidth = dpy->driverContext.shared.virtualWidth;
- psp->fbHeight = dpy->driverContext.shared.virtualHeight;
- psp->fbBPP = dpy->driverContext.bpp;
+ psp->fbOrigin = driverContext->shared.fbOrigin;
+ psp->fbSize = driverContext->shared.fbSize;
+ //psp->fbStride = driverContext->shared.fbStride;
+ psp->devPrivSize = driverContext->driverClientMsgSize;
+ psp->pDevPriv = driverContext->driverClientMsg;
+ psp->fbWidth = driverContext->shared.virtualWidth;
+ psp->fbHeight = driverContext->shared.virtualHeight;
+ psp->fbBPP = driverContext->bpp;
- psp->pFB = dpy->driverContext.FBAddress;
+ psp->pFB = driverContext->FBAddress;
/* install driver's callback functions */
memcpy(&psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec));
@@ -793,7 +779,7 @@ __driUtilCreateScreenNoDRM(Display *dpy, int scrn, __DRIscreen *psc,
* resolution (a screen parameter as far as the driver is concerned).
*/
void
-__driUtilInitScreen( Display *dpy, int scrn, __DRIscreen *psc )
+__driUtilInitScreen( __DRIscreen *psc )
{
psc->destroyScreen = driDestroyScreen;
psc->createContext = driCreateContext;
diff --git a/src/miniglx/dri_util.h b/src/miniglx/dri_util.h
index b7c22a3e776..cb59634644a 100644
--- a/src/miniglx/dri_util.h
+++ b/src/miniglx/dri_util.h
@@ -52,6 +52,7 @@
#include "sarea.h" /* for XF86DRISAREAPtr */
#include "GL/internal/glcore.h" /* for __GLcontextModes */
#include "miniglxP.h" /* XID, etc */
+#include "sarea.h"
typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate; /**< \brief Alias for __DRIdisplayPrivateRec */
@@ -179,7 +180,7 @@ struct __DRIdrawablePrivateRec {
/**
* \brief X's drawable ID associated with this private drawable.
*/
- GLXDrawable draw;
+ //GLXDrawable draw;
/**
* \brief Reference count for number of context's currently bound to this
@@ -252,10 +253,16 @@ struct __DRIdrawablePrivateRec {
* __driUtilUpdateDrawableInfo() which calls XF86DRIGetDrawableInfo().
*/
/*@{*/
- Display *display;
- int screen;
+ //Display *display;
+ //int screen;
/*@}*/
+ int cpp;
+ int frontOffset;
+ int frontPitch;
+ int backOffset;
+ int backPitch;
+
/**
* \brief Called via glXSwapBuffers().
*/
@@ -284,7 +291,7 @@ struct __DRIcontextPrivateRec {
/**
* \brief This context's display pointer.
*/
- Display *display;
+ //Display *display;
/**
* \brief Pointer to drawable currently bound to this context.
@@ -304,7 +311,7 @@ struct __DRIscreenPrivateRec {
/**
* \brief Display for this screen
*/
- Display *display;
+ //Display *display;
/**
* \brief Current screen's number
@@ -441,7 +448,6 @@ struct __DRIscreenPrivateRec {
};
-
extern void
__driUtilMessage(const char *f, ...);
@@ -451,27 +457,27 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp);
extern __DRIscreenPrivate *
-__driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config,
- const struct __DriverAPIRec *driverAPI);
+__driUtilCreateScreen(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc, const struct __DriverAPIRec *driverAPI);
__DRIscreenPrivate *
-__driUtilCreateScreenNoDRM(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config,
- const struct __DriverAPIRec *driverAPI);
+__driUtilCreateScreenNoDRM(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc, const struct __DriverAPIRec *driverAPI);
/** This must be implemented in each driver */
extern void *
-__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config);
+__driCreateScreen(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc);
/** This is optionally implemented in each driver */
extern void
__driRegisterExtensions( void );
-
extern void
-__driUtilInitScreen( Display *dpy, int scrn, __DRIscreen *psc );
+__driUtilInitScreen( __DRIscreen *psc );
#endif /* _DRI_UTIL_H_ */
diff --git a/src/miniglx/miniglx.c b/src/miniglx/miniglx.c
index cd83e6fb17e..c54c6c45f70 100644
--- a/src/miniglx/miniglx.c
+++ b/src/miniglx/miniglx.c
@@ -22,7 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* $Id: miniglx.c,v 1.1.4.53 2003/04/26 21:17:47 keithw Exp $ */
+/* $Id: miniglx.c,v 1.1.4.53.4.1 2003/05/06 00:01:40 dok666 Exp $ */
/**
@@ -111,13 +111,11 @@
#include <linux/vt.h>
#include "miniglxP.h"
+#include "dri_util.h"
#include "glapi.h"
-extern void
-__driUtilInitScreen( Display *dpy, int scrn, __DRIscreen *psc );
-
/**
* \brief Current GLX context.
*
@@ -402,7 +400,7 @@ SetupFBDev( Display *dpy )
dpy->driverContext.shared.virtualHeight = height;
dpy->driverContext.shared.virtualWidth = width;
-
+
/* set the depth, resolution, etc */
dpy->VarInfo = dpy->OrigVarInfo;
dpy->VarInfo.bits_per_pixel = dpy->driverContext.bpp;
@@ -564,6 +562,10 @@ SetupFBDev( Display *dpy )
}
}
+ dpy->driverContext.shared.fbOrigin = dpy->FixedInfo.line_length * height * 2;
+ dpy->driverContext.shared.fbSize -= dpy->driverContext.shared.fbOrigin;
+
+
/* May need to restore regs fbdev has clobbered:
*/
if (!dpy->driver->postValidateMode( &dpy->driverContext )) {
@@ -651,24 +653,6 @@ CloseFBDev( Display *dpy )
/*@{*/
/**
- * \brief Find the DRI screen dependent methods associated with the display.
- *
- * \param dpy a display handle, as returned by XOpenDisplay().
- * \param scrn the screen number. Not referenced.
- *
- * \returns a pointer to a __DRIscreenRec structure.
- *
- * \internal
- * Returns the MiniGLXDisplayRec::driScreen attribute.
- */
-__DRIscreen *
-__glXFindDRIScreen(Display *dpy, int scrn)
-{
- (void) scrn;
- return &(dpy->driScreen);
-}
-
-/**
* \brief Validate a drawable.
*
* \param dpy a display handle, as returned by XOpenDisplay().
@@ -958,6 +942,13 @@ __miniglx_StartServer( const char *display_name )
return NULL;
}
+ /* do fbdev setup
+ */
+ if (!SetupFBDev(dpy)) {
+ fprintf(stderr, "SetupFBDev failed\n");
+ FREE(dpy);
+ return NULL;
+ }
/* Ask the driver for a list of supported configs:
*/
@@ -974,16 +965,8 @@ __miniglx_StartServer( const char *display_name )
/* Setup some callbacks in the screen private.
*/
- __driUtilInitScreen( dpy, 0, &(dpy->driScreen) );
+ __driUtilInitScreen( &dpy->driScreen );
- /* do fbdev setup
- */
- if (!SetupFBDev(dpy)) {
- fprintf(stderr, "SetupFBDev failed\n");
- FREE(dpy);
- return NULL;
- }
-
/* Ready for clients:
*/
@@ -1013,7 +996,7 @@ XOpenDisplay( const char *display_name )
if (!dpy)
return NULL;
- dpy->IsClient = True;
+ dpy->IsClient = dpy->driverContext.IsClient = True;
/* read config file
*/
@@ -1042,7 +1025,6 @@ XOpenDisplay( const char *display_name )
*/
dpy->driver->initScreenConfigs( &dpy->driverContext,
&dpy->numConfigs, &dpy->configs );
-
/* Perform the client-side initialization.
*
@@ -1051,10 +1033,9 @@ XOpenDisplay( const char *display_name )
*
* Need to shut down DRM and free DRI data in XDestroyWindow(), too.
*/
- dpy->driScreen.private = (*dpy->createScreen)(dpy, 0,
- &(dpy->driScreen),
- dpy->numConfigs,
- dpy->configs);
+ dpy->driScreen.private = (*dpy->createScreen)(dpy->driver,
+ &dpy->driverContext,
+ &dpy->driScreen);
if (!dpy->driScreen.private) {
fprintf(stderr, "%s: __driCreateScreen failed\n", __FUNCTION__);
dlclose(dpy->dlHandle);
@@ -1065,7 +1046,7 @@ XOpenDisplay( const char *display_name )
/* Setup some callbacks in the screen private.
*/
- __driUtilInitScreen( dpy, 0, &(dpy->driScreen) );
+ __driUtilInitScreen( &dpy->driScreen );
@@ -1100,7 +1081,7 @@ XCloseDisplay( Display *dpy )
/* As this is done in XOpenDisplay, need to undo it here:
*/
if (dpy->driScreen.private)
- (*dpy->driScreen.destroyScreen)(dpy, 0, dpy->driScreen.private);
+ (*dpy->driScreen.destroyScreen)(&dpy->driScreen, dpy->driScreen.private);
__miniglx_close_connections( dpy );
@@ -1164,6 +1145,7 @@ XCreateWindow( Display *display, Window parent, int x, int y,
XSetWindowAttributes *attributes )
{
Window win;
+ __DRIdrawablePrivate *dPriv;
/* ignored */
(void) x;
@@ -1205,7 +1187,7 @@ XCreateWindow( Display *display, Window parent, int x, int y,
win->visual = visual; /* ptr assignment */
win->bytesPerPixel = display->driverContext.cpp;
- win->rowStride = display->VarInfo.xres_virtual * win->bytesPerPixel;
+ win->rowStride = display->driverContext.shared.virtualWidth * win->bytesPerPixel;
win->size = win->rowStride * height;
win->frontStart = display->driverContext.FBAddress;
win->frontBottom = (GLubyte *) win->frontStart + (height-1) * win->rowStride;
@@ -1229,7 +1211,8 @@ XCreateWindow( Display *display, Window parent, int x, int y,
}
win->driDrawable.private = display->driScreen.createDrawable(
- display, 0, win, visual->visInfo->visualid, &(win->driDrawable));
+ &display->driScreen, win->w, win->h, display->clientID,
+ visual->visInfo->visualid, &(win->driDrawable));
if (!win->driDrawable.private) {
fprintf(stderr, "%s: dri.createDrawable failed\n", __FUNCTION__);
@@ -1237,6 +1220,17 @@ XCreateWindow( Display *display, Window parent, int x, int y,
return NULL;
}
+ dPriv = win->driDrawable.private;
+
+ dPriv->cpp = win->bytesPerPixel;
+ dPriv->frontOffset = 0;
+ dPriv->frontPitch = win->rowStride;
+ dPriv->backOffset = dPriv->frontOffset;
+ dPriv->backPitch = win->rowStride;
+
+ if (visual->glxConfig->doubleBuffer)
+ dPriv->backOffset += win->rowStride * display->driverContext.shared.virtualHeight;
+
display->NumWindows++;
display->TheWindow = win;
@@ -1270,7 +1264,7 @@ XDestroyWindow( Display *display, Window w )
/* Destroy the drawable.
*/
if (w->driDrawable.private)
- (*w->driDrawable.destroyDrawable)(display, w->driDrawable.private);
+ (*w->driDrawable.destroyDrawable)(&display->driScreen, w->driDrawable.private);
FREE(w);
/* unlink window from display */
@@ -1714,7 +1708,7 @@ glXCreateContext( Display *dpy, XVisualInfo *vis,
sharePriv = shareList->driContext.private;
else
sharePriv = NULL;
- ctx->driContext.private = (*dpy->driScreen.createContext)(dpy, vis,
+ ctx->driContext.private = (*dpy->driScreen.createContext)(&dpy->driScreen, ctx->vid,
sharePriv, &(ctx->driContext));
if (!ctx->driContext.private) {
FREE(ctx);
@@ -1743,10 +1737,10 @@ glXDestroyContext( Display *dpy, GLXContext ctx )
if (ctx) {
if (glxctx == ctx) {
/* destroying current context */
- (*ctx->driContext.bindContext)(dpy, 0, 0, 0);
+ (*ctx->driContext.bindContext)(&dpy->driScreen, 0, 0);
CurrentContext = 0;
}
- (*ctx->driContext.destroyContext)(dpy, 0, ctx->driContext.private);
+ (*ctx->driContext.destroyContext)(&dpy->driScreen, ctx->driContext.private);
FREE(ctx);
}
}
@@ -1786,18 +1780,20 @@ glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx)
GLXDrawable oldDrawable = glXGetCurrentDrawable();
/* unbind old */
if (oldContext) {
- (*oldContext->driContext.unbindContext)(dpy, 0, oldDrawable,
- oldContext, 0);
+ (*oldContext->driContext.unbindContext)(&dpy->driScreen,
+ &oldDrawable->driDrawable,
+ &oldContext->driContext, 0);
}
/* bind new */
CurrentContext = ctx;
- (*ctx->driContext.bindContext)(dpy, 0, drawable, ctx);
+ (*ctx->driContext.bindContext)(&dpy->driScreen,
+ &drawable->driDrawable, &ctx->driContext);
ctx->drawBuffer = drawable;
ctx->curBuffer = drawable;
}
else if (ctx && dpy) {
/* unbind */
- (*ctx->driContext.bindContext)(dpy, 0, 0, 0);
+ (*ctx->driContext.bindContext)(&dpy->driScreen, 0, 0);
}
else if (dpy) {
CurrentContext = 0; /* kw: this seems to be intended??? */
@@ -1827,7 +1823,7 @@ glXSwapBuffers( Display *dpy, GLXDrawable drawable )
if (!dpy || !drawable)
return;
- (*drawable->driDrawable.swapBuffers)(dpy, drawable->driDrawable.private);
+ (*drawable->driDrawable.swapBuffers)(&dpy->driScreen, drawable->driDrawable.private);
}
diff --git a/src/miniglx/miniglxP.h b/src/miniglx/miniglxP.h
index 0049a8a9a1f..c7b60cd774f 100644
--- a/src/miniglx/miniglxP.h
+++ b/src/miniglx/miniglxP.h
@@ -57,9 +57,6 @@ typedef struct __DRIcontextRec __DRIcontext; /**< \copydoc __DRIcontextRec */
typedef struct __DRIdrawableRec __DRIdrawable; /**< \copydoc __DRIdrawableRec */
-typedef void *(*CreateScreenFunc)(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config);
-
/**
@@ -72,26 +69,29 @@ struct __DRIscreenRec {
/**
* \brief Method to destroy the private DRI screen data.
*/
- void (*destroyScreen)(Display *dpy, int scrn, void *screenPrivate);
+ void (*destroyScreen)(__DRIscreen *pDRIscreen, void *screenPrivate);
/**
* \brief Method to create the private DRI context data and initialize the
* context dependent methods.
*/
- void *(*createContext)(Display *dpy, XVisualInfo *vis, void *sharedPrivate,
+ void *(*createContext)(__DRIscreen *pDRIscreen,
+ VisualID vid, void *sharedPrivate,
__DRIcontext *pctx);
/**
* \brief Method to create the private DRI drawable data and initialize the
* drawable dependent methods.
*/
- void *(*createDrawable)(Display *dpy, int scrn, GLXDrawable draw,
+ void *(*createDrawable)(__DRIscreen *pDRIscreen, int width,
+ int height, int index,
VisualID vid, __DRIdrawable *pdraw);
/**
* \brief Method to return a pointer to the DRI drawable data.
*/
- __DRIdrawable *(*getDrawable)(Display *dpy, GLXDrawable draw,
+ __DRIdrawable *(*getDrawable)(__DRIscreen *pDRIscreen,
+ GLXDrawable draw,
void *drawablePrivate);
/*
@@ -118,7 +118,7 @@ struct __DRIcontextRec {
/**
* \brief Method to destroy the private DRI context data.
*/
- void (*destroyContext)(Display *dpy, int scrn, void *contextPrivate);
+ void (*destroyContext)(__DRIscreen *pDRIscreen, void *contextPrivate);
/**
* \brief Method to bind a DRI drawable to a DRI graphics context.
@@ -126,14 +126,14 @@ struct __DRIcontextRec {
* \todo XXX in the future, also pass a 'read' GLXDrawable for
* glXMakeCurrentReadSGI() and GLX 1.3's glXMakeContextCurrent().
*/
- Bool (*bindContext)(Display *dpy, int scrn, GLXDrawable draw,
- GLXContext gc);
+ Bool (*bindContext)(__DRIscreen *pDRIscreen, __DRIdrawable *drawable,
+ __DRIcontext *context);
/**
* \brief Method to unbind a DRI drawable to a DRI graphics context.
*/
- Bool (*unbindContext)(Display *dpy, int scrn, GLXDrawable draw,
- GLXContext gc, int will_rebind);
+ Bool (*unbindContext)(__DRIscreen *pDRIscreen, __DRIdrawable *drawable,
+ __DRIcontext *context, int will_rebind);
/**
* \brief Opaque pointer to private per context direct rendering data.
@@ -156,12 +156,14 @@ struct __DRIdrawableRec {
/**
* \brief Method to destroy the private DRI drawable data.
*/
- void (*destroyDrawable)(Display *dpy, void *drawablePrivate);
+ void (*destroyDrawable)(__DRIscreen *pDRIScreen,
+ void *drawablePrivate);
/**
* \brief Method to swap the front and back buffers.
*/
- void (*swapBuffers)(Display *dpy, void *drawablePrivate);
+ void (*swapBuffers)(__DRIscreen *pDRIScreen,
+ void *drawablePrivate);
/**
* \brief Opaque pointer to private per drawable direct rendering data.
@@ -206,10 +208,11 @@ struct DRIDriverContextRec {
unsigned long hFrameBuffer;
int fbOrigin;
int fbSize;
- int fbStride;
int virtualWidth;
int virtualHeight;
} shared;
+
+ int IsClient;
/*@}*/
/**
@@ -280,14 +283,17 @@ struct DRIDriverRec {
int (*restoreHardware)( struct DRIDriverContextRec *dpy );
/**
+ * \brief Wait for the engine, DMA etc. being idle.
+ */
+ int (*waitForIdleHardware)( struct DRIDriverContextRec *dpy );
+
+ /**
* \brief Notify hardware driver of gain/loose focus. May be zero
* as this is of limited utility for most drivers.
*/
void (*notifyFocus)( int have_focus );
};
-
-
/**
* \brief Supported pixel formats.
*/
@@ -372,6 +378,10 @@ struct MiniGLXConnection {
int writebuf_count;
};
+typedef void *(*CreateScreenFunc)(struct DRIDriverRec *driver,
+ struct DRIDriverContextRec *driverContext,
+ __DRIscreen *psc);
+
/**
* \brief X Display type
@@ -444,18 +454,6 @@ struct MiniGLXDisplayRec {
/*@}*/
};
-/**
- * \brief Clip rectangle definition.
- */
-typedef struct _XF86DRIClipRect {
- unsigned short x1; /**< \brief Upper: inclusive */
- unsigned short y1; /**< \brief Left: inclusive */
- unsigned short x2; /**< \brief Lower: exclusive */
- unsigned short y2; /**< \brief Right: exclusive */
-} XF86DRIClipRectRec, *XF86DRIClipRectPtr;
-
-
-extern __DRIscreen *__glXFindDRIScreen(Display *dpy, int scrn);
extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
diff --git a/src/miniglx/sarea.h b/src/miniglx/sarea.h
index 89de065b8af..7daa7454461 100644
--- a/src/miniglx/sarea.h
+++ b/src/miniglx/sarea.h
@@ -51,6 +51,16 @@
#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000
/**
+ * \brief Clip rectangle definition.
+ */
+typedef struct _XF86DRIClipRect {
+ unsigned short x1; /**< \brief Upper: inclusive */
+ unsigned short y1; /**< \brief Left: inclusive */
+ unsigned short x2; /**< \brief Lower: exclusive */
+ unsigned short y2; /**< \brief Right: exclusive */
+} XF86DRIClipRectRec, *XF86DRIClipRectPtr;
+
+/**
* \brief SAREA per drawable information.
*
* \sa _XF86DRISAREA.
diff --git a/src/miniglx/xf86drm.c b/src/miniglx/xf86drm.c
index 078a8025eb8..dc392fb6e3d 100644
--- a/src/miniglx/xf86drm.c
+++ b/src/miniglx/xf86drm.c
@@ -954,7 +954,7 @@ int drmUnlock(int fd, drmContext context)
if (drm_unlock_callback) {
drm_unlock_callback();
}
-
+
return ret;
}