diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_context.c | 43 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_context.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_ioctl.c | 63 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_screen.c | 13 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_texmem.c | 3 |
5 files changed, 65 insertions, 60 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 15b57b95b71..326f34a0f98 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -65,7 +65,6 @@ #include "vblank.h" #include "utils.h" -viaContextPtr current_mesa; #ifdef DEBUG GLuint VIA_DEBUG = 0; #endif @@ -78,7 +77,6 @@ GLuint idle = 0; hash_element hash_table[HASH_TABLE_SIZE][HASH_TABLE_DEPTH]; #endif /*=* John Sheng [2003.5.31] agp tex *=*/ -extern GLuint agpFullCount; static GLboolean AllocateBuffer(viaContextPtr vmesa) @@ -204,7 +202,8 @@ calculate_buffer_parameters( viaContextPtr vmesa ) + extra; vmesa->back.size = vmesa->back.pitch * vmesa->driDrawable->h; - if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent backbuffer: w = %d h = %d bpp = %d sizs = %d\n", + if (VIA_DEBUG) fprintf(stderr, "%s backbuffer: w = %d h = %d bpp = %d sizs = %d\n", + __FUNCTION__, vmesa->back.pitch, vmesa->driDrawable->h, 8 << shift, @@ -224,7 +223,8 @@ calculate_buffer_parameters( viaContextPtr vmesa ) (void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) ); } - if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent depthbuffer: w = %d h = %d bpp = %d sizs = %d\n", + if (VIA_DEBUG) fprintf(stderr, "%s depthbuffer: w = %d h = %d bpp = %d sizs = %d\n", + __FUNCTION__, vmesa->depth.pitch, vmesa->driDrawable->h, vmesa->depth.bpp, @@ -254,10 +254,9 @@ calculate_buffer_parameters( viaContextPtr vmesa ) void viaReAllocateBuffers(GLframebuffer *drawbuffer) { - GLcontext *ctx; - viaContextPtr vmesa = current_mesa; + GET_CURRENT_CONTEXT(ctx); + viaContextPtr vmesa = VIA_CONTEXT(ctx); - ctx = vmesa->glCtx; ctx->DrawBuffer->Width = drawbuffer->Width; ctx->DrawBuffer->Height = drawbuffer->Height; @@ -273,11 +272,11 @@ void viaReAllocateBuffers(GLframebuffer *drawbuffer) if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); } -static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height) -{ - /* MESA5.0 */ - viaContextPtr vmesa = current_mesa; +static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height) +{ + GET_CURRENT_CONTEXT(ctx); + viaContextPtr vmesa = VIA_CONTEXT(ctx); *width = vmesa->driDrawable->w; *height = vmesa->driDrawable->h; } @@ -406,7 +405,6 @@ viaCreateContext(const __GLcontextModes *mesaVis, driParseConfigFiles (&vmesa->optionCache, &viaScreen->optionCache, sPriv->myNum, "via"); - current_mesa = vmesa; /* pick back buffer */ if (mesaVis->doubleBufferMode) { vmesa->hasBack = GL_TRUE; @@ -657,12 +655,12 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv) viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate; if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); assert(vmesa); /* should never be null */ - viaFlushPrimsLocked(vmesa); +/* viaFlushPrimsLocked(vmesa); */ WAIT_IDLE if (vmesa) { /*=* John Sheng [2003.5.31] agp tex *=*/ - if(VIA_DEBUG) fprintf(stderr, "agpFullCount = %d\n", agpFullCount); + if(VIA_DEBUG) fprintf(stderr, "agpFullCount = %d\n", vmesa->agpFullCount); _swsetup_DestroyContext(vmesa->glCtx); _tnl_DestroyContext(vmesa->glCtx); @@ -927,8 +925,6 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv, if (driContextPriv) { viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate; - current_mesa = vmesa; - if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent: w = %d\n", vmesa->driDrawable->w); if ( vmesa->driDrawable != driDrawPriv ) { @@ -963,8 +959,13 @@ void viaGetLock(viaContextPtr vmesa, GLuint flags) __DRIscreenPrivate *psp; pdp = dPriv; psp = sPriv; - if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); - if (VIA_DEBUG) fprintf(stderr, "drmGetLock - in\n"); + if (VIA_DEBUG) { + fprintf(stderr, "%s - in\n", __FUNCTION__); + fprintf(stderr, "is: %x non-contend: %x want: %x\n", + *(GLuint *)vmesa->driHwLock, vmesa->hHWContext, + (DRM_LOCK_HELD|vmesa->hHWContext)); + } + drmGetLock(vmesa->driFd, vmesa->hHWContext, flags); DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv ); @@ -972,11 +973,7 @@ void viaGetLock(viaContextPtr vmesa, GLuint flags) if (sarea->ctxOwner != me) { vmesa->uploadCliprects = GL_TRUE; sarea->ctxOwner = me; - vmesa->dirty |= (VIA_UPLOAD_CTX | - VIA_UPLOAD_BUFFERS | - VIA_UPLOAD_TEX0 | - VIA_UPLOAD_TEX1 | - VIA_UPLOAD_CLIPRECTS); + vmesa->needUploadAllState = 1; } viaXMesaWindowMoved(vmesa); diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h index 88054301e86..41ce1ce0954 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.h +++ b/src/mesa/drivers/dri/unichrome/via_context.h @@ -292,6 +292,9 @@ struct via_context_t { GLuint* agpBase; GLuint drawType; + GLuint nDoneFirstFlip; + GLuint agpFullCount; + /* Configuration cache */ driOptionCache optionCache; diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c index 64f9e6cd45f..9286501616e 100644 --- a/src/mesa/drivers/dri/unichrome/via_ioctl.c +++ b/src/mesa/drivers/dri/unichrome/via_ioctl.c @@ -77,11 +77,7 @@ v * copy of this software and associated documentation files (the "Software"), typedef enum {VIABLIT_TRANSCOPY, VIABLIT_COPY, VIABLIT_FILL} ViaBlitOps; -GLuint FrameCount = 0; -GLuint dmaLow = 0; /*=* John Sheng [2003.5.31] flip *=*/ -GLuint nFirstSwap = GL_TRUE; -GLuint nFirstFlip = GL_TRUE; #define SetReg2DAGP(nReg, nData) { \ *((GLuint *)(vb)) = ((nReg) >> 2) | 0xF0000000; \ *((GLuint *)(vb) + 1) = (nData); \ @@ -475,10 +471,10 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv) } SetReg2DAGP(0x214, nBackBase); viaFlushPrimsLocked(vmesa);*/ - if (nFirstFlip) { + if (!vmesa->nDoneFirstFlip) { *((volatile GLuint *)((GLuint)vmesa->regMMIOBase + 0x43c)) = 0x00fe0000; *((volatile GLuint *)((GLuint)vmesa->regMMIOBase + 0x440)) = 0x00001004; - nFirstFlip = GL_FALSE; + vmesa->nDoneFirstFlip = GL_TRUE; } *((GLuint *)((GLuint)vmesa->regMMIOBase + 0x214)) = nBackBase; } @@ -486,14 +482,14 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv) else { viaFlushPrimsLocked(vmesa); vb = viaCheckDma(vmesa, 8 * 4); - if (nFirstFlip) { + if (!vmesa->nDoneFirstFlip) { *vb++ = HALCYON_HEADER2; *vb++ = 0x00fe0000; *vb++ = 0x0000000e; *vb++ = 0x0000000e; vmesa->dmaLow += 16; - nFirstFlip = GL_FALSE; + vmesa->nDoneFirstFlip = GL_FALSE; } nBackBase = (vmesa->back.offset ); @@ -580,6 +576,10 @@ void viaFlushPrimsLocked(viaContextPtr vmesa) GLuint *vb = viaCheckDma(vmesa, 0); int i; + if (*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|vmesa->hHWContext) && + *(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) + fprintf(stderr, "%s called without lock held\n", __FUNCTION__); + if (vmesa->dmaLow == DMA_OFFSET) { return; } @@ -635,20 +635,7 @@ void viaFlushPrimsLocked(viaContextPtr vmesa) else if (nbox > VIA_NR_SAREA_CLIPRECTS) { vmesa->uploadCliprects = GL_TRUE; } -/*=* John Sheng [2003.5.31] flip *=*/ -/* - if (VIA_DEBUG) { - GLuint i; - GLuint *data = (GLuint *)vmesa->dmaAddr; - for (i = 0; i < vmesa->dmaLow; i += 16) { - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x\n", *data++); - } - fprintf(stderr, "******************************************\n"); - } -*/ + if (!nbox || !vmesa->uploadCliprects) { if (nbox == 1) sarea->nbox = 0; @@ -1294,7 +1281,6 @@ void viaDoSwapPBuffers(viaContextPtr vmesa) #define VIA_CMDBUF_MAX_LAG 50000 int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf) - { GLuint *pnBuf; GLuint *pnEnd; @@ -1372,15 +1358,24 @@ int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf) bSiz.size = VIA_CMDBUF_MAX_LAG; while ( -EAGAIN == (ret = drmCommandWriteRead(vmesa->driFd, DRM_VIA_CMDBUF_SIZE, &bSiz, sizeof(bSiz)))); - if (ret) - _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, "viaCommandBufferLag"); + if (ret) { + _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, __FUNCTION__); + abort(); + } while ( -EAGAIN == (ret = drmCommandWrite(vmesa->driFd, DRM_VIA_CMDBUFFER, &bufI, sizeof(bufI)))); + if (ret) { + abort(); + } } if (ret) { if (vmesa->useAgp) WAIT_IDLE; + +/* for (i = 0; */ + if (drmCommandWrite(vmesa->driFd, DRM_VIA_PCICMD, &bufI, sizeof(bufI))) { - _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, "viaCommandBufferFlush"); + _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, __FUNCTION__); + abort(); } } } @@ -1450,16 +1445,22 @@ int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf) bSiz.size = VIA_CMDBUF_MAX_LAG; while ( -EAGAIN == (ret = drmCommandWriteRead(vmesa->driFd, DRM_VIA_CMDBUF_SIZE, &bSiz, sizeof(bSiz)))); - if (ret) - _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, "viaCommandBufferLag"); - while ( -EAGAIN == (ret = drmCommandWrite(vmesa->driFd, DRM_VIA_CMDBUFFER, - &bufI, sizeof(bufI)))); + if (ret) { + _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, __FUNCTION__); + abort(); + } + while ( -EAGAIN == (ret = drmCommandWrite(vmesa->driFd, DRM_VIA_CMDBUFFER, + &bufI, sizeof(bufI)))); + if (ret) { + abort(); + } } if (ret) { if (vmesa->useAgp) WAIT_IDLE; if (drmCommandWrite(vmesa->driFd, DRM_VIA_PCICMD, &bufI, sizeof(bufI))) { - _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, "viaCommandBufferFlush"); + _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, __FUNCTION__); + abort(); } } diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index ec2affb3339..1a47fe57c6f 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -60,8 +60,6 @@ DRI_CONF_END; static const GLuint __driNConfigOptions = 3; -extern viaContextPtr current_mesa; - #ifdef USE_NEW_INTERFACE static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; #endif /* USE_NEW_INTERFACE */ @@ -221,10 +219,17 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv, const __GLcontextModes *mesaVis, GLboolean isPixmap) { - viaContextPtr vmesa = current_mesa; + /* KW: Bogus: Do this sort of thing in MakeCurrent or similar. + */ + viaContextPtr vmesa; + GET_CURRENT_CONTEXT(ctx); + + if (ctx) + vmesa = VIA_CONTEXT(ctx); + if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); /*=* John Sheng [2003.7.2] for visual config & patch viewperf *=*/ - if (mesaVis->depthBits == 32 && vmesa->depthBits == 16) { + if (vmesa && mesaVis->depthBits == 32 && vmesa->depthBits == 16) { vmesa->depthBits = mesaVis->depthBits; vmesa->depth.size *= 2; vmesa->depth.pitch *= 2; diff --git a/src/mesa/drivers/dri/unichrome/via_texmem.c b/src/mesa/drivers/dri/unichrome/via_texmem.c index 58033947425..6f4edde64e1 100644 --- a/src/mesa/drivers/dri/unichrome/via_texmem.c +++ b/src/mesa/drivers/dri/unichrome/via_texmem.c @@ -40,7 +40,6 @@ #include "via_ioctl.h" #include "via_fb.h" /*=* John Sheng [2003.5.31] agp tex *=*/ -GLuint agpFullCount = 0; void viaDestroyTexObj(viaContextPtr vmesa, viaTextureObjectPtr t) { @@ -410,7 +409,7 @@ void viaUploadTexImages(viaContextPtr vmesa, viaTextureObjectPtr t) if (via_alloc_texture(vmesa, t)) break; - agpFullCount++; + vmesa->agpFullCount++; if (vmesa->TexObjList.prev == vmesa->CurrentTexObj[0] || vmesa->TexObjList.prev == vmesa->CurrentTexObj[1]) { if (VIA_DEBUG) fprintf(stderr, "Hit bound texture in upload\n"); |