Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xpm slow?



  From:  Philip Brown <philb@soda.berkeley.edu>
  Date:  Mon, 14 Mar 1994 21:55:10 -0800 (PST)

  >>>>[From Eric A. Anderson]
      
      Mark Wedel <master@rahul.net> writes:
      >  However, with client server, this should not be a problem.
  
      My guess is with client server it will still be a little problem.  My
      roomate commented that pixmaps seemed to make things slower.  I agreed
      with him.  This was over a local connection -- e.g. the crossfire
      server and the X server on the same machine.
  
  I disagree. The reason pixmaps are slow is because of X overhead.
  the reason fonts ar quicker is because of font mechanisms to reduce X
  overhead.

i've been looking a bit at what's going on with the XPM stuff (using
xscope, which is an invaluable tool for doing X performance analysis).
i see a number of issues:

- the pixmap creation itself is really dumb.  i think this is the XPM
    library's fault, but the game is re-allocating the colors for each
    pixmap.  that's probably more than 2000 extra times for figuring
    out what 'black' looks like.  startup time could be *much* faster

- the display code uses CopyArea, but doesn't turn off graohics exposures.
    this means that for every call to CopyArea, there's a NoExpose
    event coming back from the server.  extra work for both sides,
    and its thrown on the floor.  this is a trivial fix, and will also
    speed up bitmaps.

- the display code sets the clip a lot -- but often the clip is
    the same as what it already is (nothing).  i tweaked this and cut
    down some more on the number of packets going over the wire.


its not obvious whether these last two changes made it faster (it was
already nice for me) but they certainly cut down on the wire traffic.


and in the font vs pixmap category, fonts are probably going to be faster,
simply because server vendors optimize them better.  some displays also
stick pixmaps in different memory, and it can take longer to get them out.

Dave

here are the diffs if people want to try them -- i may have screwed up
the clipmask stuff, though i haven't seen any visual glitches.

*** xio.c	Tue Mar 15 16:24:30 1994
--- ../../tmp/crossfire-0.90.3/server/xio.c	Fri Mar 11 19:43:31 1994
***************
*** 247,253 ****
       XSetForeground(p->gdisp,p->gc_game,p->gforeground);
       XSetBackground(p->gdisp,p->gc_game,p->gbackground);
    }
-   XSetGraphicsExposures(p->gdisp, p->gc_game, False);
    if(!p->use_pixmaps) {
      p->game_font=p->font=XLoadFont(p->gdisp,font_graphic);
      XSetFont(p->gdisp,p->gc_game,p->font);
--- 247,252 ----
***************
*** 255,262 ****
    if (p->color_pixmaps) {
  	p->gc_xpm_floor = XCreateGC(p->gdisp,p->win_game,0,0);
  	p->gc_xpm_object = XCreateGC(p->gdisp,p->win_game,0,0);
- 	XSetGraphicsExposures(p->gdisp, p->gc_xpm_floor, False);
- 	XSetGraphicsExposures(p->gdisp, p->gc_xpm_object, False);
  	XSetClipOrigin(p->gdisp, p->gc_xpm_object,
  		0, 0);
  	p->xpm_pixmap = XCreatePixmap(p->gdisp, RootWindow(p->gdisp,
--- 254,259 ----
***************
*** 2159,2165 ****
  void draw_color_pix(object *pl) {
      int i,j,ax,ay; /* ax and ay goes from 0 to max-size of arrays */
      Face	*face,*floor;
-     static Pixmap	obj_mask = 0;
    
      for(j=pl->y+WINUPPER;j<=pl->y+WINLOWER;j++) {
        ay=j-pl->y-WINUPPER;
--- 2156,2161 ----
***************
*** 2198,2208 ****
  		XCopyArea(pl->contr->gdisp, pl->contr->pixmaps[floor->number],
  			pl->contr->xpm_pixmap, pl->contr->gc_xpm_floor,
  			0, 0, 24, 24, 0, 0);
- 		if (obj_mask != pl->contr->masks[face->number]) {
  		    XSetClipMask(pl->contr->gdisp, pl->contr->gc_xpm_object,
  			pl->contr->masks[face->number]);
- 			obj_mask = pl->contr->masks[face->number];
- 		}
  	        XCopyArea(pl->contr->gdisp,pl->contr->pixmaps[face->number],
                      pl->contr->xpm_pixmap,pl->contr->gc_xpm_object,
                      0,0,24,24,0, 0);
--- 2194,2201 ----
***************
*** 2219,2229 ****
                      pl->contr->xpm_pixmap,pl->contr->gc_xpm_floor,
                      0,0,24,24,0,0);
  	    if (face->number != floor->number) {
- 		if (obj_mask != pl->contr->masks[face->number]) {
  		    XSetClipMask(pl->contr->gdisp, pl->contr->gc_xpm_object,
  			pl->contr->masks[face->number]);
- 			obj_mask = pl->contr->masks[face->number];
- 		}
  		XCopyArea(pl->contr->gdisp,pl->contr->pixmaps[face->number],
                      pl->contr->xpm_pixmap,pl->contr->gc_xpm_object,
                      0,0,24,24,0,0);
--- 2212,2219 ----