# XFlush

**URL:** <https://discourse.libsdl.org/t/xflush/11854>\
**Category:** SDL Development\
**Created:** [February 8, 2005, 2:55am UTC](https://discourse.libsdl.org/t/xflush/11854 "2005-02-08T02:55:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fernando\_Benites](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/f/e5b9ba/32.png) [@Fernando\_Benites](https://discourse.libsdl.org/u/Fernando_Benites)\
**Post date:** [February 8, 2005, 2:55am UTC](https://discourse.libsdl.org/t/xflush/11854/1 "2005-02-08T02:55:44Z")

</div>

Hi!  
I got a problem with the file:  
SDL-1.2.8/src/video/x11/SDL\_x11image.c

in X11\_MITSHMUpdate i changed the code to:  
Uint32 then, now, first=0,frames=0;

```
for ( i=0; i<numrects; ++i ) {
	if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */
		continue;
	}
	XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
			rects[i].x, rects[i].y,
			rects[i].x, rects[i].y, rects[i].w, rects[i].h,
								False);
}
then = SDL_GetTicks();
if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
	XFlush(GFX_Display);
	blit_queued = 1;
} else {		
	XSync(GFX_Display, False);
}
now = SDL_GetTicks();
fprintf(stderr,",,,,%i ms

```

%2.2f\n",(now-then),(double)1000\*frames/(double)(now-first));

and i get as output:  
,74 ms 0.00

well i know the code is crappy, but the output is always about 80 ms  
seconds… i have a athlon xp 1700 500 mb ram nvidia geforce 2 mx 4.  
Opengl works very well but somehow sdl is very slow, does someone know why?  
thx!  
Fernando Benites–  
DSL Komplett von GMX +++ Superg?nstig und stressfrei einsteigen!  
AKTION “Kein Einrichtungspreis” nutzen: [http://www.gmx.net/de/go/dsl](http://www.gmx.net/de/go/dsl)

---

<div class="post-metadata">

**Author:** ![Stephane\_Marchesin](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/a183cd/32.png) [@Stephane\_Marchesin](https://discourse.libsdl.org/u/Stephane_Marchesin)\
**Post date:** [February 9, 2005, 12:06pm UTC](https://discourse.libsdl.org/t/xflush/11854/2 "2005-02-09T12:06:10Z")

</div>

Fernando Benites wrote:

> Hi!  
> I got a problem with the file:  
> SDL-1.2.8/src/video/x11/SDL\_x11image.c
> 
> in X11\_MITSHMUpdate i changed the code to:  
> Uint32 then, now, first=0,frames=0;
> 
> for ( i=0; i\<numrects; ++i ) {  
> if ( rects[i].w == 0 || rects[i].h == 0 ) { /\* Clipped? _/  
> continue;  
> }  
> XShmPutImage(GFX\_Display, SDL\_Window, SDL\_GC, SDL\_Ximage,  
> rects[i].x, rects[i].y,  
> rects[i].x, rects[i].y, rects[i].w, rects[i].h,  
> False);  
> }  
> then = SDL\_GetTicks();  
> if ( SDL\_VideoSurface-\>flags & SDL\_ASYNCBLIT ) {  
> XFlush(GFX\_Display);  
> blit\_queued = 1;  
> } else {   
> XSync(GFX\_Display, False);  
> }  
> now = SDL\_GetTicks();  
> fprintf(stderr,“,%i ms  
> %2.2f\n”,(now-then),(double)1000_frames/(double)(now-first));
> 
> and i get as output:  
> ,74 ms 0.00
> 
> well i know the code is crappy, but the output is always about 80 ms  
> seconds… i have a athlon xp 1700 500 mb ram nvidia geforce 2 mx 4.  
> Opengl works very well but somehow sdl is very slow, does someone know why?

So you say that’s because of XFlush ? That would mean that you are using  
ASYNCBLIT ?

Stephane

---

<div class="post-metadata">

**Author:** ![Fernando\_Benites](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/f/e5b9ba/32.png) [@Fernando\_Benites](https://discourse.libsdl.org/u/Fernando_Benites)\
**Post date:** [February 9, 2005, 12:07pm UTC](https://discourse.libsdl.org/t/xflush/11854/3 "2005-02-09T12:07:01Z")

</div>

> Fernando Benites wrote:

> > then = SDL\_GetTicks();  
> > if ( SDL\_VideoSurface-\>flags & SDL\_ASYNCBLIT ) {  
> > XFlush(GFX\_Display);  
> > blit\_queued = 1;  
> > } else {   
> > XSync(GFX\_Display, False);  
> > }  
> > So you say that’s because of XFlush ? That would mean that you are using  
> > ASYNCBLIT ?
> 
> Stephane

It doesnt matter, XSync is also so slow.  
Fernando Benites–  
Lassen Sie Ihren Gedanken freien Lauf… z.B. per FreeSMS  
GMX bietet bis zu 100 FreeSMS/Monat: [GMX E-Mail ✉ sichere & kostenlose E-Mail-Adresse ✉](http://www.gmx.net/de/go/mail)

---

<div class="post-metadata">

**Author:** ![Stephane\_Marchesin](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/a183cd/32.png) [@Stephane\_Marchesin](https://discourse.libsdl.org/u/Stephane_Marchesin)\
**Post date:** [February 9, 2005, 12:16pm UTC](https://discourse.libsdl.org/t/xflush/11854/4 "2005-02-09T12:16:55Z")

</div>

Fernando Benites wrote:

> > Fernando Benites wrote:
> 
> > > then = SDL\_GetTicks();  
> > > if ( SDL\_VideoSurface-\>flags & SDL\_ASYNCBLIT ) {  
> > > XFlush(GFX\_Display);  
> > > blit\_queued = 1;  
> > > } else {   
> > > XSync(GFX\_Display, False);  
> > > }
> > 
> > So you say that’s because of XFlush ? That would mean that you are using  
> > ASYNCBLIT ?
> > 
> > Stephane
> 
> It doesnt matter, XSync is also so slow.

Ok, does this happen with any SDL program or one in particular ? If it  
is with a particular program, can you send a small source code ?

Also, what X version are you using (please send the output of xdpyinfo)  
? On which distribution ?

Stephane

---

<div class="post-metadata">

**Author:** ![Fernando\_Benites](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/f/e5b9ba/32.png) [@Fernando\_Benites](https://discourse.libsdl.org/u/Fernando_Benites)\
**Post date:** [February 9, 2005, 12:41pm UTC](https://discourse.libsdl.org/t/xflush/11854/5 "2005-02-09T12:41:56Z")

</div>

WEll… i tried to update my X… and now it isnt working…  
I will reinstall, it will take some days so i can send a better diagonase…  
Fernando Benites–  
DSL Komplett von GMX +++ Superg?nstig und stressfrei einsteigen!  
AKTION “Kein Einrichtungspreis” nutzen: [http://www.gmx.net/de/go/dsl](http://www.gmx.net/de/go/dsl)
