#ifdef DEBUG | #ifdef DEBUG | ||||
GLuint VIA_DEBUG = 0; | GLuint VIA_DEBUG = 0; | ||||
#endif | #endif | ||||
GLuint DRAW_FRONT = 0; | |||||
#define DMA_SIZE 2 | #define DMA_SIZE 2 | ||||
GLuint VIA_PERFORMANCE = 0; | GLuint VIA_PERFORMANCE = 0; | ||||
#ifdef PERFORMANCE_MEASURE | #ifdef PERFORMANCE_MEASURE | ||||
/* Allocate depth-buffer */ | /* Allocate depth-buffer */ | ||||
if ( vmesa->hasStencil || vmesa->hasDepth ) { | if ( vmesa->hasStencil || vmesa->hasDepth ) { | ||||
const unsigned dShift = (vmesa->hasStencil) | |||||
? 2 : (vmesa->depthBits / 16); | |||||
vmesa->depth.bpp = vmesa->depthBits; | |||||
if (vmesa->depth.bpp == 24) | |||||
vmesa->depth.bpp = 32; | |||||
vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) << dShift) | |||||
+ extra; | |||||
vmesa->depth.bpp = 8 << dShift; | |||||
vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) * (vmesa->depth.bpp/8)) + extra; | |||||
vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h; | vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h; | ||||
} | } | ||||
else { | else { | ||||
/*=* John Sheng [2003.5.31] flip *=*/ | /*=* John Sheng [2003.5.31] flip *=*/ | ||||
if( vmesa->viaScreen->width == vmesa->driDrawable->w && | if( vmesa->viaScreen->width == vmesa->driDrawable->w && | ||||
vmesa->viaScreen->height == vmesa->driDrawable->h ) { | vmesa->viaScreen->height == vmesa->driDrawable->h ) { | ||||
#define ALLOW_EXPERIMENTAL_PAGEFLIP 1 | |||||
#define ALLOW_EXPERIMENTAL_PAGEFLIP 0 | |||||
#if ALLOW_EXPERIMENTAL_PAGEFLIP | #if ALLOW_EXPERIMENTAL_PAGEFLIP | ||||
vmesa->doPageFlip = GL_TRUE; | vmesa->doPageFlip = GL_TRUE; | ||||
#else | #else | ||||
sPriv->myNum, "via"); | sPriv->myNum, "via"); | ||||
/* pick back buffer */ | /* pick back buffer */ | ||||
if (mesaVis->doubleBufferMode) { | |||||
vmesa->hasBack = GL_TRUE; | |||||
} | |||||
else { | |||||
vmesa->hasBack = GL_FALSE; | |||||
} | |||||
/* pick z buffer */ | |||||
if (mesaVis->haveDepthBuffer) { | |||||
vmesa->hasDepth = GL_TRUE; | |||||
vmesa->depthBits = mesaVis->depthBits; | |||||
} | |||||
else { | |||||
vmesa->hasDepth = GL_FALSE; | |||||
vmesa->depthBits = 0; | |||||
} | |||||
/* pick stencil buffer */ | |||||
if (mesaVis->haveStencilBuffer) { | |||||
vmesa->hasStencil = GL_TRUE; | |||||
vmesa->stencilBits = mesaVis->stencilBits; | |||||
} | |||||
else { | |||||
vmesa->hasStencil = GL_FALSE; | |||||
vmesa->stencilBits = 0; | |||||
vmesa->hasBack = mesaVis->doubleBufferMode; | |||||
switch(mesaVis->depthBits) { | |||||
case 0: | |||||
vmesa->hasDepth = GL_FALSE; | |||||
vmesa->depthBits = 0; | |||||
break; | |||||
case 16: | |||||
vmesa->hasDepth = GL_TRUE; | |||||
vmesa->depthBits = mesaVis->depthBits; | |||||
vmesa->have_hw_stencil = GL_FALSE; | |||||
vmesa->depth_scale = 1.0/0xffff; | |||||
vmesa->depth_clear_mask = 0xf << 28; | |||||
vmesa->ClearDepth = 0xffff; | |||||
break; | |||||
case 24: | |||||
vmesa->hasDepth = GL_TRUE; | |||||
vmesa->depthBits = mesaVis->depthBits; | |||||
vmesa->depth_scale = 1.0/0xffffff; | |||||
vmesa->depth_clear_mask = 0xe << 28; | |||||
vmesa->ClearDepth = 0xffffff00; | |||||
assert(mesaVis->haveStencilBuffer); | |||||
assert(mesaVis->stencilBits == 8); | |||||
vmesa->have_hw_stencil = GL_TRUE; | |||||
vmesa->stencilBits = mesaVis->stencilBits; | |||||
vmesa->stencil_clear_mask = 0x1 << 28; | |||||
break; | |||||
case 32: | |||||
vmesa->hasDepth = GL_TRUE; | |||||
vmesa->depthBits = mesaVis->depthBits; | |||||
assert(!mesaVis->haveStencilBuffer); | |||||
vmesa->have_hw_stencil = GL_FALSE; | |||||
vmesa->depth_scale = 1.0/0xffffffff; | |||||
vmesa->depth_clear_mask = 0; | |||||
vmesa->ClearDepth = 0xffffffff; | |||||
vmesa->depth_clear_mask = 0xf << 28; | |||||
break; | |||||
default: | |||||
assert(0); | |||||
break; | |||||
} | } | ||||
_mesa_init_driver_functions(&functions); | _mesa_init_driver_functions(&functions); | ||||
viaInitTextureFuncs(&functions); | viaInitTextureFuncs(&functions); | ||||
ctx = vmesa->glCtx; | ctx = vmesa->glCtx; | ||||
/* check */ | |||||
/*=* John Sheng [2003.7.2] for visual config number can't excess 8 *=*/ | |||||
/*if (viaScreen->textureSize < 2 * 1024 * 1024) { | |||||
ctx->Const.MaxTextureLevels = 9; | |||||
} | |||||
else if (viaScreen->textureSize < 8 * 1024 * 1024) { | |||||
ctx->Const.MaxTextureLevels = 10; | |||||
} | |||||
else { | |||||
ctx->Const.MaxTextureLevels = 11; | |||||
}*/ | |||||
ctx->Const.MaxTextureLevels = 11; | |||||
ctx->Const.MaxTextureLevels = 11; | |||||
ctx->Const.MaxTextureUnits = 2; | ctx->Const.MaxTextureUnits = 2; | ||||
ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; | ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; | ||||
ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; | ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; | ||||
VIA_DEBUG = 0; | VIA_DEBUG = 0; | ||||
#endif | #endif | ||||
if (getenv("DRAW_FRONT")) | |||||
DRAW_FRONT = 1; | |||||
else | |||||
DRAW_FRONT = 0; | |||||
if (getenv("VIA_NO_RAST")) | |||||
FALLBACK(vmesa, VIA_FALLBACK_USER_DISABLE, 1); | |||||
#ifdef PERFORMANCE_MEASURE | #ifdef PERFORMANCE_MEASURE | ||||
if (getenv("VIA_PERFORMANCE")) | if (getenv("VIA_PERFORMANCE")) | ||||
} | } | ||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); | ||||
{ | |||||
#ifndef USE_XINERAMA | |||||
vmesa->saam = 0; | |||||
#else | |||||
GLboolean saam = XineramaIsActive(vmesa->display); | |||||
int count = 0, fbSize; | |||||
if (saam && vmesa->viaScreen->drixinerama) { | |||||
vmesa->xsi = XineramaQueryScreens(vmesa->display, &count); | |||||
/* Test RightOf or Down */ | |||||
if (vmesa->xsi[0].x_org == 0 && vmesa->xsi[0].y_org == 0) { | |||||
if (vmesa->xsi[1].x_org == vmesa->xsi[1].width) { | |||||
vmesa->saam = RightOf; | |||||
} | |||||
else { | |||||
vmesa->saam = Down; | |||||
} | |||||
} | |||||
/* Test LeftOf or Up */ | |||||
else if (vmesa->xsi[0].x_org == vmesa->xsi[0].width) { | |||||
vmesa->saam = LeftOf; | |||||
} | |||||
else if (vmesa->xsi[0].y_org == vmesa->xsi[0].height) { | |||||
vmesa->saam = Up; | |||||
} | |||||
else | |||||
vmesa->saam = 0; | |||||
fbSize = vmesa->viaScreen->fbSize; | |||||
} | |||||
else | |||||
vmesa->saam = 0; | |||||
#endif | |||||
} | |||||
vmesa->pSaamRects = (drm_clip_rect_t *) malloc(sizeof(drm_clip_rect_t)); | |||||
return GL_TRUE; | return GL_TRUE; | ||||
} | } | ||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); | ||||
assert(vmesa); /* should never be null */ | assert(vmesa); /* should never be null */ | ||||
/* viaFlushPrimsLocked(vmesa); */ | /* viaFlushPrimsLocked(vmesa); */ | ||||
WAIT_IDLE | |||||
if (vmesa) { | if (vmesa) { | ||||
/*=* John Sheng [2003.5.31] agp tex *=*/ | /*=* John Sheng [2003.5.31] agp tex *=*/ | ||||
WAIT_IDLE(vmesa); | |||||
if(VIA_DEBUG) fprintf(stderr, "agpFullCount = %d\n", vmesa->agpFullCount); | if(VIA_DEBUG) fprintf(stderr, "agpFullCount = %d\n", vmesa->agpFullCount); | ||||
_swsetup_DestroyContext(vmesa->glCtx); | _swsetup_DestroyContext(vmesa->glCtx); | ||||
{ | { | ||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; | __DRIdrawablePrivate *dPriv = vmesa->driDrawable; | ||||
if (!dPriv) | |||||
return; | |||||
vmesa->numClipRects = dPriv->numClipRects; | vmesa->numClipRects = dPriv->numClipRects; | ||||
vmesa->pClipRects = dPriv->pClipRects; | vmesa->pClipRects = dPriv->pClipRects; | ||||
vmesa->drawX = dPriv->x; | vmesa->drawX = dPriv->x; | ||||
void viaXMesaSetBackClipRects(viaContextPtr vmesa) | void viaXMesaSetBackClipRects(viaContextPtr vmesa) | ||||
{ | { | ||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; | |||||
/*=* John Sheng [2003.6.9] fix glxgears dirty screen */ | |||||
/*if (vmesa->saam) {*/ | |||||
vmesa->numClipRects = dPriv->numClipRects; | |||||
vmesa->pClipRects = dPriv->pClipRects; | |||||
vmesa->drawX = dPriv->x; | |||||
vmesa->drawY = dPriv->y; | |||||
vmesa->drawW = dPriv->w; | |||||
vmesa->drawH = dPriv->h; | |||||
/*} | |||||
else { | |||||
if (dPriv->numBackClipRects == 0) { | |||||
vmesa->numClipRects = dPriv->numClipRects; | |||||
vmesa->pClipRects = dPriv->pClipRects; | |||||
vmesa->drawX = dPriv->x; | |||||
vmesa->drawY = dPriv->y; | |||||
vmesa->drawW = dPriv->w; | |||||
vmesa->drawH = dPriv->h; | |||||
} | |||||
else { | |||||
vmesa->numClipRects = dPriv->numBackClipRects; | |||||
vmesa->pClipRects = dPriv->pBackClipRects; | |||||
vmesa->drawX = dPriv->backX; | |||||
vmesa->drawY = dPriv->backY; | |||||
vmesa->drawW = dPriv->w; | |||||
vmesa->drawH = dPriv->h; | |||||
} | |||||
}*/ | |||||
viaEmitDrawingRectangle(vmesa); | |||||
vmesa->uploadCliprects = GL_TRUE; | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; | |||||
if (!dPriv) | |||||
return; | |||||
/*=* John Sheng [2003.6.9] fix glxgears dirty screen */ | |||||
vmesa->numClipRects = dPriv->numClipRects; | |||||
vmesa->pClipRects = dPriv->pClipRects; | |||||
vmesa->drawX = dPriv->x; | |||||
vmesa->drawY = dPriv->y; | |||||
vmesa->drawW = dPriv->w; | |||||
vmesa->drawH = dPriv->h; | |||||
viaEmitDrawingRectangle(vmesa); | |||||
vmesa->uploadCliprects = GL_TRUE; | |||||
} | } | ||||
void viaXMesaWindowMoved(viaContextPtr vmesa) | void viaXMesaWindowMoved(viaContextPtr vmesa) | ||||
{ | { | ||||
GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; | GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; | ||||
#ifdef USE_XINERAMA | |||||
GLuint side = 0; | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; | |||||
#endif | |||||
switch (vmesa->glCtx->Color._DrawDestMask[0]) { | switch (vmesa->glCtx->Color._DrawDestMask[0]) { | ||||
case __GL_FRONT_BUFFER_MASK: | |||||
case DD_FRONT_LEFT_BIT: | |||||
viaXMesaSetFrontClipRects(vmesa); | viaXMesaSetFrontClipRects(vmesa); | ||||
break; | break; | ||||
case __GL_BACK_BUFFER_MASK: | |||||
case DD_BACK_LEFT_BIT: | |||||
viaXMesaSetBackClipRects(vmesa); | viaXMesaSetBackClipRects(vmesa); | ||||
break; | break; | ||||
default: | default: | ||||
viaXMesaSetFrontClipRects(vmesa); | |||||
break; | break; | ||||
} | } | ||||
#ifndef USE_XINERAMA | |||||
vmesa->viaScreen->fbOffset = 0; | vmesa->viaScreen->fbOffset = 0; | ||||
vmesa->saam &= ~S1; | |||||
vmesa->saam |= S0; | |||||
#else | |||||
side = vmesa->saam & P_MASK; | |||||
switch (side) { | |||||
case RightOf: | |||||
/* full in screen 1 */ | |||||
if (vmesa->drawX >= vmesa->xsi[0].width) { | |||||
vmesa->viaScreen->fbOffset = vmesa->viaScreen->fbSize; | |||||
vmesa->drawX = vmesa->drawX - vmesa->xsi[1].width; | |||||
vmesa->numClipRects = dPriv->numBackClipRects; | |||||
vmesa->pClipRects = dPriv->pBackClipRects; | |||||
vmesa->drawX = dPriv->backX; | |||||
vmesa->drawY = dPriv->backY; | |||||
vmesa->saam &= ~S0; | |||||
vmesa->saam |= S1; | |||||
} | |||||
/* full in screen 0 */ | |||||
else if ((vmesa->drawX + vmesa->drawW) <= vmesa->xsi[0].width) { | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
vmesa->saam &= ~S1; | |||||
vmesa->saam |= S0; | |||||
} | |||||
/* between screen 0 && screen 1 */ | |||||
else { | |||||
vmesa->numSaamRects = dPriv->numBackClipRects; | |||||
vmesa->pSaamRects = dPriv->pBackClipRects; | |||||
vmesa->drawXSaam = dPriv->backX; | |||||
vmesa->drawYSaam = dPriv->backY; | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
vmesa->saam |= S0; | |||||
vmesa->saam |= S1; | |||||
} | |||||
break; | |||||
case LeftOf: | |||||
/* full in screen 1 */ | |||||
if (vmesa->drawX + vmesa->drawW <= 0) { | |||||
vmesa->viaScreen->fbOffset = vmesa->viaScreen->fbSize; | |||||
vmesa->drawX = vmesa->drawX + vmesa->xsi[1].width; | |||||
vmesa->numClipRects = dPriv->numBackClipRects; | |||||
vmesa->pClipRects = dPriv->pBackClipRects; | |||||
vmesa->drawX = dPriv->backX; | |||||
vmesa->drawY = dPriv->backY; | |||||
vmesa->saam &= ~S0; | |||||
vmesa->saam |= S1; | |||||
} | |||||
/* full in screen 0 */ | |||||
else if (vmesa->drawX >= 0) { | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
vmesa->saam &= ~S1; | |||||
vmesa->saam |= S0; | |||||
} | |||||
/* between screen 0 && screen 1 */ | |||||
else { | |||||
vmesa->numSaamRects = dPriv->numBackClipRects; | |||||
vmesa->pSaamRects = dPriv->pBackClipRects; | |||||
vmesa->drawXSaam = dPriv->backX; | |||||
vmesa->drawYSaam = dPriv->backY; | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
vmesa->saam |= S0; | |||||
vmesa->saam |= S1; | |||||
} | |||||
break; | |||||
case Down : | |||||
/* full in screen 1 */ | |||||
if (vmesa->drawY >= vmesa->xsi[0].height) { | |||||
vmesa->viaScreen->fbOffset = vmesa->viaScreen->fbSize; | |||||
vmesa->drawY = vmesa->drawY - vmesa->xsi[1].height; | |||||
vmesa->numClipRects = dPriv->numBackClipRects; | |||||
vmesa->pClipRects = dPriv->pBackClipRects; | |||||
vmesa->drawX = dPriv->backX; | |||||
vmesa->drawY = dPriv->backY; | |||||
vmesa->saam &= ~S0; | |||||
vmesa->saam |= S1; | |||||
} | |||||
/* full in screen 0 */ | |||||
else if ((vmesa->drawY + vmesa->drawH) <= vmesa->xsi[0].height) { | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
vmesa->saam &= ~S1; | |||||
vmesa->saam |= S0; | |||||
} | |||||
/* between screen 0 && screen 1 */ | |||||
else { | |||||
vmesa->numSaamRects = dPriv->numBackClipRects; | |||||
vmesa->pSaamRects = dPriv->pBackClipRects; | |||||
vmesa->drawXSaam = dPriv->backX; | |||||
vmesa->drawYSaam = dPriv->backY; | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
vmesa->saam |= S0; | |||||
vmesa->saam |= S1; | |||||
} | |||||
break; | |||||
case Up : | |||||
/* full in screen 1 */ | |||||
if ((vmesa->drawY + vmesa->drawH) <= 0) { | |||||
vmesa->viaScreen->fbOffset = vmesa->viaScreen->fbSize; | |||||
vmesa->drawY = vmesa->drawY + vmesa->xsi[1].height; | |||||
vmesa->numClipRects = dPriv->numBackClipRects; | |||||
vmesa->pClipRects = dPriv->pBackClipRects; | |||||
vmesa->drawX = dPriv->backX; | |||||
vmesa->drawY = dPriv->backY; | |||||
vmesa->saam &= ~S0; | |||||
vmesa->saam |= S1; | |||||
} | |||||
/* full in screen 0 */ | |||||
else if (vmesa->drawY >= 0) { | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
vmesa->saam &= ~S1; | |||||
vmesa->saam |= S0; | |||||
} | |||||
/* between screen 0 && screen 1 */ | |||||
else { | |||||
vmesa->numSaamRects = dPriv->numBackClipRects; | |||||
vmesa->pSaamRects = dPriv->pBackClipRects; | |||||
vmesa->drawXSaam = dPriv->backX; | |||||
vmesa->drawYSaam = dPriv->backY; | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
vmesa->saam |= S0; | |||||
vmesa->saam |= S1; | |||||
} | |||||
break; | |||||
default: | |||||
vmesa->viaScreen->fbOffset = 0; | |||||
} | |||||
#endif | |||||
{ | { | ||||
GLuint pitch, offset; | GLuint pitch, offset; | ||||
pitch = vmesa->front.pitch; | pitch = vmesa->front.pitch; | ||||
offset = vmesa->viaScreen->fbOffset + (vmesa->drawY * pitch + vmesa->drawX * bytePerPixel); | offset = vmesa->viaScreen->fbOffset + (vmesa->drawY * pitch + vmesa->drawX * bytePerPixel); | ||||
vmesa->drawXoff = (GLuint)((offset & 0x1f) / bytePerPixel); | |||||
if (vmesa->saam) { | |||||
if (vmesa->pSaamRects) { | |||||
offset = vmesa->viaScreen->fbOffset + (vmesa->pSaamRects[0].y1 * pitch + | |||||
vmesa->pSaamRects[0].x1 * bytePerPixel); | |||||
vmesa->drawXoffSaam = (GLuint)((offset & 0x1f) / bytePerPixel); | |||||
} | |||||
else | |||||
vmesa->drawXoffSaam = 0; | |||||
} | |||||
else | |||||
vmesa->drawXoffSaam = 0; | |||||
assert(vmesa->viaScreen->fbOffset % bytePerPixel == 0); | |||||
assert(pitch % bytePerPixel == 0); | |||||
/* KW: I don't know what this was, but it was giving incorrect | |||||
* results for backbuffer rendering: | |||||
*/ | |||||
/* vmesa->drawXoff = (GLuint)(((vmesa->drawX * bytePerPixel) & 0x1f) / bytePerPixel); */ | |||||
vmesa->drawXoff = 0; | |||||
} | } | ||||
viaCalcViewport(vmesa->glCtx); | viaCalcViewport(vmesa->glCtx); | ||||
if (driContextPriv) { | if (driContextPriv) { | ||||
viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate; | viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate; | ||||
GLcontext *ctx = vmesa->glCtx; | |||||
if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent: w = %d\n", vmesa->driDrawable->w); | if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent: w = %d\n", vmesa->driDrawable->w); | ||||
if ( ! calculate_buffer_parameters( vmesa ) ) { | if ( ! calculate_buffer_parameters( vmesa ) ) { | ||||
return GL_FALSE; | return GL_FALSE; | ||||
} | } | ||||
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] ); | |||||
} | } | ||||
_mesa_make_current2(vmesa->glCtx, | _mesa_make_current2(vmesa->glCtx, | ||||
(GLframebuffer *)driReadPriv->driverPrivate); | (GLframebuffer *)driReadPriv->driverPrivate); | ||||
if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext); | if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext); | ||||
viaXMesaWindowMoved(vmesa); | viaXMesaWindowMoved(vmesa); | ||||
} | } | ||||
else { | else { | ||||
_mesa_make_current(0,0); | _mesa_make_current(0,0); | ||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); | ||||
} | } | ||||
#if 0 | |||||
void viaLock(viaContextPtr vmesa, GLuint flags) | |||||
{ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; | |||||
__DRIscreenPrivate *sPriv = vmesa->driScreen; | |||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); | |||||
/*=* John Sheng [2003.6.16] for xf43 */ | |||||
if(dPriv->pStamp == NULL) | |||||
dPriv->pStamp = &dPriv->lastStamp; | |||||
if (*(dPriv->pStamp) != dPriv->lastStamp || vmesa->saam) { | |||||
GLuint scrn; | |||||
scrn = vmesa->saam & S_MASK; | |||||
DRM_SPINLOCK(&sPriv->pSAREA->drawable_lock, sPriv->drawLockID); | |||||
if (scrn == S1) | |||||
__driUtilUpdateDrawableInfo(dPriv); | |||||
else | |||||
DRI_VALIDATE_DRAWABLE_INFO_ONCE(dPriv); | |||||
viaXMesaWindowMoved(vmesa); | |||||
DRM_SPINUNLOCK(&sPriv->pSAREA->drawable_lock, sPriv->drawLockID); | |||||
} | |||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); | |||||
return; | |||||
} | |||||
#endif | |||||
void viaUnLock(viaContextPtr vmesa, GLuint flags) | |||||
{ | |||||
drm_via_sarea_t *sarea = vmesa->sarea; | |||||
int me = vmesa->hHWContext; | |||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); | |||||
if (VIA_DEBUG) fprintf(stderr, "sarea->ctxOwner = %d\n", sarea->ctxOwner); | |||||
if (VIA_DEBUG) fprintf(stderr, "me = %d\n", me); | |||||
if (sarea->ctxOwner == me) { | |||||
sarea->ctxOwner = 0; | |||||
} | |||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); | |||||
} | |||||
void | void | ||||
viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate) | viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate) |
#include "via_tex.h" | #include "via_tex.h" | ||||
#include "via_common.h" | #include "via_common.h" | ||||
#include "xf86drmVIA.h" | #include "xf86drmVIA.h" | ||||
#ifdef USE_XINERAMA | |||||
#include "../../../../../include/extensions/Xinerama.h" | |||||
#endif | |||||
#define VIA_FALLBACK_TEXTURE 0x1 | #define VIA_FALLBACK_TEXTURE 0x1 | ||||
#define VIA_FALLBACK_DRAW_BUFFER 0x2 | #define VIA_FALLBACK_DRAW_BUFFER 0x2 | ||||
#define VIA_FALLBACK_READ_BUFFER 0x4 | #define VIA_FALLBACK_READ_BUFFER 0x4 | ||||
#define VIA_FALLBACK_STENCIL 0x100 | #define VIA_FALLBACK_STENCIL 0x100 | ||||
#define VIA_FALLBACK_BLEND_EQ 0x200 | #define VIA_FALLBACK_BLEND_EQ 0x200 | ||||
#define VIA_FALLBACK_BLEND_FUNC 0x400 | #define VIA_FALLBACK_BLEND_FUNC 0x400 | ||||
#define VIA_FALLBACK_USER_DISABLE 0x800 | |||||
#define VIA_UPLOAD_NONE 0x0000 | #define VIA_UPLOAD_NONE 0x0000 | ||||
#define VIA_UPLOAD_ALPHATEST 0x0001 | #define VIA_UPLOAD_ALPHATEST 0x0001 | ||||
GLboolean hasAccum; | GLboolean hasAccum; | ||||
GLuint depthBits; | GLuint depthBits; | ||||
GLuint stencilBits; | GLuint stencilBits; | ||||
GLboolean have_hw_stencil; | |||||
GLuint ClearDepth; | |||||
GLuint depth_clear_mask; | |||||
GLuint stencil_clear_mask; | |||||
GLfloat depth_scale; | |||||
GLuint *dma; | GLuint *dma; | ||||
viaRegion tex; | viaRegion tex; | ||||
int drawW; | int drawW; | ||||
int drawH; | int drawH; | ||||
GLuint saam; | |||||
#ifdef USE_XINERAMA | |||||
XineramaScreenInfo *xsi; | |||||
#endif | |||||
int drawXoffSaam; | |||||
drm_clip_rect_t *pSaamRects; | |||||
int drawXSaam; | |||||
int drawYSaam; | |||||
GLuint numSaamRects; | |||||
int drawPitch; | int drawPitch; | ||||
int readPitch; | int readPitch; | ||||
/* Lock the hardware and validate our state. | /* Lock the hardware and validate our state. | ||||
*/ | */ | ||||
/* | |||||
#define LOCK_HARDWARE(vmesa) \ | |||||
do { \ | |||||
char __ret = 0; \ | |||||
DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \ | |||||
(DRM_LOCK_HELD|vmesa->hHWContext), __ret); \ | |||||
if (__ret) \ | |||||
viaGetLock(vmesa, 0); \ | |||||
} while (0) | |||||
*/ | |||||
/*=* John Sheng [2003.6.20] fix pci *=*/ | |||||
/*=* John Sheng [2003.7.25] fix viewperf black shadow *=*/ | |||||
#define LOCK_HARDWARE(vmesa) \ | #define LOCK_HARDWARE(vmesa) \ | ||||
if(1) \ | |||||
do { \ | do { \ | ||||
char __ret = 0; \ | char __ret = 0; \ | ||||
DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \ | DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \ | ||||
(DRM_LOCK_HELD|vmesa->hHWContext), __ret); \ | (DRM_LOCK_HELD|vmesa->hHWContext), __ret); \ | ||||
if (__ret) \ | if (__ret) \ | ||||
viaGetLock(vmesa, 0); \ | viaGetLock(vmesa, 0); \ | ||||
} while (0); \ | |||||
else \ | |||||
viaLock(vmesa, 0) | |||||
} while (0) | |||||
/* | |||||
#define LOCK_HARDWARE(vmesa) \ | |||||
viaLock(vmesa, 0); | |||||
*/ | |||||
/* Release the kernel lock. | /* Release the kernel lock. | ||||
*/ | */ | ||||
/* | |||||
#define UNLOCK_HARDWARE(vmesa) \ | |||||
DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); | |||||
*/ | |||||
/*=* John Sheng [2003.6.20] fix pci *=*/ | |||||
/*=* John Sheng [2003.7.25] fix viewperf black shadow *=*/ | |||||
#define UNLOCK_HARDWARE(vmesa) \ | #define UNLOCK_HARDWARE(vmesa) \ | ||||
if(1) \ | |||||
DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); \ | |||||
else \ | |||||
viaUnLock(vmesa, 0); | |||||
/* | |||||
#define UNLOCK_HARDWARE(vmesa) \ | |||||
viaUnLock(vmesa, 0); | |||||
*/ | |||||
#define WAIT_IDLE \ | |||||
while (1) { \ | |||||
DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); | |||||
#define WAIT_IDLE(vmesa) \ | |||||
do { \ | |||||
if ((((GLuint)*vmesa->regEngineStatus) & 0xFFFEFFFF) == 0x00020000) \ | if ((((GLuint)*vmesa->regEngineStatus) & 0xFFFEFFFF) == 0x00020000) \ | ||||
break; \ | break; \ | ||||
} | |||||
} while (1) | |||||
#define LOCK_HARDWARE_QUIESCENT(vmesa) \ | #define LOCK_HARDWARE_QUIESCENT(vmesa) \ | ||||
do { \ | do { \ | ||||
#endif | #endif | ||||
extern GLuint DRAW_FRONT; | |||||
extern void viaGetLock(viaContextPtr vmesa, GLuint flags); | extern void viaGetLock(viaContextPtr vmesa, GLuint flags); | ||||
extern void viaLock(viaContextPtr vmesa, GLuint flags); | extern void viaLock(viaContextPtr vmesa, GLuint flags); | ||||
extern void viaUnLock(viaContextPtr vmesa, GLuint flags); | extern void viaUnLock(viaContextPtr vmesa, GLuint flags); |
int priv2; | int priv2; | ||||
int fbOffset; | int fbOffset; | ||||
int fbSize; | int fbSize; | ||||
#ifdef USE_XINERAMA | |||||
Bool drixinerama; | |||||
#endif | |||||
int backOffset; | int backOffset; | ||||
int depthOffset; | int depthOffset; | ||||
int textureOffset; | int textureOffset; |
void viaPageFlip(const __DRIdrawablePrivate *dpriv); | void viaPageFlip(const __DRIdrawablePrivate *dpriv); | ||||
int via_check_copy(int fd); | int via_check_copy(int fd); | ||||
void viaFillFrontBuffer(viaContextPtr vmesa); | void viaFillFrontBuffer(viaContextPtr vmesa); | ||||
void viaFillFrontBufferSaam(viaContextPtr vmesa); | |||||
void viaFillFrontPBuffer(viaContextPtr vmesa); | void viaFillFrontPBuffer(viaContextPtr vmesa); | ||||
void viaFillBackBuffer(viaContextPtr vmesa); | void viaFillBackBuffer(viaContextPtr vmesa); | ||||
void viaFillDepthBuffer(viaContextPtr vmesa, GLuint pixel); | |||||
void viaFillStencilBuffer(viaContextPtr vmesa, GLuint pixel); | |||||
void viaFillStencilDepthBuffer(viaContextPtr vmesa, GLuint pixel); | |||||
void viaFillDepthBuffer(viaContextPtr vmesa, GLuint pixel, GLuint mask); | |||||
void viaDoSwapBuffers(viaContextPtr vmesa); | void viaDoSwapBuffers(viaContextPtr vmesa); | ||||
void viaDoSwapBuffersSaam(viaContextPtr vmesa); | |||||
void viaDoSwapPBuffers(viaContextPtr vmesa); | void viaDoSwapPBuffers(viaContextPtr vmesa); | ||||
int flush_agp(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd); | int flush_agp(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd); | ||||
int flush_agp_saam(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd); | |||||
int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf); | int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf); | ||||
#define VIA_STATECHANGE(vmesa, flag) \ | #define VIA_STATECHANGE(vmesa, flag) \ |
viaScreen->irqEnabled = gDRIPriv->irqEnabled; | viaScreen->irqEnabled = gDRIPriv->irqEnabled; | ||||
viaScreen->irqEnabled = 1; | viaScreen->irqEnabled = 1; | ||||
#ifdef USE_XINERAMA | |||||
viaScreen->drixinerama = gDRIPriv->drixinerama; | |||||
#endif | |||||
if (VIA_DEBUG) { | if (VIA_DEBUG) { | ||||
fprintf(stderr, "deviceID = %08x\n", viaScreen->deviceID); | fprintf(stderr, "deviceID = %08x\n", viaScreen->deviceID); | ||||
fprintf(stderr, "width = %08x\n", viaScreen->width); | fprintf(stderr, "width = %08x\n", viaScreen->width); | ||||
const __GLcontextModes *mesaVis, | const __GLcontextModes *mesaVis, | ||||
GLboolean isPixmap) | GLboolean isPixmap) | ||||
{ | { | ||||
/* KW: Bogus: Do this sort of thing in MakeCurrent or similar. | |||||
*/ | |||||
viaContextPtr vmesa; | |||||
viaContextPtr vmesa = 0; | |||||
GET_CURRENT_CONTEXT(ctx); | GET_CURRENT_CONTEXT(ctx); | ||||
GLboolean swStencil = (mesaVis->stencilBits > 0 && | |||||
mesaVis->depthBits != 24); | |||||
if (ctx) | if (ctx) | ||||
vmesa = VIA_CONTEXT(ctx); | vmesa = VIA_CONTEXT(ctx); | ||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); | ||||
/*=* John Sheng [2003.7.2] for visual config & patch viewperf *=*/ | |||||
if (vmesa && mesaVis->depthBits == 32 && vmesa->depthBits == 16) { | |||||
vmesa->depthBits = mesaVis->depthBits; | |||||
vmesa->depth.size *= 2; | |||||
vmesa->depth.pitch *= 2; | |||||
vmesa->depth.bpp *= 2; | |||||
if (vmesa->depth.map) | |||||
via_free_depth_buffer(vmesa); | |||||
if (!via_alloc_depth_buffer(vmesa)) { | |||||
via_free_depth_buffer(vmesa); | |||||
return GL_FALSE; | |||||
} | |||||
((__GLcontextModes*)mesaVis)->depthBits = 16; /* XXX : sure you want to change read-only data? */ | |||||
} | |||||
/* KW: removed bogus depth recalculations. | |||||
*/ | |||||
if (isPixmap) { | if (isPixmap) { | ||||
driDrawPriv->driverPrivate = (void *) | driDrawPriv->driverPrivate = (void *) | ||||
_mesa_create_framebuffer(mesaVis, | _mesa_create_framebuffer(mesaVis, | ||||
GL_FALSE, /* software depth buffer? */ | GL_FALSE, /* software depth buffer? */ | ||||
mesaVis->stencilBits > 0, | |||||
swStencil, | |||||
mesaVis->accumRedBits > 0, | mesaVis->accumRedBits > 0, | ||||
GL_FALSE /* s/w alpha planes */); | GL_FALSE /* s/w alpha planes */); | ||||
driDrawPriv->driverPrivate = (void *) | driDrawPriv->driverPrivate = (void *) | ||||
_mesa_create_framebuffer(mesaVis, | _mesa_create_framebuffer(mesaVis, | ||||
GL_FALSE, /* software depth buffer? */ | GL_FALSE, /* software depth buffer? */ | ||||
mesaVis->stencilBits > 0, | |||||
swStencil, | |||||
mesaVis->accumRedBits > 0, | mesaVis->accumRedBits > 0, | ||||
GL_FALSE /* s/w alpha planes */); | GL_FALSE /* s/w alpha planes */); | ||||
int fbFormat; | int fbFormat; | ||||
int fbOffset; | int fbOffset; | ||||
int fbSize; | int fbSize; | ||||
#ifdef USE_XINERAMA | |||||
Bool drixinerama; | |||||
#endif | |||||
int fbStride; | int fbStride; | ||||
#include "swrast/swrast.h" | #include "swrast/swrast.h" | ||||
#define DBG 0 | #define DBG 0 | ||||
#define LOCAL_VARS \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||||
viaScreenPrivate *viaScreen = vmesa->viaScreen; \ | |||||
GLuint pitch = vmesa->drawPitch; \ | |||||
GLuint height = dPriv->h; \ | |||||
GLushort p; \ | |||||
char *buf = (char *)(vmesa->drawMap + \ | |||||
dPriv->x * viaScreen->bytesPerPixel + \ | |||||
dPriv->y * pitch); \ | |||||
char *read_buf = (char *)(vmesa->readMap + \ | |||||
dPriv->x * viaScreen->bytesPerPixel + \ | |||||
dPriv->y * pitch); \ | |||||
(void)read_buf; (void)buf; (void)p | |||||
#define LOCAL_DEPTH_VARS \ | #define LOCAL_DEPTH_VARS \ | ||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | ||||
viaScreenPrivate *viaScreen = vmesa->viaScreen; \ | viaScreenPrivate *viaScreen = vmesa->viaScreen; \ | ||||
GLuint pitch = viaScreen->backPitch; \ | GLuint pitch = viaScreen->backPitch; \ | ||||
GLuint height = dPriv->h; \ | GLuint height = dPriv->h; \ | ||||
char *buf = (char *)(vmesa->depth.map + \ | |||||
dPriv->x * 2 + \ | |||||
dPriv->y * pitch) | |||||
char *buf = (char *)(vmesa->depth.map) | |||||
#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \ | #define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \ | ||||
_y >= miny && _y < maxy) | _y >= miny && _y < maxy) | ||||
#define Y_FLIP(_y) (height - _y - 1) | #define Y_FLIP(_y) (height - _y - 1) | ||||
#define HW_LOCK() \ | |||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \ | |||||
LOCK_HARDWARE_QUIESCENT(vmesa); | |||||
/*=* [DBG] csmash saam : bitmap option menu can't be drawn in saam *=*/ | |||||
/*#define HW_CLIPLOOP() \ | |||||
do { \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||||
int _nc = dPriv->numClipRects; \ | |||||
while (_nc--) { \ | |||||
int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \ | |||||
int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \ | |||||
int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \ | |||||
int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;*/ | |||||
#define HW_CLIPLOOP() \ | |||||
do { \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||||
int _nc = dPriv->numClipRects; \ | |||||
GLuint scrn = vmesa->saam & S_MASK; \ | |||||
if(scrn == S1) _nc = 1; \ | |||||
while (_nc--) { \ | |||||
int minx; \ | |||||
int miny; \ | |||||
int maxx; \ | |||||
int maxy; \ | |||||
if (!vmesa->saam) { \ | |||||
minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \ | |||||
miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \ | |||||
maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \ | |||||
maxy = dPriv->pClipRects[_nc].y2 - dPriv->y; \ | |||||
} \ | |||||
else { \ | |||||
minx = -10000; \ | |||||
miny = -10000; \ | |||||
maxx = 10000; \ | |||||
maxy = 10000; \ | |||||
} | |||||
/*else if (scrn == S0) { \ | |||||
minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \ | |||||
miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \ | |||||
maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \ | |||||
maxy = dPriv->pClipRects[_nc].y2 - dPriv->y; \ | |||||
} \ | |||||
else if (scrn == S1) { \ | |||||
drm_clip_rect_t *b = vmesa->sarea->boxes; \ | |||||
minx = b->x1; \ | |||||
miny = b->y1; \ | |||||
maxx = b->x2; \ | |||||
maxy = b->y2; \ | |||||
} \ | |||||
else { \ | |||||
drm_clip_rect_t *b = vmesa->sarea->boxes + vmesa->numClipRects;\ | |||||
minx = b->x1; \ | |||||
miny = b->y1; \ | |||||
maxx = b->x2; \ | |||||
maxy = b->y2; \ | |||||
}*/ | |||||
#define HW_LOCK() | |||||
#define HW_CLIPLOOP() \ | |||||
do { \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||||
int _nc = dPriv->numClipRects; \ | |||||
while (_nc--) { \ | |||||
int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \ | |||||
int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \ | |||||
int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \ | |||||
int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y; | |||||
#define HW_ENDCLIPLOOP() \ | #define HW_ENDCLIPLOOP() \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
#define HW_UNLOCK() \ | |||||
UNLOCK_HARDWARE(vmesa); | |||||
#define HW_UNLOCK() | |||||
/* 16 bit, 565 rgb color spanline and pixel functions | /* 16 bit, 565 rgb color spanline and pixel functions | ||||
*/ | */ | ||||
/*=* [DBG] csmash : fix options worng position *=*/ | |||||
/*#define LOCAL_VARS \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||||
GLuint pitch = vmesa->drawPitch; \ | |||||
GLuint height = dPriv->h; \ | |||||
GLushort p; \ | |||||
char *buf = (char *)(vmesa->drawMap + \ | |||||
dPriv->x * 2 + \ | |||||
dPriv->y * pitch); \ | |||||
char *read_buf = (char *)(vmesa->readMap + \ | |||||
dPriv->x * 2 + \ | |||||
dPriv->y * pitch); \ | |||||
(void)read_buf; (void)buf; (void)p*/ | |||||
#undef LOCAL_VARS | #undef LOCAL_VARS | ||||
#define LOCAL_VARS \ | #define LOCAL_VARS \ | ||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | ||||
GLuint pitch = vmesa->drawPitch; \ | GLuint pitch = vmesa->drawPitch; \ | ||||
GLuint height = dPriv->h; \ | GLuint height = dPriv->h; \ | ||||
GLushort p; \ | GLushort p; \ | ||||
char *buf, *read_buf; \ | char *buf, *read_buf; \ | ||||
p = 0; \ | p = 0; \ | ||||
if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { \ | |||||
if (vmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT) { \ | |||||
buf = (char *)(vmesa->drawMap); \ | buf = (char *)(vmesa->drawMap); \ | ||||
read_buf = (char *)(vmesa->readMap); \ | read_buf = (char *)(vmesa->readMap); \ | ||||
} \ | } \ | ||||
*/ | */ | ||||
#undef LOCAL_VARS | #undef LOCAL_VARS | ||||
#undef LOCAL_DEPTH_VARS | #undef LOCAL_DEPTH_VARS | ||||
#undef INIT_MONO_PIXEL | |||||
#undef DBG | |||||
#define DBG 0 | |||||
#define LOCAL_VARS \ | #define LOCAL_VARS \ | ||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | ||||
GLuint pitch = vmesa->drawPitch; \ | GLuint pitch = vmesa->drawPitch; \ | ||||
GLuint height = dPriv->h; \ | GLuint height = dPriv->h; \ | ||||
GLuint p; \ | GLuint p; \ | ||||
char *buf, *read_buf; \ | char *buf, *read_buf; \ | ||||
p = 0; \ | p = 0; \ | ||||
if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { \ | |||||
if (vmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT) { \ | |||||
buf = (char *)(vmesa->drawMap); \ | buf = (char *)(vmesa->drawMap); \ | ||||
read_buf = (char *)(vmesa->readMap); \ | read_buf = (char *)(vmesa->readMap); \ | ||||
} \ | } \ | ||||
/* 16 bit depthbuffer functions. | /* 16 bit depthbuffer functions. | ||||
*/ | */ | ||||
/*=* John Sheng [2003.6.16] fix exy press 'i' dirty screen *=*/ | |||||
/*#define LOCAL_DEPTH_VARS \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||||
GLuint pitch = vmesa->depth.pitch; \ | |||||
GLuint height = dPriv->h; \ | |||||
char *buf = (char *)(vmesa->depth.map + \ | |||||
dPriv->x * 2 + \ | |||||
dPriv->y * pitch) */ | |||||
#define LOCAL_DEPTH_VARS \ | #define LOCAL_DEPTH_VARS \ | ||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \ | |||||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | ||||
/*viaScreenPrivate *viaScreen = vmesa->viaScreen;*/ \ | |||||
GLuint pitch = vmesa->depth.pitch; \ | GLuint pitch = vmesa->depth.pitch; \ | ||||
GLuint height = dPriv->h; \ | GLuint height = dPriv->h; \ | ||||
char *buf = (char *)(vmesa->depth.map) | char *buf = (char *)(vmesa->depth.map) | ||||
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS | |||||
#define WRITE_DEPTH(_x, _y, d) \ | #define WRITE_DEPTH(_x, _y, d) \ | ||||
*(GLushort *)(buf + _x * 2 + _y * pitch) = d; | *(GLushort *)(buf + _x * 2 + _y * pitch) = d; | ||||
#define TAG(x) via##x##_32 | #define TAG(x) via##x##_32 | ||||
#include "depthtmp.h" | #include "depthtmp.h" | ||||
/* 24/8 bit depthbuffer functions. | |||||
/* 24/8 bit interleaved depth/stencil functions | |||||
*/ | */ | ||||
/* | |||||
#define WRITE_DEPTH(_x, _y, d) { \ | |||||
GLuint tmp = *(GLuint *)(buf + _x * 4 + y * pitch); \ | |||||
tmp &= 0xff; \ | |||||
tmp |= (d) & 0xffffff00; \ | |||||
*(GLuint *)(buf + _x * 4 + _y * pitch) = tmp; \ | |||||
#define WRITE_DEPTH( _x, _y, d ) { \ | |||||
GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \ | |||||
tmp &= 0x000000ff; \ | |||||
tmp |= ((d)<<8); \ | |||||
*(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \ | |||||
} | |||||
#define READ_DEPTH( d, _x, _y ) \ | |||||
d = (*(GLuint *)(buf + (_x)*4 + (_y)*pitch)) >> 8; | |||||
#define READ_DEPTH(d, _x, _y) \ | |||||
d = (*(GLuint *)(buf + _x * 4 + _y * pitch) & ~0xff) >> 8; | |||||
#define TAG(x) via##x##_24_8 | #define TAG(x) via##x##_24_8 | ||||
#include "depthtmp.h" | #include "depthtmp.h" | ||||
*/ | |||||
#define WRITE_STENCIL( _x, _y, d ) { \ | |||||
GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \ | |||||
tmp &= 0xffffff00; \ | |||||
tmp |= (d); \ | |||||
*(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \ | |||||
} | |||||
#define READ_STENCIL( d, _x, _y ) \ | |||||
d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch) & 0xff; | |||||
#define TAG(x) via##x##_24_8 | |||||
#include "stenciltmp.h" | |||||
static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer, | static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer, | ||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); | ||||
} | } | ||||
/* Move locking out to get reasonable span performance. | |||||
*/ | |||||
static void viaSpanRenderStart( GLcontext *ctx ) | |||||
{ | |||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); | |||||
LOCK_HARDWARE(vmesa); | |||||
viaFlushPrimsLocked(vmesa); | |||||
WAIT_IDLE(vmesa); | |||||
} | |||||
static void viaSpanRenderFinish( GLcontext *ctx ) | |||||
{ | |||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); | |||||
_swrast_flush( ctx ); | |||||
UNLOCK_HARDWARE( vmesa ); | |||||
} | |||||
void viaInitSpanFuncs(GLcontext *ctx) | void viaInitSpanFuncs(GLcontext *ctx) | ||||
{ | { | ||||
swdd->SetBuffer = viaSetBuffer; | swdd->SetBuffer = viaSetBuffer; | ||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); | ||||
if (vmesa->viaScreen->bitsPerPixel == 0x10) { | |||||
if (vmesa->viaScreen->bitsPerPixel == 16) { | |||||
swdd->WriteRGBASpan = viaWriteRGBASpan_565; | swdd->WriteRGBASpan = viaWriteRGBASpan_565; | ||||
swdd->WriteRGBSpan = viaWriteRGBSpan_565; | swdd->WriteRGBSpan = viaWriteRGBSpan_565; | ||||
swdd->WriteMonoRGBASpan = viaWriteMonoRGBASpan_565; | swdd->WriteMonoRGBASpan = viaWriteMonoRGBASpan_565; | ||||
swdd->ReadRGBASpan = viaReadRGBASpan_565; | swdd->ReadRGBASpan = viaReadRGBASpan_565; | ||||
swdd->ReadRGBAPixels = viaReadRGBAPixels_565; | swdd->ReadRGBAPixels = viaReadRGBAPixels_565; | ||||
} | } | ||||
else if (vmesa->viaScreen->bitsPerPixel == 0x20) { | |||||
else if (vmesa->viaScreen->bitsPerPixel == 32) { | |||||
viaInitPointers_8888( swdd ); | viaInitPointers_8888( swdd ); | ||||
} | } | ||||
else | |||||
ASSERT(0); | |||||
else { | |||||
fprintf(stderr, "%s: failed\n", __FUNCTION__); | |||||
assert(0); | |||||
} | |||||
if (vmesa->glCtx->Visual.depthBits == 0x10) { | |||||
if (vmesa->glCtx->Visual.depthBits == 16) { | |||||
swdd->ReadDepthSpan = viaReadDepthSpan_16; | swdd->ReadDepthSpan = viaReadDepthSpan_16; | ||||
swdd->WriteDepthSpan = viaWriteDepthSpan_16; | swdd->WriteDepthSpan = viaWriteDepthSpan_16; | ||||
swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_16; | |||||
swdd->ReadDepthPixels = viaReadDepthPixels_16; | swdd->ReadDepthPixels = viaReadDepthPixels_16; | ||||
swdd->WriteDepthPixels = viaWriteDepthPixels_16; | swdd->WriteDepthPixels = viaWriteDepthPixels_16; | ||||
} | } | ||||
else if (vmesa->glCtx->Visual.depthBits == 0x20) { | |||||
else if (vmesa->glCtx->Visual.depthBits == 24) { | |||||
fprintf(stderr, "%s: 24/8 span functions\n", __FUNCTION__); | |||||
swdd->ReadDepthSpan = viaReadDepthSpan_24_8; | |||||
swdd->WriteDepthSpan = viaWriteDepthSpan_24_8; | |||||
swdd->ReadDepthPixels = viaReadDepthPixels_24_8; | |||||
swdd->WriteDepthPixels = viaWriteDepthPixels_24_8; | |||||
swdd->WriteStencilSpan = viaWriteStencilSpan_24_8; | |||||
swdd->ReadStencilSpan = viaReadStencilSpan_24_8; | |||||
swdd->WriteStencilPixels = viaWriteStencilPixels_24_8; | |||||
swdd->ReadStencilPixels = viaReadStencilPixels_24_8; | |||||
} | |||||
else if (vmesa->glCtx->Visual.depthBits == 32) { | |||||
swdd->ReadDepthSpan = viaReadDepthSpan_32; | swdd->ReadDepthSpan = viaReadDepthSpan_32; | ||||
swdd->WriteDepthSpan = viaWriteDepthSpan_32; | swdd->WriteDepthSpan = viaWriteDepthSpan_32; | ||||
swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_32; | |||||
swdd->ReadDepthPixels = viaReadDepthPixels_32; | swdd->ReadDepthPixels = viaReadDepthPixels_32; | ||||
swdd->WriteDepthPixels = viaWriteDepthPixels_32; | swdd->WriteDepthPixels = viaWriteDepthPixels_32; | ||||
} | } | ||||
swdd->SpanRenderStart = viaSpanRenderStart; | |||||
swdd->SpanRenderFinish = viaSpanRenderFinish; | |||||
swdd->WriteCI8Span = NULL; | swdd->WriteCI8Span = NULL; | ||||
swdd->WriteCI32Span = NULL; | swdd->WriteCI32Span = NULL; |
GLsizei w, GLsizei h) | GLsizei w, GLsizei h) | ||||
{ | { | ||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); | viaContextPtr vmesa = VIA_CONTEXT(ctx); | ||||
if (!vmesa->driDrawable) | |||||
return; | |||||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); | ||||
if (ctx->Scissor.Enabled) { | if (ctx->Scissor.Enabled) { | ||||
VIA_FIREVERTICES(vmesa); /* don't pipeline cliprect changes */ | VIA_FIREVERTICES(vmesa); /* don't pipeline cliprect changes */ | ||||
vmesa->uploadCliprects = GL_TRUE; | vmesa->uploadCliprects = GL_TRUE; | ||||
FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE); | FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE); | ||||
return; | return; | ||||
} | } | ||||
/* We want to update the s/w rast state too so that r200SetBuffer() | |||||
* gets called. | |||||
*/ | |||||
_swrast_DrawBuffer(ctx, mode); | |||||
if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); | ||||
} | } | ||||
vmesa = vmesa; | vmesa = vmesa; | ||||
} | } | ||||
static void viaBitmap( GLcontext *ctx, GLint px, GLint py, | |||||
GLsizei width, GLsizei height, | |||||
const struct gl_pixelstore_attrib *unpack, | |||||
const GLubyte *bitmap ) | |||||
{ | |||||
viaContextPtr vmesa = VIA_CONTEXT(ctx); | |||||
/*=* [DBG] csmash : fix background overlap option menu *=*/ | |||||
LOCK_HARDWARE(vmesa); | |||||
viaFlushPrimsLocked(vmesa); | |||||
UNLOCK_HARDWARE(vmesa); | |||||
WAIT_IDLE | |||||
/*=* [DBG] csmash : fix segmentation fault *=*/ | |||||
/*=* John Sheng [2003.7.18] texenv *=*/ | |||||
/*if (!vmesa->drawMap && !vmesa->readMap) {*/ | |||||
if (1) { | |||||
if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { | |||||
viaDrawBuffer(ctx, GL_BACK); | |||||
} | |||||
else { | |||||
viaDrawBuffer(ctx, GL_FRONT); | |||||
} | |||||
} | |||||
/*=* [DBG] csmash : white option words become brown *=*/ | |||||
/*_swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap );*/ | |||||
{ | |||||
GLboolean fog; | |||||
fog = ctx->Fog.Enabled; | |||||
ctx->Fog.Enabled = GL_FALSE; | |||||
_swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap ); | |||||
ctx->Fog.Enabled = fog; | |||||
} | |||||
} | |||||
/* ============================================================= | /* ============================================================= | ||||
* Color masks | * Color masks | ||||
m[MAT_TX] = v[MAT_TX] + vmesa->drawXoff; | m[MAT_TX] = v[MAT_TX] + vmesa->drawXoff; | ||||
m[MAT_SY] = - v[MAT_SY]; | m[MAT_SY] = - v[MAT_SY]; | ||||
m[MAT_TY] = - v[MAT_TY] + vmesa->driDrawable->h; | m[MAT_TY] = - v[MAT_TY] + vmesa->driDrawable->h; | ||||
/*=* John Sheng [2003.7.2] for visual config & viewperf drv-08 *=*/ | |||||
if (vmesa->depth.bpp == 16) { | |||||
m[MAT_SZ] = v[MAT_SZ] * (1.0 / 0xffff); | |||||
m[MAT_TZ] = v[MAT_TZ] * (1.0 / 0xffff); | |||||
} | |||||
else { | |||||
m[MAT_SZ] = v[MAT_SZ] * (1.0 / 0xffffffff); | |||||
m[MAT_TZ] = v[MAT_TZ] * (1.0 / 0xffffffff); | |||||
} | |||||
m[MAT_SZ] = v[MAT_SZ] * vmesa->depth_scale; | |||||
m[MAT_TZ] = v[MAT_TZ] * vmesa->depth_scale; | |||||
} | } | ||||
static void viaViewport(GLcontext *ctx, | static void viaViewport(GLcontext *ctx, | ||||
vmesa->regCmdB = HC_ACMD_HCmdB | HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z; | vmesa->regCmdB = HC_ACMD_HCmdB | HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z; | ||||
vmesa->regEnable = HC_HenCW_MASK; | vmesa->regEnable = HC_HenCW_MASK; | ||||
if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { | |||||
vmesa->drawMap = vmesa->back.map; | |||||
vmesa->readMap = vmesa->back.map; | |||||
} | |||||
else { | |||||
vmesa->drawMap = (char *)vmesa->driScreen->pFB; | |||||
vmesa->readMap = (char *)vmesa->driScreen->pFB; | |||||
} | |||||
/* Mesa should do this for us: | |||||
*/ | |||||
ctx->Driver.AlphaFunc( ctx, | |||||
ctx->Color.AlphaFunc, | |||||
ctx->Color.AlphaRef); | |||||
/* ctx->Driver.BlendColor( ctx, */ | |||||
/* ctx->Color.BlendColor ); */ | |||||
ctx->Driver.BlendEquationSeparate( ctx, | |||||
ctx->Color.BlendEquationRGB, | |||||
ctx->Color.BlendEquationA); | |||||
ctx->Driver.BlendFuncSeparate( ctx, | |||||
ctx->Color.BlendSrcRGB, | |||||
ctx->Color.BlendDstRGB, | |||||
ctx->Color.BlendSrcA, | |||||
ctx->Color.BlendDstA); | |||||
ctx->Driver.ColorMask( ctx, | |||||
ctx->Color.ColorMask[RCOMP], | |||||
ctx->Color.ColorMask[GCOMP], | |||||
ctx->Color.ColorMask[BCOMP], | |||||
ctx->Color.ColorMask[ACOMP]); | |||||
ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode ); | |||||
ctx->Driver.DepthFunc( ctx, ctx->Depth.Func ); | |||||
ctx->Driver.DepthMask( ctx, ctx->Depth.Mask ); | |||||
ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled ); | |||||
ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled ); | |||||
ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled ); | |||||
ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled ); | |||||
ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag ); | |||||
ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test ); | |||||
ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag ); | |||||
ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled ); | |||||
ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled ); | |||||
ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag ); | |||||
ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag ); | |||||
ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled ); | |||||
ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled ); | |||||
ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE ); | |||||
ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE ); | |||||
ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE ); | |||||
ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE ); | |||||
ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE ); | |||||
ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color ); | |||||
ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 ); | |||||
ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density ); | |||||
ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start ); | |||||
ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End ); | |||||
ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace ); | |||||
{ | |||||
GLfloat f = (GLfloat)ctx->Light.Model.ColorControl; | |||||
ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f ); | |||||
} | |||||
ctx->Driver.LineWidth( ctx, ctx->Line.Width ); | |||||
ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp ); | |||||
ctx->Driver.PointSize( ctx, ctx->Point.Size ); | |||||
ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple ); | |||||
ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y, | |||||
ctx->Scissor.Width, ctx->Scissor.Height ); | |||||
ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel ); | |||||
/* ctx->Driver.StencilFunc( ctx, */ | |||||
/* ctx->Stencil.Function[0], */ | |||||
/* ctx->Stencil.Ref[0], */ | |||||
/* ctx->Stencil.ValueMask[0] ); */ | |||||
/* ctx->Driver.StencilMask( ctx, ctx->Stencil.WriteMask[0] ); */ | |||||
/* ctx->Driver.StencilOp( ctx, */ | |||||
/* ctx->Stencil.FailFunc[0], */ | |||||
/* ctx->Stencil.ZFailFunc[0], */ | |||||
/* ctx->Stencil.ZPassFunc[0]); */ | |||||
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] ); | |||||
} | } | ||||
/** | /** | ||||
/* Pixel path fallbacks. | /* Pixel path fallbacks. | ||||
*/ | */ | ||||
ctx->Driver.Accum = _swrast_Accum; | ctx->Driver.Accum = _swrast_Accum; | ||||
ctx->Driver.Bitmap = viaBitmap; | |||||
ctx->Driver.Bitmap = _swrast_Bitmap; | |||||
ctx->Driver.CopyPixels = _swrast_CopyPixels; | ctx->Driver.CopyPixels = _swrast_CopyPixels; | ||||
ctx->Driver.DrawPixels = _swrast_DrawPixels; | ctx->Driver.DrawPixels = _swrast_DrawPixels; | ||||
ctx->Driver.ReadPixels = _swrast_ReadPixels; | ctx->Driver.ReadPixels = _swrast_ReadPixels; |
*vb++ = ((HC_SubA_HROP << 24) | vmesa->regHROP); | *vb++ = ((HC_SubA_HROP << 24) | vmesa->regHROP); | ||||
i += 5; | i += 5; | ||||
if (vmesa->hasDepth && vmesa->hasStencil) { | |||||
if (vmesa->have_hw_stencil) { | |||||
GLuint pitch, format, offset; | GLuint pitch, format, offset; | ||||
format = HC_HZWBFM_24; | |||||
format = HC_HZWBFM_24; | |||||
offset = vmesa->depth.offset; | offset = vmesa->depth.offset; | ||||
pitch = vmesa->depth.pitch; | pitch = vmesa->depth.pitch; | ||||
*vb++ = ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)); | *vb++ = ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)); | ||||
*vb++ = ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)); | *vb++ = ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)); | ||||
*vb++ = ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | | *vb++ = ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | | ||||
format | pitch); | format | pitch); | ||||
pitch = vmesa->depth.pitch; | pitch = vmesa->depth.pitch; | ||||
*vb++ = ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)); | *vb++ = ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)); | ||||
*vb++ = ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)); | *vb++ = ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)); | ||||
*vb++ = ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | | *vb++ = ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | | ||||
format | pitch); | format | pitch); | ||||
*vb++ = ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD); | *vb++ = ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD); | ||||
i += 4; | i += 4; | ||||
} | } | ||||
else if (vmesa->hasStencil) { | |||||
GLuint pitch, format, offset; | |||||
format = HC_HZWBFM_24; | |||||
offset = vmesa->depth.offset; | |||||
pitch = vmesa->depth.pitch; | |||||
*vb++ = ((HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF)); | |||||
*vb++ = ((HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24)); | |||||
*vb++ = ((HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK | | |||||
format | pitch); | |||||
*vb++ = ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD); | |||||
/* set stencil */ | |||||
*vb++ = ((HC_SubA_HSTREF << 24) | vmesa->regHSTREF); | |||||
*vb++ = ((HC_SubA_HSTMD << 24) | vmesa->regHSTMD); | |||||
i += 6; | |||||
} | |||||
if (ctx->Color.AlphaEnabled) { | if (ctx->Color.AlphaEnabled) { | ||||
*vb++ = ((HC_SubA_HATMD << 24) | vmesa->regHATMD); | *vb++ = ((HC_SubA_HATMD << 24) | vmesa->regHATMD); | ||||
} | } | ||||
static void emit_partial_state(viaContextPtr vmesa) | |||||
{ | |||||
GLcontext *ctx = vmesa->glCtx; | |||||
GLuint dirty = vmesa->dirty; | |||||
GLuint *vb = viaCheckDma(vmesa, 0x110); | |||||
GLuint i = 0; | |||||
if( VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); | |||||
#ifdef PERFORMANCE_MEASURE | |||||
if (VIA_PERFORMANCE) P_M; | |||||
#endif | |||||
vb = vb; | |||||
*vb++ = HC_HEADER2; | |||||
*vb++ = (HC_ParaType_NotTex << 16); | |||||
*vb++ = ((HC_SubA_HEnable << 24) | vmesa->regEnable); | |||||
*vb++ = ((HC_SubA_HFBBMSKL << 24) | vmesa->regHFBBMSKL); | |||||
*vb++ = ((HC_SubA_HROP << 24) | vmesa->regHROP); | |||||
i += 5; | |||||
if (dirty & VIA_UPLOAD_DESTBUFFER) { | |||||
} | |||||
if (dirty & VIA_UPLOAD_DEPTHBUFFER) { | |||||
} | |||||
if (dirty * VIA_UPLOAD_DEPTH) { | |||||
*vb++ = ((HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD); | |||||
i++; | |||||
} | |||||
if (dirty * VIA_UPLOAD_ALPHATEST) { | |||||
*vb++ = ((HC_SubA_HATMD << 24) | vmesa->regHATMD); | |||||
i++; | |||||
} | |||||
if (dirty & VIA_UPLOAD_BLEND) { | |||||
*vb++ = ((HC_SubA_HABLCsat << 24) | vmesa->regHABLCsat); | |||||
*vb++ = ((HC_SubA_HABLCop << 24) | vmesa->regHABLCop); | |||||
*vb++ = ((HC_SubA_HABLAsat << 24) | vmesa->regHABLAsat); | |||||
*vb++ = ((HC_SubA_HABLAop << 24) | vmesa->regHABLAop); | |||||
*vb++ = ((HC_SubA_HABLRCa << 24) | vmesa->regHABLRCa); | |||||
*vb++ = ((HC_SubA_HABLRFCa << 24) | vmesa->regHABLRFCa); | |||||
*vb++ = ((HC_SubA_HABLRCbias << 24) | vmesa->regHABLRCbias); | |||||
*vb++ = ((HC_SubA_HABLRCb << 24) | vmesa->regHABLRCb); | |||||
*vb++ = ((HC_SubA_HABLRFCb << 24) | vmesa->regHABLRFCb); | |||||
*vb++ = ((HC_SubA_HABLRAa << 24) | vmesa->regHABLRAa); | |||||
*vb++ = ((HC_SubA_HABLRAb << 24) | vmesa->regHABLRAb); | |||||
i += 11; | |||||
} | |||||
if (dirty & VIA_UPLOAD_FOG) { | |||||
*vb++ = ((HC_SubA_HFogLF << 24) | vmesa->regHFogLF); | |||||
*vb++ = ((HC_SubA_HFogCL << 24) | vmesa->regHFogCL); | |||||
*vb++ = ((HC_SubA_HFogCH << 24) | vmesa->regHFogCH); | |||||
i += 3; | |||||
} | |||||
if (dirty & VIA_UPLOAD_LINESTIPPLE) { | |||||
*vb++ = ((HC_SubA_HLP << 24) | ctx->Line.StipplePattern); | |||||
*vb++ = ((HC_SubA_HLPRF << 24) | ctx->Line.StippleFactor); | |||||
} | |||||
else { | |||||
*vb++ = ((HC_SubA_HLP << 24) | 0xFFFF); | |||||
*vb++ = ((HC_SubA_HLPRF << 24) | 0x1); | |||||
} | |||||
i += 2; | |||||
*vb++ = ((HC_SubA_HPixGC << 24) | 0x0); | |||||
i++; | |||||
if (i & 0x1) { | |||||
*vb++ = HC_DUMMY; | |||||
i++; | |||||
} | |||||
if (dirty & VIA_UPLOAD_TEXTURE) { | |||||
} | |||||
if (dirty & VIA_UPLOAD_POLYGONSTIPPLE) { | |||||
} | |||||
vmesa->dmaLow += (i << 2); | |||||
vmesa->dirty = 0; | |||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); | |||||
} | |||||
/**********************************************************************/ | /**********************************************************************/ | ||||
/* High level hooks for t_vb_render.c */ | /* High level hooks for t_vb_render.c */ | ||||
vmesa->newState = 0; | vmesa->newState = 0; | ||||
} | } | ||||
if (vmesa->needUploadAllState) | |||||
emit_all_state(vmesa); | |||||
else | |||||
emit_partial_state(vmesa); | |||||
emit_all_state(vmesa); | |||||
_tnl_run_pipeline(ctx); | _tnl_run_pipeline(ctx); | ||||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); | if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); |