diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2004-12-22 19:30:02 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2004-12-22 19:30:02 +0000 |
commit | 7db50bb3a893ba0ec0ec2fe1ec54a07ff6472435 (patch) | |
tree | ad6d7b3d9781e0d71e52faecd161af5166ad8752 /src | |
parent | 922bfd70ffdf5e668f197d06937bd79ff6026557 (diff) |
Remove dead code.
Fix 24/8 depth/stencil visuals.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_context.c | 393 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_context.h | 65 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_dri.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_ioctl.c | 1001 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_ioctl.h | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_screen.c | 33 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_screen.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_span.c | 210 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_state.c | 148 | ||||
-rw-r--r-- | src/mesa/drivers/dri/unichrome/via_tris.c | 123 |
10 files changed, 600 insertions, 1386 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 326f34a0f9..bb1dfdd6ca 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -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) diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h index 41ce1ce095..187b81154f 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.h +++ b/src/mesa/drivers/dri/unichrome/via_context.h @@ -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); diff --git a/src/mesa/drivers/dri/unichrome/via_dri.h b/src/mesa/drivers/dri/unichrome/via_dri.h index 6a0331424d..01ca0ea55b 100644 --- a/src/mesa/drivers/dri/unichrome/via_dri.h +++ b/src/mesa/drivers/dri/unichrome/via_dri.h @@ -29,9 +29,6 @@ typedef struct { int priv2; int fbOffset; int fbSize; -#ifdef USE_XINERAMA - Bool drixinerama; -#endif int backOffset; int depthOffset; int textureOffset; diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c index 58a3012729..8f6768542c 100644 --- a/src/mesa/drivers/dri/unichrome/via_ioctl.c +++ b/src/mesa/drivers/dri/unichrome/via_ioctl.c @@ -90,218 +90,117 @@ typedef enum {VIABLIT_TRANSCOPY, VIABLIT_COPY, VIABLIT_FILL} ViaBlitOps; static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch) { - viaContextPtr vmesa = VIA_CONTEXT(ctx); - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - const GLuint colorMask = *((GLuint *)&ctx->Color.ColorMask); - int flag = 0; - GLuint scrn = 0, i = 0, side = 0; - scrn = vmesa->saam & S_MASK; - side = vmesa->saam & P_MASK; - if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); - VIA_FIREVERTICES(vmesa); - - if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) { - flag |= VIA_FRONT; - mask &= ~DD_FRONT_LEFT_BIT; - } - - if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) { - flag |= VIA_BACK; - mask &= ~DD_BACK_LEFT_BIT; - } - - if (mask & DD_DEPTH_BIT) { - if (ctx->Depth.Mask) - flag |= VIA_DEPTH; - mask &= ~DD_DEPTH_BIT; - } - - if (mask & DD_STENCIL_BIT) { - if (ctx->Stencil.Enabled) - flag |= VIA_STENCIL; - mask &= ~DD_STENCIL_BIT; - } + viaContextPtr vmesa = VIA_CONTEXT(ctx); + __DRIdrawablePrivate *dPriv = vmesa->driDrawable; + const GLuint colorMask = *((GLuint *)&ctx->Color.ColorMask); + int flag = 0; + GLuint i = 0; + GLuint clear_depth_mask = 0xf << 28; + GLuint clear_depth = 0; + + VIA_FIREVERTICES(vmesa); + + if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) { + flag |= VIA_FRONT; + mask &= ~DD_FRONT_LEFT_BIT; + } + + if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) { + flag |= VIA_BACK; + mask &= ~DD_BACK_LEFT_BIT; + } + + if (mask & DD_DEPTH_BIT) { + flag |= VIA_DEPTH; + clear_depth = (GLuint)(ctx->Depth.Clear * vmesa->ClearDepth); + clear_depth_mask &= ~vmesa->depth_clear_mask; + mask &= ~DD_DEPTH_BIT; + } - /*=* [DBG] make draw to front buffer *=*/ - if(DRAW_FRONT) { - flag |= VIA_FRONT; - flag &= ~VIA_BACK; - } + if (mask & DD_STENCIL_BIT) { + if (vmesa->have_hw_stencil) { + if (ctx->Stencil.WriteMask[0] == 0xff) { + flag |= VIA_DEPTH; + clear_depth &= ~0xff; + clear_depth |= (ctx->Stencil.Clear & 0xff); + clear_depth_mask &= ~vmesa->stencil_clear_mask; + mask &= ~DD_STENCIL_BIT; + } + else { + fprintf(stderr, "XXX: Clear stencil writemask %x -- need triangles (or a ROP?)\n", + ctx->Stencil.WriteMask[0]); + /* Fixme - clear with triangles */ + } + } + } - if (flag) { - LOCK_HARDWARE(vmesa); - /* flip top to bottom */ - cy = dPriv->h - cy - ch; - cx += vmesa->drawX; - cy += vmesa->drawY; + if (flag) { + LOCK_HARDWARE(vmesa); + /* flip top to bottom */ + cy = dPriv->h - cy - ch; + cx += vmesa->drawX; + cy += vmesa->drawY; - if (vmesa->numClipRects) { - int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, vmesa->numClipRects); - drm_clip_rect_t *box = vmesa->pClipRects; - drm_clip_rect_t *b = vmesa->sarea->boxes; - int n = 0; + if (vmesa->numClipRects) { + int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, vmesa->numClipRects); + drm_clip_rect_t *box = vmesa->pClipRects; + drm_clip_rect_t *b = vmesa->sarea->boxes; + int n = 0; - if (!vmesa->saam) { - if (!all) { - if (VIA_DEBUG) fprintf(stderr,"!all"); - for (; i < nr; i++) { - GLint x = box[i].x1; - GLint y = box[i].y1; - GLint w = box[i].x2 - x; - GLint h = box[i].y2 - y; - - if (x < cx) w -= cx - x, x = cx; - if (y < cy) h -= cy - y, y = cy; - if (x + w > cx + cw) w = cx + cw - x; - if (y + h > cy + ch) h = cy + ch - y; - if (w <= 0) continue; - if (h <= 0) continue; - - b->x1 = x; - b->y1 = y; - b->x2 = x + w; - b->y2 = y + h; - b++; - n++; - } - } - else { - for (; i < nr; i++) { - *b++ = *(drm_clip_rect_t *)&box[i]; - n++; - } - } - vmesa->sarea->nbox = n; + if (!all) { + for (; i < nr; i++) { + GLint x = box[i].x1; + GLint y = box[i].y1; + GLint w = box[i].x2 - x; + GLint h = box[i].y2 - y; + + if (x < cx) w -= cx - x, x = cx; + if (y < cy) h -= cy - y, y = cy; + if (x + w > cx + cw) w = cx + cw - x; + if (y + h > cy + ch) h = cy + ch - y; + if (w <= 0) continue; + if (h <= 0) continue; + + b->x1 = x; + b->y1 = y; + b->x2 = x + w; + b->y2 = y + h; + b++; + n++; } - else { - GLuint scrn = 0; - scrn = vmesa->saam & S_MASK; - - if (scrn == S0 || scrn == S1) { - if (!all) { - for (; i < nr; i++) { - GLint x = box[i].x1; - GLint y = box[i].y1; - GLint w = box[i].x2 - x; - GLint h = box[i].y2 - y; - - if (x < cx) w -= cx - x, x = cx; - if (y < cy) h -= cy - y, y = cy; - if (x + w > cx + cw) w = cx + cw - x; - if (y + h > cy + ch) h = cy + ch - y; - if (w <= 0) continue; - if (h <= 0) continue; - - b->x1 = x; - b->y1 = y; - b->x2 = x + w; - b->y2 = y + h; - b++; - n++; - } - } - else { - for (; i < nr; i++) { - *b++ = *(drm_clip_rect_t *)&box[i]; - n++; - } - } - vmesa->sarea->nbox = n; - } - /* between */ - else { - if (!all) { - for (; i < nr; i++) { - GLint x = box[i].x1; - GLint y = box[i].y1; - GLint w = box[i].x2 - x; - GLint h = box[i].y2 - y; - - if (x < cx) w -= cx - x, x = cx; - if (y < cy) h -= cy - y, y = cy; - if (x + w > cx + cw) w = cx + cw - x; - if (y + h > cy + ch) h = cy + ch - y; - if (w <= 0) continue; - if (h <= 0) continue; - - b->x1 = x; - b->y1 = y; - b->x2 = x + w; - b->y2 = y + h; - b++; - n++; - } - - } - else { - for (; i < nr; i++) { - *b++ = *(drm_clip_rect_t *)&box[n]; - n++; - } - } - *b++ = *(drm_clip_rect_t *)vmesa->pSaamRects; - vmesa->sarea->nbox = n; - } + } + else { + for (; i < nr; i++) { + *b++ = *(drm_clip_rect_t *)&box[i]; + n++; } + } + vmesa->sarea->nbox = n; + + } - { - if (flag & VIA_FRONT) { - - if (vmesa->drawType == GLX_PBUFFER_BIT) - viaFillFrontPBuffer(vmesa); - else - viaFillFrontBuffer(vmesa); - - if (vmesa->saam && (scrn == (S0 | S1))) { - nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, vmesa->numSaamRects); - box = vmesa->pSaamRects; - b = vmesa->sarea->boxes; - n = 0; - - for (i = 0; i < nr; i++) { - *b++ = *(drm_clip_rect_t *)&box[n]; - n++; - } - - vmesa->sarea->nbox = n; - viaFillFrontBufferSaam(vmesa); - } - } + if (flag & VIA_FRONT) { + if (vmesa->drawType == GLX_PBUFFER_BIT) + viaFillFrontPBuffer(vmesa); + else + viaFillFrontBuffer(vmesa); + } - if (flag & VIA_BACK) { - viaFillBackBuffer(vmesa); - } + if (flag & VIA_BACK) { + viaFillBackBuffer(vmesa); + } - if (flag & VIA_DEPTH) { - double depth_clamp, range = 0xffffffff; - if (vmesa->hasStencil == 0) { - if (vmesa->depthBits == 32) { - depth_clamp = ((double)ctx->Depth.Clear)*range; - viaFillDepthBuffer(vmesa, (GLuint)depth_clamp); - } - else { - depth_clamp = ((double)ctx->Depth.Clear)*range; - viaFillDepthBuffer(vmesa, (GLuint)depth_clamp); - } - } - else { - depth_clamp = ((double)ctx->Depth.Clear)*range; - viaFillStencilDepthBuffer(vmesa, (GLuint)depth_clamp); - } - } - /*=* [DBG] Fix tuxracer depth error *=*/ - else if (flag & VIA_STENCIL) { - viaFillStencilBuffer(vmesa, (GLuint)ctx->Stencil.Clear); - } - } - } - UNLOCK_HARDWARE(vmesa); - vmesa->uploadCliprects = GL_TRUE; - } + if (flag & VIA_DEPTH) { + viaFillDepthBuffer(vmesa, clear_depth, clear_depth_mask); + } - if (mask) - _swrast_Clear(ctx, mask, all, cx, cy, cw, ch); - if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); + UNLOCK_HARDWARE(vmesa); + vmesa->uploadCliprects = GL_TRUE; + } + + if (mask) + _swrast_Clear(ctx, mask, all, cx, cy, cw, ch); + if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); } /* @@ -309,110 +208,61 @@ static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all, */ void viaCopyBuffer(const __DRIdrawablePrivate *dPriv) { - viaContextPtr vmesa; - drm_clip_rect_t *pbox; - int nbox, i; - GLuint scrn = 0, side = 0; - GLboolean missed_target; - int64_t ust; - - if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); - assert(dPriv); - assert(dPriv->driContextPriv); - assert(dPriv->driContextPriv->driverPrivate); - - vmesa = (viaContextPtr)dPriv->driContextPriv->driverPrivate; + viaContextPtr vmesa; + drm_clip_rect_t *pbox; + int nbox, i; + GLboolean missed_target; + int64_t ust; + + if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); + assert(dPriv); + assert(dPriv->driContextPriv); + assert(dPriv->driContextPriv->driverPrivate); + + vmesa = (viaContextPtr)dPriv->driContextPriv->driverPrivate; - VIA_FIREVERTICES(vmesa); + VIA_FIREVERTICES(vmesa); - driWaitForVBlank( dPriv, & vmesa->vbl_seq, vmesa->vblank_flags, & missed_target ); - LOCK_HARDWARE(vmesa); - - scrn = vmesa->saam & S_MASK; - side = vmesa->saam & P_MASK; + driWaitForVBlank( dPriv, & vmesa->vbl_seq, vmesa->vblank_flags, & missed_target ); + LOCK_HARDWARE(vmesa); - pbox = vmesa->pClipRects; - nbox = vmesa->numClipRects; + pbox = vmesa->pClipRects; + nbox = vmesa->numClipRects; - if (VIA_DEBUG) fprintf(stderr, "%s %d cliprects (%d), SAAM (%d)\n", - __FUNCTION__, nbox, vmesa->drawType, vmesa->saam); + if (VIA_DEBUG) fprintf(stderr, "%s %d cliprects (%d)\n", + __FUNCTION__, nbox, vmesa->drawType); - if (vmesa->drawType == GLX_PBUFFER_BIT) { - viaDoSwapPBuffers(vmesa); - if (VIA_DEBUG) fprintf(stderr, "%s SwapPBuffers\n", __FUNCTION__); - } - else { - GLuint scrn = 0; - scrn = vmesa->saam & S_MASK; - if (!vmesa->saam) { - for (i = 0; i < nbox; ) { - int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, dPriv->numClipRects); - drm_clip_rect_t *b = (drm_clip_rect_t *)vmesa->sarea->boxes; - - vmesa->sarea->nbox = nr - i; - - for (; i < nr; i++) - *b++ = pbox[i]; - viaDoSwapBuffers(vmesa); - if (VIA_DEBUG) fprintf(stderr, "%s SwapBuffers\n", __FUNCTION__); - } - } - else if (scrn == S0 || scrn == S1) { - for (i = 0; i < nbox; ) { - int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, vmesa->numClipRects); - drm_clip_rect_t *b = (drm_clip_rect_t *)vmesa->sarea->boxes; - - vmesa->sarea->nbox = nr - i; - - for (; i < nr; i++) { - *b++ = pbox[i]; - } - viaDoSwapBuffers(vmesa); - } - } - /* between */ - else { - for (i = 0; i < nbox; ) { - int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, dPriv->numClipRects); - drm_clip_rect_t *b = (drm_clip_rect_t *)vmesa->sarea->boxes; - - vmesa->sarea->nbox = nr - i; - - for (; i < nr; i++) - *b++ = pbox[i]; - viaDoSwapBuffers(vmesa); - } - - pbox = vmesa->pSaamRects; - nbox = vmesa->numSaamRects; - - for (i = 0; i < nbox; ) { - int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, vmesa->numSaamRects); - drm_clip_rect_t *b = (drm_clip_rect_t *)vmesa->sarea->boxes; - - vmesa->sarea->nbox = nr - i; - - for (; i < nr; i++) - *b++ = pbox[i]; - - viaDoSwapBuffersSaam(vmesa); - } - } - } - UNLOCK_HARDWARE(vmesa); - vmesa->uploadCliprects = GL_TRUE; - - vmesa->swap_count++; - (*vmesa->get_ust)( & ust ); - if ( missed_target ) { - vmesa->swap_missed_count++; - vmesa->swap_missed_ust = ust - vmesa->swap_ust; - } + if (vmesa->drawType == GLX_PBUFFER_BIT) { + viaDoSwapPBuffers(vmesa); + if (VIA_DEBUG) fprintf(stderr, "%s SwapPBuffers\n", __FUNCTION__); + } + else { + for (i = 0; i < nbox; ) { + int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, dPriv->numClipRects); + drm_clip_rect_t *b = (drm_clip_rect_t *)vmesa->sarea->boxes; + + vmesa->sarea->nbox = nr - i; + + for (; i < nr; i++) + *b++ = pbox[i]; + viaDoSwapBuffers(vmesa); + if (VIA_DEBUG) fprintf(stderr, "%s SwapBuffers\n", __FUNCTION__); + } + } + UNLOCK_HARDWARE(vmesa); + vmesa->uploadCliprects = GL_TRUE; + + vmesa->swap_count++; + (*vmesa->get_ust)( & ust ); + if ( missed_target ) { + vmesa->swap_missed_count++; + vmesa->swap_missed_ust = ust - vmesa->swap_ust; + } - vmesa->swap_ust = ust; + vmesa->swap_ust = ust; - if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); + if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); } /* @@ -436,10 +286,6 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv) ctx = vmesa->glCtx; - /*=* [DBG] make draw to front buffer *=*/ - if(DRAW_FRONT) - return; - VIA_FIREVERTICES(vmesa); /* Now wait for the vblank: @@ -514,7 +360,7 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv) if(vmesa->currentPage) { vmesa->currentPage = 0; - if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { + if (vmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT) { ctx->Driver.DrawBuffer(ctx, GL_BACK); } else { @@ -523,7 +369,7 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv) } else { vmesa->currentPage = 1; - if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { + if (vmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT) { ctx->Driver.DrawBuffer(ctx, GL_BACK); } else { @@ -569,268 +415,163 @@ static int intersect_rect(drm_clip_rect_t *out, void viaFlushPrimsLocked(viaContextPtr vmesa) { - drm_clip_rect_t *pbox = (drm_clip_rect_t *)vmesa->pClipRects; - int nbox = vmesa->numClipRects; - drm_via_sarea_t *sarea = vmesa->sarea; - drm_via_flush_sys_t sysCmd; - GLuint *vb = viaCheckDma(vmesa, 0); - int i; - - if (*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|vmesa->hHWContext) && - *(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) - fprintf(stderr, "%s called without lock held\n", __FUNCTION__); - - if (vmesa->dmaLow == DMA_OFFSET) { - return; - } - if (vmesa->dmaLow > (VIA_DMA_BUFSIZ - 256)) - fprintf(stderr, "buffer overflow in Flush Prims = %d\n",vmesa->dmaLow); + drm_clip_rect_t *pbox = (drm_clip_rect_t *)vmesa->pClipRects; + int nbox = vmesa->numClipRects; + drm_via_sarea_t *sarea = vmesa->sarea; + drm_via_flush_sys_t sysCmd; + GLuint *vb = viaCheckDma(vmesa, 0); + int i; + + if (*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|vmesa->hHWContext) && + *(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) + fprintf(stderr, "%s called without lock held\n", __FUNCTION__); + + if (vmesa->dmaLow == DMA_OFFSET) { + return; + } + if (vmesa->dmaLow > (VIA_DMA_BUFSIZ - 256)) + fprintf(stderr, "buffer overflow in Flush Prims = %d\n",vmesa->dmaLow); - switch (vmesa->dmaLow & 0x1F) { - case 8: - *vb++ = HC_HEADER2; - *vb++ = (HC_ParaType_NotTex << 16); - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - vmesa->dmaLow += 24; - break; - case 16: - *vb++ = HC_HEADER2; - *vb++ = (HC_ParaType_NotTex << 16); - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - vmesa->dmaLow += 16; - break; - case 24: - *vb++ = HC_HEADER2; - *vb++ = (HC_ParaType_NotTex << 16); - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - *vb++ = HC_DUMMY; - vmesa->dmaLow += 40; - break; - case 0: - break; - default: - break; - } + switch (vmesa->dmaLow & 0x1F) { + case 8: + *vb++ = HC_HEADER2; + *vb++ = (HC_ParaType_NotTex << 16); + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + vmesa->dmaLow += 24; + break; + case 16: + *vb++ = HC_HEADER2; + *vb++ = (HC_ParaType_NotTex << 16); + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + vmesa->dmaLow += 16; + break; + case 24: + *vb++ = HC_HEADER2; + *vb++ = (HC_ParaType_NotTex << 16); + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + *vb++ = HC_DUMMY; + vmesa->dmaLow += 40; + break; + case 0: + break; + default: + break; + } - sysCmd.offset = 0x0; - sysCmd.size = vmesa->dmaLow; - sysCmd.index = (GLuint)vmesa->dma; - sysCmd.discard = 0; + sysCmd.offset = 0x0; + sysCmd.size = vmesa->dmaLow; + sysCmd.index = (GLuint)vmesa->dma; + sysCmd.discard = 0; - sarea->vertexPrim = vmesa->hwPrimitive; + sarea->vertexPrim = vmesa->hwPrimitive; - if (!nbox) { + if (!nbox) { sysCmd.size = 0; - } - else if (nbox > VIA_NR_SAREA_CLIPRECTS) { - vmesa->uploadCliprects = GL_TRUE; - } - - if (!nbox || !vmesa->uploadCliprects) { - if (nbox == 1) - sarea->nbox = 0; - else - sarea->nbox = nbox; - - sysCmd.discard = 1; - flush_sys(vmesa, &sysCmd); - } - else { - GLuint scrn; - GLuint side; - scrn = vmesa->saam & S_MASK; - side = vmesa->saam & P_MASK; - - for (i = 0; i < nbox; ) { - int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, nbox); - drm_clip_rect_t *b = sarea->boxes; - - if (!vmesa->saam) { - if (vmesa->glCtx->Scissor.Enabled) { - sarea->nbox = 0; - - for (; i < nr; i++) { - b->x1 = pbox[i].x1 - vmesa->drawX; - b->y1 = pbox[i].y1 - vmesa->drawY; - b->x2 = pbox[i].x2 - vmesa->drawX; - b->y2 = pbox[i].y2 - vmesa->drawY; - if (intersect_rect(b, b, &vmesa->scissorRect)) { - sarea->nbox++; - b++; - } - } - if (!sarea->nbox) { - if (nr < nbox) continue; - sysCmd.size = 0; - } - } - else { - sarea->nbox = nr - i; - for (; i < nr; i++, b++) { - b->x1 = pbox[i].x1 - vmesa->drawX; - b->y1 = pbox[i].y1 - vmesa->drawY; - b->x2 = pbox[i].x2 - vmesa->drawX; - b->y2 = pbox[i].y2 - vmesa->drawY; - } - } - } - else if (scrn == S0 || scrn == S1){ - if (vmesa->scissor) { - sarea->nbox = 0; - for (; i < nr; i++) { - b->x1 = pbox[i].x1 - vmesa->drawX; - b->y1 = pbox[i].y1 - vmesa->drawY; - b->x2 = pbox[i].x2 - vmesa->drawX; - b->y2 = pbox[i].y2 - vmesa->drawY; - if (intersect_rect(b, b, &vmesa->scissorRect)) { - sarea->nbox++; - b++; - } - } - if (!sarea->nbox) { - if (nr < nbox) continue; - sysCmd.size = 0; - } - } - else { - sarea->nbox = nr - i; - for (; i < nr; i++, b++) { - b->x1 = pbox[i].x1 - vmesa->drawX; - b->y1 = pbox[i].y1 - vmesa->drawY; - b->x2 = pbox[i].x2 - vmesa->drawX; - b->y2 = pbox[i].y2 - vmesa->drawY; - } - } - + } + else if (nbox > VIA_NR_SAREA_CLIPRECTS) { + vmesa->uploadCliprects = GL_TRUE; + } + + if (!nbox || !vmesa->uploadCliprects) { + if (nbox == 1) + sarea->nbox = 0; + else + sarea->nbox = nbox; + + sysCmd.discard = 1; + flush_sys(vmesa, &sysCmd); + } + else { + for (i = 0; i < nbox; ) { + int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, nbox); + drm_clip_rect_t *b = sarea->boxes; + + if (vmesa->glCtx->Scissor.Enabled) { + sarea->nbox = 0; + + for (; i < nr; i++) { + b->x1 = pbox[i].x1 - vmesa->drawX; + b->y1 = pbox[i].y1 - vmesa->drawY; + b->x2 = pbox[i].x2 - vmesa->drawX; + b->y2 = pbox[i].y2 - vmesa->drawY; + if (intersect_rect(b, b, &vmesa->scissorRect)) { + sarea->nbox++; + b++; + } } - /* between */ - else { - if (vmesa->scissor) { - sarea->nbox = 0; - for (; i < nr; i++) { - b->x1 = pbox[i].x1 - vmesa->drawX; - b->y1 = pbox[i].y1 - vmesa->drawY; - b->x2 = pbox[i].x2 - vmesa->drawX; - b->y2 = pbox[i].y2 - vmesa->drawY; - - if (intersect_rect(b, b, &vmesa->scissorRect)) { - sarea->nbox++; - b++; - } - } - if (!sarea->nbox) { - if (nr < nbox) continue; - sysCmd.size = 0; - } - } - else { - sarea->nbox = nr - i; - for (; i < nr; i++, b++) { - b->x1 = pbox[i].x1 - vmesa->drawX; - b->y1 = pbox[i].y1 - vmesa->drawY; - b->x2 = pbox[i].x2 - vmesa->drawX; - b->y2 = pbox[i].y2 - vmesa->drawY; - } - } + if (!sarea->nbox) { + if (nr < nbox) continue; + sysCmd.size = 0; } - - if (nr == nbox) { - sysCmd.discard = 1; - flush_sys(vmesa, &sysCmd); + } + else { + sarea->nbox = nr - i; + for (; i < nr; i++, b++) { + b->x1 = pbox[i].x1 - vmesa->drawX; + b->y1 = pbox[i].y1 - vmesa->drawY; + b->x2 = pbox[i].x2 - vmesa->drawX; + b->y2 = pbox[i].y2 - vmesa->drawY; } - - if (scrn == (S0 | S1)) { - pbox = (drm_clip_rect_t *)vmesa->pSaamRects; - nbox = vmesa->numSaamRects; - for (i = 0; i < nbox; ) { - int nr = MIN2(i + VIA_NR_SAREA_CLIPRECTS, nbox); - drm_clip_rect_t *b = sarea->boxes; - if (vmesa->scissor) { - sarea->nbox = 0; - for (; i < nr; i++) { - b->x1 = pbox[i].x1 - vmesa->drawXSaam; - b->y1 = pbox[i].y1 - vmesa->drawYSaam; - b->x2 = pbox[i].x2 - vmesa->drawXSaam; - b->y2 = pbox[i].y2 - vmesa->drawYSaam; - - if (intersect_rect(b, b, &vmesa->scissorRect)) { - sarea->nbox++; - b++; - } - } - if (!sarea->nbox) { - if (nr < nbox) continue; - sysCmd.size = 0; - } - } - else { - sarea->nbox = nr - i; - for (; i < nr; i++, b++) { - b->x1 = pbox[i].x1 - vmesa->drawXSaam; - b->y1 = pbox[i].y1 - vmesa->drawYSaam; - b->x2 = pbox[i].x2 - vmesa->drawXSaam; - b->y2 = pbox[i].y2 - vmesa->drawYSaam; - } - } - } - flush_sys(vmesa, &sysCmd); - } - } - } - if (VIA_DEBUG) { - GLuint i; - GLuint *data = (GLuint *)vmesa->dmaAddr; - for (i = 0; i < vmesa->dmaLow; i += 16) { - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x ", *data++); - fprintf(stderr, "%08x\n", *data++); - } - fprintf(stderr, "******************************************\n"); - } - /* Reset vmesa vars: - */ - vmesa->dmaLow = DMA_OFFSET; - vmesa->dmaAddr = (unsigned char *)vmesa->dma; - vmesa->dmaHigh = VIA_DMA_BUFSIZ; - vmesa->dmaLastPrim = DMA_OFFSET; + } + + if (nr == nbox) { + sysCmd.discard = 1; + flush_sys(vmesa, &sysCmd); + } + } + } + if (VIA_DEBUG) { + GLuint i; + GLuint *data = (GLuint *)vmesa->dmaAddr; + for (i = 0; i < vmesa->dmaLow; i += 16) { + fprintf(stderr, "%08x ", *data++); + fprintf(stderr, "%08x ", *data++); + fprintf(stderr, "%08x ", *data++); + fprintf(stderr, "%08x\n", *data++); + } + fprintf(stderr, "******************************************\n"); + } + /* Reset vmesa vars: + */ + vmesa->dmaLow = DMA_OFFSET; + vmesa->dmaAddr = (unsigned char *)vmesa->dma; + vmesa->dmaHigh = VIA_DMA_BUFSIZ; + vmesa->dmaLastPrim = DMA_OFFSET; } void viaFlushPrims(viaContextPtr vmesa) { - if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); + if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); - if (vmesa->dmaLow) { + if (vmesa->dmaLow) { LOCK_HARDWARE(vmesa); - viaFlushPrimsLocked(vmesa); + viaFlushPrimsLocked(vmesa); UNLOCK_HARDWARE(vmesa); - } - if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); + } + if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); } static void viaFlush(GLcontext *ctx) { viaContextPtr vmesa = VIA_CONTEXT(ctx); - if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); VIA_FIREVERTICES(vmesa); - if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); } static void viaFinish(GLcontext *ctx) { - if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__); - if (VIA_DEBUG) fprintf(stderr, "%s out\n", __FUNCTION__); - return; + viaContextPtr vmesa = VIA_CONTEXT(ctx); + VIA_FIREVERTICES(vmesa); + WAIT_IDLE(vmesa); } static void viaClearStencil(GLcontext *ctx, int s) @@ -857,6 +598,11 @@ GLuint *viaBlit(viaContextPtr vmesa, GLuint bpp,GLuint srcBase, GLuint dwGEMode = 0, srcY=0, srcX, dstY=0, dstX; GLuint cmd; + if (VIA_DEBUG) + fprintf(stderr, "%s bpp %d src %x/%x dst %x/%x w %d h %d dir %d,%d mode: %x color: 0x%08x mask 0x%08x\n", + __FUNCTION__, bpp, srcBase, srcPitch, dstBase, dstPitch, w,h, xdir, ydir, blitMode, color, nMask); + + if (!w || !h) return vb; @@ -943,30 +689,6 @@ void viaFillFrontBuffer(viaContextPtr vmesa) viaFlushPrimsLocked(vmesa); } -void viaFillFrontBufferSaam(viaContextPtr vmesa) -{ - GLuint nDestBase, nDestPitch, nDestWidth, nDestHeight,i; - drm_clip_rect_t *b = vmesa->sarea->boxes; - GLuint *vb = viaCheckDma(vmesa, vmesa->sarea->nbox*VIA_BLITSIZE); - GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; - GLuint pixel = (GLuint)vmesa->ClearColor; - - nDestPitch = vmesa->front.pitch; - - for (i = 0; i < vmesa->sarea->nbox ; i++) { - nDestWidth = b->x2 - b->x1; - nDestHeight = b->y2 - b->y1; - nDestBase = vmesa->viaScreen->fbOffset + - (vmesa->drawYSaam* nDestPitch + vmesa->drawXSaam * bytePerPixel); - vb = viaBlit(vmesa,vmesa->viaScreen->bitsPerPixel, nDestBase, nDestPitch, - nDestBase , nDestPitch, nDestWidth, nDestHeight, - 0,0,VIABLIT_FILL, pixel, 0x0, vb); - b++; - } - - viaFlushPrimsLocked(vmesa); -} - void viaFillFrontPBuffer(viaContextPtr vmesa) { GLuint nDestBase, nDestPitch, nDestWidth, nDestHeight, offset; @@ -990,7 +712,7 @@ void viaFillFrontPBuffer(viaContextPtr vmesa) void viaFillBackBuffer(viaContextPtr vmesa) { - GLuint nDestBase, nDestPitch, nDestWidth, nDestHeight, offsetX, offset; + GLuint nDestBase, nDestPitch, nDestWidth, nDestHeight, offset; GLcontext *ctx = vmesa->glCtx; GLuint *vb = viaCheckDma(vmesa, vmesa->sarea->nbox*VIA_BLITSIZE); GLuint pixel = (GLuint)vmesa->ClearColor; @@ -1000,7 +722,6 @@ void viaFillBackBuffer(viaContextPtr vmesa) if (VIA_DEBUG) fprintf(stderr, "Fill Back offset = %08x\n", offset); nDestBase = offset; nDestPitch = vmesa->back.pitch; - offsetX = vmesa->drawXoff; if (!ctx->Scissor.Enabled) { nDestWidth = (vmesa->back.pitch / bytePerPixel); @@ -1031,71 +752,27 @@ void viaFillBackBuffer(viaContextPtr vmesa) } } -void viaFillStencilDepthBuffer(viaContextPtr vmesa, GLuint pixel) -{ - GLuint nDestBase, nDestPitch, nDestWidth, nDestHeight, offsetX, offset; - GLuint *vb = viaCheckDma(vmesa, VIA_BLITSIZE); - - offset = vmesa->depth.offset; - if (VIA_DEBUG) fprintf(stderr, "Fill Stencil Depth offset = %08x\n", offset); - nDestBase = offset; - nDestPitch = vmesa->depth.pitch; - offsetX = vmesa->drawXoff; - pixel = pixel & 0xffffff00; - nDestWidth = (vmesa->depth.pitch / vmesa->depthBits * 8) - offsetX; - nDestHeight = vmesa->driDrawable->h; - - viaBlit(vmesa, vmesa->depth.bpp , nDestBase, nDestPitch, - nDestBase , nDestPitch, nDestWidth, nDestHeight, - 0,0,VIABLIT_FILL, pixel, 0x10000000, vb); - - if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { - viaFlushPrimsLocked(vmesa); - } -} - -void viaFillStencilBuffer(viaContextPtr vmesa, GLuint pixel) -{ - GLuint nDestBase, nDestPitch, nDestWidth, nDestHeight, offsetX, offset; - GLuint *vb = viaCheckDma(vmesa, VIA_BLITSIZE); - - offset = vmesa->depth.offset; - if (VIA_DEBUG) fprintf(stderr, "Fill Stencil offset = %08x\n", offset); - nDestBase = offset; - nDestPitch = vmesa->depth.pitch; - offsetX = vmesa->drawXoff; - pixel = pixel & 0x000000ff; - nDestWidth = (vmesa->depth.pitch / vmesa->depthBits * 8) - offsetX; - nDestHeight = vmesa->driDrawable->h; - - viaBlit(vmesa, vmesa->depth.bpp , nDestBase, nDestPitch, - nDestBase , nDestPitch, nDestWidth, nDestHeight, - 0,0,VIABLIT_FILL, pixel, 0xe0000000, vb); - if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { - viaFlushPrimsLocked(vmesa); - } -} - -void viaFillDepthBuffer(viaContextPtr vmesa, GLuint pixel) +void viaFillDepthBuffer(viaContextPtr vmesa, GLuint pixel, GLuint mask) { GLuint nDestBase, nDestPitch, nDestWidth, nDestHeight, offsetX, offset; GLuint *vb = viaCheckDma(vmesa, VIA_BLITSIZE); offset = vmesa->depth.offset; - if (VIA_DEBUG) fprintf(stderr, "Fill Depth offset = %08x\n", offset); + if (VIA_DEBUG) + fprintf(stderr, "Fill Depth offset = %08x, pixel %x, mask %x\n", offset, pixel, mask); nDestBase = offset; nDestPitch = vmesa->depth.pitch; offsetX = vmesa->drawXoff; - nDestWidth = (vmesa->depth.pitch / vmesa->depthBits * 8) - offsetX; + nDestWidth = (vmesa->depth.pitch / vmesa->depth.bpp * 8) - offsetX; nDestHeight = vmesa->driDrawable->h; viaBlit(vmesa, vmesa->depth.bpp , nDestBase, nDestPitch, nDestBase , nDestPitch, nDestWidth, nDestHeight, - 0,0,VIABLIT_FILL, pixel, 0, vb); + 0,0,VIABLIT_FILL, pixel, mask, vb); - if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { + if (vmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT) { viaFlushPrimsLocked(vmesa); } } @@ -1114,10 +791,6 @@ void viaDoSwapBuffers(viaContextPtr vmesa) nFrontPitch = vmesa->front.pitch; nBackPitch = vmesa->back.pitch; - /*=* [DBG] make draw to front buffer *=*/ - if(DRAW_FRONT) - return; - for (i = 0; i < vmesa->sarea->nbox; i++) { /* Width, Height */ @@ -1139,79 +812,6 @@ void viaDoSwapBuffers(viaContextPtr vmesa) if (VIA_DEBUG) fprintf(stderr, "Do Swap Buffer\n"); } -void viaDoSwapBuffersSaam(viaContextPtr vmesa) -{ - GLuint *vb = viaCheckDma(vmesa, vmesa->sarea->nbox*56 + 8); - GLuint nFrontPitch; - GLuint nBackPitch; - GLuint nFrontWidth, nFrontHeight, nBackWidth, nBackHeight; - GLuint nFrontBase, nBackBase; - GLuint nFrontOffsetX, nFrontOffsetY, nBackOffsetX, nBackOffsetY; - drm_clip_rect_t *b = vmesa->sarea->boxes; - GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; - GLuint i, blitMode; - GLuint EngStatus = *(vmesa->pnGEMode); - - switch(bytePerPixel) { - case 4: - blitMode = 0x300; - break; - case 2: - blitMode = 0x100; - break; - default: - blitMode = 0x000; - break; - } - - /* Restore mode */ - SetReg2DAGP(0x04, (EngStatus & 0xFFFFFCFF) | blitMode); - - - nFrontPitch = vmesa->front.pitch; - nBackPitch = vmesa->back.pitch; - - /* Caculate Base */ - nFrontBase = vmesa->viaScreen->fbSize + (vmesa->drawYSaam * nFrontPitch + vmesa->drawXSaam * bytePerPixel); - nBackBase = vmesa->back.offset; - /* 128 bit alignment*/ - nFrontBase = nFrontBase & 0xffffffe0; - - /*=* [DBG] make draw to front buffer *=*/ - if(DRAW_FRONT) - return; - - for (i = 0; i < vmesa->sarea->nbox; i++) { - /* Width, Height */ - nFrontWidth = nBackWidth = b->x2 - b->x1 - 1; - nFrontHeight = nBackHeight = b->y2 - b->y1 - 1; - /* Offset */ - nFrontOffsetX = (b->x1 - vmesa->drawXSaam) + vmesa->drawXoff; - nFrontOffsetY = b->y1 - vmesa->drawYSaam; - - nBackOffsetX = nFrontOffsetX; - nBackOffsetY = nFrontOffsetY; - /* GEWD */ - SetReg2DAGP(0x10, nFrontWidth | (nFrontHeight << 16)); - /* GEDST */ - SetReg2DAGP(0x0C, nFrontOffsetX | (nFrontOffsetY << 16)); - /* GESRC */ - SetReg2DAGP(0x08, nBackOffsetX | (nBackOffsetY << 16)); - /* GEDSTBASE */ - SetReg2DAGP(0x34, (nFrontBase >> 3)); - /* GESCRBASE */ - SetReg2DAGP(0x30, (nBackBase >> 3)); - /* GEPITCH */ - SetReg2DAGP(0x38, (((nFrontPitch >> 3) << 16) & 0x7FF0000) | 0x80000000 | - ((nBackPitch >> 3) & 0x7FF)); - /* BITBLT */ - SetReg2DAGP(0x0, 0x1 | 0xCC000000); - b++; - } - - viaFlushPrimsLocked(vmesa); - if (VIA_DEBUG) fprintf(stderr, "Do Swap Buffer\n"); -} void viaDoSwapPBuffers(viaContextPtr vmesa) { @@ -1296,11 +896,7 @@ int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf) pnBuf = (GLuint *)(buf->index + buf->offset); pnEnd = (GLuint *)((GLuint)pnBuf + buf->size); - /*=* [DBG] make draw to front buffer *=*/ - if(DRAW_FRONT) - vmesa->glCtx->Color._DrawDestMask[0] = __GL_FRONT_BUFFER_MASK; - - if (vmesa->glCtx->Color._DrawDestMask[0] == __GL_BACK_BUFFER_MASK) { + if (vmesa->glCtx->Color._DrawDestMask[0] == DD_BACK_LEFT_BIT) { *vb++ = HC_HEADER2; *vb++ = (HC_ParaType_NotTex << 16); @@ -1369,7 +965,7 @@ int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf) } } if (ret) { - if (vmesa->useAgp) WAIT_IDLE; + if (vmesa->useAgp) WAIT_IDLE(vmesa); /* for (i = 0; */ @@ -1457,7 +1053,9 @@ int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf) } if (ret) { - if (vmesa->useAgp) WAIT_IDLE; + if (vmesa->useAgp) + WAIT_IDLE(vmesa); + if (drmCommandWrite(vmesa->driFd, DRM_VIA_PCICMD, &bufI, sizeof(bufI))) { _mesa_error(vmesa->glCtx, GL_INVALID_OPERATION, __FUNCTION__); abort(); @@ -1472,6 +1070,7 @@ int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf) #if 0 /*=* John Sheng [2003.6.20] debug pci *=*/ +#if 0 if (VIA_DEBUG) { GLuint *pnEngBase = (GLuint *)((GLuint)pnMMIOBase + 0x400); int nStatus; diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.h b/src/mesa/drivers/dri/unichrome/via_ioctl.h index d178dda807..fec13c9362 100644 --- a/src/mesa/drivers/dri/unichrome/via_ioctl.h +++ b/src/mesa/drivers/dri/unichrome/via_ioctl.h @@ -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) \ diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index 1a47fe57c6..b7f049022b 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -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 */); diff --git a/src/mesa/drivers/dri/unichrome/via_screen.h b/src/mesa/drivers/dri/unichrome/via_screen.h index c70ff447fd..01613eac21 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.h +++ b/src/mesa/drivers/dri/unichrome/via_screen.h @@ -44,9 +44,6 @@ typedef struct { int fbFormat; int fbOffset; int fbSize; -#ifdef USE_XINERAMA - Bool drixinerama; -#endif int fbStride; diff --git a/src/mesa/drivers/dri/unichrome/via_span.c b/src/mesa/drivers/dri/unichrome/via_span.c index 343d1993fa..89cafa37ae 100644 --- a/src/mesa/drivers/dri/unichrome/via_span.c +++ b/src/mesa/drivers/dri/unichrome/via_span.c @@ -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; diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c index 8c5a45c983..bb06b327bb 100644 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ b/src/mesa/drivers/dri/unichrome/via_state.c @@ -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; diff --git a/src/mesa/drivers/dri/unichrome/via_tris.c b/src/mesa/drivers/dri/unichrome/via_tris.c index cf9c99bbd4..60b835d040 100644 --- a/src/mesa/drivers/dri/unichrome/via_tris.c +++ b/src/mesa/drivers/dri/unichrome/via_tris.c @@ -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__); |