61 Commits
Author SHA1 Message Date
Eric Anholt 585c703699 Add some missing spacing in generated code. 2015-07-15 16:09:06 -07:00
Eric Anholt b2c00a18af Use a concatenated string for enum descriptions.
Saves another 15kb of compiled code.
2015-07-15 16:09:06 -07:00
Eric Anholt d4620b7dd3 Use __attribute__((packed)) to reduce our data size.
Since our provider enums are small, we can store them as bytes or
shorts if we just let the compiler know that it's OK.  Saves 20kb in
the compiled library.
2015-07-15 14:47:39 -07:00
Eric Anholt 62861d12f9 Emit APIENTRY for typedefs that use it.
The XML uses a node for where the string should be.  This should fix
segfaults using GL_ARB_debug_output on windows.

Fixes #46.
2015-07-15 14:27:48 -07:00
Chun-wei Fan e9f68fe3a3 Fix generated code for building on MSVC 2013
This updates the script to generate code that is buildable by Visual Studio
2013 by:

-Using a macro to define the compiler-specific way to do noinline for a
 function, and use it when needed.

-Avoid using empty arrays and structs as that is a C99 feature that will
 likely be never support on Visual Studio as it is now an optional feature
 of C11.
2015-06-05 17:51:08 -07:00
Eric Anholt 136cf85424 Use the provider enum to tie-break sorting by function provider name.
Without this, we got code generation that was dependent on the
original ordering in the hash table, and thus non-reproducible builds.

Based on a commit by Stephan Kulow, but retaining the sorting by
function name first (that way all providers with the same name appear
next to each other like before, and also happens to ensure that core
names tend to appear before non-core names)
2015-06-05 17:22:58 -07:00
Eric Anholt 568533441f Move __stdcall into the parens for function pointer definitions.
MSVC 2010 appears to require that it be located there.
2014-04-10 13:37:47 -07:00
Eric Anholt 3e09de7550 win32: Delay using dispatch tables until the second MakeCurrent.
Fixes #11.
2014-03-28 16:45:26 -07:00
Eric Anholt 370c49d5cd Use #defines to shrink the size of gl_generated_dispatch.c
I was running into file size limits with win32 debug symbols.
2014-03-28 16:33:53 -07:00
Eric Anholt 11a946cbf5 Prefer non-aliased functions when resolving.
This increases the size of the library, but avoids some of the
concerns that have been brought up with the library silently switching
you from glWhateverEXT() to glWhatever() if there might be slight
behavior differences between the two that hadn't been identified.  The
downside is that it means we can't share the resolver functions among aliases.
2014-03-28 16:33:53 -07:00
Eric Anholt e7d3088d71 win32: Add support for wglUseFontBitmaps().
Fixes #10.
2014-03-27 15:33:21 -07:00
Eric Anholt 9efad17eb4 Actually fix #21 (hopefully). 2014-03-17 11:21:11 -07:00
Eric Anholt 766422a82c Use the same typedefs as upstream khrplatform.h in a couple cases.
This should avoid any differences we might end up with compared to
system khrplatform.h.
2014-02-06 11:23:43 -08:00
Eric Anholt c996534080 Define the rest of the khrplatform.h types, and prevent its inclusion.
One of the problems with krhplatform.h (besides it being a terrible
idea in the first place) is that it's not present on many systems at
all, including apple, win32, and linux before late 2009.

So, unless we introduce the first ./configure dependency to the core
library build, we really do need to define these standard types to
their standard values.  But if we allow khrplatform.h inclusion as
well, we'll get long-vs-int redefinition warnings on 32-bit.  So, we
have to completely replicate the header, which is a thing we've done
for everything else except for eglplatform.h.

A testcase will be used to make sure that our types don't drift from
the system khrplatform.h types, if it even exists.

Fixes #17
2014-02-06 11:16:11 -08:00
Eric Anholt 1064406814 Fix using epoxy on systems with only EGL and GLES1 or GLES2.
Fixes #19
2014-01-31 15:51:53 -08:00
Eric Anholt 12ef9dcf2d Do a trivial sort on the enums generated.
Python was apparently randomizing the output of the hash iterator,
preventing ccache after a make clean.
2014-01-28 15:20:11 -08:00
Eric Anholt aa778ef39d Add support for Mesa's GLES1 implementation.
Mesa reports "OpenGL ES-CM 1.1", so we need to not look for a space
after "ES", and 1.1 is still a 1.0-compatible implementation.
2014-01-22 01:06:04 -08:00
Eric Anholt 9bc909f5a7 win32: Convert the API to being based on function pointers, like Linux.
For performance, I want to be able to make single-context (well,
single-pixel-format-and-device) apps be able to directly call GL
functions through function pointers.  Bake that into the ABI now so I
can get a release out the door and fix this up later.

This also fixes the lack of __stdcall annotation on the
PFNWHATEVERPROC typedefs.
2013-12-17 15:08:02 -08:00
Eric Anholt c4214a39f4 win32: Reset all dispatch tables to re-resolve on any wglMakeCurrent. 2013-12-17 14:12:14 -08:00
Eric Anholt 417927e2eb win32: Start wrapping the 1.0 wgl functions.
I want to have a chance to intercept wglMakeCurrent for WGL's
context-dependent function pointer handling.
2013-12-17 12:11:05 -08:00
Eric Anholt 9a7be0784f win32: Use thread local storage to get us a dispatch table per thread. 2013-12-17 12:11:05 -08:00
Eric Anholt 8022cda75d Don't forget to tell our users that the epoxy GL functions are __dllimport.
This lets the compiler generate faster function calls (call through
function pointer, instead of call into a linker-generated stub func
containing jump to function pointer).
2013-12-17 12:10:34 -08:00
Eric Anholt 920543faa4 Add and clean up some more comments in the python.
Fixes #8
2013-12-16 10:43:29 -08:00
Eric Anholt 7a8553f799 Update python comments about aliases. 2013-12-16 10:43:25 -08:00
Eric Anholt bf628d9cf3 Add support for lower-priority aliases of functions.
For example, on desktop 2.1 GL on Apple, there's no glBindVertexArray,
but there is glBindVertexArrayAPPLE, and as far as a caller is
concerned, the APPLE variant should be able to stand in for the
core/ARB version.  Similarly for trying to do FBOs on an old Mesa
implementation that didn't have ARB_fbo yet, but did have EXT_fbo.
2013-12-16 09:33:33 -08:00
Eric Anholt 28c2dcb99b Use a non-inlined helper for the simple case of a single provider.
This reduces the built size by another 37k.
2013-12-15 20:16:01 -08:00
Eric Anholt c4f582b532 Reuse the same string table in one more place.
Saves another 53k on disk, no relocations.
2013-12-15 20:16:01 -08:00
Eric Anholt 39ccf7089b Use offsets into a string table to reduce the binary size.
Saves 54k on disk and 3700 relocations.
2013-12-15 20:16:01 -08:00
Eric Anholt 982e39f188 Move the #defines into the main generated header.
I initially thought I was going to have two sets of defines you chose
from using #include, but that never ended up being necessary.
2013-12-15 20:16:01 -08:00
Eric Anholt 3d2a2b3c80 Abandon ifuncs and go with the traditional global function pointers.
In addition to the failing testcase, there were a couple of
regressions in piglit's attribs test: one from glBegin_unwrapped vs
glBegin confusion in the __asm__ directives we were generating, and
one where the function pointers apparently were just getting mixed up
at application runtime.
2013-12-15 20:15:51 -08:00
Eric Anholt cb647a0853 Fix loading of EGL 1.1+ entrypoints. 2013-12-12 17:17:17 -08:00
Eric Anholt dd6feb7b00 Include epoxy/gl.h instead of epoxy/gl_generated.h from egl_generated.h
This gets us the safety check for including GL/gl.h before epoxy/gl.h
2013-12-12 13:12:19 -08:00
Eric Anholt 0cfb0a044b Fix most GLhandleARB warnings on OS X with a big comment in our code. 2013-12-12 11:39:34 -08:00
Eric Anholt 1e443b2daf Use ifuncs on Linux to avoid dispatch table overhead.
These tell the linker to generate GNU_IFUNC relocs that rewrite the
PLT entries in the user's address space to point to our resolved GL
function, so there's no extra function pointer.  It also, as a bonus,
cuts 400k out of the library.

This requires a toolchain from 2010 or so.  Unfortunately, it's going
to take a bit more investigation to find out what specific bits are
required.

Fixes #4
2013-12-11 15:03:58 -08:00
Eric Anholt 85dc3821fe Move the unwrapped logic to function setup.
I'm going to want the same stuff for ifuncs.
2013-12-11 13:15:39 -08:00
Eric Anholt 8a56585dcb Make func.alias_name always have the name of our alias.
The "None" for "we're not an alias of anything else" wasn't actually
simplifying things.
2013-12-11 12:58:43 -08:00
Eric Anholt f843d63da2 Reduce the overhead of the dispatch table usage.
We now initialize our dispatch table with function pointers that go
and do the rewrite, then we never have to check for a NULL table entry
again.  On my 64-bit build, epoxy_glClear() drops from 83 bytes to 14,
while the total library size only goes up by 5%.

This also paves the way for fixing our dispatch table management using
TLS on windows.
2013-12-10 17:19:38 -08:00
Eric Anholt 1d746bfeb2 Add dispatch generation for wgl.
This is very poorly tested at this point, but survives a simple testcase.
2013-12-10 14:13:22 -08:00
Eric Anholt f4992e1518 Use get_core_proc_address() on win32.
This is needed for glGetString() lookup to work, since
wglGetProcAddress() returns NULL for core procs.
2013-12-10 14:11:26 -08:00
Eric Anholt b128dd9b25 Move the check for whether to dlsym or GPA on linux to the common C code.
This is going to change for macos and win32, and this will be easier
than trying to spread that logic through the python code and into the
generated code.
2013-12-09 23:01:33 -08:00
Eric Anholt 0e7b9c0939 Fix generation of redundant typedefs. 2013-12-06 17:32:13 -08:00
Eric Anholt 26ca6ac8e8 Add missing #defines for GL versions and extensions.
Not having them broke some piglit ES2 compat tests.
2013-12-05 17:40:16 -08:00
Eric Anholt f097de94eb Add support for GLES extensions.
I think we don't want to be checking that the context is actually of
the declared types -- if the extension is exposed in the extension
string, the entrypoints had better be there.
2013-12-05 15:41:27 -08:00
Eric Anholt 0983996e49 Fix calling new entrypoints from within glBegin()/glEnd(). 2013-12-05 15:07:08 -08:00
Eric Anholt 4d0d93b1c0 Fix indentation in generated code 2013-12-05 13:14:47 -08:00
Eric Anholt c6df72b7d0 Drop a bit of commented out python.
It was used in debugging before I figured out I needed to resolve
aliases late.
2013-12-05 12:38:42 -08:00
Eric Anholt 0270c80008 Add support for EGL.
This totally replaces the getprocaddress and dlsym code, which was
basically just stubs up until now.  The is_glx/is_egl() is also
dropped -- they weren't doing anything, and the only false answer they
could give is if the dlopen were to fail.
2013-12-05 12:38:15 -08:00
Eric Anholt 111c54992b Drop the installed _common.h headers.
I was thinking at one point that part of the build was going to
require not including the #defines from the generated code, but would
want these prototypes.  It turns out that's not the case (and if it
is, I'll just wrap the #defines in an ifdef).
2013-12-05 11:12:23 -08:00
Eric Anholt de70a2a0ab Fix a similar bug to HEAD~2, this time in epoxy_has_glx_extension(). 2013-12-04 19:22:13 -08:00
Eric Anholt 0f67bf3f11 Fix bug in public entrypoint for epoxy_glx_version()
Unfortunately, for GLX 1.4+ entrypoints (just glxGetProcAddress
currently) or extensions, if there isn't a context bound then we don't
have a dpy and screen available to provide useful debug messages.  Oh
well.
2013-12-04 19:18:31 -08:00