summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkeithw <keithw>2000-02-14 20:06:37 +0000
committerkeithw <keithw>2000-02-14 20:06:37 +0000
commit7f0a14306795a822e6a6f1af170859624be5489e (patch)
tree3a5b6400864985aa812ea5f422ef9e80bcad89be
parent87df4883316e9d83543f83a51da3f1855191aa13 (diff)
Rework state managment to be less obscure.
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c9
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h7
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgafastpath.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.c122
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgalib.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaspan.c29
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgastate.c71
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatex.c110
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatex.h3
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgavb.c1
11 files changed, 210 insertions, 161 deletions
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
index a58d106eb..eea725fe0 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
@@ -147,7 +147,9 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
mgaScreen->mAccess = serverInfo->mAccess;
- fprintf(stderr, "\n\n\nbackOffset: %x\n", mgaScreen->backOffset);
+ fprintf(stderr, "\n\n\nbackOffset: %x pitch %x\n",
+ mgaScreen->backOffset,
+ mgaScreen->backPitch);
mgaScreen->Attrib = MGA_PF_565;
@@ -511,16 +513,17 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
*/
XMESA_VALIDATE_DRAWABLE_INFO(mmesa->display, sPriv, dPriv);
+ if (0)
fprintf(stderr, "mgaGetLock, last enque: %d last dispatch: %d\n",
sarea->last_enqueue,
sarea->last_dispatch);
mmesa->dirty |= MGA_UPLOAD_CTX;
- if (sarea->ctxOwner != me) {
mmesa->dirty |= (MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0 |
MGA_UPLOAD_TEX1 | MGA_UPLOAD_PIPE |
MGA_UPLOAD_CLIPRECTS);
+ if (sarea->ctxOwner != me) {
}
if (sarea->texAge != mmesa->texAge) {
@@ -528,7 +531,7 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
int idx, nr = 0;
/* Have to go right round from the back to ensure stuff ends up
- * LRU in our local list...
+ * LRU in our local list... Fix with a cursor pointer.
*/
for (idx = sarea->texList[MGA_NR_TEX_REGIONS].prev ;
idx != MGA_NR_TEX_REGIONS && nr < MGA_NR_TEX_REGIONS ;
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
index 261049554..f76950b7a 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
@@ -94,10 +94,11 @@ extern void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa );
#define LOCK_HARDWARE( mmesa ) \
do { \
char __ret=0; \
+ if (0) fprintf(stderr, "lock in %s\n", __FUNCTION__); \
DRM_CAS(mmesa->driHwLock, mmesa->hHWContext, \
(DRM_LOCK_HELD|mmesa->hHWContext), __ret); \
- if (__ret) \
- mgaGetLock( mmesa, 0 ); \
+ if (__ret) \
+ mgaGetLock( mmesa, 0 ); \
} while (0)
@@ -113,7 +114,7 @@ extern void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa );
/* Unlock the hardware using the global current context
*/
-#define UNLOCK_HARDWARE(mmesa) \
+#define UNLOCK_HARDWARE(mmesa) \
DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
index a2a9b7c66..51f2dacfe 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
@@ -509,12 +509,10 @@ void mgaDDFastPath( struct vertex_buffer *VB )
mga_project_clipped_vertices( VB ); /* clip->device space */
mga_render_elements_direct( VB ); /* render using new list */
- mgaFlushVertices( mmesa );
}
} else {
mga_project_vertices( VB ); /* clip->device space */
mga_render_elements_direct( VB ); /* render using orig list */
- mgaFlushVertices( mmesa );
}
/* This indicates that there is no cached data to reuse.
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
index f1b7910f1..51f69c81f 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
@@ -36,7 +36,7 @@ static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
iload.texture.y2 = y2;
iload.age = ++mmesa->sarea->last_enqueue;
-/* if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) */
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "DRM_IOCTL_MGA_ILOAD idx %d dst %x maccess %x %d,%d-%d,%d\n",
iload.idx, iload.destOrg, iload.mAccess,
iload.texture.x1,
@@ -51,7 +51,7 @@ static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
}
mmesa->iload_buffer = 0;
-/* if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) */
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "finished iload dma put\n");
}
@@ -74,7 +74,6 @@ static drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
dma.send_list = NULL;
dma.send_sizes = NULL;
dma.flags = 0;
- dma.flags = DRM_DMA_WAIT /* | DRM_LARGER_OK | DRM_SMALLER_OK */;
dma.request_count = 1;
dma.request_size = MGA_DMA_BUF_SZ;
dma.request_list = &idx;
@@ -96,8 +95,7 @@ static drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
dma.request_sizes[0],
dma.request_list[0],
dma.granted_count);
- break;
-#if 0
+
if (retcode == 0 &&
dma.request_list[0] &&
dma.request_sizes[0] &&
@@ -108,7 +106,6 @@ static drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
fprintf(stderr, "\n\nflush");
ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH);
-#endif
}
buf = &(mmesa->mgaScreen->bufs->list[idx]);
@@ -145,7 +142,7 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
clear.clear_color = mmesa->ClearColor;
clear.clear_depth = (mgaUI32) (ctx->Depth.Clear * DEPTH_SCALE);
- mgaFlushVertices( mmesa );
+ FLUSH_BATCH( mmesa );
if (mask & GL_COLOR_BUFFER_BIT) {
if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) {
@@ -249,10 +246,9 @@ void mgaSwapBuffers( mgaContextPtr mmesa )
static int nrswaps;
int retcode;
int i;
+ int tmp;
- mgaFlushVertices( mmesa );
-
-
+ FLUSH_BATCH( mmesa );
LOCK_HARDWARE( mmesa );
{
@@ -289,29 +285,14 @@ void mgaSwapBuffers( mgaContextPtr mmesa )
}
}
+ tmp = GET_ENQUEUE_AGE(mmesa);
-#if 1
- UNLOCK_HARDWARE(mmesa);
-#else
- {
- last_enqueue = mmesa->sarea->lastEnqueue;
- last_dispatch = mmesa->sarea->lastDispatch;
- UNLOCK_HARDWARE;
-
- /* Throttle runaway apps - there should be an easier way to sleep
- * on dma without locking out the rest of the system!
- */
- if (mmesa->lastSwap > last_dispatch) {
- drmGetLock(mmesa->driFd, mmesa->hHWContext, DRM_LOCK_QUIESCENT);
- DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
- }
+ UNLOCK_HARDWARE( mmesa );
- mmesa->lastSwap = last_enqueue;
- }
-#endif
+ if (GET_DISPATCH_AGE(mmesa) < mmesa->lastSwap)
+ mgaWaitAge(mmesa, mmesa->lastSwap);
- if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "finished mgaSwapBuffers\n");
+ mmesa->lastSwap = tmp;
}
@@ -325,8 +306,10 @@ void mgaDDFinish( GLcontext *ctx )
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "mgaRegetLockQuiescent\n");
- drmUnlock(mmesa->driFd, mmesa->hHWContext);
- mgaGetLock( mmesa, DRM_LOCK_QUIESCENT );
+ LOCK_HARDWARE( mmesa );
+ mgaRegetLockQuiescent( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+
mmesa->sarea->last_quiescent = mmesa->sarea->last_enqueue;
}
}
@@ -350,7 +333,7 @@ void mgaWaitAgeLocked( mgaContextPtr mmesa, int age )
i++;
if (GET_DISPATCH_AGE(mmesa) < age) {
-#if 0
+#if 1
if (0) fprintf(stderr, "ioctl\n");
ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH);
#else
@@ -367,10 +350,11 @@ void mgaWaitAge( mgaContextPtr mmesa, int age )
i++;
if (GET_DISPATCH_AGE(mmesa) < age) {
-#if 0
+#if 1
LOCK_HARDWARE(mmesa);
if (GET_DISPATCH_AGE(mmesa) < age)
ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH);
+ UNLOCK_HARDWARE(mmesa);
#else
LOCK_HARDWARE_QUIESCENT(mmesa);
UNLOCK_HARDWARE(mmesa);
@@ -395,16 +379,6 @@ static int intersect_rect( xf86drmClipRectRec *out,
-void mgaFlushVertices( mgaContextPtr mmesa )
-{
- if (mmesa->dma_buffer) {
- LOCK_HARDWARE( mmesa );
- mgaFlushVerticesLocked( mmesa );
- UNLOCK_HARDWARE( mmesa );
- }
- if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "finished mgaFlushVertices\n");
-}
static void age_mmesa( mgaContextPtr mmesa, int age )
{
@@ -416,7 +390,7 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
{
XF86DRIClipRectPtr pbox = mmesa->pClipRects;
int nbox = mmesa->numClipRects;
- drmBufPtr real_buffer = mmesa->dma_buffer;
+ drmBufPtr real_buffer = mmesa->vertex_dma_buffer;
drm_mga_vertex_t vertex;
static int nrvertex;
int retcode;
@@ -431,11 +405,11 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "mgaFlushVerticesLocked, used %d\n",
- mmesa->dma_buffer->used);
+ mmesa->vertex_dma_buffer->used);
vertex.real_idx = real_buffer->idx;
vertex.real_used = real_buffer->used;
- mmesa->dma_buffer = 0;
+ mmesa->vertex_dma_buffer = 0;
if (nbox >= MGA_NR_SAREA_CLIPRECTS)
mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
@@ -448,7 +422,8 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
if (nbox == 1) nbox = 0;
mmesa->sarea->nbox = nbox;
- fprintf(stderr, "Firing vertex -- case a\n");
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "Firing vertex -- case a nbox %d\n", nbox);
retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_VERTEX, &vertex);
if (retcode) {
@@ -456,6 +431,11 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
exit(1);
}
} else {
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "Firing vertex -- case b, nbox %d dirty %d\n",
+ nbox, !!(mmesa->dirty & MGA_UPLOAD_CLIPRECTS));
+
for (i = 0 ; i < nbox ; )
{
int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, nbox);
@@ -465,7 +445,7 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
if (mmesa->scissor) {
mmesa->sarea->nbox = 0;
- if (MGA_DEBUG&DEBUG_VERBOSE_2D)
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "SCISSOR %d,%d-%d,%d\n",
mmesa->scissor_rect.x1,
mmesa->scissor_rect.y1,
@@ -477,7 +457,7 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
*b = pbox[i];
if (intersect_rect(b, b, &mmesa->scissor_rect)) {
- if (MGA_DEBUG&DEBUG_VERBOSE_2D)
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "BOX %d: %d,%d-%d,%d\n",
mmesa->sarea->nbox, b->x1, b->y1, b->x2, b->y2);
@@ -506,9 +486,9 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
vertex.idx = tmp->idx;
} else {
vertex.idx = vertex.real_idx;
- vertex.discard = discard;
}
+ vertex.discard = discard;
vertex.age = ++mmesa->sarea->last_enqueue;
age_mmesa(mmesa, vertex.age);
@@ -533,6 +513,12 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
fprintf(stderr, "finished mgaFlushVerticesLocked\n");
}
+void mgaFlushVertices( mgaContextPtr mmesa )
+{
+ LOCK_HARDWARE( mmesa );
+ mgaFlushVerticesLocked( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+}
mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords )
@@ -540,17 +526,22 @@ mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords )
int bytes = dwords * 4;
mgaUI32 *head;
- if (!mmesa->dma_buffer)
- mgaGetVertexDmaBuffer( mmesa );
- else if (mmesa->dma_buffer->used + bytes > mmesa->dma_buffer->total) {
- mgaFlushVertices( mmesa );
- mgaGetVertexDmaBuffer( mmesa );
+ if (!mmesa->vertex_dma_buffer) {
+ LOCK_HARDWARE( mmesa );
+ mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+ } else if (mmesa->vertex_dma_buffer->used + bytes >
+ mmesa->vertex_dma_buffer->total) {
+ LOCK_HARDWARE( mmesa );
+ mgaFlushVerticesLocked( mmesa );
+ mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
+ UNLOCK_HARDWARE( mmesa );
}
- head = (mgaUI32 *)((char *)mmesa->dma_buffer->address +
- mmesa->dma_buffer->used);
+ head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address +
+ mmesa->vertex_dma_buffer->used);
- mmesa->dma_buffer->used += bytes;
+ mmesa->vertex_dma_buffer->used += bytes;
return head;
}
@@ -574,7 +565,7 @@ void mgaFireILoadLocked( mgaContextPtr mmesa,
mga_iload_dma_ioctl( mmesa, x, y, x+width, y+height, offset, maccess );
}
-void mgaGetILoadBuffer( mgaContextPtr mmesa )
+void mgaGetILoadBufferLocked( mgaContextPtr mmesa )
{
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "start mgaGetIloadBuffer (buffer now %p)\n",
@@ -584,19 +575,10 @@ void mgaGetILoadBuffer( mgaContextPtr mmesa )
fprintf(stderr, "finished mgaGetIloadBuffer\n");
}
-void mgaGetVertexDmaBuffer( mgaContextPtr mmesa )
-{
- if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "start mgaGetVertexDmaBuffer (buffer now %p)\n",
- mmesa->dma_buffer);
- mmesa->dma_buffer = mga_get_buffer_ioctl( mmesa );
- if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "finished mgaGetVertexDmaBuffer\n");
-}
static void mgaDDFlush( GLcontext *ctx )
{
- mgaFlushVertices( MGA_CONTEXT( ctx ) );
+ FLUSH_BATCH( MGA_CONTEXT( ctx ) );
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
index 6017678cc..9db77d527 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
@@ -14,8 +14,7 @@ void mgaSwapBuffers( mgaContextPtr mmesa );
mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
-void mgaGetVertexDmaBuffer( mgaContextPtr mmesa );
-void mgaGetILoadBuffer( mgaContextPtr mmesa );
+void mgaGetILoadBufferLocked( mgaContextPtr mmesa );
void mgaFireILoadLocked( mgaContextPtr mmesa,
GLuint x, GLuint y, GLuint width, GLuint height,
@@ -35,5 +34,11 @@ void mgaDDFinish( GLcontext *ctx );
void mgaDDInitIoctlFuncs( GLcontext *ctx );
+#define FLUSH_BATCH(mmesa) do { \
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) \
+ fprintf(stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \
+ if (mmesa->vertex_dma_buffer) mgaFlushVertices(mmesa); \
+} while (0)
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgalib.h b/xc/lib/GL/mesa/src/drv/mga/mgalib.h
index f4c238d8e..cf56d5307 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgalib.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgalib.h
@@ -155,7 +155,7 @@ struct mga_context_t {
/* DRI stuff
*/
- drmBufPtr dma_buffer;
+ drmBufPtr vertex_dma_buffer;
drmBufPtr iload_buffer;
GLframebuffer *glBuffer;
@@ -171,7 +171,9 @@ struct mga_context_t {
GLuint numClipRects; /* cliprects for that buffer */
XF86DRIClipRectPtr pClipRects;
- int texAge;
+ int texAge; /* texture LRU age */
+ int dirtyAge; /* buffer age for synchronization */
+ int lastSwap; /* throttling runaway apps */
drmContext hHWContext;
@@ -236,7 +238,7 @@ extern mgaGlx_t mgaglx;
((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-#define MGA_DEBUG 0
+/* #define MGA_DEBUG 0 */
#ifndef MGA_DEBUG
extern int MGA_DEBUG;
#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
index 1c69dd260..b216cf83f 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
@@ -5,7 +5,7 @@
#include "mgalog.h"
#include "mgaspan.h"
-
+#define DBG 0
#define HW_LOCK() \
mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
@@ -15,7 +15,7 @@
__DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
- GLuint pitch = mgaScreen->backPitch; \
+ GLuint pitch = mgaScreen->frontPitch; \
GLuint height = dPriv->h; \
char *buf = (char *)(sPriv->pFB + \
mmesa->drawOffset + \
@@ -60,18 +60,19 @@
#define Y_FLIP(_y) (height - _y)
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
- *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0x1f) << 11) | \
- ((g & 0x3f) << 5) | \
- ((b & 0x1f)))
+ *(GLushort *)(buf + _x*2 + _y*pitch) = ( (((int)r & 0xf8) << 8) | \
+ (((int)g & 0xfc) << 3) | \
+ (((int)b & 0xf8) >> 3))
+
#define WRITE_PIXEL( _x, _y, p ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = p
#define READ_RGBA( rgba, _x, _y ) \
do { \
GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
- rgba[0] = (p >> 11) & 0x1f; \
- rgba[1] = (p >> 5) & 0x3f; \
- rgba[2] = (p >> 0) & 0x1f; \
+ rgba[0] = (p >> 8) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xfc; \
+ rgba[2] = (p << 3) & 0xf8; \
rgba[3] = 0; /* or 255? */ \
} while(0)
@@ -83,9 +84,9 @@ do { \
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
- *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0x1f) << 10) | \
- ((g & 0x1f) << 5) | \
- ((b & 0x1f)))
+ *(GLushort *)(buf + _x*2 + _y*pitch) = (((r & 0xf8) << 7) | \
+ ((g & 0xf8) << 3) | \
+ ((b & 0xf8) >> 3))
#define WRITE_PIXEL( _x, _y, p ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = p
@@ -93,9 +94,9 @@ do { \
#define READ_RGBA( rgba, _x, _y ) \
do { \
GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \
- rgba[0] = (p >> 10) & 0x1f; \
- rgba[1] = (p >> 5) & 0x1f; \
- rgba[2] = (p >> 0) & 0x1f; \
+ rgba[0] = (p >> 7) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xf8; \
+ rgba[2] = (p << 3) & 0xf8; \
rgba[3] = 0; /* or 255? */ \
} while(0)
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgastate.c b/xc/lib/GL/mesa/src/drv/mga/mgastate.c
index 98dc3885d..4932f16e7 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgastate.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgastate.c
@@ -60,17 +60,20 @@ static void mgaUpdateZMode(const GLcontext *ctx)
static void mgaDDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
}
static void mgaDDBlendEquation(GLcontext *ctx, GLenum mode)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
}
static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
}
@@ -78,6 +81,7 @@ static void mgaDDBlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
GLenum dfactorRGB, GLenum sfactorA,
GLenum dfactorA )
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
}
@@ -87,6 +91,7 @@ static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname,
const GLfloat *param)
{
if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
}
}
@@ -95,6 +100,7 @@ static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname,
static void mgaDDShadeModel(GLcontext *ctx, GLenum mode)
{
if (1) {
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
mgaMsg(8, "mgaDDShadeModel: %x\n", mode);
}
@@ -103,11 +109,13 @@ static void mgaDDShadeModel(GLcontext *ctx, GLenum mode)
static void mgaDDDepthFunc(GLcontext *ctx, GLenum func)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
}
static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
}
@@ -134,6 +142,7 @@ static void mgaUpdateFogAttrib( GLcontext *ctx )
static void mgaDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_FOG;
}
@@ -307,6 +316,7 @@ static void mgaUpdateClipping(const GLcontext *ctx)
static void mgaDDScissor( GLcontext *ctx, GLint x, GLint y,
GLsizei w, GLsizei h )
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_CLIP;
}
@@ -324,6 +334,8 @@ static GLboolean mgaDDSetBuffer(GLcontext *ctx, GLenum mode )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
+
mmesa->Fallback &= ~MGA_FALLBACK_BUFFER;
if (mode == GL_FRONT_LEFT)
@@ -407,6 +419,7 @@ static void mgaUpdateCull( GLcontext *ctx )
static void mgaDDCullFaceFrontFace(GLcontext *ctx, GLenum mode)
{
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_CULL;
}
@@ -442,6 +455,7 @@ static GLboolean mgaDDColorMask(GLcontext *ctx,
}
if (mmesa->Setup[MGA_CTXREG_PLNWT] != mask) {
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
mmesa->Setup[MGA_CTXREG_PLNWT] = mask;
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_MASK;
mmesa->dirty |= MGA_UPLOAD_CTX;
@@ -461,7 +475,7 @@ static void mgaDDPrintDirty( const char *msg, GLuint state )
fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s\n",
msg,
(unsigned int) state,
- (state & MGA_REQUIRE_QUIESCENT) ? "req-quiescent, " : "",
+ (state & MGA_WAIT_AGE) ? "wait-age, " : "",
(state & MGA_UPLOAD_TEX0IMAGE) ? "upload-tex0-img, " : "",
(state & MGA_UPLOAD_TEX1IMAGE) ? "upload-tex1-img, " : "",
(state & MGA_UPLOAD_CTX) ? "upload-ctx, " : "",
@@ -485,29 +499,24 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
if ((mmesa->dirty & MGA_UPLOAD_TEX1IMAGE) && mmesa->CurrentTexObj[1])
mgaUploadTexImages(mmesa, mmesa->CurrentTexObj[1]);
- if (mmesa->dirty & MGA_UPLOAD_CTX) {
+ if (mmesa->dirty & MGA_UPLOAD_CTX)
memcpy( mmesa->sarea->ContextState,
mmesa->Setup,
sizeof(mmesa->Setup));
- if (mmesa->CurrentTexObj[0])
-/* && (mmesa->setupindex & MGA_TEX0_BIT)) */
+ if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0])
memcpy(mmesa->sarea->TexState[0],
mmesa->CurrentTexObj[0]->Setup,
sizeof(mmesa->sarea->TexState[0]));
- if (mmesa->CurrentTexObj[1])
-/* && (mmesa->setupindex & MGA_TEX1_BIT)) */
+ if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1])
memcpy(mmesa->sarea->TexState[1],
mmesa->CurrentTexObj[1]->Setup,
sizeof(mmesa->sarea->TexState[1]));
- }
- if (mmesa->dirty & MGA_UPLOAD_PIPE)
- mmesa->sarea->WarpPipe = mmesa->setupindex & MGA_WARP_T2GZSAF;
-
+ mmesa->sarea->WarpPipe = mmesa->setupindex & MGA_WARP_T2GZSAF;
mmesa->sarea->dirty |= mmesa->dirty;
- mmesa->dirty &= MGA_UPLOAD_CLIPRECTS;
+ mmesa->dirty &= (MGA_UPLOAD_CLIPRECTS|MGA_WAIT_AGE);
}
@@ -519,26 +528,33 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
{
switch(cap) {
case GL_ALPHA_TEST:
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
break;
case GL_BLEND:
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
break;
case GL_DEPTH_TEST:
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
break;
case GL_SCISSOR_TEST:
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_CLIP;
break;
case GL_FOG:
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_FOG;
break;
case GL_CULL_FACE:
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_CULL;
break;
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
break;
default:
@@ -596,12 +612,9 @@ void mgaDDUpdateHwState( GLcontext *ctx )
if (new_state)
{
- mmesa->new_state = 0;
+ FLUSH_BATCH( mmesa );
- /* Emit any vertices for the current state. This will also
- * push the current state into the sarea.
- */
-/* mgaFlushVertices( mmesa ); */
+ mmesa->new_state = 0;
if (MESA_VERBOSE&VERBOSE_DRIVER)
mgaDDPrintState("UpdateHwState", new_state);
@@ -626,8 +639,6 @@ void mgaDDUpdateHwState( GLcontext *ctx )
if (new_state & (MGA_NEW_WARP|MGA_NEW_TEXTURE))
mgaUpdateTextureState(ctx);
-
- mmesa->new_state = 0; /* tex uploads scribble newstate */
}
}
@@ -639,7 +650,7 @@ void mgaDDUpdateHwState( GLcontext *ctx )
void mgaDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
{
- mgaFlushVertices( MGA_CONTEXT(ctx) );
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
mgaUpdateCull(ctx);
}
@@ -662,9 +673,9 @@ void mgaDDUpdateState( GLcontext *ctx )
/* Have to do this here to detect texture fallbacks in time:
*/
- if (MGA_CONTEXT(ctx)->new_state & MGA_NEW_TEXTURE)
+ if (mmesa->new_state & MGA_NEW_TEXTURE)
mgaDDUpdateHwState( ctx );
-
+
if (!mmesa->Fallback) {
ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
ctx->IndirectTriangles |= mmesa->IndirectTriangles;
@@ -691,19 +702,19 @@ void mgaInitState( mgaContextPtr mmesa )
fprintf(stderr, "set DSTORG %x in mgaInitState\n",
mmesa->Setup[MGA_CTXREG_DSTORG]);
- mmesa->Setup[MGA_CTXREG_MACCESS] = mgaScreen->mAccess;
- mmesa->Setup[MGA_CTXREG_MACCESS] = 0x1;
+/* mmesa->Setup[MGA_CTXREG_MACCESS] = mgaScreen->mAccess; */
+/* mmesa->Setup[MGA_CTXREG_DWGCTL] = ( DC_clipdis_disable | */
+/* (0xC << DC_bop_SHIFT) | */
+/* DC_shftzero_enable | */
+/* DC_zmode_nozcmp | */
+/* DC_atype_zi ); */
- mmesa->Setup[MGA_CTXREG_PLNWT] = ~0;
- mmesa->Setup[MGA_CTXREG_DWGCTL] = ( DC_clipdis_disable |
- (0xC << DC_bop_SHIFT) |
- DC_shftzero_enable |
- DC_zmode_nozcmp |
- DC_atype_zi );
+ mmesa->Setup[MGA_CTXREG_MACCESS] = 0x1;
+ mmesa->Setup[MGA_CTXREG_DWGCTL] = 0xc4074;
+ mmesa->Setup[MGA_CTXREG_PLNWT] = ~0;
- mmesa->Setup[MGA_CTXREG_DWGCTL] = 0xc4074;
mmesa->Setup[MGA_CTXREG_ALPHACTRL] = ( AC_src_one |
AC_dst_zero |
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatex.c b/xc/lib/GL/mesa/src/drv/mga/mgatex.c
index 2c0aaa0c5..9aba9167f 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatex.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatex.c
@@ -47,23 +47,25 @@
* to it.
*/
static void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) {
- int i;
if ( !t ) return;
/* free the texture memory */
- mmFreeMem( t->MemBlock );
+ if (t->MemBlock) {
+ mmFreeMem( t->MemBlock );
+ t->MemBlock = 0;
+
+ if (t->age > mmesa->dirtyAge)
+ mmesa->dirtyAge = t->age;
+ }
/* free mesa's link */
if (t->tObj)
t->tObj->DriverData = NULL;
/* see if it was the driver's current object */
- for ( i = 0 ; i < 2 ; i++ ) {
- if ( mmesa->CurrentTexObj[i] == t ) {
- mmesa->CurrentTexObj[i] = NULL;
- }
- }
+ if (t->bound)
+ mmesa->CurrentTexObj[t->bound - 1] = 0;
remove_from_list(t);
free( t );
@@ -74,6 +76,9 @@ static void mgaSwapOutTexObj(mgaContextPtr mmesa, mgaTextureObjectPtr t)
if (t->MemBlock) {
mmFreeMem(t->MemBlock);
t->MemBlock = 0;
+
+ if (t->age > mmesa->dirtyAge)
+ mmesa->dirtyAge = t->age;
}
t->dirty_images = ~0;
@@ -168,7 +173,7 @@ void mgaTexturesGone( mgaContextPtr mmesa,
/* It overlaps - kick it off. Need to hold onto the currently bound
* objects, however.
*/
- if (t == mmesa->CurrentTexObj[0] || t == mmesa->CurrentTexObj[1])
+ if (t->bound)
mgaSwapOutTexObj( mmesa, t );
else
mgaDestroyTexObj( mmesa, t );
@@ -317,9 +322,10 @@ static void mgaUploadSubImageLocked( mgaContextPtr mmesa,
- fprintf(stderr, "UPLOAD t %p level %d ofs %x + %x + %p\n",
- t, level, t->MemBlock->ofs, t->offsets[level],
- mmesa->mgaScreen->textureOffset);
+ if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
+ fprintf(stderr, "UPLOAD t %p level %d ofs %x + %x + %x\n",
+ t, level, t->MemBlock->ofs, t->offsets[level],
+ mmesa->mgaScreen->textureOffset);
/* turn on PCI/AGP if needed
@@ -544,6 +550,8 @@ static void mgaCreateTexObj(mgaContextPtr mmesa, struct gl_texture_object *tObj)
/* fill in our mga texture object */
t->tObj = tObj;
t->ctx = mmesa;
+ t->age = 0;
+ t->bound = 0;
insert_at_tail(&(mmesa->SwappedOut), t);
@@ -627,17 +635,22 @@ int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t )
if (!t->MemBlock) {
while (1)
{
- t->MemBlock = mmAllocMem( mmesa->texHeap, t->totalSize, 12, 0 );
+ mgaTextureObjectPtr tmp = mmesa->TexObjList.prev;
+
+ t->MemBlock = mmAllocMem( mmesa->texHeap, t->totalSize,
+ 12, 0 );
if (t->MemBlock)
break;
- if (mmesa->TexObjList.prev == &(mmesa->TexObjList)) {
- fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
+ if (tmp == &(mmesa->TexObjList) || tmp->bound) {
+ fprintf(stderr,
+ "Failed to upload texture, "
+ "sz %d\n", t->totalSize);
mmDumpMemInfo( mmesa->texHeap );
return -1;
}
- mgaDestroyTexObj( mmesa, mmesa->TexObjList.prev );
+ mgaDestroyTexObj( mmesa, tmp );
}
ofs = t->MemBlock->ofs
@@ -657,8 +670,16 @@ int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t )
*/
mgaUpdateTexLRU( mmesa, t );
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
+ fprintf(stderr, "dispatch age: %d age freed memory: %d\n",
+ GET_DISPATCH_AGE(mmesa), mmesa->dirtyAge);
+
+ if (mmesa->dirtyAge >= GET_DISPATCH_AGE(mmesa))
+ mgaWaitAgeLocked( mmesa, mmesa->dirtyAge );
+
if (t->dirty_images) {
- if (MGA_DEBUG & DEBUG_VERBOSE_MSG)
+ if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
fprintf(stderr, "*");
for (i = 0 ; i <= t->lastLevel ; i++)
@@ -822,7 +843,6 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) {
if ( !tObj->DriverData ) {
/* clear the current pointer so that texture object can be
swapped out if necessary to make room */
- mmesa->CurrentTexObj[source] = NULL;
mgaCreateTexObj( mmesa, tObj );
if ( !tObj->DriverData ) {
@@ -841,7 +861,10 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) {
if (t->dirty_images)
mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit);
+ if (mmesa->CurrentTexObj[unit]) mmesa->CurrentTexObj[unit]->bound = 0;
mmesa->CurrentTexObj[unit] = t;
+ t->bound = unit+1;
+
t->Setup[MGA_TEXREG_CTL2] &= ~TMC_dualtex_enable;
if (ctx->Texture.Enabled == (TEXTURE0_2D|TEXTURE1_2D))
@@ -869,14 +892,15 @@ void mgaUpdateTextureState( GLcontext *ctx )
mgaUpdateTextureObject( ctx, 0 );
mgaUpdateTextureStage( ctx, 0 );
- mmesa->Setup[MGA_CTXREG_TDUAL1] = mmesa->Setup[MGA_CTXREG_TDUAL0];
+ mmesa->Setup[MGA_CTXREG_TDUAL1] =
+ mmesa->Setup[MGA_CTXREG_TDUAL0];
if (mmesa->multitex) {
mgaUpdateTextureObject( ctx, 1 );
mgaUpdateTextureStage( ctx, 1 );
}
- mmesa->dirty |= MGA_UPLOAD_TEX1;
+ mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1;
} else {
mgaUpdateTextureObject( ctx, 0 );
mgaUpdateTextureEnvG200( ctx );
@@ -904,7 +928,7 @@ void mgaTexEnv( GLcontext *ctx, GLenum pname, const GLfloat *param ) {
if (pname == GL_TEXTURE_ENV_MODE) {
/* force the texture state to be updated */
- MGA_CONTEXT(ctx)->CurrentTexObj[0] = 0;
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
}
}
@@ -926,6 +950,7 @@ void mgaTexImage( GLcontext *ctx, GLenum target,
mgaUpdateTextureState time. */
t = (mgaTextureObjectPtr) tObj->DriverData;
if ( t ) {
+ if (t->bound) FLUSH_BATCH(mmesa);
/* if this is the current object, it will force an update */
mgaDestroyTexObj( mmesa, t );
mmesa->new_state |= MGA_NEW_TEXTURE;
@@ -955,6 +980,7 @@ void mgaTexSubImage( GLcontext *ctx, GLenum target,
mgaUpdateTextureState time. */
t = (mgaTextureObjectPtr) tObj->DriverData;
if ( t ) {
+ if (t->bound) FLUSH_BATCH(mmesa);
/* if this is the current object, it will force an update */
mgaDestroyTexObj( mmesa, t );
mmesa->new_state |= MGA_NEW_TEXTURE;
@@ -975,7 +1001,9 @@ void mgaTexSubImage( GLcontext *ctx, GLenum target,
*/
void mgaTexParameter( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params ) {
+ GLenum pname, const GLfloat *params )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
mgaTextureObjectPtr t;
mgaMsg( 10, "mgaTexParameter( %p, %i )\n", tObj, pname );
@@ -992,52 +1020,68 @@ void mgaTexParameter( GLcontext *ctx, GLenum target,
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
+ if (t->bound) FLUSH_BATCH(mmesa);
mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
break;
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
+ if (t->bound) FLUSH_BATCH(mmesa);
mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT);
break;
case GL_TEXTURE_BORDER_COLOR:
+ if (t->bound) FLUSH_BATCH(mmesa);
mgaSetTexBorderColor(t,tObj->BorderColor);
break;
default:
return;
}
- /* force the texture state to be updated */
- MGA_CONTEXT(ctx)->CurrentTexObj[0] = NULL;
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
+
+ mmesa->new_state |= MGA_NEW_TEXTURE;
}
/*
* mgaBindTexture
*/
void mgaBindTexture( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj ) {
+ struct gl_texture_object *tObj )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
mgaMsg( 10, "mgaBindTexture( %p )\n", tObj );
-
+
+ FLUSH_BATCH(mmesa);
+
+ if (mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]) {
+ mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0;
+ mmesa->CurrentTexObj[ctx->Texture.CurrentUnit] = 0;
+ }
+
/* force the texture state to be updated
*/
- MGA_CONTEXT(ctx)->CurrentTexObj[0] = NULL;
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
}
/*
* mgaDeleteTexture
*/
-void mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) {
+void mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData;
mgaMsg( 10, "mgaDeleteTexture( %p )\n", tObj );
- /* delete our driver data */
- if ( tObj->DriverData ) {
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaDestroyTexObj( mmesa,
- (mgaTextureObjectPtr)(tObj->DriverData) );
+ if ( t ) {
+ if (t->bound) {
+ FLUSH_BATCH(mmesa);
+ mmesa->CurrentTexObj[t->bound-1] = 0;
+ mmesa->new_state |= MGA_NEW_TEXTURE;
+ }
+
+ mgaDestroyTexObj( mmesa, t );
mmesa->new_state |= MGA_NEW_TEXTURE;
}
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatex.h b/xc/lib/GL/mesa/src/drv/mga/mgatex.h
index 48030ef98..6405cac42 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatex.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatex.h
@@ -48,7 +48,8 @@ typedef struct mga_texture_object_s {
mgaUI32 dirty_images;
mgaUI32 totalSize;
int texelBytes;
- mgaUI32 age;
+ mgaUI32 age;
+ int bound;
mgaUI32 Setup[MGA_TEX_SETUP_SIZE];
} mgaTextureObject_t;
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.c b/xc/lib/GL/mesa/src/drv/mga/mgavb.c
index 6f0d7f4fb..160d155da 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgavb.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.c
@@ -298,6 +298,7 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx)
if (0)
mgaPrintSetupFlags("xsmesa: full setup function", funcindex);
+ mmesa->dirty |= MGA_UPLOAD_PIPE;
mmesa->setupindex = funcindex;
/* Called by mesa's clip functons: