From: Maneesh Sahani (maneesh@gatsby.ucl.ac.uk)
Date: Mon 14 Feb 2000 - 17:32:38 IST
I have just begun to use svgalib, so I apologise in advance if this
proves to be a newbie misunderstanding. It appears that gl_copyscreen()
is actually doing a memcpy(), even though I have pageflipping enabled.
I'm using an s3 card and svgalib-1.4.1. On startup svgalib reports:
svgalib: Using S3 driver (Trio64, 4096K) svgalib: s3: chipsets newer
than S3-864 is not supported well yet. svgalib: RAMDAC: Trio64: MCLK
= 40.091 MHz
Here's my test code (mostly lifted from the tutorial):
int main(void)
{
int flipmode;
struct timeval tic, toc;
int gmode = G640x480x256;
vga_init();
if (!vga_hasmode(gmode)) {
printf ("requested mode is not supported\n");
return 1;
}
vga_setmode(gmode);
gl_setcontextvga(gmode);
physicalscreen = gl_allocatecontext();
gl_getcontext(physicalscreen);
gl_setcontextvgavirtual(gmode);
virtualscreen = gl_allocatecontext();
gl_getcontext(virtualscreen);
flipmode = gl_enablepageflipping (physicalscreen);
printf ("%d cols, %d bpp (%s): %d buffers\n",
physicalscreen->colors,
physicalscreen->bytesperpixel,
gl_modetypes[physicalscreen->modetype],
flipmode);
gl_setcontext(virtualscreen);
draw(); /* draw into current context */
gettimeofday(&tic, NULL);
gl_copyscreen(physicalscreen);
gettimeofday(&toc, NULL);
getchar();
gl_clearscreen(0);
vga_setmode(0);
printf("gl_copyscreen took %gms\n",
(toc.tv_sec-tic.tv_sec)*1000 + (toc.tv_usec-tic.tv_usec)/1000.);
return 0;
}
The first printf confirms that I have 256 colours, 8bpp, the mode is
CONTEXT_PAGED (gl_modetypes is a static char *[]) and triplebuffering
is enabled.
The time elapsed in the gl_copyscreen() is about 6.5ms. This time is
exactly the same if I remove the gl_enablepageflipping() call.
It appears that gl_copyscreen is written so that a memcpy occurs in
some cases even if gl_enablepageflipping() has succeeded. In
particular the block (grlib.c:854-866):
int soffset = 0;
int doffset = screenoffset;
size = SCREENSIZE(__currentcontext);
while (soffset < size) {
int schunk, dchunk;
int count;
schunk = __svgalib_driver_setread(&__currentcontext, soffset,&svp);
dchunk = __svgalib_driver_setwrite(gc, doffset, &dvp);
count = min(min(schunk, dchunk), (size - soffset));
__memcpy(dvp, svp, count);
soffset += count;
doffset += count;
}
is executed unless one of the following conditions is true:
(gc->modetype == CONTEXT_MODEX)
(gc->modetype == CONTEXT_PLANAR16)
(BYTESPERPIXEL == 4 && gc->bytesperpixel == 3)
(BYTESPERPIXEL == 4 && gc->bytesperpixel == 4 &&
(gc->modeflags & MODEFLAG_32BPP_SHIFT8))
In particular, an inserted printf confirms that it is being run for my
code. Is this really the correct behaviour?
m.
--
Maneesh Sahani
Gatsby Computational Neuroscience Unit maneesh at gatsby.ucl.ac.uk
17 Queen Square, tel: +44 (0)20 7679 1187
London WC1N 3AR U.K. fax: +44 (0)20 7679 1173
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST