Re: Where is the function implementation?

Brian Paul <[email protected]>
Newsgroups gmane.comp.video.mesa3d.user
Organization VMware, Inc.
Message-ID <[email protected]>
On 01/30/2013 10:16 AM, denzig kervan wrote:
> Hi, I'm a newcomer, so please be nice.
> Analysing only the case for intel 32bit and that I have
> _glapi_tls_Dispatch. I don't understand gas so the code in file
> glapi_x86.S I understood as a black box for PIC addressing mode.
> So I have the global variable _glapi_tls_Dispatch that when processed
> by the code in glapi_x86.S creates the glfoo interface directing
> correctly to the appropriate pointer to function in the _glapi_table.
> Then I get stuck. Although I can see the declaration of all the
> pointer to functions in _glapi_table I cannot know where it is its
> implementations. Again, my best bet is _mesa_foo, but I don't know
> how, for example, void (GLAPIENTRYP NewList)(GLuint list, GLenum mode)
> could become _mesa_NewList(GLuint name, GLenum mode). Thanks in advance.

You're right that the implementation of most OpenGL functions, such as 
glTexImage2D is called _mesa_TexImage2D.

The dispatch code basically works like this (using glEnable() as an 
example):

void glEnable(GLenum cap)
{
    d = get_current_dispatch_table_for_calling_thread();
    d->Enable(cap);
}

That is, for every GL function, get a pointer to the thread's dispatch 
table, then jump through the table to call the function.

These dispatch functions can be implemented in C or x86 assembly code.

The dispatch table is created during context creation.  The pointer to 
the current dispatch table is set in glXMakeCurrent() or 
wglMakeCurrent(), etc.

-Brian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.