[comp.windows.x] Graphics Context in X11

shebs@utah-cs.UUCP (Stanley Shebs) (01/21/88)

The X11 Xlib document warns against using too many graphics contexts and
switching between them, as opposed to re-setting the attributes of a few.
I would like to know:

1. Does anybody actually cache GC data in the hardware, and if so, what sorts
of data and how much is typically cached?

2. What is the range in performance variation between using, say, 30 GCs whose
attributes are never changed, vs one GC with an average of two attribute
settings per graphics call?  I'm especially interested in differences between
one server and another.

Any info will be greatly appreciated.

							stan shebs
							shebs@cs.utah.edu

black@masscomp.UUCP (Sam Black) (01/25/88)

> The X11 Xlib document warns against using too many graphics contexts and
> switching between them, as opposed to re-setting the attributes of a few.
> I would like to know:
>
> 1. Does anybody actually cache GC data in the hardware, and if so, what sorts
> of data and how much is typically cached?
>
> 2. What is the range in performance variation between using, say, 30 GCs whose
> attributes are never changed, vs one GC with an average of two attribute
> settings per graphics call?  I'm especially interested in differences between
> one server and another.

Our server implementation works just the opposite way:  it is MUCH faster
to switch between GCs than to change values in GCs, assuming you do
not switch windows (and thus recalculate clipping).  There are several
reasons:

	1) ValidateGC is avoided
	2) ChangeGC is avoided
	3) we cache GCs in the hardware (up to several hundred)

We haven't come up with actual timing differences, but it can be noticeable.

		- sam black

--------------------------------------

The only difference between men and boys is the price of
their toys.  And the one who dies with the most toys wins.

	...!{cca,decvax,harvard}!masscomp!black	UUCP
	black%masscomp.uucp@<internet gateway>	Internet

--------------------------------------

adamj@web8h.berkeley.edu (Adam J. Richter) (01/31/88)

In article <5163X@utah-cs.UUCP> shebs@utah-cs.UUCP (Stanley Shebs) writes:
>The X11 Xlib document warns against using too many graphics contexts and
>switching between them, as opposed to re-setting the attributes of a few.

	Good advice if you're using the server that I've been porting
for Jupiter Systems ("graphics far beyond your puny earthling
needs.").  Their system has eight cached GCs.  (Some of them are used
by server GCs to do things like drawing the cursor; in practice,
you'll have fewer.)

	While I think that GCs are a good idea, I don't think that
there is a good general rule for GC usage.  If there are free hardware
GCs, then, obviously, you want use them.  If there are more software
GCs than hardware GCs and a lot of software GCs are being accessed,
then you'll "thrash."  It's just like physical and virtual memory.

	As for the Jupiter, it can change parts of a GC
element-by-element, so changing the GC is cheap.  On the other hand,
if you were using a system in which you could only load hardware GCs
whole-hog, then it would always be better to use separate GCs.

	This sort of hardware information might be useful to ask for
in the form of an extension.  On the other hand, I'm hoping for a
public-domain NeWS.

P.S.--> Has anybody out there noticed that all the X protocol requests,
	except the ellipse stuff, can be generalized to N dimensions?

Adam J. Richter			adamj@widow.berkeley.edu
				....!ucbvax!widow!adamj
				Home: (415)549-6377
				Work: (415)523-9000
				Sun room: (415)642-7762