Remove the bogus 'current_vmesa' pointer.
#include "vblank.h"
#include "utils.h"
-viaContextPtr current_mesa;
#ifdef DEBUG
GLuint VIA_DEBUG = 0;
#endif
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)
+ 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,
(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,
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;
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;
}
driParseConfigFiles (&vmesa->optionCache, &viaScreen->optionCache,
sPriv->myNum, "via");
- current_mesa = vmesa;
/* pick back buffer */
if (mesaVis->doubleBufferMode) {
vmesa->hasBack = GL_TRUE;
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);
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 ) {
__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 );
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);
GLuint* agpBase;
GLuint drawType;
+ GLuint nDoneFirstFlip;
+ GLuint agpFullCount;
+
/* Configuration cache
*/
driOptionCache optionCache;
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); \
}
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;
}
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 );
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;
}
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;
#define VIA_CMDBUF_MAX_LAG 50000
int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf)
-
{
GLuint *pnBuf;
GLuint *pnEnd;
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();
}
}
}
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();
}
}
static const GLuint __driNConfigOptions = 3;
-extern viaContextPtr current_mesa;
-
#ifdef USE_NEW_INTERFACE
static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
#endif /* USE_NEW_INTERFACE */
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;
#include "via_ioctl.h"
#include "via_fb.h"
/*=* John Sheng [2003.5.31] agp tex *=*/
-GLuint agpFullCount = 0;
void viaDestroyTexObj(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");