Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merged DGA video surface handling improvements, unified locking code.
Fixed matrox blit bug where src Y less than dst Y
Fixed hardware surface init when no resolution change
  • Loading branch information
Sam Lantinga committed Jul 13, 2001
1 parent 0d9c8e2 commit 79bd9f0
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 113 deletions.
25 changes: 11 additions & 14 deletions src/video/fbcon/SDL_fb3dfx.c
Expand Up @@ -32,18 +32,6 @@ static char rcsid =
#include "3dfx_mmio.h"


static int LockHWSurface(_THIS, SDL_Surface *surface)
{
if ( surface == SDL_VideoSurface ) {
tdfx_waitidle();
}
return(0);
}
static void UnlockHWSurface(_THIS, SDL_Surface *surface)
{
return;
}

/* Wait for vertical retrace */
static void WaitVBL(_THIS)
{
Expand All @@ -55,6 +43,10 @@ static void WaitVBL(_THIS)
while( (tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0 )
;
}
static void WaitIdle(_THIS)
{
tdfx_waitidle();
}

/* Sets video mem colorkey and accelerated blit function */
static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
Expand Down Expand Up @@ -86,6 +78,9 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT);
tdfx_out32(DSTSIZE, rect->w | (rect->h << 16));
tdfx_out32(LAUNCH_2D, dstX | (dstY << 16));

FB_AddBusySurface(dst);

return(0);
}

Expand Down Expand Up @@ -151,6 +146,9 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
tdfx_out32(DSTXY, dstX | (dstY << 16));
tdfx_out32(LAUNCH_2D, srcX | (srcY << 16));

FB_AddBusySurface(src);
FB_AddBusySurface(dst);

return(0);
}

Expand Down Expand Up @@ -185,9 +183,8 @@ void FB_3DfxAccel(_THIS, __u32 card)
{
/* We have hardware accelerated surface functions */
this->CheckHWBlit = CheckHWBlit;
this->LockHWSurface = LockHWSurface;
this->UnlockHWSurface = UnlockHWSurface;
wait_vbl = WaitVBL;
wait_idle = WaitIdle;

/* Reset the 3Dfx controller */
tdfx_out32(BRESERROR0, 0);
Expand Down
80 changes: 32 additions & 48 deletions src/video/fbcon/SDL_fbmatrox.c
Expand Up @@ -32,18 +32,6 @@ static char rcsid =
#include "matrox_mmio.h"


static int LockHWSurface(_THIS, SDL_Surface *surface)
{
if ( surface == SDL_VideoSurface ) {
mga_waitidle();
}
return(0);
}
static void UnlockHWSurface(_THIS, SDL_Surface *surface)
{
return;
}

/* Wait for vertical retrace - taken from the XFree86 Matrox driver */
static void WaitVBL(_THIS)
{
Expand All @@ -60,6 +48,10 @@ static void WaitVBL(_THIS)
while ( mga_in32(0x1E20) < count )
;
}
static void WaitIdle(_THIS)
{
mga_waitidle();
}

/* Sets video mem colorkey and accelerated blit function */
static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
Expand Down Expand Up @@ -91,8 +83,7 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
}

/* Set up the X/Y base coordinates */
dstX = 0;
dstY = ((char *)dst->pixels - mapped_mem) / SDL_VideoSurface->pitch;
FB_dst_to_xy(this, dst, &dstX, &dstY);

/* Adjust for the current rectangle */
dstX += rect->x;
Expand All @@ -104,19 +95,6 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
/* Set up the Y boundaries */
ydstlen = (rect->h | (dstY << 16));

#if 0 /* This old way doesn't work on the Matrox G450 */
/* Set up for color fill operation */
fillop = MGADWG_TRAP | MGADWG_SOLID |
MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO |
MGADWG_BFCOL | MGADWG_BLK;

/* Execute the operations! */
mga_wait(4);
mga_out32(MGAREG_FCOL, color);
mga_out32(MGAREG_FXBNDRY, fxbndry);
mga_out32(MGAREG_YDSTLEN, ydstlen);
mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, fillop);
#else
/* Set up for color fill operation */
fillop = MGADWG_TRAP | MGADWG_SOLID |
MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO;
Expand All @@ -127,7 +105,8 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
mga_out32(MGAREG_FCOL, color);
mga_out32(MGAREG_FXBNDRY, fxbndry);
mga_out32(MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen);
#endif

FB_AddBusySurface(dst);

return(0);
}
Expand All @@ -136,12 +115,12 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
SDL_VideoDevice *this;
int bpp;
int pitch, w, h;
int srcX, srcY;
int dstX, dstY;
Uint32 sign;
Uint32 sstart, sstop;
int sskip;
Uint32 start, stop;
int skip;
Uint32 blitop;

/* FIXME: For now, only blit to display surface */
Expand All @@ -151,16 +130,17 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,

/* Calculate source and destination base coordinates (in pixels) */
this = current_video;
srcX= 0; /* FIXME: Calculate this from memory offset */
srcY = ((char *)src->pixels - mapped_mem) / SDL_VideoSurface->pitch;
dstX = 0; /* FIXME: Calculate this from memory offset */
dstY = ((char *)dst->pixels - mapped_mem) / SDL_VideoSurface->pitch;
w = dstrect->w;
h = dstrect->h;
FB_dst_to_xy(this, src, &srcX, &srcY);
FB_dst_to_xy(this, dst, &dstX, &dstY);

/* Adjust for the current blit rectangles */
srcX += srcrect->x;
srcY += srcrect->y;
dstX += dstrect->x;
dstY += dstrect->y;
pitch = dst->pitch/dst->format->BytesPerPixel;

/* Set up the blit direction (sign) flags */
sign = 0;
Expand All @@ -169,19 +149,21 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
}
if ( srcY < dstY ) {
sign |= 4;
srcY += (h - 1);
dstY += (h - 1);
}

/* Set up the blit source row start, end, and skip (in pixels) */
bpp = src->format->BytesPerPixel;
sstop = sstart = ((srcY * SDL_VideoSurface->pitch)/bpp) + srcX;
stop = start = (srcY * pitch) + srcX;
if ( srcX < dstX ) {
sstart += (dstrect->w - 1);
start += (w - 1);
} else {
sstop += (dstrect->w - 1);
stop += (w - 1);
}
sskip = src->pitch/bpp;
if ( srcY < dstY ) {
sskip = -sskip;
skip = -pitch;
} else {
skip = pitch;
}

/* Set up the blit operation */
Expand Down Expand Up @@ -209,13 +191,16 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
}
mga_wait(7);
mga_out32(MGAREG_SGN, sign);
mga_out32(MGAREG_AR3, sstart);
mga_out32(MGAREG_AR0, sstop);
mga_out32(MGAREG_AR5, sskip);
mga_out32(MGAREG_FXBNDRY, (dstX | ((dstX + dstrect->w-1) << 16)));
mga_out32(MGAREG_YDSTLEN, (dstY << 16) | dstrect->h);
mga_out32(MGAREG_AR3, start);
mga_out32(MGAREG_AR0, stop);
mga_out32(MGAREG_AR5, skip);
mga_out32(MGAREG_FXBNDRY, (dstX | ((dstX + w-1) << 16)));
mga_out32(MGAREG_YDSTLEN, (dstY << 16) | h);
mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, blitop);

FB_AddBusySurface(src);
FB_AddBusySurface(dst);

return(0);
}

Expand Down Expand Up @@ -250,9 +235,8 @@ void FB_MatroxAccel(_THIS, __u32 card)
{
/* We have hardware accelerated surface functions */
this->CheckHWBlit = CheckHWBlit;
this->LockHWSurface = LockHWSurface;
this->UnlockHWSurface = UnlockHWSurface;
wait_vbl = WaitVBL;
wait_idle = WaitIdle;

/* The Matrox has an accelerated color fill */
this->info.blit_fill = 1;
Expand Down

0 comments on commit 79bd9f0

Please sign in to comment.