Compare commits

...

126 Commits

Author SHA1 Message Date
Kristian Høgsberg
faa8c0ce8c Merge remote branch 'origin/7.8' into 7.8-gles 2010-05-14 15:05:02 -04:00
Kristian Høgsberg
8e60aeca2e egl: Implement EGL_NOK_texture_from_pixmap
This extension allows a color buffer to be used for both rendering and
texturing.  EGL allows the use of color buffers of pbuffer drawables
for texturing, this extension extends this to allow the use of color
buffers of pixmaps too.
2010-05-14 15:04:34 -04:00
Kristian Høgsberg
f2e8f4c473 egl: Only allow valid config attributes in _eglParseConfigAttribList()
Passing 0x3030, 0 in the chooser list didn't get caught.
2010-05-14 15:04:30 -04:00
Brian Paul
cf83f0b812 egl: remove duplicate ARRAY_SIZE() macro declaration 2010-05-14 15:04:25 -04:00
Vinson Lee
407ef9b5cc egl: Silence uninitialized variable warnings. 2010-05-14 15:04:22 -04:00
Kristian Høgsberg
61cc9a7538 egl: Implement EGL_NOK_swap_region
This extension adds a new function which provides an alternative to
eglSwapBuffers. eglSwapBuffersRegionNOK accepts two new parameters in
addition to those in eglSwapBuffers. The new parameters consist of a
pointer to a list of 4-integer blocks defining rectangles (x, y,
width, height) and an integer specifying the number of rectangles in
the list.
2010-05-14 15:04:12 -04:00
Kristian Høgsberg
59cee11522 egl_dri2: Enable KHR_gl_texture_2D_image
Forgot to set the enabled bit when I implemented the extension.
2010-05-14 15:03:17 -04:00
Chia-I Wu
5a27e8e2ae egl_dri2: Flush before context switch and swap buffers.
DRI does not define any callback to flush the current context.  GLX
loader simply calls glFlush.  Follow the GLX loader here.
2010-05-14 14:57:44 -04:00
Eric Anholt
533b766383 i965: Fix scissoring when width or height is 0.
We would run into trouble due to the hardware using inclusive numbers
and the subtraction to handle that producing negative (meaning large
positive) coordinates.

Bug #27643.
(cherry picked from commit 64516430be)
2010-05-13 13:43:06 -07:00
Eric Anholt
71f028bf93 i965: Fix assertion for surface tile offset usage on Ironlake.
Fixes assertion failure in fbo-generatemipmap-npot.
(cherry picked from commit b2e52e7278)
2010-05-13 13:43:06 -07:00
Eric Anholt
f007d0f89d i965: Fix cube map layouts on Ironlake.
We were doubling up the offsets for the mipmap levels for CPU access.
Instead of reimplementing i945_miptree_layout_2d with 6 cube images
separated by qpitch, share that function and provide the level offsets
later.

Fixes piglit cubemap and fbo-cubemap.
(cherry picked from commit 7d8f0fc282
Conflict due to mt->pitch still being here resolved -- i945 layout
should set it.)
2010-05-13 13:42:36 -07:00
Zhenyu Wang
728df9aaca intel: Clean up chipset name and gen num for Ironlake
Rename old IGDNG to Ironlake, and set 'gen' number for
Ironlake as 5, so tracking the features with generation num
instead of special is_ironlake flag.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
(cherry picked from commit cdcef6cbf4)
2010-05-13 13:41:33 -07:00
Kristian Høgsberg
f8a500d96b egl: Allow a prioritized list of default drivers
When there is no user driver or any matching display drivers we fall
back to the default driver.  This patch lets us have a list of default
drivers instead of just one.  The drivers are loaded in turn and we
attempt to initialize the display.  If it fails we unload the driver
and move on to the next one.

Compared to the display driver mechanism, this avoids loading a number
of drivers and then only using one.  Also, we call Initialize to see
if the driver will work instead of relying on Probe.  To know for sure
that a driver will work, Probe really have to do a full Initialize, so
we will just use Initialize directly.
2010-05-13 16:16:26 -04:00
Kristian Høgsberg
12f4f51873 egl_dri2: Downgrade initialization errors to warnings
Don't want to shutdown everything if egl_dri2 fails to initialize.
2010-05-13 16:16:21 -04:00
Kristian Høgsberg
0c3f95e5e8 egl: Drop broken _EGL_PLATFORM_NO_OS code
It would do strlen(library_suffix()) in _eglLoaderFile(), with
library_suffix() returning NULL.  So obviuosly not used or tested.
2010-05-13 16:15:25 -04:00
Kristian Høgsberg
b3e27bca9f egl: Don't try to load driver basename if the platform needs a suffix
That is, don't dlopen(egl_glx) when we know we need to append .so.
2010-05-13 16:15:19 -04:00
Eric Anholt
d2ade4b802 i965: When an RB gets a new region, clear the old from the state cache.
This prevents memory usage explosion in blender due to the state cache
hanging on to old fake frontbuffer regions.  Sigh at blender still
using frontbuffer rendering.

Bug #24119.
(cherry picked from commit ce914fff08)
2010-05-13 11:41:14 -07:00
Eric Anholt
e48964a561 intel: Don't tile textures so small that size is blown up by over 2x.
Noted on the mailing list for an app that puts each glyph for its text
into a separate texture.
(cherry picked from commit 453f0b1f24)
2010-05-13 11:41:10 -07:00
Eric Anholt
53557f1f34 i965: Reject shaders with uninlined function calls instead of hanging.
Most of the failure from using uninlined function calls ends up being
just bad rendering, but nested function calls in the VS currently hang
the GPU, so reject them and explain why.
(cherry picked from commit ee29b86129)
2010-05-13 11:40:21 -07:00
Eric Anholt
3bf7ea2a1c mesa: Don't overwrite a driver's shader infolog with generic failure message.
(cherry picked from commit 07a248a366)
2010-05-13 11:40:17 -07:00
Kristian Høgsberg
4784a5030a Merge remote branch 'origin/7.8' into 7.8-gles 2010-05-12 16:11:42 -04:00
Chia-I Wu
bf3b9187f0 mesa: Add missing features.
Add features tested in the code but missing from mfeatures.h.

This also fixes some tests of features.  They should be tested with
"#if", not "#ifdef".
2010-05-12 15:54:02 -04:00
Chia-I Wu
d747bfc224 mesa: Add umbrella features.
Add FEATURE_GL, FEATURE_ES1, and FEATURE_ES2 for OpenGL, OpenGL ES 1.x,
and OpenGL ES 2.x respectively.  Define individual features through the
new umbrella features.  There is no real change introduced by this
commit.
2010-05-12 15:54:00 -04:00
Kristian Høgsberg
f3b55494f3 egl_dri2: Zero out driver struct
Otherwise testing ->Probe for non-NULL and calling it goes boom.
2010-05-12 14:51:25 -04:00
Kristian Høgsberg
8b68c0aa24 glx: Get GLX_SCREEN first in __glXQueryContextInfo()
And lookup the GLX screen for the context.  Otherwise we'll end up
jumping through a NULL-pointer once we try to look up the visual
or config for the shared context.

https://bugs.freedesktop.org/show_bug.cgi?id=14245
2010-05-12 14:50:04 -04:00
Brian Paul
3c407b52ff osmesa: fix OSMesa for CHAN_BITS=32
CHAN_BITS=16 still broken.

NOTE: this is a candidate for back-porting to the 7.8 stable branch.
(cherry picked from commit 36b3a8bd5a)
2010-05-07 09:00:05 -06:00
Brian Paul
210b74c613 glsl: change variable declared assertion into conditional
The slang_variable::declared field originated as a debug field but
can be promoted for use during sematic error checking.

Fixes fd.o bug 27921.

NOTE: this is a candidate for back-porting to the 7.8 stable branch.
(cherry picked from commit a12614362a)
2010-05-07 08:59:08 -06:00
Kristian Høgsberg
dd0292dcf9 Merge remote branch 'origin/7.8' into 7.8-gles 2010-05-06 11:07:11 -04:00
Chia-I Wu
8c1b3b102d mesa: Fix build of ES overlay.
ES overlay is built with FEATURE_ES1 or FEATURE_ES2, and is built
without FEATURE_GL.  Fix the build by always building OpenGL ES sources,
but test for FEATURE_ES1 or FEATURE_ES2.  Also, define symbols that are
missing because FEATURE_GL is not defined.
2010-05-06 11:05:01 -04:00
Kristian Høgsberg
320b7ac65e Fix gles .pc file generation 2010-05-06 11:04:44 -04:00
Kristian Høgsberg
5571689f8f Add egl.pc file 2010-05-06 11:04:41 -04:00
Kristian Høgsberg
49dbb9def6 intel: Enable GL_EXT_framebuffer_object for gles2 2010-05-06 11:04:28 -04:00
Chia-I Wu
90d824edaf gles: Add -I$(TOP)/include. 2010-05-06 11:04:20 -04:00
Kristian Høgsberg
d3702fc3ea mesa: Forgot to add .pc.in files for gles
Some day I'll grow up and remember to add new files when I commit.
2010-05-06 11:04:10 -04:00
Xavier Chantry
f7638f004d gallium: untrack u_indices_gen.c and u_indices_gen.c
These files are built with make and removed with make clean, so it does not
seem necessary to track them.

Looking at the Makefile, it seems that the two u_indices_* files are handled
similarly to u_format_srgb.c u_format_table.c and u_half.c, and these 3
files are already untracked and in .gitignore

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: José Fonseca <jfonseca@vmware.com>
2010-05-06 12:40:36 +01:00
José Fonseca
30e9ffcd3b mesa/st: Fill in native program limits.
In the lack of more fine grained capabilities in Gallium, assume that if
the pipe driver supports GLSL then native limits match Mesa software
limits.
(cherry picked from commit 40a90cd11234a09c2477f5c9984dd6d9fac3f52c)
2010-05-04 15:37:25 +01:00
Kristian Høgsberg
cdf9f4680f mesa: Only initialize TNL for OpenGL 2010-05-03 21:32:05 -04:00
Kristian Høgsberg
0bb23b4b6f mesa: Only initialize save dispatch table for OpenGL 2010-05-03 21:32:01 -04:00
Chia-I Wu
a2dcd67c39 mesa: Add OES_EGL_image to extension list. 2010-05-03 12:27:21 -04:00
Kristian Høgsberg
34e4091a44 Generate es glapi files when es1 or es2 is enabled 2010-05-03 12:22:30 -04:00
Xavier Chantry
ebb5228d18 Update dri state tracker to use new API aware context create 2010-05-03 12:22:29 -04:00
Kristian Høgsberg
df104eaa47 configure.ac: Fix test for whether to build src/gles 2010-05-03 12:22:29 -04:00
Kristian Høgsberg
ebf84d9a2c mesa: Include mfeatures.h before testing feature macros 2010-05-03 12:22:29 -04:00
Kristian Høgsberg
2b1b51db7d mesa: Only compile ES files when ES1 or ES2 are selected
This still requieres manual generation of the es1 and es2 glapis and is
disabled by default.
2010-05-03 12:22:28 -04:00
José Fonseca
a5fca974cf mesa: #ifdef out more remap_table related code when disabled.
Seems to get everything building again here.
2010-05-03 12:22:28 -04:00
Kristian Høgsberg
269f416864 Hook in install rules for es1 and es2 2010-05-03 12:22:28 -04:00
Kristian Høgsberg
6434e18af2 Add glesv2.pc and glesv1_cm.pc pkg-config files for ES 1 and 2 2010-05-03 12:22:27 -04:00
Kristian Høgsberg
dbf423975c st/mesa: Create context for API_OPENGL as first priority 2010-05-03 12:22:27 -04:00
Kristian Høgsberg
e53e7c9346 gles: Build libGLESv1_CM.so and libGLESv2.so from glapi files 2010-05-03 12:22:27 -04:00
Kristian Høgsberg
144b103f7f intel: Only register ES2 extensions for ES2 contexts 2010-05-03 12:22:27 -04:00
Kristian Høgsberg
09cd109d98 configure.ac: Add options to enable GLES1/2 API support 2010-05-03 12:22:26 -04:00
Kristian Høgsberg
136a938559 intel: Advertise GLES1/2 for i915+ when enabled 2010-05-03 12:22:26 -04:00
Kristian Høgsberg
159dc4deff dri: Add DRI entrypoints to create a context for a given API 2010-05-03 12:22:26 -04:00
Kristian Høgsberg
2a366a296f egl_dri2: Use new DRI API to create a GLES1/2 context when asked to 2010-05-03 12:22:25 -04:00
Kristian Høgsberg
6d54bba2d5 dri: Add DRI entrypoints to create a context for a given API 2010-05-03 12:22:25 -04:00
Kristian Høgsberg
74070e397f st/mesa: Move st_cb_drawtex.c to the mesa state tracker 2010-05-03 12:22:19 -04:00
Kristian Høgsberg
95b25b642e es: Drop es specific enums.c 2010-05-03 11:53:31 -04:00
Kristian Høgsberg
11d8caf376 glapi: Regenerate enums.c for all APIs 2010-05-03 11:53:31 -04:00
Kristian Høgsberg
5510842f97 glapi: Update gl_enum.py to generate enum tables for multiple APIs 2010-05-03 11:50:27 -04:00
Kristian Høgsberg
56e993e946 mesa: Drop unused _mesa_init_drawtex_dispatch() 2010-05-03 11:50:27 -04:00
Kristian Høgsberg
b5157a0885 mesa: Move drawtex functionality to main/ 2010-05-03 11:50:27 -04:00
Kristian Høgsberg
72c3667cb7 mesa: Move glQueryMatrixxOES() implementation to core mesa 2010-05-03 11:50:27 -04:00
Kristian Høgsberg
a063e12754 mesa: Move GLES1 texgen functions to texgen.c 2010-05-03 11:50:27 -04:00
Kristian Høgsberg
1f34dd5a7e mesa: Move support for paletted textures to main/teximage.c 2010-05-03 11:50:27 -04:00
Kristian Høgsberg
623ff81931 mesa: Handle GL_TEXTURE_GEN_STR_OES in _mesa_Enable() 2010-05-03 11:50:26 -04:00
Kristian Høgsberg
98227f3181 mesa: Move get_es*.c to main/ 2010-05-03 11:50:26 -04:00
Kristian Høgsberg
381ccb50b9 es: Prefix the get* functions with _es1/2 so they don't conflict 2010-05-03 11:50:26 -04:00
Kristian Høgsberg
64386d0893 mesa: Move GL_RGB565 workaround into fbobject.c 2010-05-03 11:50:26 -04:00
Kristian Høgsberg
cd53b44af0 mesa: Move GLES1/2 vbo entrypoints to vbo_exec_api.c
This let's us drop stubs.c.
2010-05-03 11:50:26 -04:00
Kristian Høgsberg
fda7cbdc80 mesa: Move GLES2 shader stubs to main/shaders.c 2010-05-03 11:49:31 -04:00
Kristian Høgsberg
3f03f71caf mesa: Move api_exec_es*.c into mesa/main
This requires renaming a few functions to have unique names so that
they can all live within the same driver.
2010-05-03 11:49:31 -04:00
Kristian Høgsberg
a6ba493d71 mesa: Move references to main/remap_helper.h to api_exec.c 2010-05-03 11:49:30 -04:00
Kristian Høgsberg
2180ba68f1 mesa: Move struct _glapi_table allocation out of context.c
We now allocate the table from api_exec.c and dlist.c where we fill out
the table.  This way, context.c doesn't need to know the actual contents
of struct _glapi_table.
2010-05-03 11:49:30 -04:00
Kristian Høgsberg
2a2f8580b7 mesa: Compute extension string according to API
We can now stop special casing glGetString() and drop specials_es*.c.
2010-05-03 11:49:30 -04:00
Kristian Høgsberg
7fca3e5243 es2: Move over es2 code to compute extensions 2010-05-03 11:48:10 -04:00
Kristian Høgsberg
d233c5b75e main: Report GL_SHADING_LANGUAGE_VERSION according to API 2010-05-03 11:48:10 -04:00
Kristian Høgsberg
df4d6bcbe8 mesa: Compute GL version according to API 2010-05-03 11:48:10 -04:00
Kristian Høgsberg
ba34fdb5b9 mesa: Move API specific context intialization into context.c 2010-05-03 11:48:10 -04:00
Kristian Høgsberg
2c9cc93f2a st/mesa: Use API-aware context constructor
The mesa state tracker is currently the only place where we create a
context and expect it to implement GLES1/2.  Use the API-aware constructor
to communicate this to core mesa.
2010-05-03 11:40:00 -04:00
Kristian Høgsberg
07f9b7cf82 mesa: Track the OpenGL API we're implementing in the context
This introduces a new way to create or initialize a context:

  _mesa_create_context_for_api and
  _mesa_initialize_context_for_api

which in addition to the current arguments take an api enum to indicate
which OpenGL API the context should implement.  At this point the
API field in GLcontext isn't used anywhere, but later commits will
key certain functionality off of it.

The _mesa_create_context and _mesa_initialize_context functions are
kept in place as wrappers around the *_for_api versions, passing in
API_OPENGL to get the same behavior as before.
2010-05-03 11:40:00 -04:00
Jeremy Huddleston
4d63be67f3 darwin: Fix build
This is a regression from e42d84eaba

https://bugs.freedesktop.org/show_bug.cgi?id=27929

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-05-01 13:59:30 -07:00
Brian Paul
7b640f9f70 st/mesa: fix incorrect RowStride computation
Fixes incorrect stride when getting a compressed tex image.
2010-04-28 10:06:08 -06:00
Brian Paul
56f99ee640 st/mesa: fill in stImage->level in st_generate_mipmap()
Before, this field was always zero for all the new mipmap levels.
Fixes problems with glGetTexImage() from a generated mipmap.
2010-04-28 10:05:06 -06:00
Jakob Bornecrantz
ef9a8fcb1b glx: Fix build 2010-04-28 16:25:28 +01:00
Micah Fedke
9cfaaa291f egl: dri2 driver error output
This patch amends the error output string for the case where the
dri2 egl driver could not open the dri dev node.

Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-28 07:26:01 -06:00
Brian Paul
eecd2a59c1 osmesa: update SRC_DIRS to fix build 2010-04-27 17:06:17 -06:00
Brian Paul
29fc97606b osdemos: replace assertion with error handler 2010-04-27 17:05:56 -06:00
Brian Paul
c5bf13c537 osmesa: don't need to link with -lGL
The gl entrypoints are in libOSMesa.so
2010-04-27 16:57:43 -06:00
Pierre Willenbrock
c0b41116f1 mesa: Disable scissor when begining meta operations
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-27 15:58:58 -06:00
Pierre Willenbrock
717e86738f mesa: Don't set srcLevel on GL_TEXTURE_RECTANGLE_ARB targets
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-27 15:54:24 -06:00
Pierre Willenbrok
cc806f70b2 glx: Initialize have_back.
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-27 15:53:28 -06:00
Jeremy Huddleston
a1cb3babbe Buildfixes to work around issues in OpenGL.framework
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-27 12:37:16 -07:00
Jeremy Huddleston
f64773010d Update OpenGL specs
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-27 11:26:51 -07:00
Jeremy Huddleston
f5aa5377a5 apple: Use mesa gl.h rather than generating one.
Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
2010-04-27 11:26:51 -07:00
Jeremy Huddleston
de96d063b1 apple: Integrate our libGL into the existing build system better
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-27 11:26:51 -07:00
Jeremy Huddleston
163901bc7f darwin: Use clientattrib
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-27 11:26:51 -07:00
Jeremy Huddleston
80b280db88 apple: Change ifdefs for DRI to be DRI && !APPLE
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-27 11:26:51 -07:00
Jeremy Huddleston
77dc40b289 apple: Remove duplicate headers that already exist in mesa.
Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
2010-04-27 11:26:50 -07:00
Jeremy Huddleston
ad503c4155 apple: Initial import of libGL for OSX from AppleSGLX svn repository.
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-27 11:26:50 -07:00
Chia-I Wu
f1381880a8 glapi: Fix loading of old DRI drivers.
The removal of _glapi_noop_enable_warnings and _glapi_set_warning_func
in e4f168a6f4 prevents DRI drivers built
before the commit from loading.  Add stub versions of the functions to
make them load again.
2010-04-27 23:19:27 +08:00
Pedro Maia
ea373df069 nv30/40g: fix calls to draw_create(), draw_set_rasterizer_state()
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-27 08:22:11 -06:00
Brian Paul
b0e2c5f8aa docs: document updated glext.h and glxext.h files 2010-04-26 20:32:24 -06:00
Brian Paul
4eb803975d glxext.h: upgraded to 2010/02/10 version 2010-04-26 20:32:02 -06:00
Brian Paul
273058b677 glext: upgraded to version 61 2010-04-26 20:31:19 -06:00
Brian Paul
b695cbd57c docs: add links to old mailing list archives 2010-04-23 15:36:40 -06:00
Aaron Plattner
ad7d36e919 Fix __glXInitializeVisualConfigFromTags's handling of unrecognized fbconfig tags.
__glXInitializeVisualConfigFromTags doesn't skip the payload of
unrecognized tags.  Instead, it treats the value as if it were the
next tag, which can happen if the server's GLX extension is not
Mesa's.  For example, this falls down when NVIDIA sends a
GLX_FLOAT_COMPONENTS_NV = 0 pair, causing
__glXInitializeVisualConfigFromTags to bail out early.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-04-23 11:48:11 -07:00
Jerome Glisse
eb4dc54788 r600: don't enable depth test if there is no depth buffer
If there is no depth buffer bound to current context don't
enable depth test. GL states that if depth test is enabled
without depth buffer it's as if depth buffer always pass.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
2010-04-23 11:56:06 +02:00
Michel Dänzer
c37e275e77 glx/dri2: Fix build with dri2proto which doesn't define X_DRI2SwapInterval. 2010-04-23 11:16:03 +02:00
Tormod Volden
355370e30b radeon: 9800 SE has only one quadpipe
Although these cards have 2 pipelines on the silicon only
the first passed the QA and the other should be disabled.

http://www.digital-daily.com/video/ati-radeon9800se/
http://www.rojakpot.com/showarticle.aspx?artno=101&pgno=1

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
2010-04-22 17:14:15 -04:00
Brian Paul
b1a9c76b57 st/mesa: add cases for MESA_FORMAT_Z24_X8, MESA_FORMAT_X8_Z24 2010-04-22 11:06:19 -06:00
Brian Paul
4d7ef6e06b mesa: fix conversion errors in signed_rgba8888[rev] texel fetch
Without the cast the returned texel colors were wrong.
Also, we don't need the "& 0xff" part anymore.
Bug found by Vinson Lee.
2010-04-22 11:06:19 -06:00
Alex Deucher
986eb4b99f r300: fix vertex unit setup
RV3xx is 2, RV560,RV570 is 8

Noticed by Tormod Volden.
2010-04-22 02:33:10 -04:00
Aaron Plattner
2e995cdf25 progs/demos: Fix the progs/demos/rain help text
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-21 18:13:19 -06:00
Dan Nicholson
88be2171e7 egl: Pass flags to locate Xlib headers and libraries
eglplatform.h pulls in Xlib.h on X11 platforms. Likewise, the egl glx
driver and egl programs needs to link to libX11. Make sure we use the
locations the user told us about.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-19 20:21:57 -07:00
Dan Nicholson
8e5effefc7 progs: Fix linking of Xlib demos for non-autoconf builds
The Xlib demos were fixed to use $(X11_LIBS) so that configure could
detect the proper directory to link the library from, but this broke
the non-autoconf builds. Give X11_LIBS a default value to fallback on.
(cherry picked from commit e40fce13e1)
2010-04-19 20:21:57 -07:00
Dan Nicholson
4e7a4bed37 Change libX11 variables to not conflict with AC_PATH_XTRA
The variable X_LIBS from AC_PATH_XTRA contains only the -L searchdir
parameter and not the -lX11 to link to Xlib. Use X11 prefixed build vars
for linking with Xlib to avoid the conflict.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
(cherry picked from commit e725ef171b)
2010-04-19 20:21:57 -07:00
Dan Nicholson
4f8bf353bd gallium: Respect user's CFLAGS for including X headers
This can break on systems that don't have a system X installation.

Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
(cherry picked from commit de4ee20578)

Conflicts:

	src/gallium/winsys/xlib/Makefile
2010-04-19 20:21:57 -07:00
Jeff Smith
3b693fd93f Use X_LIBS from pkg-config, instead of libdir, for locating libX11
Signed-off-by: Jeff Smith <whydoubt@yahoo.com>
Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
(cherry picked from commit 8d86d395dc)
2010-04-19 20:21:57 -07:00
Jesse Barnes
0a18cdb0ed DRI2: check for swapAvailable before using swap interval protocol
This should have been part of the last change...
2010-04-19 14:20:21 -07:00
Jesse Barnes
385e2896eb DRI2: synchronize swap interval with server at startup time
In the direct rendered case, we need to tell the server our initial swap
interval.  If we don't, the local and server values will be out of sync,
since the server and client defaults may be different (as they were
before this patch).
2010-04-19 09:56:32 -07:00
Brian Paul
c060265bdb st/mesa: invert scissor rect depending on FB orientation
Fixes fd.o bug 27715
2010-04-19 10:10:47 -06:00
Matthieu Herrb
cf7d08b443 mesa: Fix build with gcc 3.3.
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-19 09:33:53 -06:00
Matthieu Herrb
f4553d99c6 radeon: Let this build with gcc 3.3
Declaring the loop index inside for () is not supported by this version.

Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-19 09:33:53 -06:00
Owain Ainsworth
c39ab02ae9 radeon: Fix command type for DRM_RADEON_IRQ_EMIT ioctl.
This should be drmCommandWriteRead to avoid an EINVAL error on systems
that strictly check ioctl args. This command has been r/w for ever.
Discussion with airlied agreed that this was the correct course.

Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-19 09:33:50 -06:00
Matthieu Herrb
7f1ae3a94d mesa: Use __OpenBSD__ to check for OpenBSD.
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-19 09:33:42 -06:00
Brian Paul
e3a34cc7f6 gallium/draw: use correct rasterization state for wide/AA points/lines
When points or lines are decomposed into triangles, we need to be sure
to disable polygon culling, stippling, "un-filled" modes, etc.

This patch sets the rasterization state to disable those things prior to
drawing points/lines with triangles, then restores the previous state
afterward.

The new piglit point-no-line-cull test checks this problem & solution.
2010-04-19 08:35:53 -06:00
286 changed files with 61939 additions and 12605 deletions

View File

@@ -14,6 +14,8 @@ ARCH_FLAGS = @ARCH_FLAGS@
ASM_FLAGS = @ASM_FLAGS@
PIC_FLAGS = @PIC_FLAGS@
DEFINES = @DEFINES@
API_DEFINES = @API_DEFINES@
APIS = @APIS@
CFLAGS = @CPPFLAGS@ @CFLAGS@ \
$(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ \
@@ -24,8 +26,10 @@ RADEON_CFLAGS = @RADEON_CFLAGS@
RADEON_LDFLAGS = @RADEON_LDFLAGS@
INTEL_LIBS = @INTEL_LIBS@
INTEL_CFLAGS = @INTEL_CFLAGS@
X11_LIBS = @X11_LIBS@
X11_CFLAGS = @X11_CFLAGS@
# Assembler
# Source selection
MESA_ASM_SOURCES = @MESA_ASM_SOURCES@
GLAPI_ASM_SOURCES = @GLAPI_ASM_SOURCES@
@@ -47,6 +51,8 @@ GLU_LIB = GLU
GLUT_LIB = glut
GLW_LIB = GLw
OSMESA_LIB = @OSMESA_LIB@
GLESv1_CM_LIB = GLESv1_CM
GLESv2_LIB = GLESv2
# Library names (actual file names)
GL_LIB_NAME = @GL_LIB_NAME@
@@ -55,6 +61,8 @@ GLUT_LIB_NAME = @GLUT_LIB_NAME@
GLW_LIB_NAME = @GLW_LIB_NAME@
OSMESA_LIB_NAME = @OSMESA_LIB_NAME@
EGL_LIB_NAME = @EGL_LIB_NAME@
GLESv1_CM_LIB_NAME = @GLESv1_CM_LIB_NAME@
GLESv2_LIB_NAME = @GLESv2_LIB_NAME@
# Globs used to install the lib and all symlinks
GL_LIB_GLOB = @GL_LIB_GLOB@
@@ -63,6 +71,8 @@ GLUT_LIB_GLOB = @GLUT_LIB_GLOB@
GLW_LIB_GLOB = @GLW_LIB_GLOB@
OSMESA_LIB_GLOB = @OSMESA_LIB_GLOB@
EGL_LIB_GLOB = @EGL_LIB_GLOB@
GLESv1_CM_LIB_GLOB = @GLESv1_CM_LIB_GLOB@
GLESv2_LIB_GLOB = @GLESv2_LIB_GLOB@
# Directories to build
LIB_DIR = @LIB_DIR@
@@ -105,6 +115,8 @@ GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLUT_MESA_DEPS@ \
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLW_MESA_DEPS@ \
$(EXTRA_LIB_PATH) @GLW_LIB_DEPS@
APP_LIB_DEPS = $(EXTRA_LIB_PATH) @APP_LIB_DEPS@
GLESv1_CM_LIB_DEPS = $(EXTRA_LIB_PATH) @GLESv1_LIB_DEPS@
GLESv2_LIB_DEPS = $(EXTRA_LIB_PATH) @GLESv2_LIB_DEPS@
# DRI dependencies
DRI_LIB_DEPS = $(EXTRA_LIB_PATH) @DRI_LIB_DEPS@
@@ -153,6 +165,11 @@ GLW_PC_LIB_PRIV = @GLW_PC_LIB_PRIV@
GLW_PC_CFLAGS = @GLW_PC_CFLAGS@
OSMESA_PC_REQ = @OSMESA_PC_REQ@
OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@
GLESv1_CM_PC_LIB_PRIV = @GLESv1_CM_PC_LIB_PRIV@
GLESv2_PC_LIB_PRIV = @GLESv2_PC_LIB_PRIV@
EGL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@
EGL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@
EGL_PC_CFLAGS = @GL_PC_CFLAGS@
EGL_DRI2_CFLAGS = @EGL_DRI2_CFLAGS@
EGL_DRI2_LIBS = @EGL_DRI2_LIBS@

View File

@@ -13,7 +13,10 @@ CC = gcc
CXX = g++
PIC_FLAGS = -fPIC
DEFINES = -D_DARWIN_C_SOURCE -DPTHREADS -D_GNU_SOURCE \
-DGLX_ALIAS_UNSUPPORTED -DGLX_INDIRECT_RENDERING
-DGLX_ALIAS_UNSUPPORTED \
-DGLX_DIRECT_RENDERING -DGLX_USE_APPLEGL
# -DGLX_INDIRECT_RENDERING \
# -D_GNU_SOURCE - for src/mesa/main ...
# -DGLX_DIRECT_RENDERING - pulls in libdrm stuff in glx
@@ -49,7 +52,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXmu -lXt -lXi -lm
# omit glw lib for now:
SRC_DIRS = glsl glx mesa gallium glu glut/glx glew
SRC_DIRS = glsl glx/apple mesa gallium glu glut/glx glew
GLU_DIRS = sgi
DRIVER_DIRS = osmesa
#DRIVER_DIRS = dri

View File

@@ -119,7 +119,7 @@ APP_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LI
# Program dependencies - specific GL/glut libraries added in Makefiles
APP_LIB_DEPS = -lm
X11_LIBS = -lX11
# Installation directories (for make install)
INSTALL_DIR = /usr/local

View File

@@ -9,7 +9,7 @@ CONFIG_NAME = linux-osmesa
# Compiler and flags
CC = gcc
CXX = g++
CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS
CFLAGS = -g -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -DPTHREADS
CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
# Work around aliasing bugs - developers should comment this out
@@ -17,12 +17,12 @@ CFLAGS += -fno-strict-aliasing
CXXFLAGS += -fno-strict-aliasing
# Directories
SRC_DIRS = gallium mesa glu
SRC_DIRS = glsl mesa glu
DRIVER_DIRS = osmesa
PROGRAM_DIRS = osdemos
# Dependencies
OSMESA_LIB_DEPS = -lm -lpthread
OSMESA_LIB_DEPS = -lm -lpthread -ldl
GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
APP_LIB_DEPS = -lm -lpthread

View File

@@ -20,7 +20,7 @@ OSMESA_LIB_NAME = libOSMesa16.so
# Directories
SRC_DIRS = gallium mesa glu
SRC_DIRS = glsl mesa glu
DRIVER_DIRS = osmesa
PROGRAM_DIRS =

View File

@@ -20,7 +20,7 @@ OSMESA_LIB_NAME = libOSMesa32.so
# Directories
SRC_DIRS = gallium mesa glu
SRC_DIRS = glsl mesa glu
DRIVER_DIRS = osmesa
PROGRAM_DIRS =

View File

@@ -279,6 +279,8 @@ GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION}
GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION}
OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION}
EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION}
GLESv1_CM_LIB_NAME='lib$(GLESv1_CM_LIB).'${LIB_EXTENSION}
GLESv2_LIB_NAME='lib$(GLESv2_LIB).'${LIB_EXTENSION}
GL_LIB_GLOB='lib$(GL_LIB).*'${LIB_EXTENSION}'*'
GLU_LIB_GLOB='lib$(GLU_LIB).*'${LIB_EXTENSION}'*'
@@ -286,6 +288,8 @@ GLUT_LIB_GLOB='lib$(GLUT_LIB).*'${LIB_EXTENSION}'*'
GLW_LIB_GLOB='lib$(GLW_LIB).*'${LIB_EXTENSION}'*'
OSMESA_LIB_GLOB='lib$(OSMESA_LIB).*'${LIB_EXTENSION}'*'
EGL_LIB_GLOB='lib$(EGL_LIB).*'${LIB_EXTENSION}'*'
GLESv1_CM_LIB_GLOB='lib$(GLESv1_CM_LIB).*'${LIB_EXTENSION}'*'
GLESv2_LIB_GLOB='lib$(GLESv2_LIB).*'${LIB_EXTENSION}'*'
AC_SUBST([GL_LIB_NAME])
AC_SUBST([GLU_LIB_NAME])
@@ -293,6 +297,8 @@ AC_SUBST([GLUT_LIB_NAME])
AC_SUBST([GLW_LIB_NAME])
AC_SUBST([OSMESA_LIB_NAME])
AC_SUBST([EGL_LIB_NAME])
AC_SUBST([GLESv1_CM_LIB_NAME])
AC_SUBST([GLESv2_LIB_NAME])
AC_SUBST([GL_LIB_GLOB])
AC_SUBST([GLU_LIB_GLOB])
@@ -300,6 +306,8 @@ AC_SUBST([GLUT_LIB_GLOB])
AC_SUBST([GLW_LIB_GLOB])
AC_SUBST([OSMESA_LIB_GLOB])
AC_SUBST([EGL_LIB_GLOB])
AC_SUBST([GLESv1_CM_LIB_GLOB])
AC_SUBST([GLESv2_LIB_GLOB])
dnl
dnl Arch/platform-specific settings
@@ -547,8 +555,14 @@ else
x11_pkgconfig=no
fi
dnl Use the autoconf macro if no pkg-config files
if test "$x11_pkgconfig" = no; then
if test "$x11_pkgconfig" = yes; then
PKG_CHECK_MODULES([X11], [x11])
else
AC_PATH_XTRA
test -z "$X11_CFLAGS" && X11_CFLAGS="$X_CFLAGS"
test -z "$X11_LIBS" && X11_LIBS="$X_LIBS -lX11"
AC_SUBST([X11_CFLAGS])
AC_SUBST([X11_LIBS])
fi
dnl Try to tell the user that the --x-* options are only used when
@@ -649,6 +663,10 @@ dri)
# need DRM libs, -lpthread, etc.
GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
GLESv2_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
;;
osmesa)
# No libGL for osmesa
@@ -660,6 +678,11 @@ AC_SUBST([GL_PC_REQ_PRIV])
AC_SUBST([GL_PC_LIB_PRIV])
AC_SUBST([GL_PC_CFLAGS])
AC_SUBST([DRI_PC_REQ_PRIV])
AC_SUBST([GLESv1_LIB_DEPS])
AC_SUBST([GLESv1_CM_PC_LIB_PRIV])
AC_SUBST([GLESv2_LIB_DEPS])
AC_SUBST([GLESv2_PC_LIB_PRIV])
dnl
dnl More X11 setup
@@ -707,6 +730,45 @@ if test "x$with_dri_drivers" = x; then
with_dri_drivers=no
fi
dnl Determine which APIs to support
AC_ARG_ENABLE([opengl],
[AS_HELP_STRING([--disable-opengl],
[disable support for standard OpenGL API @<:@default=no@:>@])],
[enable_opengl="$enableval"],
[enable_opengl=yes])
AC_ARG_ENABLE([gles1],
[AS_HELP_STRING([--enable-gles1],
[enable support for OpenGL ES 1.x API @<:@default=no@:>@])],
[enable_gles1="$enableval"],
[enable_gles1=no])
AC_ARG_ENABLE([gles2],
[AS_HELP_STRING([--enable-gles2],
[enable support for OpenGL ES 2.x API @<:@default=no@:>@])],
[enable_gles2="$enableval"],
[enable_gles2=no])
API_DEFINES=""
APIS=""
if test "x$enable_opengl" = xno; then
API_DEFINES="$API_DEFINES -DFEATURE_GL=0"
else
API_DEFINES="$API_DEFINES -DFEATURE_GL=1"
APIS="$APIS gl"
fi
if test "x$enable_gles1" = xyes; then
API_DEFINES="$API_DEFINES -DFEATURE_ES1=1"
APIS="$APIS es1"
fi
if test "x$enable_gles2" = xyes; then
API_DEFINES="$API_DEFINES -DFEATURE_ES2=1"
APIS="$APIS es2"
fi
if test "x$enable_gles1" = xyes -o "x$enable_gles2" = xyes; then
SRC_DIRS="$SRC_DIRS gles"
fi
AC_SUBST([API_DEFINES])
AC_SUBST([APIS])
dnl If $with_dri_drivers is yes, directories will be added through
dnl platform checks
DRI_DIRS=""

View File

@@ -40,6 +40,15 @@ versions are sent to this list. Very low traffic.
Follow the links above for list archives.
</p>
<p>
The old Mesa lists hosted at SourceForge are no longer in use.
The archives are still available, however:
<a href="http://sourceforge.net/mailarchive/forum.php?forum_name=mesa3d-announce" target="_parent">mesa3d-announce</a>,
<a href="http://sourceforge.net/mailarchive/forum.php?forum_name=mesa3d-users" target="_parent">mesa3d-users</a>,
<a href="http://sourceforge.net/mailarchive/forum.php?forum_name=mesa3d-dev" target="_parent">mesa3d-dev</a>.
</p>
<p>For mailing lists about Direct Rendering Modules (drm) in Linux/BSD
kernels, see the
<a href="http://dri.freedesktop.org/wiki/MailingLists" target="_parent">

View File

@@ -34,6 +34,12 @@ tbd
<p>None.</p>
<h2>Changes</h2>
<ul>
<li>Upgraded glext.h to version 61, and upgraded glxext.h
</ul>
<h2>Bug fixes</h2>
<ul>
<li>Fixed Gallium glDrawPixels(GL_DEPTH_COMPONENT).

View File

@@ -227,6 +227,25 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYCONTEXTMESA) (EGLDisplay dpy, EGLCont
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
#endif
#ifndef EGL_NOK_swap_region
#define EGL_NOK_swap_region 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint* rects);
#endif
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint* rects);
#endif
#ifndef EGL_NOK_texture_from_pixmap
#define EGL_NOK_texture_from_pixmap 1
#define EGL_Y_INVERTED_NOK 0x307F
#endif /* EGL_NOK_texture_from_pixmap */
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -124,6 +124,10 @@ extern "C" {
#define GLX_SAMPLES_ARB 100001
#endif
#ifndef GLX_ARB_vertex_buffer_object
#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095
#endif
#ifndef GLX_ARB_fbconfig_float
#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9
#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004

View File

@@ -730,7 +730,11 @@ struct __DRIdri2LoaderExtensionRec {
* constructors for DRI2.
*/
#define __DRI_DRI2 "DRI_DRI2"
#define __DRI_DRI2_VERSION 1
#define __DRI_DRI2_VERSION 2
#define __DRI_API_OPENGL 0
#define __DRI_API_GLES 1
#define __DRI_API_GLES2 2
struct __DRIdri2ExtensionRec {
__DRIextension base;
@@ -749,6 +753,14 @@ struct __DRIdri2ExtensionRec {
__DRIcontext *shared,
void *loaderPrivate);
/* Since version 2 */
unsigned int (*getAPIMask)(__DRIscreen *screen);
__DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
int api,
const __DRIconfig *config,
__DRIcontext *shared,
void *data);
};

View File

@@ -158,7 +158,7 @@ static void printhelp(void)
glRasterPos2i(60,240);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"l - Increase rain length");
glRasterPos2i(60,210);
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"k - Increase rain length");
printstring(GLUT_BITMAP_TIMES_ROMAN_24,"k - Decrease rain length");
}
static void drawrain(void)

View File

@@ -4,7 +4,7 @@ TOP = ../..
include $(TOP)/configs/current
INCLUDE_DIRS = -I$(TOP)/include
INCLUDE_DIRS = -I$(TOP)/include $(X11_CFLAGS)
HEADERS = $(TOP)/include/GLES/egl.h
LIB_DEP = $(TOP)/$(LIB_DIR)/libEGL.so
@@ -57,13 +57,13 @@ peglgears: peglgears.o $(HEADERS) $(LIB_DEP)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) -lm
xeglgears: xeglgears.o $(HEADERS) $(LIB_DEP)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm -L$(libdir) -lX11
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS)
xeglthreads: xeglthreads.o $(HEADERS) $(LIB_DEP)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm -L$(libdir) -lX11
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS)
xegl_tri: xegl_tri.o $(HEADERS) $(LIB_DEP)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm -L$(libdir) -lX11
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm $(X11_LIBS)
clean:
-rm -f *.o *~

View File

@@ -5,7 +5,7 @@ include $(TOP)/configs/current
INCDIR = $(TOP)/include
OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -l$(OSMESA_LIB) $(APP_LIB_DEPS)
OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(OSMESA_LIB) $(APP_LIB_DEPS)
OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa16 -l$(GLU_LIB) \
-l$(GL_LIB) $(APP_LIB_DEPS)

View File

@@ -399,7 +399,11 @@ test(GLenum type, GLint bits, const char *filename)
/* sanity checks */
glGetIntegerv(GL_RED_BITS, &cBits);
assert(cBits == bits);
if (cBits != bits) {
fprintf(stderr, "Unable to create %d-bit/channel renderbuffer.\n", bits);
fprintf(stderr, "May need to recompile Mesa with CHAN_BITS=16 or 32.\n");
return 0;
}
glGetIntegerv(GL_GREEN_BITS, &cBits);
assert(cBits == bits);
glGetIntegerv(GL_BLUE_BITS, &cBits);

View File

@@ -9,9 +9,9 @@ INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
# Add X11 and pthread libs to satisfy GNU gold.
APP_LIB_DEPS += -lX11 -lpthread
APP_LIB_DEPS += $(X11_LIBS) -lpthread
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(libdir) $(APP_LIB_DEPS)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
PROGS = \
corender \

View File

@@ -51,9 +51,13 @@
#include "eglsurface.h"
#include "eglimage.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
struct dri2_egl_driver
{
_EGLDriver base;
void (*glFlush)(void);
};
struct dri2_egl_display
@@ -161,7 +165,7 @@ EGLint dri2_to_egl_attribute_map[] = {
0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA */
0, /* __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE */
0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
0, /* __DRI_ATTRIB_YINVERTED */
EGL_Y_INVERTED_NOK, /* __DRI_ATTRIB_YINVERTED */
};
static void
@@ -252,9 +256,8 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
_eglSetConfigKey(&base,
EGL_BIND_TO_TEXTURE_RGBA, bind_to_texture_rgba);
/* EGL_OPENGL_ES_BIT, EGL_OPENVG_BIT, EGL_OPENGL_ES2_BIT */
_eglSetConfigKey(&base, EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT);
_eglSetConfigKey(&base, EGL_CONFORMANT, EGL_OPENGL_BIT);
_eglSetConfigKey(&base, EGL_RENDERABLE_TYPE, disp->ClientAPIsMask);
_eglSetConfigKey(&base, EGL_CONFORMANT, disp->ClientAPIsMask);
if (!_eglValidateConfig(&base, EGL_FALSE)) {
_eglLog(_EGL_DEBUG, "DRI2: failed to validate config %d", id);
@@ -641,6 +644,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
const __DRIextension **extensions;
struct dri2_egl_display *dri2_dpy;
char path[PATH_MAX], *search_paths, *p, *next, *end;
unsigned int api_mask;
dri2_dpy = malloc(sizeof *dri2_dpy);
if (!dri2_dpy)
@@ -683,10 +687,12 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
snprintf(path, sizeof path,
dri_driver_format, (int) (next - p), p, dri2_dpy->driver_name);
dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
if (dri2_dpy->driver == NULL)
_eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror());
}
if (dri2_dpy->driver == NULL) {
_eglLog(_EGL_FATAL,
_eglLog(_EGL_WARNING,
"DRI2: failed to open any driver (search paths %s)",
search_paths);
goto cleanup_conn;
@@ -695,7 +701,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
_eglLog(_EGL_DEBUG, "DRI2: dlopen(%s)", path);
extensions = dlsym(dri2_dpy->driver, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
_eglLog(_EGL_FATAL,
_eglLog(_EGL_WARNING,
"DRI2: driver exports no extensions (%s)", dlerror());
goto cleanup_driver;
}
@@ -705,8 +711,9 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
dri2_dpy->fd = open(dri2_dpy->device_name, O_RDWR);
if (dri2_dpy->fd == -1) {
_eglLog(_EGL_FATAL,
"DRI2: could not open %s (%s)", path, strerror(errno));
_eglLog(_EGL_WARNING,
"DRI2: could not open %s (%s)", dri2_dpy->device_name,
strerror(errno));
goto cleanup_driver;
}
@@ -743,7 +750,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
&dri2_dpy->driver_configs, dri2_dpy);
if (dri2_dpy->dri_screen == NULL) {
_eglLog(_EGL_FATAL, "DRI2: failed to create dri screen");
_eglLog(_EGL_WARNING, "DRI2: failed to create dri screen");
goto cleanup_fd;
}
@@ -751,15 +758,30 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
if (!dri2_bind_extensions(dri2_dpy, dri2_core_extensions, extensions))
goto cleanup_dri_screen;
if (dri2_dpy->dri2->base.version >= 2)
api_mask = dri2_dpy->dri2->getAPIMask(dri2_dpy->dri_screen);
else
api_mask = __DRI_API_OPENGL;
disp->ClientAPIsMask = 0;
if (api_mask & (1 <<__DRI_API_OPENGL))
disp->ClientAPIsMask |= EGL_OPENGL_BIT;
if (api_mask & (1 <<__DRI_API_GLES))
disp->ClientAPIsMask |= EGL_OPENGL_ES_BIT;
if (api_mask & (1 << __DRI_API_GLES2))
disp->ClientAPIsMask |= EGL_OPENGL_ES2_BIT;
if (dri2_dpy->conn) {
if (!dri2_add_configs_for_visuals(dri2_dpy, disp))
goto cleanup_configs;
}
disp->ClientAPIsMask = EGL_OPENGL_BIT;
disp->Extensions.KHR_image_base = EGL_TRUE;
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
disp->Extensions.KHR_gl_texture_2D_image = EGL_TRUE;
disp->Extensions.NOK_swap_region = EGL_TRUE;
disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
/* we're supporting EGL 1.4 */
*major = 1;
@@ -818,6 +840,7 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_context *dri2_ctx_shared = dri2_egl_context(share_list);
struct dri2_egl_config *dri2_config = dri2_egl_config(conf);
int api;
dri2_ctx = malloc(sizeof *dri2_ctx);
if (!dri2_ctx) {
@@ -828,12 +851,46 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
if (!_eglInitContext(&dri2_ctx->base, disp, conf, attrib_list))
goto cleanup;
dri2_ctx->dri_context =
dri2_dpy->dri2->createNewContext(dri2_dpy->dri_screen,
dri2_config->dri_config,
dri2_ctx_shared ?
dri2_ctx_shared->dri_context : NULL,
dri2_ctx);
switch (dri2_ctx->base.ClientAPI) {
case EGL_OPENGL_ES_API:
switch (dri2_ctx->base.ClientVersion) {
case 1:
api = __DRI_API_GLES;
break;
case 2:
api = __DRI_API_GLES2;
break;
default:
_eglError(EGL_BAD_PARAMETER, "eglCreateContext");
return NULL;
}
break;
case EGL_OPENGL_API:
api = __DRI_API_OPENGL;
break;
default:
_eglError(EGL_BAD_PARAMETER, "eglCreateContext");
return NULL;
}
if (dri2_dpy->dri2->base.version >= 2) {
dri2_ctx->dri_context =
dri2_dpy->dri2->createNewContextForAPI(dri2_dpy->dri_screen,
api,
dri2_config->dri_config,
dri2_ctx_shared ?
dri2_ctx_shared->dri_context : NULL,
dri2_ctx);
} else if (api == __DRI_API_OPENGL) {
dri2_ctx->dri_context =
dri2_dpy->dri2->createNewContext(dri2_dpy->dri_screen,
dri2_config->dri_config,
dri2_ctx_shared ?
dri2_ctx_shared->dri_context : NULL,
dri2_ctx);
} else {
/* fail */
}
if (!dri2_ctx->dri_context)
goto cleanup;
@@ -873,6 +930,7 @@ static EGLBoolean
dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
_EGLSurface *rsurf, _EGLContext *ctx)
{
struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_dsurf = dri2_egl_surface(dsurf);
struct dri2_egl_surface *dri2_rsurf = dri2_egl_surface(rsurf);
@@ -884,6 +942,10 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
if (!_eglBindContext(&ctx, &dsurf, &rsurf))
return EGL_FALSE;
/* flush before context switch */
if (ctx && dri2_drv->glFlush)
dri2_drv->glFlush();
ddraw = (dri2_dsurf) ? dri2_dsurf->dri_drawable : NULL;
rdraw = (dri2_rsurf) ? dri2_rsurf->dri_drawable : NULL;
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
@@ -1009,12 +1071,21 @@ dri2_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
}
static EGLBoolean
dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
dri2_copy_region(_EGLDriver *drv, _EGLDisplay *disp,
_EGLSurface *draw, xcb_xfixes_region_t region)
{
struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
_EGLContext *ctx;
xcb_dri2_copy_region_cookie_t cookie;
if (dri2_drv->glFlush) {
ctx = _eglGetCurrentContext();
if (ctx && ctx->DrawSurface == &dri2_surf->base)
dri2_drv->glFlush();
}
(*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
#if 0
@@ -1033,7 +1104,7 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
cookie = xcb_dri2_copy_region_unchecked(dri2_dpy->conn,
dri2_surf->drawable,
dri2_surf->region,
region,
XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT,
XCB_DRI2_ATTACHMENT_BUFFER_FAKE_FRONT_LEFT);
free(xcb_dri2_copy_region_reply(dri2_dpy->conn, cookie, NULL));
@@ -1041,6 +1112,44 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
return EGL_TRUE;
}
static EGLBoolean
dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
{
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
return dri2_copy_region(drv, disp, draw, dri2_surf->region);
}
static EGLBoolean
dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw,
EGLint numRects, const EGLint *rects)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
EGLBoolean ret;
xcb_xfixes_region_t region;
xcb_rectangle_t rectangles[16];
int i;
if (numRects > ARRAY_SIZE(rectangles))
return dri2_copy_region(drv, disp, draw, dri2_surf->region);
/* FIXME: Invert y here? */
for (i = 0; i < numRects; i++) {
rectangles[i].x = rects[i * 4];
rectangles[i].y = rects[i * 4 + 1];
rectangles[i].width = rects[i * 4 + 2];
rectangles[i].height = rects[i * 4 + 3];
}
region = xcb_generate_id(dri2_dpy->conn);
xcb_xfixes_create_region(dri2_dpy->conn, region, numRects, rectangles);
ret = dri2_copy_region(drv, disp, draw, region);
xcb_xfixes_destroy_region(dri2_dpy->conn, region);
return ret;
}
/*
* Called from eglGetProcAddress() via drv->API.GetProcAddress().
*/
@@ -1121,19 +1230,8 @@ dri2_bind_tex_image(_EGLDriver *drv,
ctx = _eglGetCurrentContext();
dri2_ctx = dri2_egl_context(ctx);
if (buffer != EGL_BACK_BUFFER) {
_eglError(EGL_BAD_PARAMETER, "eglBindTexImage");
if (!_eglBindTexImage(drv, disp, surf, buffer))
return EGL_FALSE;
}
/* We allow binding pixmaps too... Not conformat, but we can do it
* for free and it's useful for X compositors. Supposedly there's
* a EGL_NOKIA_texture_from_pixmap extension that allows that, but
* I couldn't find it at this time. */
if ((dri2_surf->base.Type & (EGL_PBUFFER_BIT | EGL_PIXMAP_BIT)) == 0) {
_eglError(EGL_BAD_SURFACE, "eglBindTexImage");
return EGL_FALSE;
}
switch (dri2_surf->base.TextureFormat) {
case EGL_TEXTURE_RGB:
@@ -1143,8 +1241,7 @@ dri2_bind_tex_image(_EGLDriver *drv,
format = __DRI_TEXTURE_FORMAT_RGBA;
break;
default:
_eglError(EGL_BAD_MATCH, "eglBindTexImage");
return EGL_FALSE;
assert(0);
}
switch (dri2_surf->base.TextureTarget) {
@@ -1152,15 +1249,14 @@ dri2_bind_tex_image(_EGLDriver *drv,
target = GL_TEXTURE_2D;
break;
default:
_eglError(EGL_BAD_PARAMETER, "eglBindTexImage");
return EGL_FALSE;
assert(0);
}
(*dri2_dpy->tex_buffer->setTexBuffer2)(dri2_ctx->dri_context,
target, format,
dri2_surf->dri_drawable);
return dri2_surf->base.BoundToTexture = EGL_TRUE;
return EGL_TRUE;
}
static EGLBoolean
@@ -1330,6 +1426,7 @@ _eglMain(const char *args)
if (!dri2_drv)
return NULL;
memset(dri2_drv, 0, sizeof *dri2_drv);
_eglInitDriverFallbacks(&dri2_drv->base);
dri2_drv->base.API.Initialize = dri2_initialize;
dri2_drv->base.API.Terminate = dri2_terminate;
@@ -1348,9 +1445,13 @@ _eglMain(const char *args)
dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image;
dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
dri2_drv->base.API.SwapBuffersRegionNOK = dri2_swap_buffers_region;
dri2_drv->base.Name = "DRI2";
dri2_drv->base.Unload = dri2_unload;
dri2_drv->glFlush =
(void (*)(void)) dri2_get_proc_address(&dri2_drv->base, "glFlush");
return &dri2_drv->base;
}

View File

@@ -10,7 +10,7 @@ EGL_INCLUDES = \
-I$(TOP)/include \
-I$(TOP)/src/egl/main
EGL_CFLAGS =
EGL_LIBS = -lX11 -lGL
EGL_CFLAGS = $(X11_CFLAGS)
EGL_LIBS = $(X11_LIBS) -lGL
include ../Makefile.template

View File

@@ -41,6 +41,7 @@
#include "eglconfigutil.h"
#include "eglconfig.h"
#include "eglcontext.h"
#include "egldefines.h"
#include "egldisplay.h"
#include "egldriver.h"
#include "eglcurrent.h"
@@ -48,7 +49,6 @@
#include "eglsurface.h"
#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#ifndef GLX_VERSION_1_4
#error "GL/glx.h must be equal to or greater than GLX 1.4"

View File

@@ -7,7 +7,7 @@ include $(TOP)/configs/current
EGL_MAJOR = 1
EGL_MINOR = 0
INCLUDE_DIRS = -I$(TOP)/include
INCLUDE_DIRS = -I$(TOP)/include $(X11_CFLAGS)
HEADERS = \
eglcompiler.h \
@@ -82,10 +82,27 @@ install-headers:
$(INSTALL) -m 644 $(TOP)/include/EGL/*.h \
$(DESTDIR)$(INSTALL_INC_DIR)/EGL
install: default install-headers
PKG_CONFIG_DIR = $(INSTALL_LIB_DIR)/pkgconfig
gl_pcedit = sed \
-e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
-e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
-e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
-e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \
-e 's,@EGL_PC_REQ_PRIV@,$(EGL_PC_REQ_PRIV),' \
-e 's,@EGL_PC_LIB_PRIV@,$(EGL_PC_LIB_PRIV),' \
-e 's,@EGL_PC_CFLAGS@,$(EGL_PC_CFLAGS),' \
-e 's,@EGL_LIB@,$(EGL_LIB),'
egl.pc: egl.pc.in
$(gl_pcedit) $< > $@
install: default install-headers egl.pc
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
$(MINSTALL) $(TOP)/$(LIB_DIR)/$(EGL_LIB_GLOB) \
$(DESTDIR)$(INSTALL_LIB_DIR)
$(INSTALL) -d $(DESTDIR)$(PKG_CONFIG_DIR)
$(INSTALL) -m 644 egl.pc $(DESTDIR)$(PKG_CONFIG_DIR)
clean:
-rm -f *.o

12
src/egl/main/egl.pc.in Normal file
View File

@@ -0,0 +1,12 @@
prefix=@INSTALL_DIR@
exec_prefix=${prefix}
libdir=@INSTALL_LIB_DIR@
includedir=@INSTALL_INC_DIR@
Name: egl
Description: Mesa EGL library
Requires.private: @EGL_PC_REQ_PRIV@
Version: @VERSION@
Libs: -L${libdir} -l@EGL_LIB@
Libs.private: @EGL_PC_LIB_PRIV@
Cflags: -I${includedir} @EGL_PC_CFLAGS@

View File

@@ -261,7 +261,7 @@ EGLBoolean EGLAPIENTRY
eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
EGLint major_int, minor_int;
EGLint major_int = 0, minor_int = 0;
if (!disp)
RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
@@ -272,13 +272,15 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
if (!drv) {
_eglPreloadDrivers();
drv = _eglMatchDriver(disp);
if (!drv)
RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
/* Initialize the particular display now */
if (drv && !drv->API.Initialize(drv, disp, &major_int, &minor_int))
RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
}
/* Initialize the particular display now */
if (!drv->API.Initialize(drv, disp, &major_int, &minor_int))
RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
if (!drv)
/* Load and initialize the first default driver that works */
drv = _eglLoadDefaultDriver(disp, &major_int, &minor_int);
if (!drv)
RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
disp->APImajor = major_int;
disp->APIminor = minor_int;
@@ -836,6 +838,9 @@ eglGetProcAddress(const char *procname)
{ "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR },
{ "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR },
#endif /* EGL_KHR_image_base */
#ifdef EGL_NOK_swap_region
{ "eglSwapBuffersRegionNOK", (_EGLProc) eglSwapBuffersRegionNOK },
#endif
{ NULL, NULL }
};
EGLint i;
@@ -1244,3 +1249,32 @@ eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
#endif /* EGL_KHR_image_base */
#ifdef EGL_NOK_swap_region
EGLBoolean
eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface,
EGLint numRects, const EGLint *rects)
{
_EGLContext *ctx = _eglGetCurrentContext();
_EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLSurface *surf = _eglLookupSurface(surface, disp);
_EGLDriver *drv;
EGLBoolean ret;
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
/* surface must be bound to current context in EGL 1.4 */
if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface)
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
if (drv->API.SwapBuffersRegionNOK)
ret = drv->API.SwapBuffersRegionNOK(drv, disp, surf, numRects, rects);
else
ret = drv->API.SwapBuffers(drv, disp, surf);
RETURN_EGL_EVAL(disp, ret);
}
#endif /* EGL_NOK_swap_region */

View File

@@ -76,6 +76,9 @@ typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLCo
typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
#endif /* EGL_KHR_image_base */
#ifdef EGL_NOK_swap_region
typedef EGLBoolean (*SwapBuffersRegionNOK_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, const EGLint *rects);
#endif
/**
* The API dispatcher jumps through these functions
@@ -134,6 +137,10 @@ struct _egl_api
CreateImageKHR_t CreateImageKHR;
DestroyImageKHR_t DestroyImageKHR;
#endif /* EGL_KHR_image_base */
#ifdef EGL_NOK_swap_region
SwapBuffersRegionNOK_t SwapBuffersRegionNOK;
#endif
};
#endif /* EGLAPI_INCLUDED */

View File

@@ -13,7 +13,6 @@
#define MIN2(A, B) (((A) < (B)) ? (A) : (B))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
/**
@@ -224,7 +223,12 @@ static const struct {
0 },
{ EGL_NONE, ATTRIB_TYPE_PSEUDO,
ATTRIB_CRITERION_IGNORE,
0 }
0 },
{ EGL_Y_INVERTED_NOK, ATTRIB_TYPE_BOOLEAN,
ATTRIB_CRITERION_EXACT,
EGL_DONT_CARE },
};
@@ -479,6 +483,28 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria)
return matched;
}
static INLINE EGLBoolean
_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
{
if (_eglIndexConfig(conf, attr) < 0)
return EGL_FALSE;
/* there are some holes in the range */
switch (attr) {
case 0x3030 /* a gap before EGL_SAMPLES */:
case EGL_NONE:
#ifdef EGL_VERSION_1_4
case EGL_MATCH_NATIVE_PIXMAP:
#endif
return EGL_FALSE;
case EGL_Y_INVERTED_NOK:
return conf->Display->Extensions.NOK_texture_from_pixmap;
default:
break;
}
return EGL_TRUE;
}
/**
* Initialize a criteria config from the given attribute list.
@@ -501,15 +527,13 @@ _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list)
/* parse the list */
for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i += 2) {
EGLint idx;
attr = attrib_list[i];
val = attrib_list[i + 1];
idx = _eglIndexConfig(conf, attr);
if (idx < 0)
return EGL_FALSE;
conf->Storage[idx] = val;
if (!_eglIsConfigAttribValid(conf, attr))
return EGL_FALSE;
SET_CONFIG_ATTRIB(conf, attr, val);
/* rememeber some attributes for post-processing */
switch (attr) {
@@ -782,28 +806,6 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
}
static INLINE EGLBoolean
_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr)
{
if (_eglIndexConfig(conf, attr) < 0)
return EGL_FALSE;
/* there are some holes in the range */
switch (attr) {
case 0x3030 /* a gap before EGL_SAMPLES */:
case EGL_NONE:
#ifdef EGL_VERSION_1_4
case EGL_MATCH_NATIVE_PIXMAP:
#endif
return EGL_FALSE;
default:
break;
}
return EGL_TRUE;
}
/**
* Fallback for eglGetConfigAttrib.
*/

View File

@@ -8,16 +8,24 @@
#define _EGL_CONFIG_FIRST_ATTRIB EGL_BUFFER_SIZE
#define _EGL_CONFIG_LAST_ATTRIB EGL_CONFORMANT
#define _EGL_CONFIG_NUM_ATTRIBS \
#define _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS \
(_EGL_CONFIG_LAST_ATTRIB - _EGL_CONFIG_FIRST_ATTRIB + 1)
#define _EGL_CONFIG_STORAGE_SIZE _EGL_CONFIG_NUM_ATTRIBS
/* Attributes outside the contiguous block:
*
* EGL_Y_INVERTED_NOK
*/
#define _EGL_CONFIG_FIRST_EXTRA_ATTRIB _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS
#define _EGL_CONFIG_NUM_EXTRA_ATTRIBS 1
#define _EGL_CONFIG_NUM_ATTRIBS \
_EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS + _EGL_CONFIG_NUM_EXTRA_ATTRIBS
struct _egl_config
{
_EGLDisplay *Display;
EGLint Storage[_EGL_CONFIG_STORAGE_SIZE];
EGLint Storage[_EGL_CONFIG_NUM_ATTRIBS];
};
@@ -37,10 +45,15 @@ _eglIndexConfig(const _EGLConfig *conf, EGLint key)
{
(void) conf;
if (key >= _EGL_CONFIG_FIRST_ATTRIB &&
key < _EGL_CONFIG_FIRST_ATTRIB + _EGL_CONFIG_NUM_ATTRIBS)
key < _EGL_CONFIG_FIRST_ATTRIB + _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS)
return key - _EGL_CONFIG_FIRST_ATTRIB;
else
switch (key) {
case EGL_Y_INVERTED_NOK:
return _EGL_CONFIG_FIRST_EXTRA_ATTRIB;
default:
return -1;
}
}

View File

@@ -40,6 +40,7 @@
#define _EGL_VENDOR_STRING "Mesa Project"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif /* EGLDEFINES_INCLUDED */

View File

@@ -46,6 +46,8 @@ struct _egl_extensions
EGLBoolean KHR_gl_texture_cubemap_image;
EGLBoolean KHR_gl_texture_3D_image;
EGLBoolean KHR_gl_renderbuffer_image;
EGLBoolean NOK_swap_region;
EGLBoolean NOK_texture_from_pixmap;
char String[_EGL_MAX_EXTENSIONS_LEN];
};

View File

@@ -36,7 +36,9 @@
/* XXX Need to decide how to do dynamic name lookup on Windows */
static const char DefaultDriverName[] = "TBD";
static const char DefaultDriverNames[] = {
"TBD",
};
typedef HMODULE lib_handle;
@@ -63,7 +65,10 @@ library_suffix(void)
#elif defined(_EGL_PLATFORM_POSIX)
static const char DefaultDriverName[] = "egl_glx";
static const char *DefaultDriverNames[] = {
"egl_dri2",
"egl_glx"
};
typedef void * lib_handle;
@@ -87,32 +92,6 @@ library_suffix(void)
}
#else /* _EGL_PLATFORM_NO_OS */
static const char DefaultDriverName[] = "builtin";
typedef void *lib_handle;
static INLINE void *
open_library(const char *filename)
{
return (void *) filename;
}
static INLINE void
close_library(void *lib)
{
}
static const char *
library_suffix(void)
{
return NULL;
}
#endif
@@ -157,12 +136,6 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle)
else {
error = dlerror();
}
#else /* _EGL_PLATFORM_NO_OS */
/* must be the default driver name */
if (strcmp(driverPath, DefaultDriverName) == 0)
mainFunc = (_EGLMain_t) _eglMain;
else
error = "not builtin driver";
#endif
if (!lib) {
@@ -293,9 +266,9 @@ _eglLoaderFile(const char *dir, size_t len, void *loader_data)
len += flen;
path[len] = '\0';
drv = _eglLoadDriver(path, NULL);
/* fix the path and load again */
if (!drv && library_suffix()) {
if (library_suffix() == NULL || strstr(path, library_suffix()))
drv = _eglLoadDriver(path, NULL);
else {
const char *suffix = library_suffix();
size_t slen = strlen(suffix);
const char *p;
@@ -306,6 +279,8 @@ _eglLoaderFile(const char *dir, size_t len, void *loader_data)
if (need_suffix && len + slen + 1 <= sizeof(path)) {
strcpy(path + len, suffix);
drv = _eglLoadDriver(path, NULL);
} else {
drv = NULL;
}
}
if (!drv)
@@ -517,17 +492,6 @@ _eglPreloadDisplayDrivers(void)
}
/**
* Preload the default driver.
*/
static EGLBoolean
_eglPreloadDefaultDriver(void)
{
return (_eglPreloadForEach(_eglGetSearchPath(),
_eglLoaderFile, (void *) DefaultDriverName) > 0);
}
/**
* Preload drivers.
*
@@ -549,15 +513,13 @@ _eglPreloadDrivers(void)
}
loaded = (_eglPreloadUserDriver() ||
_eglPreloadDisplayDrivers() ||
_eglPreloadDefaultDriver());
_eglPreloadDisplayDrivers());
_eglUnlockMutex(_eglGlobal.Mutex);
return loaded;
}
/**
* Unload preloaded drivers.
*/
@@ -588,6 +550,30 @@ _eglUnloadDrivers(void)
_eglGlobal.NumDrivers = 0;
}
_EGLDriver *
_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor)
{
_EGLDriver *drv = NULL;
int i;
_eglLockMutex(_eglGlobal.Mutex);
for (i = 0; i < ARRAY_SIZE(DefaultDriverNames); i++) {
_eglPreloadForEach(_eglGetSearchPath(),
_eglLoaderFile, (void *) DefaultDriverNames[i]);
if (_eglGlobal.NumDrivers == 0)
continue;
drv = _eglGlobal.Drivers[0];
if (drv->API.Initialize(drv, dpy, major, minor))
break;
_eglUnloadDrivers();
}
_eglUnlockMutex(_eglGlobal.Mutex);
return drv;
}
/**
* Plug all the available fallback routines into the given driver's

View File

@@ -84,6 +84,10 @@ extern void
_eglUnloadDrivers(void);
extern _EGLDriver *
_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor);
PUBLIC void
_eglInitDriverFallbacks(_EGLDriver *drv);

View File

@@ -6,9 +6,6 @@
#include "eglmutex.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
static _EGL_DECLARE_MUTEX(_eglGlobalMutex);
struct _egl_global _eglGlobal =
{

View File

@@ -96,6 +96,8 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
_EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image);
_EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image);
_EGL_CHECK_EXTENSION(NOK_swap_region);
_EGL_CHECK_EXTENSION(NOK_texture_from_pixmap);
#undef _EGL_CHECK_EXTENSION
}

View File

@@ -36,12 +36,17 @@ _eglClampSwapInterval(_EGLSurface *surf, EGLint interval)
static EGLint
_eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
{
_EGLDisplay *dpy = surf->Resource.Display;
EGLint type = surf->Type;
EGLint texture_type = EGL_PBUFFER_BIT;
EGLint i, err = EGL_SUCCESS;
if (!attrib_list)
return EGL_SUCCESS;
if (dpy->Extensions.NOK_texture_from_pixmap)
texture_type |= EGL_PIXMAP_BIT;
for (i = 0; attrib_list[i] != EGL_NONE; i++) {
EGLint attr = attrib_list[i++];
EGLint val = attrib_list[i];
@@ -125,7 +130,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
surf->LargestPbuffer = !!val;
break;
case EGL_TEXTURE_FORMAT:
if (type != EGL_PBUFFER_BIT) {
if (!(type & texture_type)) {
err = EGL_BAD_ATTRIBUTE;
break;
}
@@ -143,7 +148,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
surf->TextureFormat = val;
break;
case EGL_TEXTURE_TARGET:
if (type != EGL_PBUFFER_BIT) {
if (!(type & texture_type)) {
err = EGL_BAD_ATTRIBUTE;
break;
}
@@ -160,7 +165,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
surf->TextureTarget = val;
break;
case EGL_MIPMAP_TEXTURE:
if (type != EGL_PBUFFER_BIT) {
if (!(type & texture_type)) {
err = EGL_BAD_ATTRIBUTE;
break;
}
@@ -452,11 +457,16 @@ EGLBoolean
_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
EGLint buffer)
{
EGLint texture_type = EGL_PBUFFER_BIT;
/* Just do basic error checking and return success/fail.
* Drivers must implement the real stuff.
*/
if (surface->Type != EGL_PBUFFER_BIT) {
if (dpy->Extensions.NOK_texture_from_pixmap)
texture_type |= EGL_PIXMAP_BIT;
if (!(surface->Type & texture_type)) {
_eglError(EGL_BAD_SURFACE, "eglBindTexImage");
return EGL_FALSE;
}
@@ -466,6 +476,11 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
return EGL_FALSE;
}
if (surface->TextureTarget == EGL_NO_TEXTURE) {
_eglError(EGL_BAD_MATCH, "eglBindTexImage");
return EGL_FALSE;
}
if (buffer != EGL_BACK_BUFFER) {
_eglError(EGL_BAD_PARAMETER, "eglBindTexImage");
return EGL_FALSE;

View File

@@ -83,7 +83,7 @@ extern EGLBoolean
_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value);
extern EGLBoolean
PUBLIC extern EGLBoolean
_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer);

View File

@@ -31,6 +31,7 @@
*/
#include "pipe/p_context.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "draw_context.h"
@@ -38,7 +39,7 @@
#include "draw_gs.h"
struct draw_context *draw_create( void )
struct draw_context *draw_create( struct pipe_context *pipe )
{
struct draw_context *draw = CALLOC_STRUCT( draw_context );
if (draw == NULL)
@@ -68,6 +69,8 @@ struct draw_context *draw_create( void )
if (!draw_gs_init( draw ))
goto fail;
draw->pipe = pipe;
return draw;
fail:
@@ -78,10 +81,21 @@ fail:
void draw_destroy( struct draw_context *draw )
{
struct pipe_context *pipe = draw->pipe;
int i, j;
if (!draw)
return;
/* free any rasterizer CSOs that we may have created.
*/
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
if (draw->rasterizer_no_cull[i][j]) {
pipe->delete_rasterizer_state(pipe, draw->rasterizer_no_cull[i][j]);
}
}
}
/* Not so fast -- we're just borrowing this at the moment.
*
@@ -123,12 +137,17 @@ void draw_set_mrd(struct draw_context *draw, double mrd)
* This causes the drawing pipeline to be rebuilt.
*/
void draw_set_rasterizer_state( struct draw_context *draw,
const struct pipe_rasterizer_state *raster )
const struct pipe_rasterizer_state *raster,
void *rast_handle )
{
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
if (!draw->suspend_flushing) {
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
draw->rasterizer = raster;
draw->bypass_clipping = draw->driver.bypass_clipping;
draw->rasterizer = raster;
draw->rast_handle = rast_handle;
draw->bypass_clipping = draw->driver.bypass_clipping;
}
}
@@ -481,3 +500,37 @@ draw_current_shader_position_output(const struct draw_context *draw)
return draw->gs.position_output;
return draw->vs.position_output;
}
/**
* Return a pointer/handle for a driver/CSO rasterizer object which
* disabled culling, stippling, unfilled tris, etc.
* This is used by some pipeline stages (such as wide_point, aa_line
* and aa_point) which convert points/lines into triangles. In those
* cases we don't want to accidentally cull the triangles.
*
* \param scissor should the rasterizer state enable scissoring?
* \param flatshade should the rasterizer state use flat shading?
* \return rasterizer CSO handle
*/
void *
draw_get_rasterizer_no_cull( struct draw_context *draw,
boolean scissor,
boolean flatshade )
{
if (!draw->rasterizer_no_cull[scissor][flatshade]) {
/* create now */
struct pipe_context *pipe = draw->pipe;
struct pipe_rasterizer_state rast;
memset(&rast, 0, sizeof(rast));
rast.scissor = scissor;
rast.flatshade = flatshade;
rast.front_winding = PIPE_WINDING_CCW;
rast.gl_rasterization_rules = draw->rasterizer->gl_rasterization_rules;
draw->rasterizer_no_cull[scissor][flatshade] =
pipe->create_rasterizer_state(pipe, &rast);
}
return draw->rasterizer_no_cull[scissor][flatshade];
}

View File

@@ -49,7 +49,7 @@ struct draw_geometry_shader;
struct tgsi_sampler;
struct draw_context *draw_create( void );
struct draw_context *draw_create( struct pipe_context *pipe );
void draw_destroy( struct draw_context *draw );
@@ -60,7 +60,8 @@ void draw_set_clip_state( struct draw_context *pipe,
const struct pipe_clip_state *clip );
void draw_set_rasterizer_state( struct draw_context *draw,
const struct pipe_rasterizer_state *raster );
const struct pipe_rasterizer_state *raster,
void *rast_handle );
void draw_set_rasterize_stage( struct draw_context *draw,
struct draw_stage *stage );

View File

@@ -113,8 +113,6 @@ struct aaline_stage
void **);
void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
struct pipe_texture **);
struct pipe_context *pipe;
};
@@ -339,6 +337,7 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
static boolean
generate_aaline_fs(struct aaline_stage *aaline)
{
struct pipe_context *pipe = aaline->stage.draw->pipe;
const struct pipe_shader_state *orig_fs = &aaline->fs->state;
struct pipe_shader_state aaline_fs;
struct aa_transform_context transform;
@@ -371,7 +370,7 @@ generate_aaline_fs(struct aaline_stage *aaline)
aaline->fs->sampler_unit = transform.freeSampler;
aaline->fs->aaline_fs
= aaline->driver_create_fs_state(aaline->pipe, &aaline_fs);
= aaline->driver_create_fs_state(pipe, &aaline_fs);
if (aaline->fs->aaline_fs == NULL)
goto fail;
@@ -391,7 +390,7 @@ fail:
static boolean
aaline_create_texture(struct aaline_stage *aaline)
{
struct pipe_context *pipe = aaline->pipe;
struct pipe_context *pipe = aaline->stage.draw->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_texture texTemp;
uint level;
@@ -464,7 +463,7 @@ static boolean
aaline_create_sampler(struct aaline_stage *aaline)
{
struct pipe_sampler_state sampler;
struct pipe_context *pipe = aaline->pipe;
struct pipe_context *pipe = aaline->stage.draw->pipe;
memset(&sampler, 0, sizeof(sampler));
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
@@ -493,13 +492,14 @@ static boolean
bind_aaline_fragment_shader(struct aaline_stage *aaline)
{
struct draw_context *draw = aaline->stage.draw;
struct pipe_context *pipe = draw->pipe;
if (!aaline->fs->aaline_fs &&
!generate_aaline_fs(aaline))
return FALSE;
draw->suspend_flushing = TRUE;
aaline->driver_bind_fs_state(aaline->pipe, aaline->fs->aaline_fs);
aaline->driver_bind_fs_state(pipe, aaline->fs->aaline_fs);
draw->suspend_flushing = FALSE;
return TRUE;
@@ -639,8 +639,10 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
{
auto struct aaline_stage *aaline = aaline_stage(stage);
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = aaline->pipe;
struct pipe_context *pipe = draw->pipe;
const struct pipe_rasterizer_state *rast = draw->rasterizer;
uint num_samplers;
void *r;
assert(draw->rasterizer->line_smooth);
@@ -679,6 +681,11 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
draw->suspend_flushing = TRUE;
aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler);
aaline->driver_set_sampler_textures(pipe, num_samplers, aaline->state.texture);
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade);
pipe->bind_rasterizer_state(pipe, r);
draw->suspend_flushing = FALSE;
/* now really draw first line */
@@ -692,7 +699,7 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
{
struct draw_context *draw = stage->draw;
struct aaline_stage *aaline = aaline_stage(stage);
struct pipe_context *pipe = aaline->pipe;
struct pipe_context *pipe = draw->pipe;
stage->line = aaline_first_line;
stage->next->flush( stage->next, flags );
@@ -704,6 +711,12 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
aaline->state.sampler);
aaline->driver_set_sampler_textures(pipe, aaline->num_textures,
aaline->state.texture);
/* restore original rasterizer state */
if (draw->rast_handle) {
pipe->bind_rasterizer_state(pipe, draw->rast_handle);
}
draw->suspend_flushing = FALSE;
draw->extra_shader_outputs.slot = 0;
@@ -721,6 +734,7 @@ static void
aaline_destroy(struct draw_stage *stage)
{
struct aaline_stage *aaline = aaline_stage(stage);
struct pipe_context *pipe = stage->draw->pipe;
uint i;
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
@@ -728,7 +742,7 @@ aaline_destroy(struct draw_stage *stage)
}
if (aaline->sampler_cso)
aaline->pipe->delete_sampler_state(aaline->pipe, aaline->sampler_cso);
pipe->delete_sampler_state(pipe, aaline->sampler_cso);
if (aaline->texture)
pipe_texture_reference(&aaline->texture, NULL);
@@ -787,13 +801,14 @@ aaline_create_fs_state(struct pipe_context *pipe,
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = CALLOC_STRUCT(aaline_fragment_shader);
if (aafs == NULL)
return NULL;
aafs->state = *fs;
/* pass-through */
aafs->driver_fs = aaline->driver_create_fs_state(aaline->pipe, fs);
aafs->driver_fs = aaline->driver_create_fs_state(pipe, fs);
return aafs;
}
@@ -808,8 +823,7 @@ aaline_bind_fs_state(struct pipe_context *pipe, void *fs)
/* save current */
aaline->fs = aafs;
/* pass-through */
aaline->driver_bind_fs_state(aaline->pipe,
(aafs ? aafs->driver_fs : NULL));
aaline->driver_bind_fs_state(pipe, (aafs ? aafs->driver_fs : NULL));
}
@@ -818,11 +832,12 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
/* pass-through */
aaline->driver_delete_fs_state(aaline->pipe, aafs->driver_fs);
aaline->driver_delete_fs_state(pipe, aafs->driver_fs);
if (aafs->aaline_fs)
aaline->driver_delete_fs_state(aaline->pipe, aafs->aaline_fs);
aaline->driver_delete_fs_state(pipe, aafs->aaline_fs);
FREE(aafs);
}
@@ -839,7 +854,7 @@ aaline_bind_sampler_states(struct pipe_context *pipe,
aaline->num_samplers = num;
/* pass-through */
aaline->driver_bind_sampler_states(aaline->pipe, num, sampler);
aaline->driver_bind_sampler_states(pipe, num, sampler);
}
@@ -860,7 +875,7 @@ aaline_set_sampler_textures(struct pipe_context *pipe,
aaline->num_textures = num;
/* pass-through */
aaline->driver_set_sampler_textures(aaline->pipe, num, texture);
aaline->driver_set_sampler_textures(pipe, num, texture);
}
@@ -883,8 +898,6 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
if (!aaline)
goto fail;
aaline->pipe = pipe;
/* create special texture, sampler state */
if (!aaline_create_texture(aaline))
goto fail;

View File

@@ -107,8 +107,6 @@ struct aapoint_stage
const struct pipe_shader_state *);
void (*driver_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_fs_state)(struct pipe_context *, void *);
struct pipe_context *pipe;
};
@@ -499,6 +497,7 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
struct pipe_shader_state aapoint_fs;
struct aa_transform_context transform;
const uint newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
struct pipe_context *pipe = aapoint->stage.draw->pipe;
aapoint_fs = *orig_fs; /* copy to init */
aapoint_fs.tokens = tgsi_alloc_tokens(newLen);
@@ -527,7 +526,7 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
#endif
aapoint->fs->aapoint_fs
= aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs);
= aapoint->driver_create_fs_state(pipe, &aapoint_fs);
if (aapoint->fs->aapoint_fs == NULL)
goto fail;
@@ -549,13 +548,14 @@ static boolean
bind_aapoint_fragment_shader(struct aapoint_stage *aapoint)
{
struct draw_context *draw = aapoint->stage.draw;
struct pipe_context *pipe = draw->pipe;
if (!aapoint->fs->aapoint_fs &&
!generate_aapoint_fs(aapoint))
return FALSE;
draw->suspend_flushing = TRUE;
aapoint->driver_bind_fs_state(aapoint->pipe, aapoint->fs->aapoint_fs);
aapoint->driver_bind_fs_state(pipe, aapoint->fs->aapoint_fs);
draw->suspend_flushing = FALSE;
return TRUE;
@@ -679,6 +679,9 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
{
auto struct aapoint_stage *aapoint = aapoint_stage(stage);
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = draw->pipe;
const struct pipe_rasterizer_state *rast = draw->rasterizer;
void *r;
assert(draw->rasterizer->point_smooth);
@@ -716,6 +719,14 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
}
}
draw->suspend_flushing = TRUE;
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade);
pipe->bind_rasterizer_state(pipe, r);
draw->suspend_flushing = FALSE;
/* now really draw first point */
stage->point = aapoint_point;
stage->point(stage, header);
@@ -727,7 +738,7 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
{
struct draw_context *draw = stage->draw;
struct aapoint_stage *aapoint = aapoint_stage(stage);
struct pipe_context *pipe = aapoint->pipe;
struct pipe_context *pipe = draw->pipe;
stage->point = aapoint_first_point;
stage->next->flush( stage->next, flags );
@@ -735,6 +746,12 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
/* restore original frag shader */
draw->suspend_flushing = TRUE;
aapoint->driver_bind_fs_state(pipe, aapoint->fs->driver_fs);
/* restore original rasterizer state */
if (draw->rast_handle) {
pipe->bind_rasterizer_state(pipe, draw->rast_handle);
}
draw->suspend_flushing = FALSE;
draw->extra_shader_outputs.slot = 0;
@@ -811,7 +828,7 @@ aapoint_create_fs_state(struct pipe_context *pipe,
aafs->state = *fs;
/* pass-through */
aafs->driver_fs = aapoint->driver_create_fs_state(aapoint->pipe, fs);
aafs->driver_fs = aapoint->driver_create_fs_state(pipe, fs);
return aafs;
}
@@ -825,7 +842,7 @@ aapoint_bind_fs_state(struct pipe_context *pipe, void *fs)
/* save current */
aapoint->fs = aafs;
/* pass-through */
aapoint->driver_bind_fs_state(aapoint->pipe,
aapoint->driver_bind_fs_state(pipe,
(aafs ? aafs->driver_fs : NULL));
}
@@ -837,10 +854,10 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs)
struct aapoint_fragment_shader *aafs = (struct aapoint_fragment_shader *) fs;
/* pass-through */
aapoint->driver_delete_fs_state(aapoint->pipe, aafs->driver_fs);
aapoint->driver_delete_fs_state(pipe, aafs->driver_fs);
if (aafs->aapoint_fs)
aapoint->driver_delete_fs_state(aapoint->pipe, aafs->aapoint_fs);
aapoint->driver_delete_fs_state(pipe, aafs->aapoint_fs);
FREE(aafs);
}
@@ -857,8 +874,6 @@ draw_install_aapoint_stage(struct draw_context *draw,
{
struct aapoint_stage *aapoint;
pipe->draw = (void *) draw;
/*
* Create / install AA point drawing / prim stage
*/
@@ -866,8 +881,6 @@ draw_install_aapoint_stage(struct draw_context *draw,
if (aapoint == NULL)
return FALSE;
aapoint->pipe = pipe;
/* save original driver functions */
aapoint->driver_create_fs_state = pipe->create_fs_state;
aapoint->driver_bind_fs_state = pipe->bind_fs_state;

View File

@@ -28,6 +28,7 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
@@ -142,9 +143,40 @@ static void wideline_line( struct draw_stage *stage,
}
static void wideline_first_line( struct draw_stage *stage,
struct prim_header *header )
{
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = draw->pipe;
const struct pipe_rasterizer_state *rast = draw->rasterizer;
void *r;
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade);
draw->suspend_flushing = TRUE;
pipe->bind_rasterizer_state(pipe, r);
draw->suspend_flushing = FALSE;
stage->line = wideline_line;
wideline_line(stage, header);
}
static void wideline_flush( struct draw_stage *stage, unsigned flags )
{
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = draw->pipe;
stage->line = wideline_first_line;
stage->next->flush( stage->next, flags );
/* restore original rasterizer state */
if (draw->rast_handle) {
draw->suspend_flushing = TRUE;
pipe->bind_rasterizer_state(pipe, draw->rast_handle);
draw->suspend_flushing = FALSE;
}
}
@@ -171,7 +203,7 @@ struct draw_stage *draw_wide_line_stage( struct draw_context *draw )
wide->stage.name = "wide-line";
wide->stage.next = NULL;
wide->stage.point = draw_pipe_passthrough_point;
wide->stage.line = wideline_line;
wide->stage.line = wideline_first_line;
wide->stage.tri = draw_pipe_passthrough_tri;
wide->stage.flush = wideline_flush;
wide->stage.reset_stipple_counter = wideline_reset_stipple_counter;

View File

@@ -52,6 +52,7 @@
*/
#include "pipe/p_context.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipe/p_defines.h"
@@ -213,6 +214,9 @@ static void widepoint_first_point( struct draw_stage *stage,
{
struct widepoint_stage *wide = widepoint_stage(stage);
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = draw->pipe;
const struct pipe_rasterizer_state *rast = draw->rasterizer;
void *r;
wide->half_point_size = 0.5f * draw->rasterizer->point_size;
wide->xbias = 0.0;
@@ -222,6 +226,12 @@ static void widepoint_first_point( struct draw_stage *stage,
wide->xbias = 0.125;
}
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade);
draw->suspend_flushing = TRUE;
pipe->bind_rasterizer_state(pipe, r);
draw->suspend_flushing = FALSE;
/* XXX we won't know the real size if it's computed by the vertex shader! */
if ((draw->rasterizer->point_size > draw->pipeline.wide_point_threshold) ||
(draw->rasterizer->sprite_coord_enable && draw->pipeline.point_sprite)) {
@@ -277,9 +287,19 @@ static void widepoint_first_point( struct draw_stage *stage,
static void widepoint_flush( struct draw_stage *stage, unsigned flags )
{
struct draw_context *draw = stage->draw;
struct pipe_context *pipe = draw->pipe;
stage->point = widepoint_first_point;
stage->next->flush( stage->next, flags );
stage->draw->extra_shader_outputs.slot = 0;
/* restore original rasterizer state */
if (draw->rast_handle) {
draw->suspend_flushing = TRUE;
pipe->bind_rasterizer_state(pipe, draw->rast_handle);
draw->suspend_flushing = FALSE;
}
}

View File

@@ -82,6 +82,8 @@ struct vertex_header {
*/
struct draw_context
{
struct pipe_context *pipe;
/** Drawing/primitive pipeline stages */
struct {
struct draw_stage *first; /**< one of the following */
@@ -174,8 +176,14 @@ struct draw_context
double mrd; /**< minimum resolvable depth value, for polygon offset */
/* pipe state that we need: */
/** Current rasterizer state given to us by the driver */
const struct pipe_rasterizer_state *rasterizer;
/** Driver CSO handle for the current rasterizer state */
void *rast_handle;
/** Rasterizer CSOs without culling/stipple/etc */
void *rasterizer_no_cull[2][2];
struct pipe_viewport_state viewport;
boolean identity_viewport;
@@ -345,5 +353,10 @@ void draw_do_flush( struct draw_context *draw, unsigned flags );
void *
draw_get_rasterizer_no_cull( struct draw_context *draw,
boolean scissor,
boolean flatshade );
#endif /* DRAW_PRIVATE_H */

View File

@@ -0,0 +1,2 @@
u_indices_gen.c
u_unfilled_gen.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,992 +0,0 @@
/* File automatically generated by u_unfilled_gen.py */
/*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file
* Functions to translate and generate index lists
*/
#include "indices/u_indices.h"
#include "indices/u_indices_priv.h"
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
static unsigned out_size_idx( unsigned index_size )
{
switch (index_size) {
case 4: return OUT_UINT;
case 2: return OUT_USHORT;
default: assert(0); return OUT_USHORT;
}
}
static unsigned in_size_idx( unsigned index_size )
{
switch (index_size) {
case 4: return IN_UINT;
case 2: return IN_USHORT;
case 1: return IN_UBYTE;
default: assert(0); return IN_UBYTE;
}
}
static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT];
static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT];
static void generate_tris_ushort(
unsigned nr,
void *_out )
{
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
(out+j)[0] = (ushort)(i);
(out+j)[1] = (ushort)(i+1);
(out+j+2)[0] = (ushort)(i+1);
(out+j+2)[1] = (ushort)(i+2);
(out+j+4)[0] = (ushort)(i+2);
(out+j+4)[1] = (ushort)(i);
}
}
static void generate_tristrip_ushort(
unsigned nr,
void *_out )
{
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)(i);
(out+j)[1] = (ushort)(i+1/*+(i&1)*/);
(out+j+2)[0] = (ushort)(i+1/*+(i&1)*/);
(out+j+2)[1] = (ushort)(i+2/*-(i&1)*/);
(out+j+4)[0] = (ushort)(i+2/*-(i&1)*/);
(out+j+4)[1] = (ushort)(i);
}
}
static void generate_trifan_ushort(
unsigned nr,
void *_out )
{
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)(0);
(out+j)[1] = (ushort)(i+1);
(out+j+2)[0] = (ushort)(i+1);
(out+j+2)[1] = (ushort)(i+2);
(out+j+4)[0] = (ushort)(i+2);
(out+j+4)[1] = (ushort)(0);
}
}
static void generate_quads_ushort(
unsigned nr,
void *_out )
{
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
(out+j)[0] = (ushort)(i+0);
(out+j)[1] = (ushort)(i+1);
(out+j+2)[0] = (ushort)(i+1);
(out+j+2)[1] = (ushort)(i+2);
(out+j+4)[0] = (ushort)(i+2);
(out+j+4)[1] = (ushort)(i+3);
(out+j+6)[0] = (ushort)(i+3);
(out+j+6)[1] = (ushort)(i+0);
}
}
static void generate_quadstrip_ushort(
unsigned nr,
void *_out )
{
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
(out+j)[0] = (ushort)(i+2);
(out+j)[1] = (ushort)(i+0);
(out+j+2)[0] = (ushort)(i+0);
(out+j+2)[1] = (ushort)(i+1);
(out+j+4)[0] = (ushort)(i+1);
(out+j+4)[1] = (ushort)(i+3);
(out+j+6)[0] = (ushort)(i+3);
(out+j+6)[1] = (ushort)(i+2);
}
}
static void generate_polygon_ushort(
unsigned nr,
void *_out )
{
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)(0);
(out+j)[1] = (ushort)(i+1);
(out+j+2)[0] = (ushort)(i+1);
(out+j+2)[1] = (ushort)(i+2);
(out+j+4)[0] = (ushort)(i+2);
(out+j+4)[1] = (ushort)(0);
}
}
static void generate_tris_uint(
unsigned nr,
void *_out )
{
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
(out+j)[0] = (uint)(i);
(out+j)[1] = (uint)(i+1);
(out+j+2)[0] = (uint)(i+1);
(out+j+2)[1] = (uint)(i+2);
(out+j+4)[0] = (uint)(i+2);
(out+j+4)[1] = (uint)(i);
}
}
static void generate_tristrip_uint(
unsigned nr,
void *_out )
{
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)(i);
(out+j)[1] = (uint)(i+1/*+(i&1)*/);
(out+j+2)[0] = (uint)(i+1/*+(i&1)*/);
(out+j+2)[1] = (uint)(i+2/*-(i&1)*/);
(out+j+4)[0] = (uint)(i+2/*-(i&1)*/);
(out+j+4)[1] = (uint)(i);
}
}
static void generate_trifan_uint(
unsigned nr,
void *_out )
{
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)(0);
(out+j)[1] = (uint)(i+1);
(out+j+2)[0] = (uint)(i+1);
(out+j+2)[1] = (uint)(i+2);
(out+j+4)[0] = (uint)(i+2);
(out+j+4)[1] = (uint)(0);
}
}
static void generate_quads_uint(
unsigned nr,
void *_out )
{
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
(out+j)[0] = (uint)(i+0);
(out+j)[1] = (uint)(i+1);
(out+j+2)[0] = (uint)(i+1);
(out+j+2)[1] = (uint)(i+2);
(out+j+4)[0] = (uint)(i+2);
(out+j+4)[1] = (uint)(i+3);
(out+j+6)[0] = (uint)(i+3);
(out+j+6)[1] = (uint)(i+0);
}
}
static void generate_quadstrip_uint(
unsigned nr,
void *_out )
{
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
(out+j)[0] = (uint)(i+2);
(out+j)[1] = (uint)(i+0);
(out+j+2)[0] = (uint)(i+0);
(out+j+2)[1] = (uint)(i+1);
(out+j+4)[0] = (uint)(i+1);
(out+j+4)[1] = (uint)(i+3);
(out+j+6)[0] = (uint)(i+3);
(out+j+6)[1] = (uint)(i+2);
}
}
static void generate_polygon_uint(
unsigned nr,
void *_out )
{
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)(0);
(out+j)[1] = (uint)(i+1);
(out+j+2)[0] = (uint)(i+1);
(out+j+2)[1] = (uint)(i+2);
(out+j+4)[0] = (uint)(i+2);
(out+j+4)[1] = (uint)(0);
}
}
static void translate_tris_ubyte2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i];
}
}
static void translate_tristrip_ubyte2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (ushort)in[i];
}
}
static void translate_trifan_ubyte2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
}
static void translate_quads_ubyte2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
(out+j)[0] = (ushort)in[i+0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i+3];
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+0];
}
}
static void translate_quadstrip_ubyte2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
(out+j)[0] = (ushort)in[i+2];
(out+j)[1] = (ushort)in[i+0];
(out+j+2)[0] = (ushort)in[i+0];
(out+j+2)[1] = (ushort)in[i+1];
(out+j+4)[0] = (ushort)in[i+1];
(out+j+4)[1] = (ushort)in[i+3];
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+2];
}
}
static void translate_polygon_ubyte2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
}
static void translate_tris_ubyte2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i];
}
}
static void translate_tristrip_ubyte2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (uint)in[i];
}
}
static void translate_trifan_ubyte2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
}
static void translate_quads_ubyte2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
(out+j)[0] = (uint)in[i+0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i+3];
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+0];
}
}
static void translate_quadstrip_ubyte2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
(out+j)[0] = (uint)in[i+2];
(out+j)[1] = (uint)in[i+0];
(out+j+2)[0] = (uint)in[i+0];
(out+j+2)[1] = (uint)in[i+1];
(out+j+4)[0] = (uint)in[i+1];
(out+j+4)[1] = (uint)in[i+3];
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+2];
}
}
static void translate_polygon_ubyte2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ubyte*in = (const ubyte*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
}
static void translate_tris_ushort2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i];
}
}
static void translate_tristrip_ushort2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (ushort)in[i];
}
}
static void translate_trifan_ushort2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
}
static void translate_quads_ushort2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
(out+j)[0] = (ushort)in[i+0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i+3];
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+0];
}
}
static void translate_quadstrip_ushort2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
(out+j)[0] = (ushort)in[i+2];
(out+j)[1] = (ushort)in[i+0];
(out+j+2)[0] = (ushort)in[i+0];
(out+j+2)[1] = (ushort)in[i+1];
(out+j+4)[0] = (ushort)in[i+1];
(out+j+4)[1] = (ushort)in[i+3];
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+2];
}
}
static void translate_polygon_ushort2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
}
static void translate_tris_ushort2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i];
}
}
static void translate_tristrip_ushort2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (uint)in[i];
}
}
static void translate_trifan_ushort2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
}
static void translate_quads_ushort2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
(out+j)[0] = (uint)in[i+0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i+3];
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+0];
}
}
static void translate_quadstrip_ushort2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
(out+j)[0] = (uint)in[i+2];
(out+j)[1] = (uint)in[i+0];
(out+j+2)[0] = (uint)in[i+0];
(out+j+2)[1] = (uint)in[i+1];
(out+j+4)[0] = (uint)in[i+1];
(out+j+4)[1] = (uint)in[i+3];
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+2];
}
}
static void translate_polygon_ushort2uint(
const void * _in,
unsigned nr,
void *_out )
{
const ushort*in = (const ushort*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
}
static void translate_tris_uint2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i];
}
}
static void translate_tristrip_uint2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[i];
(out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (ushort)in[i];
}
}
static void translate_trifan_uint2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
}
static void translate_quads_uint2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
(out+j)[0] = (ushort)in[i+0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[i+3];
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+0];
}
}
static void translate_quadstrip_uint2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
(out+j)[0] = (ushort)in[i+2];
(out+j)[1] = (ushort)in[i+0];
(out+j+2)[0] = (ushort)in[i+0];
(out+j+2)[1] = (ushort)in[i+1];
(out+j+4)[0] = (ushort)in[i+1];
(out+j+4)[1] = (ushort)in[i+3];
(out+j+6)[0] = (ushort)in[i+3];
(out+j+6)[1] = (ushort)in[i+2];
}
}
static void translate_polygon_uint2ushort(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
ushort *out = (ushort*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (ushort)in[0];
(out+j)[1] = (ushort)in[i+1];
(out+j+2)[0] = (ushort)in[i+1];
(out+j+2)[1] = (ushort)in[i+2];
(out+j+4)[0] = (ushort)in[i+2];
(out+j+4)[1] = (ushort)in[0];
}
}
static void translate_tris_uint2uint(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i+=3) {
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i];
}
}
static void translate_tristrip_uint2uint(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[i];
(out+j)[1] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
(out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
(out+j+4)[1] = (uint)in[i];
}
}
static void translate_trifan_uint2uint(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
}
static void translate_quads_uint2uint(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=4) {
(out+j)[0] = (uint)in[i+0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[i+3];
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+0];
}
}
static void translate_quadstrip_uint2uint(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=8, i+=2) {
(out+j)[0] = (uint)in[i+2];
(out+j)[1] = (uint)in[i+0];
(out+j+2)[0] = (uint)in[i+0];
(out+j+2)[1] = (uint)in[i+1];
(out+j+4)[0] = (uint)in[i+1];
(out+j+4)[1] = (uint)in[i+3];
(out+j+6)[0] = (uint)in[i+3];
(out+j+6)[1] = (uint)in[i+2];
}
}
static void translate_polygon_uint2uint(
const void * _in,
unsigned nr,
void *_out )
{
const uint*in = (const uint*)_in;
uint *out = (uint*)_out;
unsigned i, j;
(void)j;
for (j = i = 0; j < nr; j+=6, i++) {
(out+j)[0] = (uint)in[0];
(out+j)[1] = (uint)in[i+1];
(out+j+2)[0] = (uint)in[i+1];
(out+j+2)[1] = (uint)in[i+2];
(out+j+4)[0] = (uint)in[i+2];
(out+j+4)[1] = (uint)in[0];
}
}
void u_unfilled_init( void )
{
static int firsttime = 1;
if (!firsttime) return;
firsttime = 0;
generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLES] = generate_tris_ushort;
generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort;
generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort;
generate_line[OUT_USHORT][PIPE_PRIM_QUADS] = generate_quads_ushort;
generate_line[OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort;
generate_line[OUT_USHORT][PIPE_PRIM_POLYGON] = generate_polygon_ushort;
generate_line[OUT_UINT][PIPE_PRIM_TRIANGLES] = generate_tris_uint;
generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint;
generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint;
generate_line[OUT_UINT][PIPE_PRIM_QUADS] = generate_quads_uint;
generate_line[OUT_UINT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint;
generate_line[OUT_UINT][PIPE_PRIM_POLYGON] = generate_polygon_uint;
translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort;
translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort;
translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort;
translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort;
translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort;
translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort;
translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint;
translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint;
translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint;
translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint;
translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint;
translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint;
translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort;
translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort;
translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort;
translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort;
translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort;
translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort;
translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint;
translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint;
translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint;
translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ushort2uint;
translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint;
translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint;
translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort;
translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort;
translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort;
translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_uint2ushort;
translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort;
translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort;
translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint;
translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint;
translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint;
translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_uint2uint;
translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint;
translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint;
}
#include "indices/u_unfilled_indices.c"

View File

@@ -210,7 +210,7 @@ i915_create_context(struct pipe_screen *screen, void *priv)
/*
* Create drawing context and plug our rendering stage into it.
*/
i915->draw = draw_create();
i915->draw = draw_create(&i915->base);
assert(i915->draw);
if (!debug_get_bool_option("I915_NO_VBUF", FALSE)) {
draw_set_rasterize_stage(i915->draw, i915_draw_vbuf_stage(i915));

View File

@@ -714,7 +714,8 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe,
/* pass-through to draw module */
draw_set_rasterizer_state(i915->draw,
(i915->rasterizer ? i915->rasterizer->templ : NULL));
(i915->rasterizer ? i915->rasterizer->templ : NULL),
raster);
i915->dirty |= I915_NEW_RASTERIZER;
}

View File

@@ -174,7 +174,7 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv )
/*
* Create drawing context and plug our rendering stage into it.
*/
llvmpipe->draw = draw_create();
llvmpipe->draw = draw_create(&llvmpipe->pipe);
if (!llvmpipe->draw)
goto fail;

View File

@@ -38,19 +38,26 @@ void *
llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
const struct pipe_rasterizer_state *rast)
{
/* We do nothing special with rasterizer state.
* The CSO handle is just a pointer to a pipe_rasterizer_state object.
*/
return mem_dup(rast, sizeof(*rast));
}
void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe,
void *rasterizer)
void
llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
const struct pipe_rasterizer_state *rasterizer =
(const struct pipe_rasterizer_state *) handle;
if (llvmpipe->rasterizer == rasterizer)
return;
/* pass-through to draw module */
draw_set_rasterizer_state(llvmpipe->draw, rasterizer);
draw_set_rasterizer_state(llvmpipe->draw, rasterizer, handle);
llvmpipe->rasterizer = rasterizer;
@@ -68,6 +75,7 @@ void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe,
llvmpipe->dirty |= LP_NEW_RASTERIZER;
}
void llvmpipe_delete_rasterizer_state(struct pipe_context *pipe,
void *rasterizer)
{

View File

@@ -76,7 +76,7 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
nv30_init_state_functions(nv30);
/* Create, configure, and install fallback swtnl path */
nv30->draw = draw_create();
nv30->draw = draw_create(&nv30->pipe);
draw_wide_point_threshold(nv30->draw, 9999999.0);
draw_wide_line_threshold(nv30->draw, 9999999.0);
draw_enable_line_stipple(nv30->draw, FALSE);

View File

@@ -76,7 +76,7 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
nv40_init_state_functions(nv40);
/* Create, configure, and install fallback swtnl path */
nv40->draw = draw_create();
nv40->draw = draw_create(&nv40->pipe);
draw_wide_point_threshold(nv40->draw, 9999999.0);
draw_wide_line_threshold(nv40->draw, 9999999.0);
draw_enable_line_stipple(nv40->draw, FALSE);

View File

@@ -164,7 +164,7 @@ nv40_state_validate_swtnl(struct nv40_context *nv40)
draw_bind_vertex_shader(draw, nv40->vertprog->draw);
if (nv40->draw_dirty & NV40_NEW_RAST)
draw_set_rasterizer_state(draw, &nv40->rasterizer->pipe);
draw_set_rasterizer_state(draw, &nv40->rasterizer->pipe, nv40->rasterizer);
if (nv40->draw_dirty & NV40_NEW_UCP)
draw_set_clip_state(draw, &nv40->clip);

View File

@@ -129,7 +129,7 @@ nv50_create(struct pipe_screen *pscreen, void *priv)
nv50_init_state_functions(nv50);
nv50_init_query_functions(nv50);
nv50->draw = draw_create();
nv50->draw = draw_create(&nv50->pipe);
assert(nv50->draw);
draw_set_rasterize_stage(nv50->draw, nv50_draw_render_stage(nv50));

View File

@@ -181,7 +181,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300->context.draw_range_elements = r300_swtcl_draw_range_elements;
/* Create a Draw. This is used for SW TCL. */
r300->draw = draw_create();
r300->draw = draw_create(&r300->context);
/* Enable our renderer. */
draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300));
/* Enable Draw's clipping. */

View File

@@ -810,7 +810,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
if (r300->draw) {
draw_flush(r300->draw);
draw_set_rasterizer_state(r300->draw, &rs->rs);
draw_set_rasterizer_state(r300->draw, &rs->rs, state);
}
if (rs) {

View File

@@ -298,7 +298,7 @@ softpipe_create_context( struct pipe_screen *screen,
/*
* Create drawing context and plug our rendering stage into it.
*/
softpipe->draw = draw_create();
softpipe->draw = draw_create(&softpipe->pipe);
if (!softpipe->draw)
goto fail;

View File

@@ -49,7 +49,7 @@ void softpipe_bind_rasterizer_state(struct pipe_context *pipe,
return;
/* pass-through to draw module */
draw_set_rasterizer_state(softpipe->draw, rasterizer);
draw_set_rasterizer_state(softpipe->draw, rasterizer, rasterizer);
softpipe->rasterizer = rasterizer;

View File

@@ -222,7 +222,8 @@ static void svga_bind_rasterizer_state( struct pipe_context *pipe,
svga->curr.rast = raster;
draw_set_rasterizer_state(svga->swtnl.draw, raster ? &raster->templ : NULL);
draw_set_rasterizer_state(svga->swtnl.draw, raster ? &raster->templ : NULL,
state);
svga->dirty |= SVGA_NEW_RAST;
}

View File

@@ -134,7 +134,7 @@ boolean svga_init_swtnl( struct svga_context *svga )
/*
* Create drawing context and plug our rendering stage into it.
*/
svga->swtnl.draw = draw_create();
svga->swtnl.draw = draw_create(&svga->pipe);
if (svga->swtnl.draw == NULL)
goto fail;

View File

@@ -113,7 +113,8 @@ static int update_swtnl_draw( struct svga_context *svga,
if (dirty & SVGA_NEW_RAST)
draw_set_rasterizer_state(svga->swtnl.draw,
&svga->curr.rast->templ);
&svga->curr.rast->templ,
(void *) svga->curr.rast);
if (dirty & SVGA_NEW_FRAME_BUFFER)
draw_set_mrd(svga->swtnl.draw,

View File

@@ -43,7 +43,7 @@
#include "util/u_memory.h"
GLboolean
dri_create_context(const __GLcontextModes * visual,
dri_create_context(gl_api api, const __GLcontextModes * visual,
__DRIcontext * cPriv, void *sharedContextPrivate)
{
__DRIscreen *sPriv = cPriv->driScreenPriv;

View File

@@ -35,6 +35,8 @@
#include "pipe/p_compiler.h"
#include "drm.h"
#include "dri_util.h"
#include "dri_wrapper.h"
#include "main/mtypes.h"
struct pipe_context;
struct pipe_fence;
@@ -109,7 +111,8 @@ dri_make_current(__DRIcontext * driContextPriv,
__DRIdrawable * driReadPriv);
boolean
dri_create_context(const __GLcontextModes * visual,
dri_create_context(gl_api api,
const __GLcontextModes * visual,
__DRIcontext * driContextPriv,
void *sharedContextPrivate);

View File

@@ -16,6 +16,7 @@ x11_INCLUDES = \
-I$(TOP)/src/gallium/drivers \
-I$(TOP)/src/glx \
-I$(TOP)/src/mesa \
$(X11_CFLAGS) \
$(shell pkg-config --cflags-only-I libdrm)
x11_SOURCES = $(wildcard x11/*.c) \

View File

@@ -5,7 +5,8 @@ LIBNAME = xlib
LIBRARY_INCLUDES = \
-I$(TOP)/include \
-I$(TOP)/src/mesa
-I$(TOP)/src/mesa \
$(X11_CFLAGS)
C_SOURCES = \
glx_api.c \

View File

@@ -20,7 +20,8 @@ INCLUDE_DIRS = \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/drivers \
-I$(TOP)/src/gallium/state_trackers/glx/xlib \
-I$(TOP)/src/gallium/auxiliary
-I$(TOP)/src/gallium/auxiliary \
$(X11_CFLAGS)
DEFINES += \
-DGALLIUM_SOFTPIPE

70
src/gles/Makefile Normal file
View File

@@ -0,0 +1,70 @@
TOP = ../..
MESA = $(TOP)/src/mesa
include $(TOP)/configs/current
include $(MESA)/sources.mak
GLESv1_CM_ASM := $(addprefix $(MESA)/es/glapi/glapi-es1/,$(GLAPI_ASM_SOURCES))
GLESv2_ASM := $(addprefix $(MESA)/es/glapi/glapi-es2/,$(GLAPI_ASM_SOURCES))
API_SOURCES := $(addprefix $(MESA)/,$(GLAPI_SOURCES))
$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) : PREFIX = es1
$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) : NAME = GLESv1_CM
$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) : PREFIX = es2
$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) : NAME = GLESv2
INCLUDES = -I$(TOP)/include -I$(MESA)/es/glapi/glapi-$(PREFIX) -I$(MESA)
OBJECTS = \
$(notdir $(GLAPI_ASM_SOURCES:%.S=%.o)) \
$(notdir $(GLAPI_SOURCES:%.c=%.o))
GLESv1_CM_OBJECTS = $(addprefix es1-,$(OBJECTS))
GLESv2_OBJECTS = $(addprefix es2-,$(OBJECTS))
es1-%.o: $(dir $(GLESv1_CM_ASM))%.S
$(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $<
es1-%.o: $(MESA)/glapi/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $<
es2-%.o: $(dir $(GLESv2_ASM))%.S
$(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $<
es2-%.o: $(MESA)/glapi/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $<
default: depend \
$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) \
$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME)
$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) : $(GLESv1_CM_OBJECTS)
$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) : $(GLESv2_OBJECTS)
$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) \
$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) : Makefile
$(MKLIB) -o $($(NAME)_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-major 1 -minor 2 $(MKLIB_OPTIONS) \
-install $(TOP)/$(LIB_DIR) -id \
$(INSTALL_LIB_DIR)/lib$($(NAME)_LIB).1.dylib \
$($(NAME)_LIB_DEPS) $($(NAME)_OBJECTS)
depend: Makefile
rm -f depend
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(API_SOURCES) \
$(ES1_API_ASM) $(ES2_API_ASM)
# Emacs tags
tags:
etags `find . -name \*.[ch]` `find $(TOP)/include`
install: $(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME)
$(MAKE) -C $(TOP)/src/mesa install-es2 install-es1
# Remove .o and backup files
clean:
-rm -f $(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_GLOB)
-rm -f $(TOP)/$(LIB_DIR)/$(GLESv2_LIB_GLOB)
-rm -f *.o *~
-rm -f depend depend.bak
-include depend

View File

@@ -90,7 +90,7 @@ install: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
# Remove .o and backup files
clean:
-rm -f $(TOP)/$(LIB_DIR)/libGL.so*
-rm -f $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB)
-rm -f *.o *~
-rm -f depend depend.bak

View File

@@ -36,7 +36,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* THIS IS NOT AN X CONSORTIUM STANDARD */
#ifdef GLX_DIRECT_RENDERING
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
#define NEED_REPLIES
#include <X11/Xlibint.h>

4
src/glx/apple/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
apple_xgl_api.[hc]
exports.list
stage.[1234]

10
src/glx/apple/GL_aliases Normal file
View File

@@ -0,0 +1,10 @@
#GL_EXT_texture_object
alias AreTexturesResidentEXT AreTexturesResident
alias BindTextureEXT BindTexture
alias DeleteTexturesEXT DeleteTextures
alias GenTexturesEXT GenTextures
alias IsTextureEXT IsTexture
alias PrioritizeTexturesEXT PrioritizeTextures
# Due to type conflicts, we handle this differently
#alias TexImage3DEXT TexImage3D

106
src/glx/apple/GL_extensions Normal file
View File

@@ -0,0 +1,106 @@
extension ARB_transpose_matrix
extension ARB_vertex_program
extension ARB_vertex_blend
extension ARB_window_pos
extension ARB_shader_objects
extension ARB_vertex_shader
extension ARB_shading_language_100
extension ARB_imaging
extension ARB_point_parameters
extension ARB_texture_env_crossbar
extension ARB_texture_border_clamp
extension ARB_multitexture
extension ARB_texture_env_add
extension ARB_texture_cube_map
extension ARB_texture_env_dot3
extension ARB_multisample
extension ARB_texture_env_combine
extension ARB_texture_compression
extension ARB_texture_mirrored_repeat
extension ARB_shadow
extension ARB_depth_texture
extension ARB_shadow_ambient
extension ARB_fragment_program
extension ARB_fragment_program_shadow
extension ARB_fragment_shader
extension ARB_occlusion_query
extension ARB_point_sprite
extension ARB_texture_non_power_of_two
extension ARB_vertex_buffer_object
extension ARB_pixel_buffer_object
extension ARB_draw_buffers
extension ARB_shader_texture_lod
extension ARB_texture_rectangle
extension ARB_texture_float
extension ARB_half_float_pixel
extension EXT_multi_draw_arrays
extension EXT_clip_volume_hint
extension EXT_rescale_normal
extension EXT_draw_range_elements
extension EXT_fog_coord
extension EXT_gpu_program_parameters
extension EXT_geometry_shader4
#The gl.spec has the wrong arguments for GetTransformFeedbackVaryingEXT
#extension EXT_transform_feedback
extension EXT_compiled_vertex_array
extension EXT_framebuffer_object
extension EXT_framebuffer_blit
extension EXT_framebuffer_multisample
extension EXT_texture_rectangle
extension EXT_texture_env_add
extension EXT_blend_color
extension EXT_blend_minmax
extension EXT_blend_subtract
extension EXT_texture_lod_bias
extension EXT_abgr
extension EXT_bgra
extension EXT_stencil_wrap
extension EXT_texture_filter_anisotropic
extension EXT_separate_specular_color
extension EXT_secondary_color
extension EXT_blend_func_separate
extension EXT_shadow_funcs
extension EXT_stencil_two_side
extension EXT_texture_compression_s3tc
extension EXT_texture_compression_dxt1
extension EXT_texture_sRGB
extension EXT_blend_equation_separate
extension EXT_texture_mirror_clamp
extension EXT_packed_depth_stencil
extension APPLE_client_storage
extension APPLE_specular_vector
extension APPLE_transform_hint
extension APPLE_packed_pixels
#The gl.spec has different argument types for this:
#extension APPLE_fence
extension APPLE_vertex_array_object
extension APPLE_vertex_program_evaluators
extension APPLE_element_array
extension APPLE_flush_render
extension APPLE_aux_depth_stencil
extension APPLE_flush_buffer_range
extension APPLE_ycbcr_422
#The gl.spec has different argument types for this:
#extension APPLE_vertex_array_range
extension APPLE_texture_range
extension APPLE_float_pixels
extension APPLE_pixel_buffer
extension APPLE_object_purgeable
#The OpenGL framework has moved this to the core OpenGL, and eliminated EXT_convolution listing.
#extension EXT_convolution
#Leopard supports these according to nm.
#Applications should use the GL_EXTENSIONS list to determine capabilities.
extension EXT_paletted_texture
extension APPLE_fence
extension NV_vertex_program4
extension EXT_draw_buffers2
extension EXT_gpu_shader4
extension ATI_pn_triangles
extension NV_register_combiners
extension EXT_depth_bounds_test

15
src/glx/apple/GL_noop Normal file
View File

@@ -0,0 +1,15 @@
#These are for compatibility with the old libGL.
noop SGI_color_table
noop EXT_convolution
noop EXT_cull_vertex
noop NV_fence
noop SGIS_detail_texture
noop SGIX_fragment_lighting
noop SGIX_flush_raster
noop EXT_vertex_array
noop SGIX_instruments
noop EXT_histogram
noop NV_vertex_program
noop PGI_misc_hints
noop SGIS_multisample
noop EXT_multisample

View File

@@ -0,0 +1,4 @@
promoted MESA_window_pos
promoted ARB_window_pos
promoted EXT_copy_texture
promoted ARB_vertex_program

129
src/glx/apple/Makefile Normal file
View File

@@ -0,0 +1,129 @@
TOP = ../../..
include $(TOP)/configs/current
#CC=gcc
#GL_CFLAGS=-Wall -ggdb3 -Os -DPTHREADS -D_REENTRANT $(RC_CFLAGS) $(CFLAGS)
#GL_LDFLAGS=-L$(INSTALL_DIR)/lib -L$(X11_DIR)/lib $(LDFLAGS) -Wl,-single_module
TCLSH=tclsh8.5
MKDIR=mkdir
INSTALL=install
LN=ln
RM=rm
#INCLUDE=-I. -Iinclude -I.. -DGLX_ALIAS_UNSUPPORTED -I$(INSTALL_DIR)/include -I$(X11_DIR)/include
#COMPILE=$(CC) $(INCLUDE) $(GL_CFLAGS) -c
#The directory with the final binaries.
BUILD_DIR=builds
all: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
SOURCES = \
apple_cgl.c \
apple_glx.c \
apple_glx_context.c \
apple_glx_drawable.c \
apple_glx_pbuffer.c \
apple_glx_pixmap.c \
apple_glx_surface.c \
apple_visual.c \
apple_xgl_api.c \
apple_xgl_api_additional.c \
apple_xgl_api_read.c \
apple_xgl_api_stereo.c \
apple_xgl_api_viewport.c \
appledri.c \
../clientattrib.c \
../compsize.c \
../glcontextmodes.c \
glx_empty.c \
glx_error.c \
../glx_pbuffer.c \
../glx_query.c \
../glxcmds.c \
../glxcurrent.c \
../glxext.c \
../glxextensions.c \
glxreply.c \
../pixel.c \
../xfont.c
include $(TOP)/src/mesa/sources.mak
LDFLAGS += -lXplugin -framework ApplicationServices -framework CoreFoundation
MESA_GLAPI_ASM_SOURCES = $(addprefix $(TOP)/src/mesa/, $(GLAPI_ASM_SOURCES))
MESA_GLAPI_SOURCES = $(addprefix $(TOP)/src/mesa/, $(GLAPI_SOURCES))
MESA_GLAPI_OBJECTS = $(addprefix $(TOP)/src/mesa/, $(GLAPI_OBJECTS))
OBJECTS = $(SOURCES:.c=.o) # $(MESA_GLAPI_OBJECTS)
INCLUDES = -I. -Iinclude -I..\
-I$(TOP)/include \
-I$(TOP)/include/GL/internal \
-I$(TOP)/src/mesa \
-I$(TOP)/src/mesa/glapi \
$(LIBDRM_CFLAGS) \
$(DRI2PROTO_CFLAGS) \
$(X11_INCLUDES)
##### RULES #####
$(OBJECTS) : apple_xgl_api.h
apple_xgl_api.c : apple_xgl_api.h
apple_xgl_api.h : gen_api_header.tcl gen_api_library.tcl gen_code.tcl gen_defs.tcl gen_exports.tcl gen_funcs.tcl gen_types.tcl
$(TCLSH) gen_code.tcl
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@
.S.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@
##### TARGETS #####
default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
# Make libGL
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
$(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-major 1 -minor 2 $(MKLIB_OPTIONS) \
-install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).1.dylib \
$(GL_LIB_DEPS) $(OBJECTS)
depend: $(SOURCES) $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) Makefile
rm -f depend
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) \
$(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES)
# Emacs tags
tags:
etags `find . -name \*.[ch]` `find $(TOP)/include`
install_headers: include/GL/gl.h
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
$(INSTALL) -m 644 include/GL/gl.h $(DESTDIR)$(INSTALL_DIR)/include/GL
install_libraries: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
$(MAKE) -C $(TOP)/src/mesa install-libgl
install: install_libraries
# Remove .o and backup files
clean:
-rm -f *.o *.a *~
-rm -f *.c~ *.h~
-rm -f apple_xgl_api.h apple_xgl_api.c
-rm -f *.dylib
-rm -f include/GL/gl.h
-rm -f $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB)
-rm -f *.o *~
-rm -f depend depend.bak
-include depend

View File

@@ -0,0 +1,18 @@
A lot of the code is automatically generated.
The following are generated based on specs/gl.spec and specs/enum.spec (from OpenGL.org):
apple_xgl_api.h
apple_xgl_api.c
exports.list
include/GL/gl.h
include/GL/glext.h (includes the OpenGL framework glext.h)
The gen_code.tcl script is what executes the various gen_*.tcl scripts to produce those.
You will need Tcl 8.5 for the gen_code.tcl script.
The tests/ directory contains some tests that are built in testbuilds.
The tests built in testbuilds don't require installation of the library.

View File

@@ -0,0 +1,8 @@
The design of most of this code is such that we extend the GLX structures
with a void * named apple.
The GLX functions that need to do Apple-specific things are passed
&s->apple in order to initialize the private structures.
Thus when updating, just run a diff against glxext.c or glxcmds.c, and
manually merge from there as needed.

View File

@@ -0,0 +1,71 @@
AppleSGLX Release Notes
o OpenGL Support
AppleSGLX supports the same version of OpenGL as Leopard (OpenGL 2.1).
Many extensions from the OpenGL framework are now builtin.
This adds support for GLSL, and a variety of other features.
o Thread Support
Thread support has been improved since the libGL in XQuartz 2.3.2.1.
o GLX 1.4 Support
The GLX 1.3 and 1.4 functions should all work with a few exceptions
as outlined in this document.
o glXMakeContextCurrent (a GLX 1.3 feature)
glXMakeContextCurrent should work with the readable drawable. The
OpenGL functions: glReadPixels, glCopyPixels, and glCopyColorTable,
should use the readable drawable if it's different than the rendering
drawable.
o glXGetProcAddress (a GLX 1.4 feature and ARB extension)
glXGetProcAddress should work and allow getting the address of any
extension functions you may need from the X11 libGL, or OpenGL framework
libGL. Previous versions of the X11 libGL didn't allow getting the newer
OpenGL framework addresses.
o GLXPixmaps
New support for GLXPixmaps works well with mixed X11 and OpenGL drawing
operations. You can create them using glXCreateGLXPixmap or
glXCreatePixmap.
o GLXPbuffers
Support for GLXPbuffers has been added. These are drawables that are
not possible to render to with X11, which is allowed by the spec.
A GLXPbuffer will never generate a clobber event, however
glXSelectEvent and glXGetSelectedEvent should operate normally.
Clobber events are not generated due to low-level architectural
differences. The contents of your pbuffers will not be clobbered.
o Shared Contexts
Due to basic low-level architectural differences the usage of shared
contexts requires a similar visual or GLXFBConfig be used in the
creation of a shared context. It's best if you specify the same
visual. This is due to a CGL design difference, and not something
that is easily worked around. UPDATE: some changes made seem to
help resolve this issue in many cases, so you may be able to use a
shared context without this restriction.
o Indirect
The X server supports indirect fairly well, so OpenGL applications
can be run remotely and displayed by XQuartz. This means you can run
applications from a remote host on an XQuartz X server.
AppleSGLX does not support indirect rendering. Any indirect context
created will appear to glXIsDirect as an indirect context, but it
does not actually support indirect rendering to a remote X server.
AppleSGLX supports GLXPixmaps and GLXPbuffers with direct and indirect
contexts, though they are all direct contexts by definition (see above).

26
src/glx/apple/TODO Normal file
View File

@@ -0,0 +1,26 @@
Test shared contexts!
Go over every glxcmd in glxcmds.c and make sure we have them working.
Verify the XError behavior of GLXPixmap support functions.
Test GLXPixmap support with various pixmap depths.
Test GLXPixmap support with invalid pixmaps (to stress the protocol code).
-- Feb 10, 2009
Test glXCopyContext.
-- Dec 12 2008
TEST glXCopyContext needs some work and additional code in apple_glx.c.
----
Make sure we report the proper list of GLX extensions available. Apple direct may not support some
that Mesa does, and vice-versa.
Modify create_destroy_context and create a new test called create_destroy_context_thread_race.
Where 2 threads are doing the same sort of path of create and destroy. The locking should protect
us there, but we need to verify nothing goes wrong.

128
src/glx/apple/apple_cgl.c Normal file
View File

@@ -0,0 +1,128 @@
/*
Copyright (c) 2008 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include "apple_cgl.h"
#include "apple_glx.h"
#ifndef OPENGL_FRAMEWORK_PATH
#define OPENGL_FRAMEWORK_PATH "/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL"
#endif
static void *dl_handle = NULL;
struct apple_cgl_api apple_cgl;
static bool initialized = false;
static void *
sym(void *h, const char *name)
{
void *s;
s = dlsym(h, name);
if (NULL == s) {
fprintf(stderr, "error: %s\n", dlerror());
abort();
}
return s;
}
void
apple_cgl_init(void)
{
void *h;
GLint major = 0, minor = 0;
const char *opengl_framework_path;
if (initialized)
return;
opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
if (!opengl_framework_path) {
opengl_framework_path = OPENGL_FRAMEWORK_PATH;
}
(void) dlerror(); /*drain dlerror */
h = dlopen(opengl_framework_path, RTLD_NOW);
if (NULL == h) {
fprintf(stderr, "error: unable to dlopen %s : %s\n",
opengl_framework_path, dlerror());
abort();
}
dl_handle = h;
apple_cgl.get_version = sym(h, "CGLGetVersion");
apple_cgl.get_version(&major, &minor);
apple_glx_diagnostic("CGL major %d minor %d\n", major, minor);
if (1 != major) {
fprintf(stderr, "WARNING: the CGL major version has changed!\n"
"libGL may be incompatible!\n");
}
apple_cgl.choose_pixel_format = sym(h, "CGLChoosePixelFormat");
apple_cgl.destroy_pixel_format = sym(h, "CGLDestroyPixelFormat");
apple_cgl.clear_drawable = sym(h, "CGLClearDrawable");
apple_cgl.flush_drawable = sym(h, "CGLFlushDrawable");
apple_cgl.create_context = sym(h, "CGLCreateContext");
apple_cgl.destroy_context = sym(h, "CGLDestroyContext");
apple_cgl.set_current_context = sym(h, "CGLSetCurrentContext");
apple_cgl.get_current_context = sym(h, "CGLGetCurrentContext");
apple_cgl.error_string = sym(h, "CGLErrorString");
apple_cgl.set_off_screen = sym(h, "CGLSetOffScreen");
apple_cgl.copy_context = sym(h, "CGLCopyContext");
apple_cgl.create_pbuffer = sym(h, "CGLCreatePBuffer");
apple_cgl.destroy_pbuffer = sym(h, "CGLDestroyPBuffer");
apple_cgl.set_pbuffer = sym(h, "CGLSetPBuffer");
initialized = true;
}
void *
apple_cgl_get_dl_handle(void)
{
return dl_handle;
}

86
src/glx/apple/apple_cgl.h Normal file
View File

@@ -0,0 +1,86 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#ifndef APPLE_CGL_H
#define APPLE_CGL_H
#include <stdio.h>
#include <OpenGL/CGLCurrent.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/OpenGL.h>
/* For GLint and GLsizei on Tiger */
#include <OpenGL/gl.h>
struct apple_cgl_api
{
void (*get_version) (GLint * majorvers, GLint * minorvers);
CGLError(*choose_pixel_format) (const CGLPixelFormatAttribute * attribs,
CGLPixelFormatObj * pix, GLint * npix);
CGLError(*destroy_pixel_format) (CGLPixelFormatObj pix);
CGLError(*clear_drawable) (CGLContextObj ctx);
CGLError(*flush_drawable) (CGLContextObj ctx);
CGLError(*create_context) (CGLPixelFormatObj pix, CGLContextObj share,
CGLContextObj * ctx);
CGLError(*destroy_context) (CGLContextObj pix);
CGLError(*set_current_context) (CGLContextObj ctx);
CGLContextObj(*get_current_context) (void);
const char *(*error_string) (CGLError error);
CGLError(*set_off_screen) (CGLContextObj ctx,
GLsizei width, GLsizei height, GLint rowbytes,
void *baseaddr);
CGLError(*copy_context) (CGLContextObj src, CGLContextObj dst,
GLbitfield mask);
CGLError(*create_pbuffer) (GLsizei width,
GLsizei height,
GLenum target,
GLenum internalFormat,
GLint max_level, CGLPBufferObj * pbuffer);
CGLError(*destroy_pbuffer) (CGLPBufferObj pbuffer);
CGLError(*set_pbuffer) (CGLContextObj ctx,
CGLPBufferObj pbuffer,
GLenum face, GLint level, GLint screen);
};
extern struct apple_cgl_api apple_cgl;
extern void apple_cgl_init(void);
extern void *apple_cgl_get_dl_handle(void);
#endif

View File

@@ -0,0 +1,623 @@
_glAccum
_glAlphaFunc
_glAreTexturesResident
_glArrayElement
_glBegin
_glBindTexture
_glBitmap
_glBlendColor
_glBlendEquation
_glBlendEquationSeparate
_glBlendFunc
_glCallList
_glCallLists
_glClear
_glClearAccum
_glClearColor
_glClearDepth
_glClearIndex
_glClearStencil
_glClipPlane
_glColor3b
_glColor3bv
_glColor3d
_glColor3dv
_glColor3f
_glColor3fv
_glColor3i
_glColor3iv
_glColor3s
_glColor3sv
_glColor3ub
_glColor3ubv
_glColor3ui
_glColor3uiv
_glColor3us
_glColor3usv
_glColor4b
_glColor4bv
_glColor4d
_glColor4dv
_glColor4f
_glColor4fv
_glColor4i
_glColor4iv
_glColor4s
_glColor4sv
_glColor4ub
_glColor4ubv
_glColor4ui
_glColor4uiv
_glColor4us
_glColor4usv
_glColorMask
_glColorMaterial
_glColorPointer
_glColorSubTable
_glColorTable
_glColorTableParameterfv
_glColorTableParameteriv
_glConvolutionFilter1D
_glConvolutionFilter2D
_glConvolutionParameterf
_glConvolutionParameterfv
_glConvolutionParameteri
_glConvolutionParameteriv
_glCopyColorSubTable
_glCopyColorTable
_glCopyConvolutionFilter1D
_glCopyConvolutionFilter2D
_glCopyPixels
_glCopyTexImage1D
_glCopyTexImage2D
_glCopyTexSubImage1D
_glCopyTexSubImage2D
_glCopyTexSubImage3D
_glCullFace
_glDeleteLists
_glDeleteTextures
_glDepthFunc
_glDepthMask
_glDepthRange
_glDisable
_glDisableClientState
_glDrawArrays
_glDrawBuffer
_glDrawElements
_glDrawPixels
_glDrawRangeElements
_glEdgeFlag
_glEdgeFlagPointer
_glEdgeFlagv
_glEnable
_glEnableClientState
_glEnd
_glEndList
_glEvalCoord1d
_glEvalCoord1dv
_glEvalCoord1f
_glEvalCoord1fv
_glEvalCoord2d
_glEvalCoord2dv
_glEvalCoord2f
_glEvalCoord2fv
_glEvalMesh1
_glEvalMesh2
_glEvalPoint1
_glEvalPoint2
_glFeedbackBuffer
_glFinish
_glFlush
_glFogf
_glFogfv
_glFogi
_glFogiv
_glFrontFace
_glFrustum
_glGenLists
_glGenTextures
_glGetBooleanv
_glGetClipPlane
_glGetColorTable
_glGetColorTableParameterfv
_glGetColorTableParameteriv
_glGetConvolutionFilter
_glGetConvolutionParameterfv
_glGetConvolutionParameteriv
_glGetDoublev
_glGetError
_glGetFloatv
_glGetHistogram
_glGetHistogramParameterfv
_glGetHistogramParameteriv
_glGetIntegerv
_glGetLightfv
_glGetLightiv
_glGetMapdv
_glGetMapfv
_glGetMapiv
_glGetMaterialfv
_glGetMaterialiv
_glGetMinmax
_glGetMinmaxParameterfv
_glGetMinmaxParameteriv
_glGetPixelMapfv
_glGetPixelMapuiv
_glGetPixelMapusv
_glGetPointerv
_glGetPolygonStipple
_glGetSeparableFilter
_glGetString
_glGetTexEnvfv
_glGetTexEnviv
_glGetTexGendv
_glGetTexGenfv
_glGetTexGeniv
_glGetTexImage
_glGetTexLevelParameterfv
_glGetTexLevelParameteriv
_glGetTexParameterfv
_glGetTexParameteriv
_glHint
_glHistogram
_glIndexMask
_glIndexPointer
_glIndexd
_glIndexdv
_glIndexf
_glIndexfv
_glIndexi
_glIndexiv
_glIndexs
_glIndexsv
_glIndexub
_glIndexubv
_glInitNames
_glInterleavedArrays
_glIsEnabled
_glIsList
_glIsTexture
_glLightModelf
_glLightModelfv
_glLightModeli
_glLightModeliv
_glLightf
_glLightfv
_glLighti
_glLightiv
_glLineStipple
_glLineWidth
_glListBase
_glLoadIdentity
_glLoadMatrixd
_glLoadMatrixf
_glLoadName
_glLogicOp
_glMap1d
_glMap1f
_glMap2d
_glMap2f
_glMapGrid1d
_glMapGrid1f
_glMapGrid2d
_glMapGrid2f
_glMaterialf
_glMaterialfv
_glMateriali
_glMaterialiv
_glMatrixMode
_glMinmax
_glMultMatrixd
_glMultMatrixf
_glNewList
_glNormal3b
_glNormal3bv
_glNormal3d
_glNormal3dv
_glNormal3f
_glNormal3fv
_glNormal3i
_glNormal3iv
_glNormal3s
_glNormal3sv
_glNormalPointer
_glOrtho
_glPassThrough
_glPixelMapfv
_glPixelMapuiv
_glPixelMapusv
_glPixelStoref
_glPixelStorei
_glPixelTransferf
_glPixelTransferi
_glPixelZoom
_glPointSize
_glPolygonMode
_glPolygonOffset
_glPolygonStipple
_glPopAttrib
_glPopClientAttrib
_glPopMatrix
_glPopName
_glPrioritizeTextures
_glPushAttrib
_glPushClientAttrib
_glPushMatrix
_glPushName
_glRasterPos2d
_glRasterPos2dv
_glRasterPos2f
_glRasterPos2fv
_glRasterPos2i
_glRasterPos2iv
_glRasterPos2s
_glRasterPos2sv
_glRasterPos3d
_glRasterPos3dv
_glRasterPos3f
_glRasterPos3fv
_glRasterPos3i
_glRasterPos3iv
_glRasterPos3s
_glRasterPos3sv
_glRasterPos4d
_glRasterPos4dv
_glRasterPos4f
_glRasterPos4fv
_glRasterPos4i
_glRasterPos4iv
_glRasterPos4s
_glRasterPos4sv
_glReadBuffer
_glReadPixels
_glRectd
_glRectdv
_glRectf
_glRectfv
_glRecti
_glRectiv
_glRects
_glRectsv
_glRenderMode
_glResetHistogram
_glResetMinmax
_glRotated
_glRotatef
_glScaled
_glScalef
_glScissor
_glSelectBuffer
_glSeparableFilter2D
_glShadeModel
_glStencilFunc
_glStencilMask
_glStencilOp
_glTexCoord1d
_glTexCoord1dv
_glTexCoord1f
_glTexCoord1fv
_glTexCoord1i
_glTexCoord1iv
_glTexCoord1s
_glTexCoord1sv
_glTexCoord2d
_glTexCoord2dv
_glTexCoord2f
_glTexCoord2fv
_glTexCoord2i
_glTexCoord2iv
_glTexCoord2s
_glTexCoord2sv
_glTexCoord3d
_glTexCoord3dv
_glTexCoord3f
_glTexCoord3fv
_glTexCoord3i
_glTexCoord3iv
_glTexCoord3s
_glTexCoord3sv
_glTexCoord4d
_glTexCoord4dv
_glTexCoord4f
_glTexCoord4fv
_glTexCoord4i
_glTexCoord4iv
_glTexCoord4s
_glTexCoord4sv
_glTexCoordPointer
_glTexEnvf
_glTexEnvfv
_glTexEnvi
_glTexEnviv
_glTexGend
_glTexGendv
_glTexGenf
_glTexGenfv
_glTexGeni
_glTexGeniv
_glTexImage1D
_glTexImage2D
_glTexImage3D
_glTexParameterf
_glTexParameterfv
_glTexParameteri
_glTexParameteriv
_glTexSubImage1D
_glTexSubImage2D
_glTexSubImage3D
_glTranslated
_glTranslatef
_glVertex2d
_glVertex2dv
_glVertex2f
_glVertex2fv
_glVertex2i
_glVertex2iv
_glVertex2s
_glVertex2sv
_glVertex3d
_glVertex3dv
_glVertex3f
_glVertex3fv
_glVertex3i
_glVertex3iv
_glVertex3s
_glVertex3sv
_glVertex4d
_glVertex4dv
_glVertex4f
_glVertex4fv
_glVertex4i
_glVertex4iv
_glVertex4s
_glVertex4sv
_glVertexPointer
_glViewport
_glSampleCoverage
_glSamplePass
_glLoadTransposeMatrixf
_glLoadTransposeMatrixd
_glMultTransposeMatrixf
_glMultTransposeMatrixd
_glCompressedTexImage3D
_glCompressedTexImage2D
_glCompressedTexImage1D
_glCompressedTexSubImage3D
_glCompressedTexSubImage2D
_glCompressedTexSubImage1D
_glGetCompressedTexImage
_glActiveTexture
_glClientActiveTexture
_glMultiTexCoord1d
_glMultiTexCoord1dv
_glMultiTexCoord1f
_glMultiTexCoord1fv
_glMultiTexCoord1i
_glMultiTexCoord1iv
_glMultiTexCoord1s
_glMultiTexCoord1sv
_glMultiTexCoord2d
_glMultiTexCoord2dv
_glMultiTexCoord2f
_glMultiTexCoord2fv
_glMultiTexCoord2i
_glMultiTexCoord2iv
_glMultiTexCoord2s
_glMultiTexCoord2sv
_glMultiTexCoord3d
_glMultiTexCoord3dv
_glMultiTexCoord3f
_glMultiTexCoord3fv
_glMultiTexCoord3i
_glMultiTexCoord3iv
_glMultiTexCoord3s
_glMultiTexCoord3sv
_glMultiTexCoord4d
_glMultiTexCoord4dv
_glMultiTexCoord4f
_glMultiTexCoord4fv
_glMultiTexCoord4i
_glMultiTexCoord4iv
_glMultiTexCoord4s
_glMultiTexCoord4sv
_glFogCoordf
_glFogCoordfv
_glFogCoordd
_glFogCoorddv
_glFogCoordPointer
_glSecondaryColor3b
_glSecondaryColor3bv
_glSecondaryColor3d
_glSecondaryColor3dv
_glSecondaryColor3f
_glSecondaryColor3fv
_glSecondaryColor3i
_glSecondaryColor3iv
_glSecondaryColor3s
_glSecondaryColor3sv
_glSecondaryColor3ub
_glSecondaryColor3ubv
_glSecondaryColor3ui
_glSecondaryColor3uiv
_glSecondaryColor3us
_glSecondaryColor3usv
_glSecondaryColorPointer
_glPointParameterf
_glPointParameterfv
_glPointParameteri
_glPointParameteriv
_glBlendFuncSeparate
_glMultiDrawArrays
_glMultiDrawElements
_glWindowPos2d
_glWindowPos2dv
_glWindowPos2f
_glWindowPos2fv
_glWindowPos2i
_glWindowPos2iv
_glWindowPos2s
_glWindowPos2sv
_glWindowPos3d
_glWindowPos3dv
_glWindowPos3f
_glWindowPos3fv
_glWindowPos3i
_glWindowPos3iv
_glWindowPos3s
_glWindowPos3sv
_glGenQueries
_glDeleteQueries
_glIsQuery
_glBeginQuery
_glEndQuery
_glGetQueryiv
_glGetQueryObjectiv
_glGetQueryObjectuiv
_glBindBuffer
_glDeleteBuffers
_glGenBuffers
_glIsBuffer
_glBufferData
_glBufferSubData
_glGetBufferSubData
_glMapBuffer
_glUnmapBuffer
_glGetBufferParameteriv
_glGetBufferPointerv
_glDrawBuffers
_glVertexAttrib1d
_glVertexAttrib1dv
_glVertexAttrib1f
_glVertexAttrib1fv
_glVertexAttrib1s
_glVertexAttrib1sv
_glVertexAttrib2d
_glVertexAttrib2dv
_glVertexAttrib2f
_glVertexAttrib2fv
_glVertexAttrib2s
_glVertexAttrib2sv
_glVertexAttrib3d
_glVertexAttrib3dv
_glVertexAttrib3f
_glVertexAttrib3fv
_glVertexAttrib3s
_glVertexAttrib3sv
_glVertexAttrib4Nbv
_glVertexAttrib4Niv
_glVertexAttrib4Nsv
_glVertexAttrib4Nub
_glVertexAttrib4Nubv
_glVertexAttrib4Nuiv
_glVertexAttrib4Nusv
_glVertexAttrib4bv
_glVertexAttrib4d
_glVertexAttrib4dv
_glVertexAttrib4f
_glVertexAttrib4fv
_glVertexAttrib4iv
_glVertexAttrib4s
_glVertexAttrib4sv
_glVertexAttrib4ubv
_glVertexAttrib4uiv
_glVertexAttrib4usv
_glVertexAttribPointer
_glEnableVertexAttribArray
_glDisableVertexAttribArray
_glGetVertexAttribdv
_glGetVertexAttribfv
_glGetVertexAttribiv
_glGetVertexAttribPointerv
_glDeleteShader
_glDetachShader
_glCreateShader
_glShaderSource
_glCompileShader
_glCreateProgram
_glAttachShader
_glLinkProgram
_glUseProgram
_glDeleteProgram
_glValidateProgram
_glUniform1f
_glUniform2f
_glUniform3f
_glUniform4f
_glUniform1i
_glUniform2i
_glUniform3i
_glUniform4i
_glUniform1fv
_glUniform2fv
_glUniform3fv
_glUniform4fv
_glUniform1iv
_glUniform2iv
_glUniform3iv
_glUniform4iv
_glUniformMatrix2fv
_glUniformMatrix3fv
_glUniformMatrix4fv
_glIsShader
_glIsProgram
_glGetShaderiv
_glGetProgramiv
_glGetAttachedShaders
_glGetShaderInfoLog
_glGetProgramInfoLog
_glGetUniformLocation
_glGetActiveUniform
_glGetUniformfv
_glGetUniformiv
_glGetShaderSource
_glBindAttribLocation
_glGetActiveAttrib
_glGetAttribLocation
_glStencilFuncSeparate
_glStencilOpSeparate
_glStencilMaskSeparate
_glUniformMatrix2x3fv
_glUniformMatrix3x2fv
_glUniformMatrix2x4fv
_glUniformMatrix4x2fv
_glUniformMatrix3x4fv
_glUniformMatrix4x3fv
_glXChooseVisual
_glXCreateContext
_glXDestroyContext
_glXMakeCurrent
_glXCopyContext
_glXSwapBuffers
_glXCreateGLXPixmap
_glXDestroyGLXPixmap
_glXQueryExtension
_glXQueryVersion
_glXIsDirect
_glXGetConfig
_glXGetCurrentContext
_glXGetCurrentDrawable
_glXWaitGL
_glXWaitX
_glXUseXFont
_glXQueryExtensionsString
_glXQueryServerString
_glXGetClientString
_glXGetCurrentDisplay
_glXChooseFBConfig
_glXGetFBConfigAttrib
_glXGetFBConfigs
_glXGetVisualFromFBConfig
_glXCreateWindow
_glXDestroyWindow
_glXCreatePixmap
_glXDestroyPixmap
_glXCreatePbuffer
_glXDestroyPbuffer
_glXQueryDrawable
_glXCreateNewContext
_glXMakeContextCurrent
_glXGetCurrentReadDrawable
_glXQueryContext
_glXSelectEvent
_glXGetSelectedEvent
_glXGetProcAddress

214
src/glx/apple/apple_glx.c Normal file
View File

@@ -0,0 +1,214 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <dlfcn.h>
#include "appledri.h"
#include "apple_glx.h"
#include "apple_glx_context.h"
#include "apple_cgl.h"
#include "apple_xgl_api.h"
static bool initialized = false;
static int dri_event_base = 0;
const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
#ifndef OPENGL_LIB_PATH
#define OPENGL_LIB_PATH "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
#endif
static void *libgl_handle = NULL;
static bool diagnostic = false;
void
apple_glx_diagnostic(const char *fmt, ...)
{
va_list vl;
if (diagnostic) {
fprintf(stderr, "DIAG: ");
va_start(vl, fmt);
vfprintf(stderr, fmt, vl);
va_end(vl);
}
}
int
apple_get_dri_event_base(void)
{
if (!initialized) {
fprintf(stderr,
"error: dri_event_base called before apple_init_glx!\n");
abort();
}
return dri_event_base;
}
static void
surface_notify_handler(Display * dpy, unsigned int uid, int kind)
{
switch (kind) {
case AppleDRISurfaceNotifyDestroyed:
apple_glx_diagnostic("%s: surface destroyed %u\n", __func__, uid);
apple_glx_surface_destroy(uid);
break;
case AppleDRISurfaceNotifyChanged:{
int updated;
updated = apple_glx_context_surface_changed(uid, pthread_self());
apple_glx_diagnostic("surface notify updated %d\n", updated);
}
break;
default:
fprintf(stderr, "unhandled kind of event: %d in %s\n", kind, __func__);
}
}
xp_client_id
apple_glx_get_client_id(void)
{
static xp_client_id id;
if (0 == id) {
if ((XP_Success != xp_init(XP_IN_BACKGROUND)) ||
(Success != xp_get_client_id(&id))) {
return 0;
}
}
return id;
}
/* Return true if an error occured. */
bool
apple_init_glx(Display * dpy)
{
int eventBase, errorBase;
int major, minor, patch;
if (!XAppleDRIQueryExtension(dpy, &eventBase, &errorBase))
return true;
if (!XAppleDRIQueryVersion(dpy, &major, &minor, &patch))
return true;
if (initialized)
return false;
if (getenv("LIBGL_DIAGNOSTIC")) {
printf("initializing libGL in %s\n", __func__);
diagnostic = true;
}
apple_cgl_init();
apple_xgl_init_direct();
libgl_handle = dlopen(OPENGL_LIB_PATH, RTLD_LAZY);
(void) apple_glx_get_client_id();
XAppleDRISetSurfaceNotifyHandler(surface_notify_handler);
/* This should really be per display. */
dri_event_base = eventBase;
initialized = true;
return false;
}
void
apple_glx_swap_buffers(void *ptr)
{
struct apple_glx_context *ac = ptr;
/* This may not be needed with CGLFlushDrawable: */
glFlush();
apple_cgl.flush_drawable(ac->context_obj);
}
void *
apple_glx_get_proc_address(const GLubyte * procname)
{
size_t len;
void *h, *s;
char *pname = (char *) procname;
assert(NULL != procname);
len = strlen(pname);
if (len < 3) {
return NULL;
}
if ((pname != strstr(pname, "glX")) && (pname != strstr(pname, "gl"))) {
fprintf(stderr,
"warning: get proc address request is not for a gl or glX function");
return NULL;
}
/* Search using the default symbols first. */
(void) dlerror(); /*drain dlerror */
h = dlopen(NULL, RTLD_NOW);
if (NULL == h) {
fprintf(stderr, "warning: get proc address: %s\n", dlerror());
return NULL;
}
s = dlsym(h, pname);
if (NULL == s) {
/* Try the libGL.dylib from the OpenGL.framework. */
s = dlsym(libgl_handle, pname);
}
dlclose(h);
return s;
}
void
apple_glx_waitx(Display * dpy, void *ptr)
{
struct apple_private_context *ac = ptr;
(void) ac;
glFlush();
glFinish();
XSync(dpy, False);
}

49
src/glx/apple/apple_glx.h Normal file
View File

@@ -0,0 +1,49 @@
/*
Copyright (c) 2008 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#ifndef APPLE_GLX_H
#define APPLE_GLX_H
#include <stdbool.h>
#include <GL/gl.h>
#include <GL/glxint.h>
#include <X11/Xlib.h>
#define XP_NO_X_HEADERS
#include <Xplugin.h>
void apple_glx_diagnostic(const char *fmt, ...);
xp_client_id apple_glx_get_client_id(void);
bool apple_init_glx(Display * dpy);
void apple_glx_swap_buffers(void *ptr);
void *apple_glx_get_proc_address(const GLubyte * procname);
void apple_glx_waitx(Display * dpy, void *ptr);
int apple_get_dri_event_base(void);
#endif

View File

@@ -0,0 +1,616 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
// Get the newer glext.h first
#include <GL/gl.h>
#include <GL/glext.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLCurrent.h>
#include <OpenGL/OpenGL.h>
#include "glxclient.h"
#include "apple_glx.h"
#include "apple_glx_context.h"
#include "appledri.h"
#include "apple_visual.h"
#include "apple_cgl.h"
#include "apple_glx_drawable.h"
static pthread_mutex_t context_lock = PTHREAD_MUTEX_INITIALIZER;
/*
* This should be locked on creation and destruction of the
* apple_glx_contexts.
*
* It's also locked when the surface_notify_handler is searching
* for a uid associated with a surface.
*/
static struct apple_glx_context *context_list = NULL;
/* This guards the context_list above. */
static void
lock_context_list(void)
{
int err;
err = pthread_mutex_lock(&context_lock);
if (err) {
fprintf(stderr, "pthread_mutex_lock failure in %s: %d\n",
__func__, err);
abort();
}
}
static void
unlock_context_list(void)
{
int err;
err = pthread_mutex_unlock(&context_lock);
if (err) {
fprintf(stderr, "pthread_mutex_unlock failure in %s: %d\n",
__func__, err);
abort();
}
}
static bool
is_context_valid(struct apple_glx_context *ac)
{
struct apple_glx_context *i;
lock_context_list();
for (i = context_list; i; i = i->next) {
if (ac == i) {
unlock_context_list();
return true;
}
}
unlock_context_list();
return false;
}
/* This creates an apple_private_context struct.
*
* It's typically called to save the struct in a GLXContext.
*
* This is also where the CGLContextObj is created, and the CGLPixelFormatObj.
*/
bool
apple_glx_create_context(void **ptr, Display * dpy, int screen,
const void *mode, void *sharedContext,
int *errorptr, bool * x11errorptr)
{
struct apple_glx_context *ac;
struct apple_glx_context *sharedac = sharedContext;
CGLError error;
*ptr = NULL;
ac = malloc(sizeof *ac);
if (NULL == ac) {
*errorptr = BadAlloc;
*x11errorptr = true;
return true;
}
if (sharedac && !is_context_valid(sharedac)) {
*errorptr = GLXBadContext;
*x11errorptr = false;
return true;
}
ac->context_obj = NULL;
ac->pixel_format_obj = NULL;
ac->drawable = NULL;
ac->thread_id = pthread_self();
ac->screen = screen;
ac->double_buffered = false;
ac->uses_stereo = false;
ac->need_update = false;
ac->is_current = false;
ac->made_current = false;
ac->last_surface_window = None;
apple_visual_create_pfobj(&ac->pixel_format_obj, mode,
&ac->double_buffered, &ac->uses_stereo,
/*offscreen */ false);
error = apple_cgl.create_context(ac->pixel_format_obj,
sharedac ? sharedac->context_obj : NULL,
&ac->context_obj);
if (error) {
(void) apple_cgl.destroy_pixel_format(ac->pixel_format_obj);
free(ac);
if (kCGLBadMatch == error) {
*errorptr = BadMatch;
*x11errorptr = true;
}
else {
*errorptr = GLXBadContext;
*x11errorptr = false;
}
if (getenv("LIBGL_DIAGNOSTIC"))
fprintf(stderr, "error: %s\n", apple_cgl.error_string(error));
return true;
}
/* The context creation succeeded, so we can link in the new context. */
lock_context_list();
if (context_list)
context_list->previous = ac;
ac->previous = NULL;
ac->next = context_list;
context_list = ac;
*ptr = ac;
apple_glx_diagnostic("%s: ac %p ac->context_obj %p\n",
__func__, (void *) ac, (void *) ac->context_obj);
unlock_context_list();
return false;
}
void
apple_glx_destroy_context(void **ptr, Display * dpy)
{
struct apple_glx_context *ac = *ptr;
if (NULL == ac)
return;
apple_glx_diagnostic("%s: ac %p ac->context_obj %p\n",
__func__, (void *) ac, (void *) ac->context_obj);
if (apple_cgl.get_current_context() == ac->context_obj) {
apple_glx_diagnostic("%s: context ac->context_obj %p "
"is still current!\n", __func__,
(void *) ac->context_obj);
if (apple_cgl.set_current_context(NULL)) {
abort();
}
}
/* Remove ac from the context_list as soon as possible. */
lock_context_list();
if (ac->previous) {
ac->previous->next = ac->next;
}
else {
context_list = ac->next;
}
if (ac->next) {
ac->next->previous = ac->previous;
}
unlock_context_list();
if (apple_cgl.clear_drawable(ac->context_obj)) {
fprintf(stderr, "error: while clearing drawable!\n");
abort();
}
/*
* This potentially causes surface_notify_handler to be called in
* apple_glx.c...
* We can NOT have a lock held at this point. It would result in
* an abort due to an attempted deadlock. This is why we earlier
* removed the ac pointer from the double-linked list.
*/
if (ac->drawable) {
ac->drawable->destroy(ac->drawable);
}
if (apple_cgl.destroy_pixel_format(ac->pixel_format_obj)) {
fprintf(stderr, "error: destroying pixel format in %s\n", __func__);
abort();
}
if (apple_cgl.destroy_context(ac->context_obj)) {
fprintf(stderr, "error: destroying context_obj in %s\n", __func__);
abort();
}
free(ac);
*ptr = NULL;
apple_glx_garbage_collect_drawables(dpy);
}
/* Return true if an error occured. */
bool
apple_glx_make_current_context(Display * dpy, void *oldptr, void *ptr,
GLXDrawable drawable)
{
struct apple_glx_context *oldac = oldptr;
struct apple_glx_context *ac = ptr;
struct apple_glx_drawable *newagd = NULL;
CGLError cglerr;
bool same_drawable = false;
#if 0
apple_glx_diagnostic("%s: oldac %p ac %p drawable 0x%lx\n",
__func__, (void *) oldac, (void *) ac, drawable);
apple_glx_diagnostic("%s: oldac->context_obj %p ac->context_obj %p\n",
__func__,
(void *) (oldac ? oldac->context_obj : NULL),
(void *) (ac ? ac->context_obj : NULL));
#endif
/* This a common path for GLUT and other apps, so special case it. */
if (ac && ac->drawable && ac->drawable->drawable == drawable) {
same_drawable = true;
if (ac->is_current)
return false;
}
/* Reset the is_current state of the old context, if non-NULL. */
if (oldac && (ac != oldac))
oldac->is_current = false;
if (NULL == ac) {
/*Clear the current context for this thread. */
apple_cgl.set_current_context(NULL);
if (oldac) {
oldac->is_current = false;
if (oldac->drawable) {
oldac->drawable->destroy(oldac->drawable);
oldac->drawable = NULL;
}
/* Invalidate this to prevent surface recreation. */
oldac->last_surface_window = None;
}
return false;
}
if (None == drawable) {
bool error = false;
/* Clear the current drawable for this context_obj. */
if (apple_cgl.set_current_context(ac->context_obj))
error = true;
if (apple_cgl.clear_drawable(ac->context_obj))
error = true;
if (ac->drawable) {
ac->drawable->destroy(ac->drawable);
ac->drawable = NULL;
}
/* Invalidate this to prevent surface recreation. */
ac->last_surface_window = None;
apple_glx_diagnostic("%s: drawable is None, error is: %d\n",
__func__, error);
return error;
}
/* This is an optimisation to avoid searching for the current drawable. */
if (ac->drawable && ac->drawable->drawable == drawable) {
newagd = ac->drawable;
}
else {
/* Find the drawable if possible, and retain a reference to it. */
newagd =
apple_glx_drawable_find(drawable, APPLE_GLX_DRAWABLE_REFERENCE);
}
/*
* Try to destroy the old drawable, so long as the new one
* isn't the old.
*/
if (ac->drawable && !same_drawable) {
ac->drawable->destroy(ac->drawable);
ac->drawable = NULL;
}
if (NULL == newagd) {
if (apple_glx_surface_create(dpy, ac->screen, drawable, &newagd))
return true;
/* The drawable is referenced once by apple_glx_surface_create. */
/*
* FIXME: We actually need 2 references to prevent premature surface
* destruction. The problem is that the surface gets destroyed in
* the case of the context being reused for another window, and
* we then lose the surface contents. Wait for destruction of a
* window to destroy a surface.
*
* Note: this may leave around surfaces we don't want around, if
* say we are using X for raster drawing after OpenGL rendering,
* but it will be compatible with the old libGL's behavior.
*
* Someday the X11 and OpenGL rendering must be unified at some
* layer. I suspect we can do that via shared memory and
* multiple threads in the X server (1 for each context created
* by a client). This would also allow users to render from
* multiple clients to the same OpenGL surface. In fact it could
* all be OpenGL.
*
*/
newagd->reference(newagd);
/* Save the new drawable with the context structure. */
ac->drawable = newagd;
}
else {
/* We are reusing an existing drawable structure. */
if (same_drawable) {
assert(ac->drawable == newagd);
/* The drawable_find above retained a reference for us. */
}
else {
ac->drawable = newagd;
}
}
/*
* Avoid this costly path if this is the same drawable and the
* context is already current.
*/
if (same_drawable && ac->is_current) {
apple_glx_diagnostic("%s: same_drawable and ac->is_current\n");
return false;
}
cglerr = apple_cgl.set_current_context(ac->context_obj);
if (kCGLNoError != cglerr) {
fprintf(stderr, "set current error: %s\n",
apple_cgl.error_string(cglerr));
return true;
}
ac->is_current = true;
assert(NULL != ac->context_obj);
assert(NULL != ac->drawable);
ac->thread_id = pthread_self();
/* This will be set if the pending_destroy code indicates it should be: */
ac->last_surface_window = None;
switch (ac->drawable->type) {
case APPLE_GLX_DRAWABLE_PBUFFER:
case APPLE_GLX_DRAWABLE_SURFACE:
case APPLE_GLX_DRAWABLE_PIXMAP:
if (ac->drawable->callbacks.make_current) {
if (ac->drawable->callbacks.make_current(ac, ac->drawable))
return true;
}
break;
default:
fprintf(stderr, "internal error: invalid drawable type: %d\n",
ac->drawable->type);
abort();
}
return false;
}
bool
apple_glx_is_current_drawable(Display * dpy, void *ptr, GLXDrawable drawable)
{
struct apple_glx_context *ac = ptr;
if (ac->drawable && ac->drawable->drawable == drawable) {
return true;
}
else if (NULL == ac->drawable && None != ac->last_surface_window) {
apple_glx_context_update(dpy, ac);
return (ac->drawable && ac->drawable->drawable == drawable);
}
return false;
}
bool
apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr,
unsigned long mask, int *errorptr, bool * x11errorptr)
{
struct apple_glx_context *src, *dest;
CGLError err;
src = srcptr;
dest = destptr;
if (src->screen != dest->screen) {
*errorptr = BadMatch;
*x11errorptr = true;
return true;
}
if (dest == currentptr || dest->is_current) {
*errorptr = BadAccess;
*x11errorptr = true;
return true;
}
/*
* If srcptr is the current context then we should do an implicit glFlush.
*/
if (currentptr == srcptr)
glFlush();
err = apple_cgl.copy_context(src->context_obj, dest->context_obj,
(GLbitfield) mask);
if (kCGLNoError != err) {
*errorptr = GLXBadContext;
*x11errorptr = false;
return true;
}
return false;
}
/*
* The value returned is the total number of contexts set to update.
* It's meant for debugging/introspection.
*/
int
apple_glx_context_surface_changed(unsigned int uid, pthread_t caller)
{
struct apple_glx_context *ac;
int updated = 0;
lock_context_list();
for (ac = context_list; ac; ac = ac->next) {
if (ac->drawable && APPLE_GLX_DRAWABLE_SURFACE == ac->drawable->type
&& ac->drawable->types.surface.uid == uid) {
if (caller == ac->thread_id) {
apple_glx_diagnostic("caller is the same thread for uid %u\n",
uid);
xp_update_gl_context(ac->context_obj);
}
else {
ac->need_update = true;
++updated;
}
}
}
unlock_context_list();
return updated;
}
void
apple_glx_context_update(Display * dpy, void *ptr)
{
struct apple_glx_context *ac = ptr;
if (NULL == ac->drawable && None != ac->last_surface_window) {
bool failed;
/* Attempt to recreate the surface for a destroyed drawable. */
failed =
apple_glx_make_current_context(dpy, ac, ac, ac->last_surface_window);
apple_glx_diagnostic("%s: surface recreation failed? %s\n", __func__,
failed ? "YES" : "NO");
}
if (ac->need_update) {
xp_update_gl_context(ac->context_obj);
ac->need_update = false;
apple_glx_diagnostic("%s: updating context %p\n", __func__, ptr);
}
if (ac->drawable && APPLE_GLX_DRAWABLE_SURFACE == ac->drawable->type
&& ac->drawable->types.surface.pending_destroy) {
apple_glx_diagnostic("%s: clearing drawable %p\n", __func__, ptr);
apple_cgl.clear_drawable(ac->context_obj);
if (ac->drawable) {
struct apple_glx_drawable *d;
apple_glx_diagnostic("%s: attempting to destroy drawable %p\n",
__func__, ptr);
apple_glx_diagnostic("%s: ac->drawable->drawable is 0x%lx\n",
__func__, ac->drawable->drawable);
d = ac->drawable;
ac->last_surface_window = d->drawable;
ac->drawable = NULL;
/*
* This will destroy the surface drawable if there are
* no references to it.
* It also subtracts 1 from the reference_count.
* If there are references to it, then it's probably made
* current in another context.
*/
d->destroy(d);
}
}
}
bool
apple_glx_context_uses_stereo(void *ptr)
{
struct apple_glx_context *ac = ptr;
return ac->uses_stereo;
}

View File

@@ -0,0 +1,93 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#ifndef APPLE_GLX_CONTEXT_H
#define APPLE_GLX_CONTEXT_H
/* <rdar://problem/6953344> */
#define glTexImage1D glTexImage1D_OSX
#define glTexImage2D glTexImage2D_OSX
#define glTexImage3D glTexImage3D_OSX
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLContext.h>
#undef glTexImage1D
#undef glTexImage2D
#undef glTexImage3D
#include <stdbool.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
#define XP_NO_X_HEADERS
#include <Xplugin.h>
#undef XP_NO_X_HEADERS
#include "apple_glx_drawable.h"
struct apple_glx_context
{
CGLContextObj context_obj;
CGLPixelFormatObj pixel_format_obj;
struct apple_glx_drawable *drawable;
pthread_t thread_id;
int screen;
bool double_buffered;
bool uses_stereo;
bool need_update;
bool is_current; /* True if the context is current in some thread. */
bool made_current; /* True if the context has ever been made current. */
/*
* last_surface is set by the pending_destroy code handler for a drawable.
* Due to a CG difference, we have to recreate a surface if the window
* is unmapped and mapped again.
*/
Window last_surface_window;
struct apple_glx_context *previous, *next;
};
bool apple_glx_create_context(void **ptr, Display * dpy, int screen,
const void *mode, void *sharedContext,
int *errorptr, bool * x11errorptr);
void apple_glx_destroy_context(void **ptr, Display * dpy);
bool apple_glx_make_current_context(Display * dpy, void *oldptr, void *ptr,
GLXDrawable drawable);
bool apple_glx_is_current_drawable(Display * dpy, void *ptr,
GLXDrawable drawable);
bool apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr,
unsigned long mask, int *errorptr,
bool * x11errorptr);
int apple_glx_context_surface_changed(unsigned int uid, pthread_t caller);
void apple_glx_context_update(Display * dpy, void *ptr);
bool apple_glx_context_uses_stereo(void *ptr);
#endif /*APPLE_GLX_CONTEXT_H */

View File

@@ -0,0 +1,542 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <pthread.h>
#include "apple_glx.h"
#include "apple_glx_context.h"
#include "apple_glx_drawable.h"
#include "appledri.h"
static pthread_mutex_t drawables_lock = PTHREAD_MUTEX_INITIALIZER;
static struct apple_glx_drawable *drawables_list = NULL;
static void
lock_drawables_list(void)
{
int err;
err = pthread_mutex_lock(&drawables_lock);
if (err) {
fprintf(stderr, "pthread_mutex_lock failure in %s: %d\n",
__func__, err);
abort();
}
}
static void
unlock_drawables_list(void)
{
int err;
err = pthread_mutex_unlock(&drawables_lock);
if (err) {
fprintf(stderr, "pthread_mutex_unlock failure in %s: %d\n",
__func__, err);
abort();
}
}
struct apple_glx_drawable *
apple_glx_find_drawable(Display * dpy, GLXDrawable drawable)
{
struct apple_glx_drawable *i, *agd = NULL;
lock_drawables_list();
for (i = drawables_list; i; i = i->next) {
if (i->drawable == drawable) {
agd = i;
break;
}
}
unlock_drawables_list();
return agd;
}
static void
drawable_lock(struct apple_glx_drawable *agd)
{
int err;
err = pthread_mutex_lock(&agd->mutex);
if (err) {
fprintf(stderr, "pthread_mutex_lock error: %d\n", err);
abort();
}
}
static void
drawable_unlock(struct apple_glx_drawable *d)
{
int err;
err = pthread_mutex_unlock(&d->mutex);
if (err) {
fprintf(stderr, "pthread_mutex_unlock error: %d\n", err);
abort();
}
}
static void
reference_drawable(struct apple_glx_drawable *d)
{
d->lock(d);
d->reference_count++;
d->unlock(d);
}
static void
release_drawable(struct apple_glx_drawable *d)
{
d->lock(d);
d->reference_count--;
d->unlock(d);
}
/* The drawables list must be locked prior to calling this. */
/* Return true if the drawable was destroyed. */
static bool
destroy_drawable(struct apple_glx_drawable *d)
{
d->lock(d);
if (d->reference_count > 0) {
d->unlock(d);
return false;
}
d->unlock(d);
if (d->previous) {
d->previous->next = d->next;
}
else {
/*
* The item must be at the head of the list, if it
* has no previous pointer.
*/
drawables_list = d->next;
}
if (d->next)
d->next->previous = d->previous;
unlock_drawables_list();
if (d->callbacks.destroy) {
/*
* Warning: this causes other routines to be called (potentially)
* from surface_notify_handler. It's probably best to not have
* any locks at this point locked.
*/
d->callbacks.destroy(d->display, d);
}
apple_glx_diagnostic("%s: freeing %p\n", __func__, (void *) d);
free(d);
/* So that the locks are balanced and the caller correctly unlocks. */
lock_drawables_list();
return true;
}
/*
* This is typically called when a context is destroyed or the current
* drawable is made None.
*/
static bool
destroy_drawable_callback(struct apple_glx_drawable *d)
{
bool result;
d->lock(d);
apple_glx_diagnostic("%s: %p ->reference_count before -- %d\n", __func__,
(void *) d, d->reference_count);
d->reference_count--;
if (d->reference_count > 0) {
d->unlock(d);
return false;
}
d->unlock(d);
lock_drawables_list();
result = destroy_drawable(d);
unlock_drawables_list();
return result;
}
static bool
is_pbuffer(struct apple_glx_drawable *d)
{
return APPLE_GLX_DRAWABLE_PBUFFER == d->type;
}
static bool
is_pixmap(struct apple_glx_drawable *d)
{
return APPLE_GLX_DRAWABLE_PIXMAP == d->type;
}
static void
common_init(Display * dpy, GLXDrawable drawable, struct apple_glx_drawable *d)
{
int err;
pthread_mutexattr_t attr;
d->display = dpy;
d->reference_count = 0;
d->drawable = drawable;
d->type = -1;
err = pthread_mutexattr_init(&attr);
if (err) {
fprintf(stderr, "pthread_mutexattr_init error: %d\n", err);
abort();
}
/*
* There are some patterns that require a recursive mutex,
* when working with locks that protect the apple_glx_drawable,
* and reference functions like ->reference, and ->release.
*/
err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if (err) {
fprintf(stderr, "error: setting pthread mutex type: %d\n", err);
abort();
}
err = pthread_mutex_init(&d->mutex, &attr);
if (err) {
fprintf(stderr, "pthread_mutex_init error: %d\n", err);
abort();
}
(void) pthread_mutexattr_destroy(&attr);
d->lock = drawable_lock;
d->unlock = drawable_unlock;
d->reference = reference_drawable;
d->release = release_drawable;
d->destroy = destroy_drawable_callback;
d->is_pbuffer = is_pbuffer;
d->is_pixmap = is_pixmap;
d->width = -1;
d->height = -1;
d->row_bytes = 0;
d->path[0] = '\0';
d->fd = -1;
d->buffer = NULL;
d->buffer_length = 0;
d->previous = NULL;
d->next = NULL;
}
static void
link_tail(struct apple_glx_drawable *agd)
{
lock_drawables_list();
/* Link the new drawable into the global list. */
agd->next = drawables_list;
if (drawables_list)
drawables_list->previous = agd;
drawables_list = agd;
unlock_drawables_list();
}
/*WARNING: this returns a locked and referenced object. */
bool
apple_glx_drawable_create(Display * dpy,
int screen,
GLXDrawable drawable,
struct apple_glx_drawable **agdResult,
struct apple_glx_drawable_callbacks *callbacks)
{
struct apple_glx_drawable *d;
d = calloc(1, sizeof *d);
if (NULL == d) {
perror("malloc");
return true;
}
common_init(dpy, drawable, d);
d->type = callbacks->type;
d->callbacks = *callbacks;
d->reference(d);
d->lock(d);
link_tail(d);
apple_glx_diagnostic("%s: new drawable %p\n", __func__, (void *) d);
*agdResult = d;
return false;
}
static int error_count = 0;
static int
error_handler(Display * dpy, XErrorEvent * err)
{
if (err->error_code == BadWindow) {
++error_count;
}
return 0;
}
void
apple_glx_garbage_collect_drawables(Display * dpy)
{
struct apple_glx_drawable *d, *dnext;
Window root;
int x, y;
unsigned int width, height, bd, depth;
int (*old_handler) (Display *, XErrorEvent *);
if (NULL == drawables_list)
return;
old_handler = XSetErrorHandler(error_handler);
XSync(dpy, False);
lock_drawables_list();
for (d = drawables_list; d;) {
dnext = d->next;
d->lock(d);
if (d->reference_count > 0) {
/*
* Skip this, because some context still retains a reference
* to the drawable.
*/
d->unlock(d);
d = dnext;
continue;
}
d->unlock(d);
error_count = 0;
/*
* Mesa uses XGetWindowAttributes, but some of these things are
* most definitely not Windows, and that's against the rules.
* XGetGeometry on the other hand is legal with a Pixmap and Window.
*/
XGetGeometry(dpy, d->drawable, &root, &x, &y, &width, &height, &bd,
&depth);
if (error_count > 0) {
/*
* Note: this may not actually destroy the drawable.
* If another context retains a reference to the drawable
* after the reference count test above.
*/
(void) destroy_drawable(d);
error_count = 0;
}
d = dnext;
}
XSetErrorHandler(old_handler);
unlock_drawables_list();
}
unsigned int
apple_glx_get_drawable_count(void)
{
unsigned int result = 0;
struct apple_glx_drawable *d;
lock_drawables_list();
for (d = drawables_list; d; d = d->next)
++result;
unlock_drawables_list();
return result;
}
struct apple_glx_drawable *
apple_glx_drawable_find_by_type(GLXDrawable drawable, int type, int flags)
{
struct apple_glx_drawable *d;
lock_drawables_list();
for (d = drawables_list; d; d = d->next) {
if (d->type == type && d->drawable == drawable) {
if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
d->reference(d);
if (flags & APPLE_GLX_DRAWABLE_LOCK)
d->lock(d);
unlock_drawables_list();
return d;
}
}
unlock_drawables_list();
return NULL;
}
struct apple_glx_drawable *
apple_glx_drawable_find(GLXDrawable drawable, int flags)
{
struct apple_glx_drawable *d;
lock_drawables_list();
for (d = drawables_list; d; d = d->next) {
if (d->drawable == drawable) {
if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
d->reference(d);
if (flags & APPLE_GLX_DRAWABLE_LOCK)
d->lock(d);
unlock_drawables_list();
return d;
}
}
unlock_drawables_list();
return NULL;
}
/* Return true if the type is valid for the drawable. */
bool
apple_glx_drawable_destroy_by_type(Display * dpy,
GLXDrawable drawable, int type)
{
struct apple_glx_drawable *d;
lock_drawables_list();
for (d = drawables_list; d; d = d->next) {
if (drawable == d->drawable && type == d->type) {
/*
* The user has requested that we destroy this resource.
* However, there may be references in the contexts to it, so
* release it, and call destroy_drawable which doesn't destroy
* if the reference_count is > 0.
*/
d->release(d);
apple_glx_diagnostic("%s d->reference_count %d\n",
__func__, d->reference_count);
destroy_drawable(d);
unlock_drawables_list();
return true;
}
}
unlock_drawables_list();
return false;
}
struct apple_glx_drawable *
apple_glx_drawable_find_by_uid(unsigned int uid, int flags)
{
struct apple_glx_drawable *d;
lock_drawables_list();
for (d = drawables_list; d; d = d->next) {
/* Only surfaces have a uid. */
if (APPLE_GLX_DRAWABLE_SURFACE == d->type) {
if (d->types.surface.uid == uid) {
if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
d->reference(d);
if (flags & APPLE_GLX_DRAWABLE_LOCK)
d->lock(d);
unlock_drawables_list();
return d;
}
}
}
unlock_drawables_list();
return NULL;
}

View File

@@ -0,0 +1,227 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#ifndef APPLE_GLX_DRAWABLE_H
#define APPLE_GLX_DRAWABLE_H
/* Must be first for:
* <rdar://problem/6953344>
*/
#include "apple_glx_context.h"
#include <pthread.h>
#include <stdbool.h>
#include <limits.h>
#include <GL/glx.h>
#define XP_NO_X_HEADERS
#include <Xplugin.h>
#undef XP_NO_X_HEADERS
enum
{
APPLE_GLX_DRAWABLE_SURFACE = 1,
APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_PIXMAP
};
/* The flag for the find routine. */
enum
{
APPLE_GLX_DRAWABLE_LOCK = 2,
APPLE_GLX_DRAWABLE_REFERENCE = 4
};
struct apple_glx_context;
struct apple_glx_drawable;
struct apple_glx_surface
{
xp_surface_id surface_id;
unsigned int uid;
bool pending_destroy;
};
struct apple_glx_pbuffer
{
GLXPbuffer xid; /* our pixmap */
int width, height;
GLint fbconfigID;
CGLPBufferObj buffer_obj;
unsigned long event_mask;
};
struct apple_glx_pixmap
{
GLXPixmap xpixmap;
void *buffer;
int width, height, pitch, /*bytes per pixel */ bpp;
size_t size;
char path[PATH_MAX];
int fd;
CGLPixelFormatObj pixel_format_obj;
CGLContextObj context_obj;
GLint fbconfigID;
};
struct apple_glx_drawable_callbacks
{
int type;
bool(*make_current) (struct apple_glx_context * ac,
struct apple_glx_drawable * d);
void (*destroy) (Display * dpy, struct apple_glx_drawable * d);
};
struct apple_glx_drawable
{
Display *display;
int reference_count;
GLXDrawable drawable;
int type; /* APPLE_GLX_DRAWABLE_* */
union
{
struct apple_glx_pixmap pixmap;
struct apple_glx_pbuffer pbuffer;
struct apple_glx_surface surface;
} types;
struct apple_glx_drawable_callbacks callbacks;
/*
* This mutex protects the reference count and any other drawable data.
* It's used to prevent an early release of a drawable.
*/
pthread_mutex_t mutex;
void (*lock) (struct apple_glx_drawable * agd);
void (*unlock) (struct apple_glx_drawable * agd);
void (*reference) (struct apple_glx_drawable * agd);
void (*release) (struct apple_glx_drawable * agd);
bool(*destroy) (struct apple_glx_drawable * agd);
bool(*is_pbuffer) (struct apple_glx_drawable * agd);
bool(*is_pixmap) (struct apple_glx_drawable * agd);
/*BEGIN These are used for the mixed mode drawing... */
int width, height;
int row_bytes;
char path[PATH_MAX];
int fd; /* The file descriptor for this drawable's shared memory. */
void *buffer; /* The memory for the drawable. Typically shared memory. */
size_t buffer_length;
/*END*/ struct apple_glx_drawable *previous, *next;
};
struct apple_glx_context;
/* May return NULL if not found */
struct apple_glx_drawable *apple_glx_find_drawable(Display * dpy,
GLXDrawable drawable);
/* Returns true on error and locks the agd result with a reference. */
bool apple_glx_drawable_create(Display * dpy,
int screen,
GLXDrawable drawable,
struct apple_glx_drawable **agd,
struct apple_glx_drawable_callbacks
*callbacks);
/* Returns true on error */
bool apple_glx_create_drawable(Display * dpy,
struct apple_glx_context *ac,
GLXDrawable drawable,
struct apple_glx_drawable **agd);
void apple_glx_garbage_collect_drawables(Display * dpy);
/*
* This returns the total number of drawables.
* It's mostly intended for debugging and introspection.
*/
unsigned int apple_glx_get_drawable_count(void);
struct apple_glx_drawable *apple_glx_drawable_find_by_type(GLXDrawable
drawable, int type,
int flags);
struct apple_glx_drawable *apple_glx_drawable_find(GLXDrawable drawable,
int flags);
bool apple_glx_drawable_destroy_by_type(Display * dpy, GLXDrawable drawable,
int type);
struct apple_glx_drawable *apple_glx_drawable_find_by_uid(unsigned int uid,
int flags);
/* Surfaces */
bool apple_glx_surface_create(Display * dpy, int screen, GLXDrawable drawable,
struct apple_glx_drawable **resultptr);
void apple_glx_surface_destroy(unsigned int uid);
/* Pbuffers */
/* Returns true if an error occurred. */
bool apple_glx_pbuffer_create(Display * dpy, GLXFBConfig config,
int width, int height, int *errorcode,
GLXPbuffer * pbuf);
/* Returns true if the pbuffer was invalid. */
bool apple_glx_pbuffer_destroy(Display * dpy, GLXPbuffer pbuf);
/* Returns true if the pbuffer was valid and the attribute. */
bool apple_glx_pbuffer_query(GLXDrawable d, int attribute,
unsigned int *value);
/* Returns true if the GLXDrawable is a valid GLXPbuffer, and the mask is set. */
bool apple_glx_pbuffer_set_event_mask(GLXDrawable d, unsigned long mask);
/* Returns true if the GLXDrawable is a valid GLXPbuffer, and the *mask is set. */
bool apple_glx_pbuffer_get_event_mask(GLXDrawable d, unsigned long *mask);
/* Pixmaps */
/* mode is a __GLcontextModes * */
/* Returns true if an error occurred. */
bool apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap,
const void *mode);
/* Returns true if an error occurred. */
bool apple_glx_pixmap_destroy(Display * dpy, Pixmap pixmap);
bool apple_glx_pixmap_query(GLXPixmap pixmap, int attribute,
unsigned int *value);
#endif

View File

@@ -0,0 +1,348 @@
/*
Copyright (c) 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
/* Must be before OpenGL.framework is included. Remove once fixed:
* <rdar://problem/7872773>
*/
#include <GL/gl.h>
#include <GL/glext.h>
#define __gltypes_h_ 1
/* Must be first for:
* <rdar://problem/6953344>
*/
#include "apple_glx_context.h"
#include "apple_glx_drawable.h"
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
#include "apple_glx.h"
#include "glcontextmodes.h"
#include "apple_cgl.h"
/* mesa defines in glew.h, Apple in glext.h.
* Due to namespace nightmares, just do it here.
*/
#ifndef GL_TEXTURE_RECTANGLE_EXT
#define GL_TEXTURE_RECTANGLE_EXT 0x84F5
#endif
static bool pbuffer_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d);
static void pbuffer_destroy(Display * dpy, struct apple_glx_drawable *d);
static struct apple_glx_drawable_callbacks callbacks = {
.type = APPLE_GLX_DRAWABLE_PBUFFER,
.make_current = pbuffer_make_current,
.destroy = pbuffer_destroy
};
/* Return true if an error occurred. */
bool
pbuffer_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d)
{
struct apple_glx_pbuffer *pbuf = &d->types.pbuffer;
CGLError cglerr;
assert(APPLE_GLX_DRAWABLE_PBUFFER == d->type);
cglerr = apple_cgl.set_pbuffer(ac->context_obj, pbuf->buffer_obj, 0, 0, 0);
if (kCGLNoError != cglerr) {
fprintf(stderr, "set_pbuffer: %s\n", apple_cgl.error_string(cglerr));
return true;
}
if (!ac->made_current) {
glViewport(0, 0, pbuf->width, pbuf->height);
glScissor(0, 0, pbuf->width, pbuf->height);
ac->made_current = true;
}
apple_glx_diagnostic("made pbuffer drawable 0x%lx current\n", d->drawable);
return false;
}
void
pbuffer_destroy(Display * dpy, struct apple_glx_drawable *d)
{
struct apple_glx_pbuffer *pbuf = &d->types.pbuffer;
assert(APPLE_GLX_DRAWABLE_PBUFFER == d->type);
apple_glx_diagnostic("destroying pbuffer for drawable 0x%lx\n",
d->drawable);
apple_cgl.destroy_pbuffer(pbuf->buffer_obj);
XFreePixmap(dpy, pbuf->xid);
}
/* Return true if an error occurred. */
bool
apple_glx_pbuffer_destroy(Display * dpy, GLXPbuffer pbuf)
{
return !apple_glx_drawable_destroy_by_type(dpy, pbuf,
APPLE_GLX_DRAWABLE_PBUFFER);
}
/* Return true if an error occurred. */
bool
apple_glx_pbuffer_create(Display * dpy, GLXFBConfig config,
int width, int height, int *errorcode,
GLXPbuffer * result)
{
struct apple_glx_drawable *d;
struct apple_glx_pbuffer *pbuf = NULL;
CGLError err;
Window root;
int screen;
Pixmap xid;
__GLcontextModes *modes = (__GLcontextModes *) config;
root = DefaultRootWindow(dpy);
screen = DefaultScreen(dpy);
/*
* This pixmap is only used for a persistent XID.
* The XC-MISC extension cleans up XIDs and reuses them transparently,
* so we need to retain a server-side reference.
*/
xid = XCreatePixmap(dpy, root, (unsigned int) 1,
(unsigned int) 1, DefaultDepth(dpy, screen));
if (None == xid) {
*errorcode = BadAlloc;
return true;
}
if (apple_glx_drawable_create(dpy, screen, xid, &d, &callbacks)) {
*errorcode = BadAlloc;
return true;
}
/* The lock is held in d from create onward. */
pbuf = &d->types.pbuffer;
pbuf->xid = xid;
pbuf->width = width;
pbuf->height = height;
err = apple_cgl.create_pbuffer(width, height, GL_TEXTURE_RECTANGLE_EXT,
(modes->alphaBits > 0) ? GL_RGBA : GL_RGB,
0, &pbuf->buffer_obj);
if (kCGLNoError != err) {
d->unlock(d);
d->destroy(d);
*errorcode = BadMatch;
return true;
}
pbuf->fbconfigID = modes->fbconfigID;
pbuf->event_mask = 0;
*result = pbuf->xid;
d->unlock(d);
return false;
}
/* Return true if an error occurred. */
static bool
get_max_size(int *widthresult, int *heightresult)
{
CGLContextObj oldcontext;
GLint ar[2];
oldcontext = apple_cgl.get_current_context();
if (!oldcontext) {
/*
* There is no current context, so we need to make one in order
* to call glGetInteger.
*/
CGLPixelFormatObj pfobj;
CGLError err;
CGLPixelFormatAttribute attr[10];
int c = 0;
GLint vsref = 0;
CGLContextObj newcontext;
attr[c++] = kCGLPFAColorSize;
attr[c++] = 32;
attr[c++] = 0;
err = apple_cgl.choose_pixel_format(attr, &pfobj, &vsref);
if (kCGLNoError != err) {
if (getenv("LIBGL_DIAGNOSTIC")) {
printf("choose_pixel_format error in %s: %s\n", __func__,
apple_cgl.error_string(err));
}
return true;
}
err = apple_cgl.create_context(pfobj, NULL, &newcontext);
if (kCGLNoError != err) {
if (getenv("LIBGL_DIAGNOSTIC")) {
printf("create_context error in %s: %s\n", __func__,
apple_cgl.error_string(err));
}
apple_cgl.destroy_pixel_format(pfobj);
return true;
}
err = apple_cgl.set_current_context(newcontext);
if (kCGLNoError != err) {
printf("set_current_context error in %s: %s\n", __func__,
apple_cgl.error_string(err));
return true;
}
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
apple_cgl.set_current_context(oldcontext);
apple_cgl.destroy_context(newcontext);
apple_cgl.destroy_pixel_format(pfobj);
}
else {
/* We have a valid context. */
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
}
*widthresult = ar[0];
*heightresult = ar[1];
return false;
}
bool
apple_glx_pbuffer_query(GLXPbuffer p, int attr, unsigned int *value)
{
bool result = false;
struct apple_glx_drawable *d;
struct apple_glx_pbuffer *pbuf;
d = apple_glx_drawable_find_by_type(p, APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_LOCK);
if (d) {
pbuf = &d->types.pbuffer;
switch (attr) {
case GLX_WIDTH:
*value = pbuf->width;
result = true;
break;
case GLX_HEIGHT:
*value = pbuf->height;
result = true;
break;
case GLX_PRESERVED_CONTENTS:
*value = true;
result = true;
break;
case GLX_LARGEST_PBUFFER:{
int width, height;
if (get_max_size(&width, &height)) {
fprintf(stderr, "internal error: "
"unable to find the largest pbuffer!\n");
}
else {
*value = width;
result = true;
}
}
break;
case GLX_FBCONFIG_ID:
*value = pbuf->fbconfigID;
result = true;
break;
}
d->unlock(d);
}
return result;
}
bool
apple_glx_pbuffer_set_event_mask(GLXDrawable drawable, unsigned long mask)
{
struct apple_glx_drawable *d;
bool result = false;
d = apple_glx_drawable_find_by_type(drawable, APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_LOCK);
if (d) {
d->types.pbuffer.event_mask = mask;
result = true;
d->unlock(d);
}
return result;
}
bool
apple_glx_pbuffer_get_event_mask(GLXDrawable drawable, unsigned long *mask)
{
struct apple_glx_drawable *d;
bool result = false;
d = apple_glx_drawable_find_by_type(drawable, APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_LOCK);
if (d) {
*mask = d->types.pbuffer.event_mask;
result = true;
d->unlock(d);
}
return result;
}

View File

@@ -0,0 +1,230 @@
/*
Copyright (c) 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <assert.h>
#include "apple_glx.h"
#include "apple_cgl.h"
#include "apple_visual.h"
#include "apple_glx_drawable.h"
#include "appledri.h"
#include "glcontextmodes.h"
static bool pixmap_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d);
static void pixmap_destroy(Display * dpy, struct apple_glx_drawable *d);
static struct apple_glx_drawable_callbacks callbacks = {
.type = APPLE_GLX_DRAWABLE_PIXMAP,
.make_current = pixmap_make_current,
.destroy = pixmap_destroy
};
static bool
pixmap_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d)
{
CGLError cglerr;
struct apple_glx_pixmap *p = &d->types.pixmap;
assert(APPLE_GLX_DRAWABLE_PIXMAP == d->type);
cglerr = apple_cgl.set_current_context(p->context_obj);
if (kCGLNoError != cglerr) {
fprintf(stderr, "set current context: %s\n",
apple_cgl.error_string(cglerr));
return true;
}
cglerr = apple_cgl.set_off_screen(p->context_obj, p->width, p->height,
p->pitch, p->buffer);
if (kCGLNoError != cglerr) {
fprintf(stderr, "set off screen: %s\n", apple_cgl.error_string(cglerr));
return true;
}
if (!ac->made_current) {
glViewport(0, 0, p->width, p->height);
glScissor(0, 0, p->width, p->height);
ac->made_current = true;
}
return false;
}
static void
pixmap_destroy(Display * dpy, struct apple_glx_drawable *d)
{
struct apple_glx_pixmap *p = &d->types.pixmap;
if (p->pixel_format_obj)
(void) apple_cgl.destroy_pixel_format(p->pixel_format_obj);
if (p->context_obj)
(void) apple_cgl.destroy_context(p->context_obj);
XAppleDRIDestroyPixmap(dpy, p->xpixmap);
if (p->buffer) {
if (munmap(p->buffer, p->size))
perror("munmap");
if (-1 == close(p->fd))
perror("close");
if (shm_unlink(p->path))
perror("shm_unlink");
}
apple_glx_diagnostic("destroyed pixmap buffer for: 0x%lx\n", d->drawable);
}
/* Return true if an error occurred. */
bool
apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap,
const void *mode)
{
struct apple_glx_drawable *d;
struct apple_glx_pixmap *p;
bool double_buffered;
bool uses_stereo;
CGLError error;
const __GLcontextModes *cmodes = mode;
if (apple_glx_drawable_create(dpy, screen, pixmap, &d, &callbacks))
return true;
/* d is locked and referenced at this point. */
p = &d->types.pixmap;
p->xpixmap = pixmap;
p->buffer = NULL;
if (!XAppleDRICreatePixmap(dpy, screen, pixmap,
&p->width, &p->height, &p->pitch, &p->bpp,
&p->size, p->path, PATH_MAX)) {
d->unlock(d);
d->destroy(d);
return true;
}
p->fd = shm_open(p->path, O_RDWR, 0);
if (p->fd < 0) {
perror("shm_open");
d->unlock(d);
d->destroy(d);
return true;
}
p->buffer = mmap(NULL, p->size, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, p->fd, 0);
if (MAP_FAILED == p->buffer) {
perror("mmap");
d->unlock(d);
d->destroy(d);
return true;
}
apple_visual_create_pfobj(&p->pixel_format_obj, mode, &double_buffered,
&uses_stereo, /*offscreen */ true);
error = apple_cgl.create_context(p->pixel_format_obj, NULL,
&p->context_obj);
if (kCGLNoError != error) {
d->unlock(d);
d->destroy(d);
return true;
}
p->fbconfigID = cmodes->fbconfigID;
d->unlock(d);
apple_glx_diagnostic("created: pixmap buffer for 0x%lx\n", d->drawable);
return false;
}
bool
apple_glx_pixmap_query(GLXPixmap pixmap, int attr, unsigned int *value)
{
struct apple_glx_drawable *d;
struct apple_glx_pixmap *p;
bool result = false;
d = apple_glx_drawable_find_by_type(pixmap, APPLE_GLX_DRAWABLE_PIXMAP,
APPLE_GLX_DRAWABLE_LOCK);
if (d) {
p = &d->types.pixmap;
switch (attr) {
case GLX_WIDTH:
*value = p->width;
result = true;
break;
case GLX_HEIGHT:
*value = p->height;
result = true;
break;
case GLX_FBCONFIG_ID:
*value = p->fbconfigID;
result = true;
break;
}
d->unlock(d);
}
return result;
}
/* Return true if the type is valid for pixmap. */
bool
apple_glx_pixmap_destroy(Display * dpy, GLXPixmap pixmap)
{
return !apple_glx_drawable_destroy_by_type(dpy, pixmap,
APPLE_GLX_DRAWABLE_PIXMAP);
}

View File

@@ -0,0 +1,224 @@
/*
Copyright (c) 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <assert.h>
#include "glxclient.h"
#include "apple_glx.h"
#include "appledri.h"
#include "apple_glx_drawable.h"
static bool surface_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d);
static void surface_destroy(Display * dpy, struct apple_glx_drawable *d);
static struct apple_glx_drawable_callbacks callbacks = {
.type = APPLE_GLX_DRAWABLE_SURFACE,
.make_current = surface_make_current,
.destroy = surface_destroy
};
static void
update_viewport_and_scissor(Display * dpy, GLXDrawable drawable)
{
Window root;
int x, y;
unsigned int width = 0, height = 0, bd, depth;
XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth);
glViewport(0, 0, width, height);
glScissor(0, 0, width, height);
}
static bool
surface_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d)
{
struct apple_glx_surface *s = &d->types.surface;
xp_error error;
assert(APPLE_GLX_DRAWABLE_SURFACE == d->type);
apple_glx_diagnostic("%s: ac->context_obj %p s->surface_id %u\n",
__func__, (void *) ac->context_obj, s->surface_id);
error = xp_attach_gl_context(ac->context_obj, s->surface_id);
if (error) {
fprintf(stderr, "error: xp_attach_gl_context returned: %d\n", error);
return true;
}
if (!ac->made_current) {
/*
* The first time a new context is made current the glViewport
* and glScissor should be updated.
*/
update_viewport_and_scissor(ac->drawable->display,
ac->drawable->drawable);
ac->made_current = true;
}
apple_glx_diagnostic("%s: drawable 0x%lx\n", __func__, d->drawable);
return false;
}
static void
surface_destroy(Display * dpy, struct apple_glx_drawable *d)
{
struct apple_glx_surface *s = &d->types.surface;
apple_glx_diagnostic("%s: s->surface_id %u\n", __func__, s->surface_id);
xp_error error = xp_destroy_surface(s->surface_id);
if (error) {
fprintf(stderr, "xp_destroy_surface error: %d\n", (int) error);
}
/*
* Check if this surface destroy came from the surface being destroyed
* on the server. If s->pending_destroy is true, then it did, and
* we don't want to try to destroy the surface on the server.
*/
if (!s->pending_destroy) {
/*
* Warning: this causes other routines to be called (potentially)
* from surface_notify_handler. It's probably best to not have
* any locks at this point locked.
*/
XAppleDRIDestroySurface(d->display, DefaultScreen(d->display),
d->drawable);
apple_glx_diagnostic
("%s: destroyed a surface for drawable 0x%lx uid %u\n", __func__,
d->drawable, s->uid);
}
}
/* Return true if an error occured. */
static bool
create_surface(Display * dpy, int screen, struct apple_glx_drawable *d)
{
struct apple_glx_surface *s = &d->types.surface;
unsigned int key[2];
xp_client_id id;
id = apple_glx_get_client_id();
if (0 == id)
return true;
assert(None != d->drawable);
s->pending_destroy = false;
if (XAppleDRICreateSurface(dpy, screen, d->drawable, id, key, &s->uid)) {
xp_error error;
error = xp_import_surface(key, &s->surface_id);
if (error) {
fprintf(stderr, "error: xp_import_surface returned: %d\n", error);
return true;
}
apple_glx_diagnostic("%s: created a surface for drawable 0x%lx"
" with uid %u\n", __func__, d->drawable, s->uid);
return false; /*success */
}
return true; /* unable to create a surface. */
}
/* Return true if an error occured. */
/* This returns a referenced object via resultptr. */
bool
apple_glx_surface_create(Display * dpy, int screen,
GLXDrawable drawable,
struct apple_glx_drawable ** resultptr)
{
struct apple_glx_drawable *d;
if (apple_glx_drawable_create(dpy, screen, drawable, &d, &callbacks))
return true;
/* apple_glx_drawable_create creates a locked and referenced object. */
if (create_surface(dpy, screen, d)) {
d->unlock(d);
d->destroy(d);
return true;
}
*resultptr = d;
d->unlock(d);
return false;
}
/*
* All surfaces are reference counted, and surfaces are only created
* when the window is made current. When all contexts no longer reference
* a surface drawable the apple_glx_drawable gets destroyed, and thus
* its surface is destroyed.
*
* However we can make the destruction occur a bit sooner by setting
* pending_destroy, which is then checked for in glViewport by
* apple_glx_context_update.
*/
void
apple_glx_surface_destroy(unsigned int uid)
{
struct apple_glx_drawable *d;
d = apple_glx_drawable_find_by_uid(uid, APPLE_GLX_DRAWABLE_REFERENCE
| APPLE_GLX_DRAWABLE_LOCK);
if (d) {
d->types.surface.pending_destroy = true;
d->release(d);
/*
* We release 2 references to the surface. One was acquired by
* the find, and the other was leftover from a context, or
* the surface being displayed, so the destroy() will decrease it
* once more.
*
* If the surface is in a context, it will take one d->destroy(d);
* to actually destroy it when the pending_destroy is processed
* by a glViewport callback (see apple_glx_context_update()).
*/
d->destroy(d);
d->unlock(d);
}
}

View File

@@ -0,0 +1,153 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <GL/gl.h>
/* <rdar://problem/6953344> */
#define glTexImage1D glTexImage1D_OSX
#define glTexImage2D glTexImage2D_OSX
#define glTexImage3D glTexImage3D_OSX
#include <OpenGL/OpenGL.h>
#include <OpenGL/CGLContext.h>
#include <OpenGL/CGLRenderers.h>
#undef glTexImage1D
#undef glTexImage2D
#undef glTexImage3D
#include "apple_cgl.h"
#include "apple_visual.h"
#include "apple_glx.h"
#include "glcontextmodes.h"
enum
{
MAX_ATTR = 60
};
/*mode is a __GlcontextModes*/
void
apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const void *mode,
bool * double_buffered, bool * uses_stereo,
bool offscreen)
{
CGLPixelFormatAttribute attr[MAX_ATTR];
const __GLcontextModes *c = mode;
int numattr = 0;
GLint vsref = 0;
CGLError error = 0;
if (offscreen) {
apple_glx_diagnostic
("offscreen rendering enabled. Using kCGLPFAOffScreen\n");
attr[numattr++] = kCGLPFAOffScreen;
attr[numattr++] = kCGLPFAColorSize;
attr[numattr++] = 32;
}
else if (getenv("LIBGL_ALWAYS_SOFTWARE") != NULL) {
apple_glx_diagnostic
("Software rendering requested. Using kCGLRendererGenericFloatID.\n");
attr[numattr++] = kCGLPFARendererID;
attr[numattr++] = kCGLRendererGenericFloatID;
}
else if (getenv("LIBGL_ALLOW_SOFTWARE") != NULL) {
apple_glx_diagnostic
("Software rendering is not being excluded. Not using kCGLPFAAccelerated.\n");
}
else {
attr[numattr++] = kCGLPFAAccelerated;
}
/*
* The program chose a config based on the fbconfigs or visuals.
* Those are based on the attributes from CGL, so we probably
* do want the closest match for the color, depth, and accum.
*/
attr[numattr++] = kCGLPFAClosestPolicy;
if (c->stereoMode) {
attr[numattr++] = kCGLPFAStereo;
*uses_stereo = true;
}
else {
*uses_stereo = false;
}
if (c->doubleBufferMode) {
attr[numattr++] = kCGLPFADoubleBuffer;
*double_buffered = true;
}
else {
*double_buffered = false;
}
attr[numattr++] = kCGLPFAColorSize;
attr[numattr++] = c->redBits + c->greenBits + c->blueBits;
attr[numattr++] = kCGLPFAAlphaSize;
attr[numattr++] = c->alphaBits;
if ((c->accumRedBits + c->accumGreenBits + c->accumBlueBits) > 0) {
attr[numattr++] = kCGLPFAAccumSize;
attr[numattr++] = c->accumRedBits + c->accumGreenBits +
c->accumBlueBits + c->accumAlphaBits;
}
if (c->depthBits > 0) {
attr[numattr++] = kCGLPFADepthSize;
attr[numattr++] = c->depthBits;
}
if (c->stencilBits > 0) {
attr[numattr++] = kCGLPFAStencilSize;
attr[numattr++] = c->stencilBits;
}
if (c->sampleBuffers > 0) {
attr[numattr++] = kCGLPFAMultisample;
attr[numattr++] = kCGLPFASampleBuffers;
attr[numattr++] = c->sampleBuffers;
attr[numattr++] = kCGLPFASamples;
attr[numattr++] = c->samples;
}
attr[numattr++] = 0;
assert(numattr < MAX_ATTR);
error = apple_cgl.choose_pixel_format(attr, pfobj, &vsref);
if (error) {
fprintf(stderr, "error: %s\n", apple_cgl.error_string(error));
abort();
}
}

View File

@@ -0,0 +1,41 @@
/*
Copyright (c) 2008 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#ifndef APPLE_VISUAL_H
#define APPLE_VISUAL_H
#include <stdbool.h>
#include <OpenGL/CGLTypes.h>
/* mode is expected to be of type __GLcontextModes. */
void apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const void *mode,
bool * double_buffered, bool * uses_stereo,
bool offscreen);
#endif

View File

@@ -0,0 +1,37 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
GLAPI void APIENTRY glTexImage3DEXT(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei
depth, GLint border, GLenum format, GLenum type, const void * pixels) {
glTexImage3D(target, level, (GLint)internalformat, width, height, depth, border, format, type, pixels);
}

View File

@@ -0,0 +1,133 @@
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
/*
* This file works with the glXMakeContextCurrent readable drawable.
*
* The way it works is by swapping the currentDrawable for the currentReadable
* drawable if they are different.
*/
#include <stdbool.h>
#include "glxclient.h"
#include "apple_glx_context.h"
#include "apple_xgl_api.h"
extern struct apple_xgl_api __gl_api;
struct apple_xgl_saved_state
{
bool swapped;
};
static void
SetRead(struct apple_xgl_saved_state *saved)
{
GLXContext gc = __glXGetCurrentContext();
/*
* By default indicate that the state was not swapped, so that UnsetRead
* functions correctly.
*/
saved->swapped = false;
/*
* If the readable drawable isn't the same as the drawable then
* the user has requested a readable drawable with glXMakeContextCurrent().
* We emulate this behavior by switching the current drawable.
*/
if (None != gc->currentReadable
&& gc->currentReadable != gc->currentDrawable) {
Display *dpy = glXGetCurrentDisplay();
saved->swapped = true;
if (apple_glx_make_current_context(dpy, gc->driContext, gc->driContext,
gc->currentReadable)) {
/* An error occurred, so try to restore the old context state. */
(void) apple_glx_make_current_context(dpy, gc->driContext, gc->driContext,
gc->currentDrawable);
saved->swapped = false;
}
}
}
static void
UnsetRead(struct apple_xgl_saved_state *saved)
{
if (saved->swapped) {
GLXContext gc = __glXGetCurrentContext();
Display *dpy = glXGetCurrentDisplay();
if (apple_glx_make_current_context(dpy, gc->driContext, gc->driContext,
gc->currentDrawable)) {
/*
* An error occurred restoring the drawable.
* It's unclear what to do about that.
*/
}
}
}
void
glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, void *pixels)
{
struct apple_xgl_saved_state saved;
SetRead(&saved);
__gl_api.ReadPixels(x, y, width, height, format, type, pixels);
UnsetRead(&saved);
}
void
glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
{
struct apple_xgl_saved_state saved;
SetRead(&saved);
__gl_api.CopyPixels(x, y, width, height, type);
UnsetRead(&saved);
}
void
glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
GLsizei width)
{
struct apple_xgl_saved_state saved;
SetRead(&saved);
__gl_api.CopyColorTable(target, internalformat, x, y, width);
UnsetRead(&saved);
}

View File

@@ -0,0 +1,128 @@
/*
Copyright (c) 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
/* This should be removed once stereo hardware bugs are fixed
* <rdar://problem/6729006>
*/
#include <stdbool.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#include "glxclient.h"
#include "apple_glx_context.h"
#include "apple_xgl_api.h"
extern struct apple_xgl_api __gl_api;
/*
* These are special functions for stereoscopic support
* differences in MacOS X.
*/
void
glDrawBuffer(GLenum mode)
{
GLXContext gc = glXGetCurrentContext();
if (gc && apple_glx_context_uses_stereo(gc->driContext)) {
GLenum buf[2];
GLsizei n = 0;
switch (mode) {
case GL_BACK:
buf[0] = GL_BACK_LEFT;
buf[1] = GL_BACK_RIGHT;
n = 2;
break;
case GL_FRONT:
buf[0] = GL_FRONT_LEFT;
buf[1] = GL_FRONT_RIGHT;
n = 2;
break;
default:
buf[0] = mode;
n = 1;
break;
}
__gl_api.DrawBuffers(n, buf);
}
else {
__gl_api.DrawBuffer(mode);
}
}
void
glDrawBuffers(GLsizei n, const GLenum * bufs)
{
GLXContext gc = glXGetCurrentContext();
if (gc && apple_glx_context_uses_stereo(gc->driContext)) {
GLenum newbuf[n + 2];
GLsizei i, outi = 0;
bool have_back = false;
bool have_front = false;
for (i = 0; i < n; ++i) {
if (GL_BACK == bufs[i]) {
have_back = true;
}
else if (GL_FRONT == bufs[i]) {
have_back = true;
}
else {
newbuf[outi++] = bufs[i];
}
}
if (have_back) {
newbuf[outi++] = GL_BACK_LEFT;
newbuf[outi++] = GL_BACK_RIGHT;
}
if (have_front) {
newbuf[outi++] = GL_FRONT_LEFT;
newbuf[outi++] = GL_FRONT_RIGHT;
}
__gl_api.DrawBuffers(outi, newbuf);
}
else {
__gl_api.DrawBuffers(n, bufs);
}
}
void
glDrawBuffersARB(GLsizei n, const GLenum * bufs)
{
glDrawBuffers(n, bufs);
}

View File

@@ -0,0 +1,46 @@
/*
Copyright (c) 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include "glxclient.h"
#include "apple_glx_context.h"
#include "apple_xgl_api.h"
extern struct apple_xgl_api __gl_api;
void
glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
GLXContext gc = __glXGetCurrentContext();
Display *dpy = glXGetCurrentDisplay();
if (gc && gc->driContext)
apple_glx_context_update(dpy, gc->driContext);
__gl_api.Viewport(x, y, width, height);
}

452
src/glx/apple/appledri.c Normal file
View File

@@ -0,0 +1,452 @@
/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.12 2001/08/27 17:40:57 dawes Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008 Apple Computer, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sub license, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
/* THIS IS NOT AN X CONSORTIUM STANDARD */
#define NEED_EVENTS
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include "appledristr.h"
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include <stdio.h>
static XExtensionInfo _appledri_info_data;
static XExtensionInfo *appledri_info = &_appledri_info_data;
static char *appledri_extension_name = APPLEDRINAME;
#define AppleDRICheckExtension(dpy,i,val) \
XextCheckExtension (dpy, i, appledri_extension_name, val)
/*****************************************************************************
* *
* private utility routines *
* *
*****************************************************************************/
static int close_display(Display * dpy, XExtCodes * extCodes);
static Bool wire_to_event(Display * dpy, XEvent * re, xEvent * event);
static /* const */ XExtensionHooks appledri_extension_hooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
close_display, /* close_display */
wire_to_event, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
NULL, /* error_string */
};
static
XEXT_GENERATE_FIND_DISPLAY(find_display, appledri_info,
appledri_extension_name,
&appledri_extension_hooks,
AppleDRINumberEvents, NULL)
static XEXT_GENERATE_CLOSE_DISPLAY(close_display, appledri_info)
static void (*surface_notify_handler) ();
void *XAppleDRISetSurfaceNotifyHandler(void (*fun) ())
{
void *old = surface_notify_handler;
surface_notify_handler = fun;
return old;
}
static Bool
wire_to_event(Display *dpy, XEvent *re, xEvent *event)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRINotifyEvent *sevent;
AppleDRICheckExtension(dpy, info, False);
switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
case AppleDRISurfaceNotify:
sevent = (xAppleDRINotifyEvent *) event;
if (surface_notify_handler != NULL) {
(*surface_notify_handler) (dpy, (unsigned int) sevent->arg,
(int) sevent->kind);
}
return False;
}
return False;
}
/*****************************************************************************
* *
* public Apple-DRI Extension routines *
* *
*****************************************************************************/
#if 0
#include <stdio.h>
#define TRACE(msg) fprintf(stderr, "AppleDRI%s\n", msg);
#else
#define TRACE(msg)
#endif
Bool
XAppleDRIQueryExtension(dpy, event_basep, error_basep)
Display *dpy;
int *event_basep, *error_basep;
{
XExtDisplayInfo *info = find_display(dpy);
TRACE("QueryExtension...");
if (XextHasExtension(info)) {
*event_basep = info->codes->first_event;
*error_basep = info->codes->first_error;
TRACE("QueryExtension... return True");
return True;
}
else {
TRACE("QueryExtension... return False");
return False;
}
}
Bool
XAppleDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
Display *dpy;
int *majorVersion;
int *minorVersion;
int *patchVersion;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIQueryVersionReply rep;
xAppleDRIQueryVersionReq *req;
TRACE("QueryVersion...");
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRIQueryVersion, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIQueryVersion;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryVersion... return False");
return False;
}
*majorVersion = rep.majorVersion;
*minorVersion = rep.minorVersion;
*patchVersion = rep.patchVersion;
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryVersion... return True");
return True;
}
Bool
XAppleDRIQueryDirectRenderingCapable(dpy, screen, isCapable)
Display *dpy;
int screen;
Bool *isCapable;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIQueryDirectRenderingCapableReply rep;
xAppleDRIQueryDirectRenderingCapableReq *req;
TRACE("QueryDirectRenderingCapable...");
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRIQueryDirectRenderingCapable, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIQueryDirectRenderingCapable;
req->screen = screen;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryDirectRenderingCapable... return False");
return False;
}
*isCapable = rep.isCapable;
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryDirectRenderingCapable... return True");
return True;
}
Bool
XAppleDRIAuthConnection(dpy, screen, magic)
Display *dpy;
int screen;
unsigned int magic;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIAuthConnectionReq *req;
xAppleDRIAuthConnectionReply rep;
TRACE("AuthConnection...");
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRIAuthConnection, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIAuthConnection;
req->screen = screen;
req->magic = magic;
rep.authenticated = 0;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("AuthConnection... return False");
return False;
}
UnlockDisplay(dpy);
SyncHandle();
TRACE("AuthConnection... return True");
return True;
}
Bool
XAppleDRICreateSurface(dpy, screen, drawable, client_id, key, uid)
Display *dpy;
int screen;
Drawable drawable;
unsigned int client_id;
unsigned int *key;
unsigned int *uid;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRICreateSurfaceReply rep;
xAppleDRICreateSurfaceReq *req;
TRACE("CreateSurface...");
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRICreateSurface, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRICreateSurface;
req->screen = screen;
req->drawable = drawable;
req->client_id = client_id;
rep.key_0 = rep.key_1 = rep.uid = 0;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.key_0) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("CreateSurface... return False");
return False;
}
key[0] = rep.key_0;
key[1] = rep.key_1;
*uid = rep.uid;
UnlockDisplay(dpy);
SyncHandle();
TRACE("CreateSurface... return True");
return True;
}
Bool
XAppleDRIDestroySurface(dpy, screen, drawable)
Display *dpy;
int screen;
Drawable drawable;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIDestroySurfaceReq *req;
TRACE("DestroySurface...");
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRIDestroySurface, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIDestroySurface;
req->screen = screen;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
TRACE("DestroySurface... return True");
return True;
}
Bool
XAppleDRICreateSharedBuffer(Display * dpy, int screen, Drawable drawable,
Bool doubleSwap, char *path, size_t pathlen,
int *width, int *height)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRICreateSharedBufferReq *req;
xAppleDRICreateSharedBufferReply rep;
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRICreateSharedBuffer, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRICreateSharedBuffer;
req->screen = screen;
req->drawable = drawable;
req->doubleSwap = doubleSwap;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
puts("REPLY ERROR");
UnlockDisplay(dpy);
SyncHandle();
return False;
}
printf("rep.stringLength %d\n", (int) rep.stringLength);
if (rep.stringLength > 0 && rep.stringLength <= pathlen) {
_XReadPad(dpy, path, rep.stringLength);
printf("path: %s\n", path);
*width = rep.width;
*height = rep.height;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
UnlockDisplay(dpy);
SyncHandle();
return False;
}
Bool
XAppleDRISwapBuffers(Display * dpy, int screen, Drawable drawable)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRISwapBuffersReq *req;
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRISwapBuffers, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRISwapBuffers;
req->screen = screen;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
XAppleDRICreatePixmap(Display * dpy, int screen, Drawable drawable,
int *width, int *height, int *pitch, int *bpp,
size_t * size, char *bufname, size_t bufnamesize)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRICreatePixmapReq *req;
xAppleDRICreatePixmapReply rep;
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRICreatePixmap, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRICreatePixmap;
req->screen = screen;
req->drawable = drawable;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
/*
printf("rep.stringLength %d\n", (int) rep.stringLength);
*/
if (rep.stringLength > 0 && rep.stringLength <= bufnamesize) {
_XReadPad(dpy, bufname, rep.stringLength);
printf("path: %s\n", bufname);
*width = rep.width;
*height = rep.height;
*pitch = rep.pitch;
*bpp = rep.bpp;
*size = rep.size;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
else if (rep.stringLength > 0) {
_XEatData(dpy, rep.stringLength);
}
UnlockDisplay(dpy);
SyncHandle();
return True;
}
/*
* Call it a drawable, because we really don't know what it is
* until it reaches the server, and we should keep that in mind.
*/
Bool
XAppleDRIDestroyPixmap(Display * dpy, Pixmap drawable)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIDestroyPixmapReq *req;
AppleDRICheckExtension(dpy, info, False);
LockDisplay(dpy);
GetReq(AppleDRIDestroyPixmap, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIDestroyPixmap;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
return True;
}

124
src/glx/apple/appledri.h Normal file
View File

@@ -0,0 +1,124 @@
/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008, 2009 Apple Computer, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sub license, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
#ifndef _APPLEDRI_H_
#define _APPLEDRI_H_
#include <X11/Xlib.h>
#include <X11/Xfuncproto.h>
#define X_AppleDRIQueryVersion 0
#define X_AppleDRIQueryDirectRenderingCapable 1
#define X_AppleDRICreateSurface 2
#define X_AppleDRIDestroySurface 3
#define X_AppleDRIAuthConnection 4
#define X_AppleDRICreateSharedBuffer 5
#define X_AppleDRISwapBuffers 6
#define X_AppleDRICreatePixmap 7
#define X_AppleDRIDestroyPixmap 8
/* Requests up to and including 18 were used in a previous version */
/* Events */
#define AppleDRIObsoleteEvent1 0
#define AppleDRIObsoleteEvent2 1
#define AppleDRIObsoleteEvent3 2
#define AppleDRISurfaceNotify 3
#define AppleDRINumberEvents 4
/* Errors */
#define AppleDRIClientNotLocal 0
#define AppleDRIOperationNotSupported 1
#define AppleDRINumberErrors (AppleDRIOperationNotSupported + 1)
/* Kinds of SurfaceNotify events: */
#define AppleDRISurfaceNotifyChanged 0
#define AppleDRISurfaceNotifyDestroyed 1
#ifndef _APPLEDRI_SERVER_
typedef struct
{
int type; /* of event */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came frome a SendEvent request */
Display *display; /* Display the event was read from */
Window window; /* window of event */
Time time; /* server timestamp when event happened */
int kind; /* subtype of event */
int arg;
} XAppleDRINotifyEvent;
_XFUNCPROTOBEGIN
Bool XAppleDRIQueryExtension(Display * dpy, int *event_base,
int *error_base);
Bool XAppleDRIQueryVersion(Display * dpy, int *majorVersion,
int *minorVersion, int *patchVersion);
Bool XAppleDRIQueryDirectRenderingCapable(Display * dpy, int screen,
Bool * isCapable);
void *XAppleDRISetSurfaceNotifyHandler(void (*fun) (Display * dpy,
unsigned uid, int kind));
Bool XAppleDRIAuthConnection(Display * dpy, int screen, unsigned int magic);
Bool XAppleDRICreateSurface(Display * dpy, int screen, Drawable drawable,
unsigned int client_id, unsigned int key[2],
unsigned int *uid);
Bool XAppleDRIDestroySurface(Display * dpy, int screen, Drawable drawable);
Bool XAppleDRISynchronizeSurfaces(Display * dpy);
Bool XAppleDRICreateSharedBuffer(Display * dpy, int screen, Drawable drawable,
Bool doubleSwap, char *path, size_t pathlen,
int *width, int *height);
Bool XAppleDRISwapBuffers(Display * dpy, int screen, Drawable drawable);
Bool XAppleDRICreatePixmap(Display * dpy, int screen, Drawable drawable,
int *width, int *height, int *pitch, int *bpp,
size_t * size, char *bufname, size_t bufnamesize);
Bool XAppleDRIDestroyPixmap(Display * dpy, Pixmap pixmap);
_XFUNCPROTOEND
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRI_H_ */

266
src/glx/apple/appledristr.h Normal file
View File

@@ -0,0 +1,266 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008, 2009 Apple Computer, Inc.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sub license, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Fiath <faith@valinux.com>
*
*/
#ifndef _APPLEDRISTR_H_
#define _APPLEDRISTR_H_
#include "appledri.h"
#define APPLEDRINAME "Apple-DRI"
#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */
#define APPLE_DRI_MINOR_VERSION 0
#define APPLE_DRI_PATCH_VERSION 0
typedef struct _AppleDRIQueryVersion
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIQueryVersion */
CARD16 length B16;
} xAppleDRIQueryVersionReq;
#define sz_xAppleDRIQueryVersionReq 4
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD16 majorVersion B16; /* major version of DRI protocol */
CARD16 minorVersion B16; /* minor version of DRI protocol */
CARD32 patchVersion B32; /* patch version of DRI protocol */
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRIQueryVersionReply;
#define sz_xAppleDRIQueryVersionReply 32
typedef struct _AppleDRIQueryDirectRenderingCapable
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
CARD16 length B16;
CARD32 screen B32;
} xAppleDRIQueryDirectRenderingCapableReq;
#define sz_xAppleDRIQueryDirectRenderingCapableReq 8
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
BOOL isCapable;
BOOL pad2;
BOOL pad3;
BOOL pad4;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
CARD32 pad8 B32;
CARD32 pad9 B32;
} xAppleDRIQueryDirectRenderingCapableReply;
#define sz_xAppleDRIQueryDirectRenderingCapableReply 32
typedef struct _AppleDRIAuthConnection
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseConnection */
CARD16 length B16;
CARD32 screen B32;
CARD32 magic B32;
} xAppleDRIAuthConnectionReq;
#define sz_xAppleDRIAuthConnectionReq 12
typedef struct
{
BYTE type;
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 authenticated B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRIAuthConnectionReply;
#define zx_xAppleDRIAuthConnectionReply 32
typedef struct _AppleDRICreateSurface
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICreateSurface */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
CARD32 client_id B32;
} xAppleDRICreateSurfaceReq;
#define sz_xAppleDRICreateSurfaceReq 16
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 key_0 B32;
CARD32 key_1 B32;
CARD32 uid B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRICreateSurfaceReply;
#define sz_xAppleDRICreateSurfaceReply 32
typedef struct _AppleDRIDestroySurface
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIDestroySurface */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xAppleDRIDestroySurfaceReq;
#define sz_xAppleDRIDestroySurfaceReq 12
typedef struct _AppleDRINotify
{
BYTE type; /* always eventBase + event type */
BYTE kind;
CARD16 sequenceNumber B16;
CARD32 time B32; /* time of change */
CARD32 pad1 B32;
CARD32 arg B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRINotifyEvent;
#define sz_xAppleDRINotifyEvent 32
typedef struct
{
CARD8 reqType;
CARD8 driReqType;
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
BOOL doubleSwap;
CARD8 pad1, pad2, pad3;
} xAppleDRICreateSharedBufferReq;
#define sz_xAppleDRICreateSharedBufferReq 16
typedef struct
{
BYTE type;
BYTE data1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 stringLength B32; /* 0 on error */
CARD32 width B32;
CARD32 height B32;
CARD32 pad1 B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
} xAppleDRICreateSharedBufferReply;
#define sz_xAppleDRICreateSharedBufferReply 32
typedef struct
{
CARD8 reqType;
CARD8 driReqType;
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xAppleDRISwapBuffersReq;
#define sz_xAppleDRISwapBuffersReq 12
typedef struct
{
CARD8 reqType; /*1 */
CARD8 driReqType; /*2 */
CARD16 length B16; /*4 */
CARD32 screen B32; /*8 */
CARD32 drawable B32; /*12 */
} xAppleDRICreatePixmapReq;
#define sz_xAppleDRICreatePixmapReq 12
typedef struct
{
BYTE type; /*1 */
BOOL pad1; /*2 */
CARD16 sequenceNumber B16; /*4 */
CARD32 length B32; /*8 */
CARD32 width B32; /*12 */
CARD32 height B32; /*16 */
CARD32 pitch B32; /*20 */
CARD32 bpp B32; /*24 */
CARD32 size B32; /*28 */
CARD32 stringLength B32; /*32 */
} xAppleDRICreatePixmapReply;
#define sz_xAppleDRICreatePixmapReply 32
typedef struct
{
CARD8 reqType; /*1 */
CARD8 driReqType; /*2 */
CARD16 length B16; /*4 */
CARD32 drawable B32; /*8 */
} xAppleDRIDestroyPixmapReq;
#define sz_xAppleDRIDestroyPixmapReq 8
#ifdef _APPLEDRI_SERVER_
void AppleDRISendEvent(
#if NeedFunctionPrototypes
int /* type */ ,
unsigned int /* mask */ ,
int /* which */ ,
int /* arg */
#endif
);
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRISTR_H_ */

View File

@@ -0,0 +1,86 @@
package require Tcl 8.5
set license {
/*
Copyright (c) 2008, 2009 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
}
set this_script [info script]
proc main {argc argv} {
if {2 != $argc} {
puts stderr "syntax is: [set ::this_script] serialized-array-file output.h"
return 1
}
set fd [open [lindex $argv 0] r]
array set api [read $fd]
close $fd
set fd [open [lindex $argv 1] w]
puts $fd "/* This file was automatically generated by [set ::this_script]. */"
puts $fd $::license
puts $fd "
#ifndef APPLE_XGL_API_H
#define APPLE_XGL_API_H
"
puts $fd "struct apple_xgl_api \{"
set sorted [lsort -dictionary [array names api]]
foreach f $sorted {
set attr $api($f)
set pstr ""
if {[dict exists $attr alias_for] || [dict exists $attr noop]} {
#Skip this function.
continue
}
foreach p [dict get $attr parameters] {
append pstr "[lindex $p 0] [lindex $p 1], "
}
set pstr [string trimright $pstr ", "]
puts $fd "\t[dict get $attr return] (*[set f])([set pstr]);"
}
puts $fd "\};"
puts $fd "void apple_xgl_init_direct(void);
#endif /*APPLE_XGL_API_H*/
"
return 0
}
exit [main $::argc $::argv]

Some files were not shown because too many files have changed in this diff Show More