On Thu, May 27, 2004 at 05:55:29PM -0700, Jon Smirl wrote:
| Why do you dynamically generate a dispatch for unknown functions instead of
| just returning null? ...

Since I'm one of the people who proposed that behavior, I guess I should
save Ian the trouble of explaining. :-)

There are several reasons, but they're all connected to the issue of
whether pointers to extension functions are independent of the current
rendering context.

If you make them context-dependent, then that's easy for the OpenGL
library and drivers to handle.  But it also means that instead of a
single pointer for a given function, applications have to maintain a
pointer for each function for each rendering context they might use.
Furthermore, code like utility libraries might be called without knowing
which rendering context is current, so it would either have to query the
context and lookup the appropriate function pointer, or re-fetch the
function pointer, every time it's needed.  Finally, context-dependent
pointers cause new classes of error conditions to arise -- before the
pointers to extension functions existed, there was no way to
accidentally call an OpenGL function that wasn't appropriate for the
current context.  All of these problems (and a few others) cropped up
under Windows, where extension function pointers are context-dependent.

However, if you make the pointers context-independent, you run into a
few new problems.  One of those is that at the time you fetch a function
pointer you have no idea whether all the rendering contexts the app will
eventually use actually support the associated extension.  (You might
finesse the the question for drivers that are available locally, but you
can't use that trick to handle remote renderers accessed by GLX.)  

Back when we were defining the Linux OpenGL ABI we were able to convince
ourselves that we could implement context-independent pointers with the
same or better performance than context-dependent pointers.  So we went
ahead and specified that they had to be context-independent in order to
keep the app developers sane.  But one of the side-effects of this is
that glXGetProcAddress will never return a null pointer, because it
never knows which rendering contexts might eventually be used.

|                  ... What does this dispatch dispatch to?

In most implementations, a dynamically-generated stub that jumps through
a known offset in a vector of function pointers.  That entry in the
vector might not exist, or might be null, if the rendering context
that's current at the time doesn't support the associated extension.

Allen


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
--
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to