@@ -68,7 +68,6 @@ | |||
#ifdef DEBUG | |||
GLuint VIA_DEBUG = 0; | |||
#endif | |||
GLuint DRAW_FRONT = 0; | |||
#define DMA_SIZE 2 | |||
GLuint VIA_PERFORMANCE = 0; | |||
#ifdef PERFORMANCE_MEASURE | |||
@@ -211,12 +210,11 @@ calculate_buffer_parameters( viaContextPtr vmesa ) | |||
/* Allocate depth-buffer */ | |||
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; | |||
} | |||
else { | |||
@@ -233,7 +231,7 @@ calculate_buffer_parameters( viaContextPtr vmesa ) | |||
/*=* John Sheng [2003.5.31] flip *=*/ | |||
if( vmesa->viaScreen->width == vmesa->driDrawable->w && | |||
vmesa->viaScreen->height == vmesa->driDrawable->h ) { | |||
#define ALLOW_EXPERIMENTAL_PAGEFLIP 1 | |||
#define ALLOW_EXPERIMENTAL_PAGEFLIP 0 | |||
#if ALLOW_EXPERIMENTAL_PAGEFLIP | |||
vmesa->doPageFlip = GL_TRUE; | |||
#else | |||
@@ -406,31 +404,51 @@ viaCreateContext(const __GLcontextModes *mesaVis, | |||
sPriv->myNum, "via"); | |||
/* 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); | |||
viaInitTextureFuncs(&functions); | |||
@@ -452,19 +470,7 @@ viaCreateContext(const __GLcontextModes *mesaVis, | |||
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.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; | |||
ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; | |||
@@ -550,10 +556,9 @@ viaCreateContext(const __GLcontextModes *mesaVis, | |||
VIA_DEBUG = 0; | |||
#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 | |||
if (getenv("VIA_PERFORMANCE")) | |||
@@ -609,43 +614,6 @@ viaCreateContext(const __GLcontextModes *mesaVis, | |||
} | |||
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; | |||
} | |||
@@ -656,10 +624,10 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv) | |||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__); | |||
assert(vmesa); /* should never be null */ | |||
/* viaFlushPrimsLocked(vmesa); */ | |||
WAIT_IDLE | |||
if (vmesa) { | |||
/*=* John Sheng [2003.5.31] agp tex *=*/ | |||
WAIT_IDLE(vmesa); | |||
if(VIA_DEBUG) fprintf(stderr, "agpFullCount = %d\n", vmesa->agpFullCount); | |||
_swsetup_DestroyContext(vmesa->glCtx); | |||
@@ -687,6 +655,9 @@ void viaXMesaSetFrontClipRects(viaContextPtr vmesa) | |||
{ | |||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; | |||
if (!dPriv) | |||
return; | |||
vmesa->numClipRects = dPriv->numClipRects; | |||
vmesa->pClipRects = dPriv->pClipRects; | |||
vmesa->drawX = dPriv->x; | |||
@@ -700,202 +671,52 @@ void viaXMesaSetFrontClipRects(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) | |||
{ | |||
GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; | |||
#ifdef USE_XINERAMA | |||
GLuint side = 0; | |||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; | |||
#endif | |||
switch (vmesa->glCtx->Color._DrawDestMask[0]) { | |||
case __GL_FRONT_BUFFER_MASK: | |||
case DD_FRONT_LEFT_BIT: | |||
viaXMesaSetFrontClipRects(vmesa); | |||
break; | |||
case __GL_BACK_BUFFER_MASK: | |||
case DD_BACK_LEFT_BIT: | |||
viaXMesaSetBackClipRects(vmesa); | |||
break; | |||
default: | |||
viaXMesaSetFrontClipRects(vmesa); | |||
break; | |||
} | |||
#ifndef USE_XINERAMA | |||
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; | |||
pitch = vmesa->front.pitch; | |||
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); | |||
@@ -924,6 +745,7 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv, | |||
if (driContextPriv) { | |||
viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate; | |||
GLcontext *ctx = vmesa->glCtx; | |||
if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent: w = %d\n", vmesa->driDrawable->w); | |||
@@ -933,6 +755,7 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv, | |||
if ( ! calculate_buffer_parameters( vmesa ) ) { | |||
return GL_FALSE; | |||
} | |||
ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] ); | |||
} | |||
_mesa_make_current2(vmesa->glCtx, | |||
@@ -940,6 +763,8 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv, | |||
(GLframebuffer *)driReadPriv->driverPrivate); | |||
if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext); | |||
viaXMesaWindowMoved(vmesa); | |||
} | |||
else { | |||
_mesa_make_current(0,0); | |||
@@ -980,52 +805,6 @@ void viaGetLock(viaContextPtr vmesa, GLuint flags) | |||
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 | |||
viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate) |
@@ -40,9 +40,6 @@ typedef struct via_texture_object_t *viaTextureObjectPtr; | |||
#include "via_tex.h" | |||
#include "via_common.h" | |||
#include "xf86drmVIA.h" | |||
#ifdef USE_XINERAMA | |||
#include "../../../../../include/extensions/Xinerama.h" | |||
#endif | |||
#define VIA_FALLBACK_TEXTURE 0x1 | |||
#define VIA_FALLBACK_DRAW_BUFFER 0x2 | |||
#define VIA_FALLBACK_READ_BUFFER 0x4 | |||
@@ -53,6 +50,7 @@ typedef struct via_texture_object_t *viaTextureObjectPtr; | |||
#define VIA_FALLBACK_STENCIL 0x100 | |||
#define VIA_FALLBACK_BLEND_EQ 0x200 | |||
#define VIA_FALLBACK_BLEND_FUNC 0x400 | |||
#define VIA_FALLBACK_USER_DISABLE 0x800 | |||
#define VIA_UPLOAD_NONE 0x0000 | |||
#define VIA_UPLOAD_ALPHATEST 0x0001 | |||
@@ -116,6 +114,13 @@ struct via_context_t { | |||
GLboolean hasAccum; | |||
GLuint depthBits; | |||
GLuint stencilBits; | |||
GLboolean have_hw_stencil; | |||
GLuint ClearDepth; | |||
GLuint depth_clear_mask; | |||
GLuint stencil_clear_mask; | |||
GLfloat depth_scale; | |||
GLuint *dma; | |||
viaRegion tex; | |||
@@ -250,15 +255,6 @@ struct via_context_t { | |||
int drawW; | |||
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 readPitch; | |||
@@ -386,58 +382,26 @@ extern hash_element hash_table[HASH_TABLE_SIZE][HASH_TABLE_DEPTH]; | |||
/* 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) \ | |||
if(1) \ | |||
do { \ | |||
char __ret = 0; \ | |||
DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \ | |||
(DRM_LOCK_HELD|vmesa->hHWContext), __ret); \ | |||
if (__ret) \ | |||
viaGetLock(vmesa, 0); \ | |||
} while (0); \ | |||
else \ | |||
viaLock(vmesa, 0) | |||
} while (0) | |||
/* | |||
#define LOCK_HARDWARE(vmesa) \ | |||
viaLock(vmesa, 0); | |||
*/ | |||
/* 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) \ | |||
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) \ | |||
break; \ | |||
} | |||
} while (1) | |||
#define LOCK_HARDWARE_QUIESCENT(vmesa) \ | |||
do { \ | |||
@@ -453,7 +417,6 @@ extern GLuint VIA_DEBUG; | |||
#endif | |||
extern GLuint DRAW_FRONT; | |||
extern void viaGetLock(viaContextPtr vmesa, GLuint flags); | |||
extern void viaLock(viaContextPtr vmesa, GLuint flags); | |||
extern void viaUnLock(viaContextPtr vmesa, GLuint flags); |
@@ -29,9 +29,6 @@ typedef struct { | |||
int priv2; | |||
int fbOffset; | |||
int fbSize; | |||
#ifdef USE_XINERAMA | |||
Bool drixinerama; | |||
#endif | |||
int backOffset; | |||
int depthOffset; | |||
int textureOffset; |
@@ -39,18 +39,13 @@ void viaCopyBuffer(const __DRIdrawablePrivate *dpriv); | |||
void viaPageFlip(const __DRIdrawablePrivate *dpriv); | |||
int via_check_copy(int fd); | |||
void viaFillFrontBuffer(viaContextPtr vmesa); | |||
void viaFillFrontBufferSaam(viaContextPtr vmesa); | |||
void viaFillFrontPBuffer(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 viaDoSwapBuffersSaam(viaContextPtr vmesa); | |||
void viaDoSwapPBuffers(viaContextPtr vmesa); | |||
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); | |||
#define VIA_STATECHANGE(vmesa, flag) \ |
@@ -117,9 +117,6 @@ viaInitDriver(__DRIscreenPrivate *sPriv) | |||
viaScreen->irqEnabled = gDRIPriv->irqEnabled; | |||
viaScreen->irqEnabled = 1; | |||
#ifdef USE_XINERAMA | |||
viaScreen->drixinerama = gDRIPriv->drixinerama; | |||
#endif | |||
if (VIA_DEBUG) { | |||
fprintf(stderr, "deviceID = %08x\n", viaScreen->deviceID); | |||
fprintf(stderr, "width = %08x\n", viaScreen->width); | |||
@@ -219,36 +216,24 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv, | |||
const __GLcontextModes *mesaVis, | |||
GLboolean isPixmap) | |||
{ | |||
/* KW: Bogus: Do this sort of thing in MakeCurrent or similar. | |||
*/ | |||
viaContextPtr vmesa; | |||
viaContextPtr vmesa = 0; | |||
GET_CURRENT_CONTEXT(ctx); | |||
GLboolean swStencil = (mesaVis->stencilBits > 0 && | |||
mesaVis->depthBits != 24); | |||
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 (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) { | |||
driDrawPriv->driverPrivate = (void *) | |||
_mesa_create_framebuffer(mesaVis, | |||
GL_FALSE, /* software depth buffer? */ | |||
mesaVis->stencilBits > 0, | |||
swStencil, | |||
mesaVis->accumRedBits > 0, | |||
GL_FALSE /* s/w alpha planes */); | |||
@@ -260,7 +245,7 @@ viaCreateBuffer(__DRIscreenPrivate *driScrnPriv, | |||
driDrawPriv->driverPrivate = (void *) | |||
_mesa_create_framebuffer(mesaVis, | |||
GL_FALSE, /* software depth buffer? */ | |||
mesaVis->stencilBits > 0, | |||
swStencil, | |||
mesaVis->accumRedBits > 0, | |||
GL_FALSE /* s/w alpha planes */); | |||
@@ -44,9 +44,6 @@ typedef struct { | |||
int fbFormat; | |||
int fbOffset; | |||
int fbSize; | |||
#ifdef USE_XINERAMA | |||
Bool drixinerama; | |||
#endif | |||
int fbStride; | |||
@@ -32,28 +32,13 @@ | |||
#include "swrast/swrast.h" | |||
#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 \ | |||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||
viaScreenPrivate *viaScreen = vmesa->viaScreen; \ | |||
GLuint pitch = viaScreen->backPitch; \ | |||
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 && \ | |||
_y >= miny && _y < maxy) | |||
@@ -72,98 +57,36 @@ | |||
#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() \ | |||
} \ | |||
} while (0) | |||
#define HW_UNLOCK() \ | |||
UNLOCK_HARDWARE(vmesa); | |||
#define HW_UNLOCK() | |||
/* 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 | |||
#define LOCAL_VARS \ | |||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \ | |||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||
GLuint pitch = vmesa->drawPitch; \ | |||
GLuint height = dPriv->h; \ | |||
GLushort p; \ | |||
char *buf, *read_buf; \ | |||
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); \ | |||
read_buf = (char *)(vmesa->readMap); \ | |||
} \ | |||
@@ -203,15 +126,19 @@ | |||
*/ | |||
#undef LOCAL_VARS | |||
#undef LOCAL_DEPTH_VARS | |||
#undef INIT_MONO_PIXEL | |||
#undef DBG | |||
#define DBG 0 | |||
#define LOCAL_VARS \ | |||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \ | |||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||
GLuint pitch = vmesa->drawPitch; \ | |||
GLuint height = dPriv->h; \ | |||
GLuint p; \ | |||
char *buf, *read_buf; \ | |||
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); \ | |||
read_buf = (char *)(vmesa->readMap); \ | |||
} \ | |||
@@ -236,21 +163,15 @@ | |||
/* 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 \ | |||
viaContextPtr vmesa = VIA_CONTEXT(ctx); \ | |||
__DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ | |||
/*viaScreenPrivate *viaScreen = vmesa->viaScreen;*/ \ | |||
GLuint pitch = vmesa->depth.pitch; \ | |||
GLuint height = dPriv->h; \ | |||
char *buf = (char *)(vmesa->depth.map) | |||
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS | |||
#define WRITE_DEPTH(_x, _y, d) \ | |||
*(GLushort *)(buf + _x * 2 + _y * pitch) = d; | |||
@@ -272,21 +193,37 @@ | |||
#define TAG(x) via##x##_32 | |||
#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 | |||
#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, | |||
@@ -312,6 +249,23 @@ static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer, | |||
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) | |||
{ | |||
@@ -320,7 +274,7 @@ void viaInitSpanFuncs(GLcontext *ctx) | |||
swdd->SetBuffer = viaSetBuffer; | |||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); | |||
if (vmesa->viaScreen->bitsPerPixel == 0x10) { | |||
if (vmesa->viaScreen->bitsPerPixel == 16) { | |||
swdd->WriteRGBASpan = viaWriteRGBASpan_565; | |||
swdd->WriteRGBSpan = viaWriteRGBSpan_565; | |||
swdd->WriteMonoRGBASpan = viaWriteMonoRGBASpan_565; | |||
@@ -329,24 +283,44 @@ void viaInitSpanFuncs(GLcontext *ctx) | |||
swdd->ReadRGBASpan = viaReadRGBASpan_565; | |||
swdd->ReadRGBAPixels = viaReadRGBAPixels_565; | |||
} | |||
else if (vmesa->viaScreen->bitsPerPixel == 0x20) { | |||
else if (vmesa->viaScreen->bitsPerPixel == 32) { | |||
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->WriteDepthSpan = viaWriteDepthSpan_16; | |||
swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_16; | |||
swdd->ReadDepthPixels = viaReadDepthPixels_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->WriteDepthSpan = viaWriteDepthSpan_32; | |||
swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_32; | |||
swdd->ReadDepthPixels = viaReadDepthPixels_32; | |||
swdd->WriteDepthPixels = viaWriteDepthPixels_32; | |||
} | |||
swdd->SpanRenderStart = viaSpanRenderStart; | |||
swdd->SpanRenderFinish = viaSpanRenderFinish; | |||
swdd->WriteCI8Span = NULL; | |||
swdd->WriteCI32Span = NULL; |
@@ -195,7 +195,12 @@ static void viaScissor(GLcontext *ctx, GLint x, GLint y, | |||
GLsizei w, GLsizei h) | |||
{ | |||
viaContextPtr vmesa = VIA_CONTEXT(ctx); | |||
if (!vmesa->driDrawable) | |||
return; | |||
if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); | |||
if (ctx->Scissor.Enabled) { | |||
VIA_FIREVERTICES(vmesa); /* don't pipeline cliprect changes */ | |||
vmesa->uploadCliprects = GL_TRUE; | |||
@@ -257,6 +262,13 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode) | |||
FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE); | |||
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__); | |||
} | |||
@@ -296,40 +308,6 @@ static void viaPointSize(GLcontext *ctx, GLfloat sz) | |||
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 | |||
@@ -426,15 +404,8 @@ void viaCalcViewport(GLcontext *ctx) | |||
m[MAT_TX] = v[MAT_TX] + vmesa->drawXoff; | |||
m[MAT_SY] = - v[MAT_SY]; | |||
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, | |||
@@ -474,14 +445,86 @@ void viaInitState(GLcontext *ctx) | |||
vmesa->regCmdB = HC_ACMD_HCmdB | HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z; | |||
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] ); | |||
} | |||
/** | |||
@@ -1366,8 +1409,7 @@ void viaInitStateFuncs(GLcontext *ctx) | |||
/* Pixel path fallbacks. | |||
*/ | |||
ctx->Driver.Accum = _swrast_Accum; | |||
ctx->Driver.Bitmap = viaBitmap; | |||
ctx->Driver.Bitmap = _swrast_Bitmap; | |||
ctx->Driver.CopyPixels = _swrast_CopyPixels; | |||
ctx->Driver.DrawPixels = _swrast_DrawPixels; | |||
ctx->Driver.ReadPixels = _swrast_ReadPixels; |
@@ -754,16 +754,14 @@ static void emit_all_state(viaContextPtr vmesa) | |||
*vb++ = ((HC_SubA_HROP << 24) | vmesa->regHROP); | |||
i += 5; | |||
if (vmesa->hasDepth && vmesa->hasStencil) { | |||
if (vmesa->have_hw_stencil) { | |||
GLuint pitch, format, offset; | |||
format = HC_HZWBFM_24; | |||
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); | |||
@@ -793,33 +791,12 @@ static void emit_all_state(viaContextPtr vmesa) | |||
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); | |||
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) { | |||
*vb++ = ((HC_SubA_HATMD << 24) | vmesa->regHATMD); | |||
@@ -1222,97 +1199,6 @@ static void emit_all_state(viaContextPtr vmesa) | |||
} | |||
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 */ | |||
@@ -1352,10 +1238,7 @@ static void viaRunPipeline(GLcontext *ctx) | |||
vmesa->newState = 0; | |||
} | |||
if (vmesa->needUploadAllState) | |||
emit_all_state(vmesa); | |||
else | |||
emit_partial_state(vmesa); | |||
emit_all_state(vmesa); | |||
_tnl_run_pipeline(ctx); | |||
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); |