Compare commits

...

195 Commits

Author SHA1 Message Date
Keith Whitwell
7b7af467dd Restore ability to build full driver.
Add config options to choose between full/subset driver, and fbdev vs. DRI
windowing systems.
2003-03-04 17:29:55 +00:00
Keith Whitwell
3101d43a76 Add a helpful message 2003-03-04 17:27:28 +00:00
Keith Whitwell
d95443f030 Initialize tnl vtxfmt stuff if _HAVE_FULL_GL 2003-03-04 17:23:34 +00:00
Keith Whitwell
be49c0fef2 Uncomment subsetted entrypoints, protect with _HAVE_FULL_GL instead. 2003-03-04 17:10:39 +00:00
Jose Fonseca
61d31cab97 Enable the extraction of static function documentation. 2003-03-02 00:28:38 +00:00
Jose Fonseca
7067815785 Doxygenization of the existing documentation. 2003-03-02 00:27:31 +00:00
Brian Paul
ad79ba8208 remove glPolygonMode 2003-02-26 20:21:54 +00:00
Keith Whitwell
b8cdeaae3a New file 2003-02-24 21:31:02 +00:00
Keith Whitwell
4b930d3080 Drop morph3d, add terrain 2003-02-23 21:36:20 +00:00
Keith Whitwell
2b3cd85107 Subset terrain 2003-02-23 21:04:38 +00:00
Keith Whitwell
12acb24b60 Subset isosurf 2003-02-23 21:04:25 +00:00
Keith Whitwell
b4bc6375d1 fix some compiler warnings 2003-02-23 20:24:11 +00:00
Keith Whitwell
c91deeffc4 Fail if detected chipset isn't an r100. 2003-02-23 20:23:34 +00:00
Keith Whitwell
728dade650 Fix radeon_tex_region_t declaration (char became int). 2003-02-23 20:16:25 +00:00
Keith Whitwell
c3ded1b33d clean up header usage 2003-02-23 19:38:23 +00:00
Keith Whitwell
080ae6edb5 Add stricter compiler warnings 2003-02-23 19:37:52 +00:00
Keith Whitwell
b8bc33a6b1 add 'void' to glXGetProcAddress prototype 2003-02-23 19:37:15 +00:00
Keith Whitwell
1d7c610c2b Add manytex demo 2003-02-23 19:27:31 +00:00
Keith Whitwell
70130333c2 Use correct pv for flatshaded quadstrips 2003-02-23 19:27:03 +00:00
Keith Whitwell
c608a0fb2a Exclude lighting, userclip state 2003-02-23 19:26:32 +00:00
Keith Whitwell
7f35ecd070 subset demos 2003-02-23 19:25:07 +00:00
Brian Paul
ef9f2d4296 added radeon_subset to header 2003-02-23 17:25:22 +00:00
Jose Fonseca
27b8f1d3ae Final documentation fixes and additions. 2003-02-23 16:50:46 +00:00
Jose Fonseca
c35fb58c35 A few documention fixes and additions. 2003-02-23 15:21:36 +00:00
Jose Fonseca
eb998b80ea Last bits of documentation. Full review still pending. 2003-02-23 02:19:13 +00:00
Jose Fonseca
b77ca3d2b7 More documentation - now almost complete. 2003-02-22 21:27:17 +00:00
Jose Fonseca
cdc64176f9 More documention additions. 2003-02-22 11:48:50 +00:00
Jose Fonseca
da69c37f98 Bunch of documention additions. 2003-02-22 09:17:11 +00:00
Keith Whitwell
661a236d09 Correctly initialize RE_LINE_PATTERN register 2003-02-21 23:59:15 +00:00
Keith Whitwell
b9f8f7f6a4 Eliminate non-subset operations 2003-02-21 23:07:40 +00:00
Keith Whitwell
66f40571e1 Eliminate use of glRectf, sleep so that we see some frames. 2003-02-21 22:20:08 +00:00
Keith Whitwell
6620693116 Eliminate use of glRectf 2003-02-21 22:18:24 +00:00
Brian Paul
730cacfa01 sample MiniGLX program 2003-02-21 21:55:58 +00:00
Keith Whitwell
2f05ae32c5 new file 2003-02-21 21:55:26 +00:00
Keith Whitwell
d9ed9e1a9a Restrict access to non-subset gl entrypoints. Other small cleanups. 2003-02-21 21:14:08 +00:00
Keith Whitwell
6133ba36ec Fix vertex copying bug, remove polygonmode support (didn't/couldn't work) 2003-02-21 21:12:51 +00:00
Jose Fonseca
4b5f9479eb Renamed and tailored the radeon doxygen file for the OpenGL subset only 2003-02-16 21:42:11 +00:00
Jose Fonseca
75019b24d1 Initial/partial documentation to the functions/structures that make the Radeon subset driver. 2003-02-16 20:48:08 +00:00
Jose Fonseca
c9118dfaba A new doxygen configuration file for the Radeon driver. 2003-02-10 17:59:46 +00:00
Jose Fonseca
a140417be9 Most of the documentation to the "server-side" part of the Radeon driver. 2003-02-10 17:58:52 +00:00
Keith Whitwell
ccf4e3e8f2 Eliminate all remaining fallbacks & usage of FALLBACK macro
Rename subset_feedback.c to subset_select.c...
Add new file subset_tex.c which agressively subsets texture operations.
2003-02-07 20:22:16 +00:00
Keith Whitwell
78e1fee39b Add files to allow the subset driver to be built as a dri driver.
At the moment have to choose to build as *either* a dri or a miniglx
driver, but shouldn't be too hard to build one driver that will work
in both environments.
2003-02-05 04:37:12 +00:00
Keith Whitwell
75ccd62be8 Add unfilled rendering and code for feedback (not yet integrated) 2003-02-03 21:33:02 +00:00
Brian Paul
cd9df92c9d clarified glPolygonMode section 2003-02-03 15:00:38 +00:00
Keith Whitwell
cfe59bd3f9 Eliminate some more code 2003-01-28 22:37:23 +00:00
Keith Whitwell
62bc31dcae Eliminate radeon_subset_tcl.c. 2003-01-28 18:28:54 +00:00
Keith Whitwell
675f151c42 Fix compilation for full driver build.
Subsetted readpixels seems to be working.
2003-01-27 16:55:30 +00:00
Keith Whitwell
151cd27866 New file containing subsetted readpixels implementation. 2003-01-24 17:11:10 +00:00
Keith Whitwell
c8facc28cc Isolated code for lighting, fog, texgen and userclip in new files.
Moved some existing swrast, swtnl specific code into files that don't
get built in the subsetted driver.
2003-01-24 15:52:52 +00:00
Keith Whitwell
086e00e086 Add new defines for lighting, texgen, userclip subsetting.
Remove unused mesa modules from link.
2003-01-24 15:50:52 +00:00
Brian Paul
49116e9fd2 terminology updates, etc 2003-01-23 17:15:38 +00:00
Keith Whitwell
9d0eff73b5 Bitmaps are right-way-up 2003-01-23 10:43:59 +00:00
Keith Whitwell
81c7427ddc Hook in accelerated bitmap function -- bitmaps are upside-down! 2003-01-22 18:21:32 +00:00
Keith Whitwell
9e3c6f3b8e (Partially) subsetted driver runs miniglxtest and texobj.
Other applications segfault at null function pointers, etc -- need to remove
these entrypoints from miniglx libGL.so.
2003-01-22 18:16:33 +00:00
Keith Whitwell
18a5321288 Rename radeon_bitmap.c to radeon_subset_bitmap.c
Add new file radeon_subset_tcl.c
	-- this is temporary and will go away eventually.
Some code removal in radeon_subset_vtx.c
2003-01-22 16:19:42 +00:00
Keith Whitwell
4c864746d6 Add new files for bitmap and subsetted begin/end processing. 2003-01-22 12:23:20 +00:00
Keith Whitwell
19b1476515 Start subsetting -- turn off swrast & swtnl. 2003-01-22 09:53:49 +00:00
Brian Paul
2005348110 updated a few of the issues in appendix A 2003-01-20 17:55:55 +00:00
Brian Paul
634a7b2f00 describe libGL 2003-01-20 15:01:39 +00:00
Brian Paul
d73e21620a new Makefiles for miniglx 2003-01-20 14:54:50 +00:00
Keith Whitwell
d5cfbef5ad Remove -C option to install 2003-01-20 14:50:18 +00:00
Jose Fonseca
1d08fddfe6 Tell CVS to ignore Doxygen tag files and output directories. 2003-01-20 14:34:41 +00:00
Jose Fonseca
447ea351dd Some spellchecking fixes. 2003-01-20 14:30:04 +00:00
Keith Whitwell
0ebc838481 Add USE_MINIGLX flags. Build as a miniglx application. 2003-01-20 11:26:30 +00:00
Keith Whitwell
14a7a05251 Make more demanding 2003-01-20 11:25:50 +00:00
Keith Whitwell
c2edc07196 Fix typo 2003-01-20 11:24:17 +00:00
Keith Whitwell
222a212569 Build radeon.o from toplevel makefile.
Add comments to example.miniglx.conf.
Install a minglx.conf in lib directory.
Remove unused 'drmModuleName' config option
2003-01-20 10:53:34 +00:00
Keith Whitwell
78469e6e3d Notes on setting up a machine to run MiniGLX apps and a list of
available demos in the source tree.
2003-01-20 10:51:04 +00:00
Brian Paul
63d0a9055c minor fixes (remove some \internal attributes) 2003-01-19 23:48:32 +00:00
Keith Whitwell
27834f06b8 Some documentation updates relating to recent changes 2003-01-19 20:11:26 +00:00
Jose Fonseca
c262531518 Fixed several typos from spell-checking. 2003-01-19 18:47:53 +00:00
Jose Fonseca
1b2c02ae98 Some documentation fixes that were left out of previous commits 2003-01-19 14:23:45 +00:00
Jose Fonseca
fb5f90d71b Rewriten some of the detail documentation to improve readability.
Several fixes.
2003-01-19 14:08:20 +00:00
Jose Fonseca
4fb1eb7be2 Add the missing detailed documentation bits on miniglx.c and xf86drm.c.
Several updates and fixes to the documentation.
2003-01-19 12:18:08 +00:00
Jose Fonseca
cf119744c3 More detailed documentation. 2003-01-19 01:57:45 +00:00
Keith Whitwell
b07ed0113a Use frontbuffer if GLUT_DOUBLE not requested 2003-01-18 19:59:27 +00:00
Jose Fonseca
d6d8d1dfce Detailed documention for glapi.c. Brief description of the structures in sarea.h. Minor fix in drm.h. 2003-01-18 13:42:06 +00:00
Jose Fonseca
f483ebddeb Enable the documentation of static functions and also the internal documentation. 2003-01-18 13:01:17 +00:00
Keith Whitwell
35fe61ce7b Remove debug printf 2003-01-18 12:41:55 +00:00
Keith Whitwell
c3b1d1e63c Restore registers clobbered by radeonfb.o -- prevents slowdown to 200fps
of mesa demos.
2003-01-18 12:41:34 +00:00
Keith Whitwell
38bfead7d3 Remove some unused members from RADEONInfoRec, add saved value for
crtc_offset_cntl
2003-01-18 12:38:40 +00:00
Keith Whitwell
56f57500b9 Add PostValidateMode hook to allow drivers to restore registers after
fbdev has finished clobbering them.
2003-01-18 12:25:56 +00:00
Keith Whitwell
2ce0615ef1 Remove chipset line from example miniglx.conf 2003-01-18 12:17:02 +00:00
Keith Whitwell
559af8ace4 Probe for chipset if one isn't supplied 2003-01-18 12:16:16 +00:00
Keith Whitwell
f73e37e154 A standalone build environment for radeonfb.o, incorporating necessary
fixes from Ani Joshi and others.  This is probably the only version of
radeonfb that we can run against at the moment, so include it here.
2003-01-18 11:15:47 +00:00
Brian Paul
ec5b054b8f fix up loose ends 2003-01-17 21:45:04 +00:00
Brian Paul
8a63d4bc99 new Makefiles for subset 2003-01-17 21:21:57 +00:00
Keith Whitwell
f58e67787f Get colors working in 16bpp 2003-01-17 19:01:22 +00:00
Keith Whitwell
deb4d4de47 add support for 16bpp modes, disabled 2003-01-17 16:19:15 +00:00
Keith Whitwell
1449a2f759 Take stride properly into account when setting up window members. 2003-01-17 00:56:14 +00:00
Keith Whitwell
f0b66442e8 Clear framebuffer at startup 2003-01-17 00:36:05 +00:00
Keith Whitwell
8830b0a941 Make miniglut exit() on error, like real glut. 2003-01-17 00:32:50 +00:00
Keith Whitwell
deb5fe3b68 use a fixed resolution defined in a config file 2003-01-16 23:39:30 +00:00
Brian Paul
1e1e71e3a7 lots of updates, practically finished 2003-01-16 23:15:28 +00:00
Keith Whitwell
53362d8858 get conform working 2003-01-14 16:52:40 +00:00
Keith Whitwell
af82796ed1 Remove debug printf 2003-01-14 11:39:11 +00:00
Jose Fonseca
6ded963ac6 Documentation for most of the DRM ioctls argument structures in drm.h.
Fixes to the xf86drm.c documentation.
2003-01-13 16:02:32 +00:00
Keith Whitwell
b4f35d5191 example miniglx.conf 2003-01-13 15:34:00 +00:00
Keith Whitwell
0b9434aafd Add config file facility and remove hardwired options from minglx.c
Move functionality for setting up glx configs into the drivers.
Allow the driver to tweak modes (eg for pitch) before setting up fbdev.
2003-01-13 15:31:31 +00:00
Jose Fonseca
fb02d9f4eb Big chunk of documention of xf86drm.c. Some oddities left to document, and still needs a review to catch typos. 2003-01-13 14:36:40 +00:00
Brian Paul
2b83583994 s/union/enum/ 2003-01-11 14:13:25 +00:00
Brian Paul
76415ea859 tweaks to Doxygen config files 2003-01-10 21:57:59 +00:00
Brian Paul
10d05983ef documentation updates 2003-01-10 21:57:41 +00:00
Brian Paul
7c35ac6e82 doc updates, new PixelFormat enum 2003-01-10 21:56:04 +00:00
Keith Whitwell
ca9cccd81c Fix GLUT_ELAPSED_TIME query 2003-01-10 17:47:49 +00:00
Jose Fonseca
ea9f98b04b Enable internal documentation in doxy/miniglx.doxy.
Enable private and static documention in doxy/core.doxy (necessary now for src/glapi.c and others later).
2003-01-09 20:37:02 +00:00
Brian Paul
8b4a34dcdb Initial check in. 2003-01-09 18:24:46 +00:00
Keith Whitwell
267bc32309 Add documentation for GLX_DEPTH_SIZE 2003-01-09 16:54:49 +00:00
Keith Whitwell
8618425250 Remove some more unused functions 2003-01-09 15:16:57 +00:00
Keith Whitwell
24259ec2d0 Bump window sizes up to next supported size when choosing modes.
Recognize the GLX_DEPTH_SIZE attrib.
2003-01-09 15:16:35 +00:00
Keith Whitwell
97aa6f3734 Initialize lastStamp to 1, so that drivers know they need to update
(ie initialize) their internal data.
2003-01-09 15:15:33 +00:00
Keith Whitwell
6b723c7720 Add section on porting apps glx->miniglx 2003-01-09 15:14:24 +00:00
Keith Whitwell
211f26ca95 more cleanups 2003-01-09 15:13:49 +00:00
Keith Whitwell
df7cbe873e Remove earlier workaround 2003-01-09 15:12:38 +00:00
Keith Whitwell
da8a7e15a6 Build the full driver for now 2003-01-09 15:12:04 +00:00
Keith Whitwell
f6546f8384 Barebones glut-alike - just enough to get the mesa demos working 2003-01-09 12:43:40 +00:00
Keith Whitwell
cd22e4b78c Remove some debug 2003-01-03 11:37:10 +00:00
Keith Whitwell
5ff65a62df Require radeon.o 1.8.x 2003-01-02 19:02:23 +00:00
Keith Whitwell
fd55975710 Take advantage of the fact that the kernel module can now shut itself
down cleanly
2003-01-02 18:49:34 +00:00
Keith Whitwell
c83b869ed2 Cleanups 2003-01-02 18:47:05 +00:00
Keith Whitwell
592250e9fc Add a bit of compile-time flexibility 2003-01-02 18:44:41 +00:00
Keith Whitwell
cdb267a918 Allow the standard radeon driver to be built without the swrast and swtnl
modules.  This effectively merges the radeon-es driver back into the
radeon driver as a compile-time option.
2002-12-30 17:24:05 +00:00
Keith Whitwell
2c2bcf8268 Lay ground work for cut-down radeon driver.
NOTE: commented out a couple of places where core mesa calls directly into
      the swrast module.
2002-12-30 15:20:35 +00:00
Keith Whitwell
695b197cb2 Bring some more initialization code from the 2d driver. 2d accels now
work (glClear).  Pageflip now works for swapbuffers.
2002-12-30 13:15:55 +00:00
Keith Whitwell
e17d611067 Remove dead code 2002-12-27 13:17:53 +00:00
Keith Whitwell
9df9883a7a Do a better job of initializing the __DRIdrawablePrivate in driCreateDrawable 2002-12-27 13:07:11 +00:00
Keith Whitwell
22477c050e Turn off stereo flag in visual configs. 2002-12-27 11:25:08 +00:00
Keith Whitwell
39afeb7cf0 Resolve stability issues starting & stopping radeon driver.
Add drmtest program to exercise the drm without the added complications of
a full driver.

Bring fb driver uptodate with changes for hw drivers.
2002-12-25 12:51:21 +00:00
Keith Whitwell
9363bd862f missing files 2002-12-23 12:18:14 +00:00
Jose Fonseca
83b936adb3 Better documentation to the data structures of miniglx.h and miniglxP.h.
Document the implementation details of most of the public functions in
miniglx.c. These details are under the doxygen's \internal tag so their
presence in the output documentation is controlled by the INTERNAL_DOCS =
YES|NO variable in the doxygen configurations files.
2002-12-22 17:11:04 +00:00
Jose Fonseca
5134d4a98b Apply the doxygen treatment to some [big] files. Some enhancements. 2002-12-21 19:06:06 +00:00
Jose Fonseca
2481eda853 Give the doxygen treatment to include/GL/miniglx.h and src/miniglx/miniglxP.h.
More documentation fixes and enhancements to src/miniglx/miniglx.c.
2002-12-21 02:47:26 +00:00
Jose Fonseca
6b31afc236 Enable documentation for private and static members.
Disable the included file listing.
2002-12-21 02:43:09 +00:00
Jose Fonseca
8fd39b4e8c Added caller documentation to the remaining public API functions.
Renamed some function arguments to match the original Xlib and GLX documentation.
2002-12-20 19:41:41 +00:00
Keith Whitwell
094eed79c2 miniglxtest runs to completion and exits with radeon driver,
but produces no graphical output.
2002-12-20 15:07:56 +00:00
Jose Fonseca
d20f1768a6 Added documentation to some functions plus a main page with introduction and references to Mini GLX. 2002-12-20 01:28:15 +00:00
Keith Whitwell
3e06eed70a Move dri initialization into XCreateWindow 2002-12-19 13:48:27 +00:00
Keith Whitwell
3e13551969 eliminate unresolved symbols 2002-12-19 12:26:15 +00:00
Keith Whitwell
3af2be61fd Radeon driver and hw init code compiles. 2002-12-19 10:16:18 +00:00
Keith Whitwell
eb7eb6e171 restore some 'drmFree' strings previously clobbered 2002-12-18 15:34:22 +00:00
Keith Whitwell
e931e819f9 Remove references to ScrnInfoPtr 2002-12-18 14:52:58 +00:00
Jose Fonseca
95936ee9ba Added doxy/miniglx.doxy based on doxy/core.doxy.
Fixed typo in doxy/README.
2002-12-18 14:31:51 +00:00
Keith Whitwell
157d9a5ac6 remove some more unused functions 2002-12-16 18:55:42 +00:00
Keith Whitwell
134930b627 remove old comment 2002-12-16 18:38:29 +00:00
Keith Whitwell
a97ce86232 Dumb framebuffer driver now in pretty good shape, though some operations
(like swapbuffers) are quite slow because the backbuffer lives in video
ram.
2002-12-16 13:40:44 +00:00
Keith Whitwell
5ca95653c4 miniglxtest.c works against swrast driver 2002-12-13 15:18:09 +00:00
Keith Whitwell
1f01a4b3b6 miniglx test will run with fb_dri.so (ie. swrast) driver, but output is
garbled.
2002-12-12 14:22:02 +00:00
Keith Whitwell
8645472e00 new files 2002-12-11 14:44:09 +00:00
Keith Whitwell
1929cacdbf more cleanups 2002-12-11 14:41:20 +00:00
Brian Paul
65e30ac06a minor tweaks 2002-12-09 22:34:40 +00:00
Brian Paul
941efe8eda added XGetVisualInfo, glXGetConfig plus misc comments and clean-ups 2002-12-09 22:33:09 +00:00
Keith Whitwell
ea4b887ef7 readded 2002-12-06 16:24:07 +00:00
Keith Whitwell
ba8e63f05b Get rid of the 'proper' glx files -- glxclient.h, glxext.c
Move the interface lines for dri drivers -- the __driUtil functions which
know a lot about glx internals now live here.
2002-12-06 16:19:45 +00:00
Keith Whitwell
117a2d76b6 Remove -lX11 from miniglx link libraries... 2002-12-04 16:03:49 +00:00
Keith Whitwell
ce75913702 Caught a couple of things after a clean build on rh 7.3 2002-12-04 16:00:05 +00:00
Keith Whitwell
cbc41d4332 Remove the USE_DRI=0 case -- this is now in drv/fb/fb_dri.c 2002-12-04 15:33:12 +00:00
Keith Whitwell
40af4d7662 A full radeon driver, seems to build ok, haven't run yet 2002-12-04 15:31:04 +00:00
Brian Paul
702b2802a0 added XFree() and glXQueryVersion() 2002-12-04 15:25:37 +00:00
Keith Whitwell
44e4e437a0 new file 2002-12-04 13:09:17 +00:00
Keith Whitwell
366ca58ea6 new makefiles to build modules as .a files 2002-12-04 12:48:09 +00:00
Keith Whitwell
90925c9777 ignore .d files 2002-12-03 22:30:41 +00:00
Brian Paul
f6b40da9a7 *** empty log message *** 2002-12-03 21:27:54 +00:00
Keith Whitwell
80798c8eab minor changes from the end of last week 2002-12-03 17:38:19 +00:00
Brian Paul
65a7a3852d miniglx.c now loads DRI drivers. glxext.c and glxclient.h no longer needed.
Many functions in XF86DRI.c are #ifdef'd out and need new implementations.
2002-11-29 16:07:51 +00:00
Brian Paul
cf8aede714 mask is always non-null in write_rgba_pixels and write_monorgba_pixels 2002-11-28 15:55:41 +00:00
Brian Paul
1e27ca69f8 fixed breakage from last check-in, more clean-ups 2002-11-28 00:24:04 +00:00
Brian Paul
9fcd566e60 added DRI awareness (incomplete, disabled by default) 2002-11-28 00:03:07 +00:00
Brian Paul
78b5f5f44f remove resize() function 2002-11-27 21:04:18 +00:00
Brian Paul
8a82d9db15 support more screen sizes, more clean-ups 2002-11-27 21:03:33 +00:00
Brian Paul
fa747cdb0a miniglx layered on fbdev works now. 2002-11-27 17:02:39 +00:00
Keith Whitwell
fa50fae202 Narrow down the missing bits of information 2002-11-27 16:31:27 +00:00
Keith Whitwell
0fb48dba7c pull in more server code, particularly for radeon init 2002-11-27 15:52:13 +00:00
Keith Whitwell
2f3585d4f1 Auto-dependency generating makefile 2002-11-27 13:58:53 +00:00
Brian Paul
7c7789c029 do some simple MMIO register reads for sanity testing 2002-11-27 00:26:59 +00:00
Brian Paul
56ad63958b set timing values explicitly. new debugging info 2002-11-26 21:20:45 +00:00
Brian Paul
aa0109bf96 move WindowExists() code into glxext.c (effectively out of the driver) 2002-11-26 18:18:54 +00:00
Keith Whitwell
0201db5a22 Added two files which should (with much tweaking) eventually allow
the radeon_dri.so driver from the dri project to be loaded and run
against an fbdev environment.
2002-11-26 17:39:32 +00:00
Brian Paul
1a1069c7e9 more trimming / hacking 2002-11-25 21:38:08 +00:00
Brian Paul
fc88680a39 more tweaks 2002-11-22 16:13:49 +00:00
Brian Paul
ff89f4b639 fix some bugs, add colormap initialization 2002-11-22 15:26:56 +00:00
Brian Paul
7d5b5c0438 added glfbdevtest and miniglxtest 2002-11-22 00:19:31 +00:00
Brian Paul
6ccaeaaa16 from DRI CVS - hacked to some extent 2002-11-21 16:42:51 +00:00
Brian Paul
e4e72da501 from Mesa 5.1 2002-11-21 16:00:27 +00:00
Brian Paul
67f87d2463 disable thread safety for now 2002-11-21 15:45:55 +00:00
Brian Paul
431c1740d5 compile glfbdev.c and miniglx.c 2002-11-21 14:59:05 +00:00
Brian Paul
fa3f447234 fixed cube texture auto-mipmap generation bug (641363) 2002-11-20 21:40:02 +00:00
Brian Paul
3a08052714 stripped, subsetted DRI-capable libGL 2002-11-20 18:09:51 +00:00
Brian Paul
424096d581 prototype interfaces and tests 2002-11-20 02:10:37 +00:00
Brian Paul
2e5a88ab6a oops, wrong branch 2002-11-20 02:09:57 +00:00
Brian Paul
d520ff08d0 tests for new interfaces 2002-11-20 01:54:12 +00:00
Brian Paul
ef0e1dcc2e prototypes for new interfaces 2002-11-20 01:53:24 +00:00
Brian Paul
6412641b19 put FEATURE_NV_vertex_program around vpstate.h include 2002-11-19 15:25:16 +00:00
Brian Paul
3ee066b48f missed a couple version string updates 2002-11-14 16:16:45 +00:00
Brian Paul
33c0b3e233 patches from Karl 2002-11-13 22:26:23 +00:00
Brian Paul
658145bd82 fix compilation problem (Philippe Houdoin) 2002-11-13 22:21:47 +00:00
184 changed files with 57548 additions and 1706 deletions

3579
docs/subset.html Normal file

File diff suppressed because it is too large Load Diff

10
doxygen/.cvsignore Normal file
View File

@@ -0,0 +1,10 @@
*.tag
array_cache
core
math
miniglx
radeon_subset
swrast
swrast_setup
tnl
tnl_dd

View File

@@ -6,4 +6,4 @@ See http://www.doxygen.org/ for more info.
Either run 'make' (Unix) or 'doxy.bat' (Windows) to run doxygen
and generate souce code documentation.
Then, load doxy/core.index.html into your web browser.
Then, load doxy/core/index.html into your web browser.

View File

@@ -4,10 +4,10 @@
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Mesa array_cache"
PROJECT_NUMBER = 4.1
OUTPUT_DIRECTORY = .
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
@@ -38,14 +38,14 @@ GENERATE_BUGLIST = YES
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_FOR_C = NO
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_UNDOCUMENTED = NO
WARN_FORMAT =
WARN_LOGFILE =
#---------------------------------------------------------------------------

View File

@@ -4,12 +4,12 @@
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Mesa Core"
PROJECT_NUMBER = 4.1
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
@@ -19,7 +19,7 @@ ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = NO
INTERNAL_DOCS = YES
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
SHORT_NAMES = NO
@@ -38,21 +38,21 @@ GENERATE_BUGLIST = YES
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_FOR_C = NO
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_UNDOCUMENTED = NO
WARN_FORMAT =
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../src/
FILE_PATTERNS = *.h *.c
FILE_PATTERNS = *.c *.h
RECURSIVE = NO
EXCLUDE = ../src/glapitemp.h ../src/glapioffsets.h
EXCLUDE_PATTERNS =
@@ -65,16 +65,16 @@ FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX = _
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
@@ -149,7 +149,7 @@ TAGFILES = tnl_dd.tag=../tnl_dd \
swrast.tag=../swrast \
swrast_setup.tag=../swrast_setup \
tnl.tag=../tnl \
array_cache.tag=array_cache
miniglx.tag=../miniglx
GENERATE_TAGFILE = core.tag
ALLEXTERNALS = NO
PERL_PATH =

View File

@@ -1,12 +1,14 @@
<html><head><title>Mesa API docs</title>
<html><head><title>Mesa Source Code Documentation</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>
<body><center>
<a href="../core/index.html">Mesa Core</a>&nbsp;
<a href="../miniglx/index.html">MiniGLX</a>&nbsp;
<a href="../array_cache/index.html">array_cache</a>&nbsp;
<a href="../core/index.html">core</a>&nbsp;
<a href="../math/index.html">math</a>&nbsp;
<a href="../swrast/index.html">swrast</a>&nbsp;
<a href="../swrast_setup/index.html">swrast_setup</a>&nbsp;
<a href="../tnl/index.html">tnl</a>&nbsp;
<a href="../tnl_dd/index.html">tnl_dd</a>&nbsp;
<a href="../radeon_subset/index.html">radeon_subset</a>&nbsp;
</center>

View File

@@ -5,6 +5,7 @@ default:
doxygen swrast.doxy
doxygen swrast_setup.doxy
doxygen tnl.doxy
doxygen miniglx.doxy
doxygen core.doxy
echo "Building again, to resolve tags"
doxygen tnl_dd.doxy
@@ -13,9 +14,11 @@ default:
doxygen swrast.doxy
doxygen swrast_setup.doxy
doxygen tnl.doxy
doxygen miniglx.doxy
doxygen radeon_subset.doxy
clean:
rm -rf array_cache core math swrast swrast_setup tnl_dd tnl
rm -rf array_cache core math swrast swrast_setup tnl_dd tnl miniglx radeon_subset
rm -rf *.tag

View File

@@ -3,13 +3,13 @@
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Mesa math"
PROJECT_NUMBER = 4.1
PROJECT_NAME = "Mesa math module"
PROJECT_NUMBER =
OUTPUT_DIRECTORY = .
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
@@ -73,7 +73,7 @@ REFERENCES_RELATION = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------

184
doxygen/miniglx.doxy Normal file
View File

@@ -0,0 +1,184 @@
# Doxyfile 0.1
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "MiniGLX"
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = YES
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
SHORT_NAMES = NO
HIDE_SCOPE_NAMES = NO
VERBATIM_HEADERS = NO
SHOW_INCLUDE_FILES = NO
JAVADOC_AUTOBRIEF = NO
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = NO
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
WARN_FORMAT =
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../src/miniglx/ ../include/GL/miniglx.h
FILE_PATTERNS = *.h *.c
RECURSIVE = NO
EXCLUDE = ../src/miniglx/glapi.c
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = miniglx
HTML_HEADER = header.html
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT =
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT =
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT =
MAN_EXTENSION =
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH = ../include/
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES = core.tag=../core \
tnl_dd.tag=../tnl_dd \
array_cache.tag=../array_cache \
math.tag=../math \
swrast.tag=../swrast \
swrast_setup.tag=../swrast_setup \
tnl.tag=../tnl \
array_cache.tag=array_cache
GENERATE_TAGFILE = miniglx.tag
ALLEXTERNALS = NO
PERL_PATH =
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
TEMPLATE_RELATIONS = YES
HIDE_UNDOC_RELATIONS = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME =
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH =
EXT_DOC_PATHS =

208
doxygen/radeon_subset.doxy Normal file
View File

@@ -0,0 +1,208 @@
# Doxyfile 0.1
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Radeon Subset Driver"
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = YES
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
SHORT_NAMES = NO
HIDE_SCOPE_NAMES = NO
VERBATIM_HEADERS = NO
SHOW_INCLUDE_FILES = NO
JAVADOC_AUTOBRIEF = NO
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = NO
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
WARN_FORMAT =
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = \
../src/drv/common/mm.c \
../src/drv/common/mm.h \
../src/drv/radeon/radeon_context.c \
../src/drv/radeon/radeon_context.h \
../src/drv/radeon/radeon_ioctl.c \
../src/drv/radeon/radeon_ioctl.h \
../src/drv/radeon/radeon_lock.c \
../src/drv/radeon/radeon_lock.h \
../src/drv/radeon/radeon_screen.c \
../src/drv/radeon/radeon_screen.h \
../src/drv/radeon/radeon_state.c \
../src/drv/radeon/radeon_state.h \
../src/drv/radeon/radeon_state_init.c \
../src/drv/radeon/radeon_subset.h \
../src/drv/radeon/radeon_subset_bitmap.c \
../src/drv/radeon/radeon_subset_readpix.c \
../src/drv/radeon/radeon_subset_select.c \
../src/drv/radeon/radeon_subset_tex.c \
../src/drv/radeon/radeon_subset_vtx.c \
../src/drv/radeon/radeon_tcl.h \
../src/drv/radeon/radeon_tex.h \
../src/drv/radeon/radeon_vtxfmt.h \
../src/drv/radeon/server
FILE_PATTERNS = *.h *.c
RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = radeon_subset
HTML_HEADER = header.html
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT =
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT =
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT =
MAN_EXTENSION =
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH = ../include/
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES = core.tag=../core \
tnl_dd.tag=../tnl_dd \
array_cache.tag=../array_cache \
math.tag=../math \
swrast.tag=../swrast \
swrast_setup.tag=../swrast_setup \
tnl.tag=../tnl \
miniglx.tag=../miniglx \
array_cache.tag=array_cache
GENERATE_TAGFILE = radeon_subset.tag
ALLEXTERNALS = NO
PERL_PATH =
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
TEMPLATE_RELATIONS = YES
HIDE_UNDOC_RELATIONS = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME =
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH =
EXT_DOC_PATHS =

View File

@@ -3,8 +3,8 @@
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Mesa swrast"
PROJECT_NUMBER = 4.1
PROJECT_NAME = "Mesa Software Rasterization (swrast)"
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
EXTRACT_ALL = NO
@@ -19,7 +19,7 @@ ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = NO
INTERNAL_DOCS = YES
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
SHORT_NAMES = NO
@@ -38,22 +38,21 @@ GENERATE_BUGLIST = YES
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_FOR_C = YES
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_UNDOCUMENTED = NO
WARN_FORMAT =
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../src/swrast/
FILE_PATTERNS = *.c \
*.h
FILE_PATTERNS = *.c *.h
RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
@@ -136,7 +135,7 @@ ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_PATH = ../include/
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
@@ -156,7 +155,7 @@ PERL_PATH =
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
CLASS_DIAGRAMS = NO
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES

View File

@@ -4,7 +4,7 @@
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Mesa swrast_setup"
PROJECT_NUMBER = 4.1
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES

View File

@@ -3,8 +3,8 @@
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Mesa tnl"
PROJECT_NUMBER = 4.1
PROJECT_NAME = "Mesa Transform and Lighting (tnl)"
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES

View File

@@ -4,7 +4,7 @@
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "Mesa tnl_dd"
PROJECT_NUMBER = 4.1
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
@@ -52,7 +52,7 @@ WARN_LOGFILE =
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../src/tnl_dd/
FILE_PATTERNS = *.h
FILE_PATTERNS = *.c *.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_PATTERNS =

View File

@@ -1,4 +1,4 @@
/* $Id: glx.h,v 1.38 2002/10/14 13:52:27 brianp Exp $ */
/* $Id: glx.h,v 1.38.4.1 2003/02/23 19:37:15 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -295,7 +295,7 @@ extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
/* GLX 1.4 and later */
extern void (*glXGetProcAddress(const GLubyte *procname))();
extern void (*glXGetProcAddress(const GLubyte *procname))( void );
#ifndef GLX_GLXEXT_LEGACY

View File

@@ -58,12 +58,12 @@ typedef struct __GLinterfaceRec __GLinterface;
** and used by the "operating system".
*/
/*
** Mode and limit information for a context. This information is
** kept around in the context so that values can be used during
** command execution, and for returning information about the
** context to the application.
*/
/**
* Mode and limit information for a context. This information is
* kept around in the context so that values can be used during
* command execution, and for returning information about the
* context to the application.
*/
typedef struct __GLcontextModesRec {
GLboolean rgbMode;
GLboolean colorIndexMode;

25
progs/demos/Makefile Normal file
View File

@@ -0,0 +1,25 @@
PROGS = gears \
glinfo \
texobj \
bounce \
terrain
##### RULES #####
.SUFFIXES:
.SUFFIXES: .c
# make executable from .c file:
.c: $(LIB_DEP)
gcc -I../include -I../util -g $< -L../lib -lglut -lGL -lm -o $@
default: $(PROGS)
clean:
-rm *.o *~

View File

@@ -1,4 +1,4 @@
/* $Id: bounce.c,v 1.3 2000/08/16 20:36:34 brianp Exp $ */
/* $Id: bounce.c,v 1.3.8.1 2003/02/23 19:25:07 keithw Exp $ */
/*
* Bouncing ball demo.
@@ -33,8 +33,8 @@ GLfloat Xmin = -4.0, Xmax = 4.0;
GLfloat Ymin = -3.8, Ymax = 4.0;
GLfloat G = -0.1;
static GLuint
make_ball(void)
static void
draw_ball(void)
{
GLuint list;
GLfloat a, b;
@@ -43,9 +43,9 @@ make_ball(void)
GLuint color;
GLfloat x, y, z;
list = glGenLists(1);
/* list = glGenLists(1); */
glNewList(list, GL_COMPILE);
/* glNewList(list, GL_COMPILE); */
color = 0;
for (a = -90.0; a + da <= 90.0; a += da) {
@@ -54,10 +54,10 @@ make_ball(void)
for (b = 0.0; b <= 360.0; b += db) {
if (color) {
glIndexi(RED);
/* glIndexi(RED); */
glColor3f(1, 0, 0);
} else {
glIndexi(WHITE);
/* glIndexi(WHITE); */
glColor3f(1, 1, 1);
}
@@ -77,11 +77,12 @@ make_ball(void)
}
glEndList();
/* glEndList(); */
return list;
/* return list; */
}
static void
reshape(int width, int height)
{
@@ -110,7 +111,7 @@ draw(void)
glClear(GL_COLOR_BUFFER_BIT);
glIndexi(CYAN);
/* glIndexi(CYAN); */
glColor3f(0, 1, 1);
glBegin(GL_LINES);
for (i = -5; i <= 5; i++) {
@@ -138,7 +139,8 @@ draw(void)
glRotatef(90.0, 1.0, 0.0, 0.0);
glRotatef(Zrot, 0.0, 0.0, 1.0);
glCallList(Ball);
/* glCallList(Ball); */
draw_ball();
glPopMatrix();
@@ -198,7 +200,7 @@ int main(int argc, char *argv[])
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("Bounce");
Ball = make_ball();
/* Ball = make_ball(); */
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glDisable(GL_DITHER);

View File

@@ -1,4 +1,4 @@
/* $Id: gears.c,v 1.6 2000/04/06 02:22:59 brianp Exp $ */
/* $Id: gears.c,v 1.6.12.1 2003/02/23 19:25:07 keithw Exp $ */
/*
* 3-D gear wheels. This program is in the public domain.
@@ -59,7 +59,7 @@ gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
glShadeModel(GL_FLAT);
glNormal3f(0.0, 0.0, 1.0);
/* glNormal3f(0.0, 0.0, 1.0); */
/* draw front face */
glBegin(GL_QUAD_STRIP);
@@ -87,7 +87,7 @@ gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
}
glEnd();
glNormal3f(0.0, 0.0, -1.0);
/* glNormal3f(0.0, 0.0, -1.0); */
/* draw back face */
glBegin(GL_QUAD_STRIP);
@@ -127,18 +127,18 @@ gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
len = sqrt(u * u + v * v);
u /= len;
v /= len;
glNormal3f(v, -u, 0.0);
/* glNormal3f(v, -u, 0.0); */
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
glNormal3f(cos(angle), sin(angle), 0.0);
/* glNormal3f(cos(angle), sin(angle), 0.0); */
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
glNormal3f(v, -u, 0.0);
/* glNormal3f(v, -u, 0.0); */
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
glNormal3f(cos(angle), sin(angle), 0.0);
/* glNormal3f(cos(angle), sin(angle), 0.0); */
}
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
@@ -149,10 +149,11 @@ gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
glShadeModel(GL_SMOOTH);
/* draw inside radius cylinder */
glColor3f( .5, .5, .5 );
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.0 * M_PI / teeth;
glNormal3f(-cos(angle), -sin(angle), 0.0);
/* glNormal3f(-cos(angle), -sin(angle), 0.0); */
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
}
@@ -167,6 +168,11 @@ static GLfloat angle = 0.0;
static void
draw(void)
{
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
glClearColor( 1,0,1,1 );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
@@ -177,19 +183,23 @@ draw(void)
glPushMatrix();
glTranslatef(-3.0, -2.0, 0.0);
glRotatef(angle, 0.0, 0.0, 1.0);
glCallList(gear1);
glColor3fv( red);
gear(1.0, 4.0, 1.0, 20, 0.7);
glPopMatrix();
glPushMatrix();
glTranslatef(3.1, -2.0, 0.0);
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
glCallList(gear2);
glColor3fv( green);
gear(0.5, 2.0, 2.0, 10, 0.7);
glPopMatrix();
glPushMatrix();
glTranslatef(-3.1, 4.2, 0.0);
glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
glCallList(gear3);
glColor3fv( blue);
gear(1.3, 2.0, 0.5, 10, 0.7);
glPopMatrix();
glPopMatrix();
@@ -284,37 +294,15 @@ static void
init(int argc, char *argv[])
{
static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0};
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
GLint i;
glLightfv(GL_LIGHT0, GL_POSITION, pos);
/* glLightfv(GL_LIGHT0, GL_POSITION, pos); */
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
/* glEnable(GL_LIGHTING); */
/* glEnable(GL_LIGHT0); */
/* glEnable(GL_DEPTH_TEST); */
/* make the gears */
gear1 = glGenLists(1);
glNewList(gear1, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
gear(1.0, 4.0, 1.0, 20, 0.7);
glEndList();
gear2 = glGenLists(1);
glNewList(gear2, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
gear(0.5, 2.0, 2.0, 10, 0.7);
glEndList();
gear3 = glGenLists(1);
glNewList(gear3, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
gear(1.3, 2.0, 0.5, 10, 0.7);
glEndList();
glEnable(GL_NORMALIZE);
/* glEnable(GL_NORMALIZE); */
for ( i=1; i<argc; i++ ) {
if (strcmp(argv[i], "-info")==0) {
@@ -345,7 +333,7 @@ int main(int argc, char *argv[])
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowPosition(0, 0);
glutInitWindowSize(300, 300);
glutInitWindowSize(900, 900);
glutCreateWindow("Gears");
init(argc, argv);

View File

@@ -1,4 +1,4 @@
/* $Id: isosurf.c,v 1.15 2002/10/18 17:47:35 kschultz Exp $ */
/* $Id: isosurf.c,v 1.15.4.1 2003/02/23 21:04:25 keithw Exp $ */
/*
* Display an isosurface of 3-D wind speed volume.
@@ -484,7 +484,7 @@ static void draw_surface( unsigned int with_state )
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
glBegin( GL_TRIANGLES );
for (k = 0 ; k < nr ; k++) {
glNormal3fv( &compressed_data[tri_indices[i+k]][3] );
glColor3fv( &compressed_data[tri_indices[i+k]][3] );
glVertex3fv( &compressed_data[tri_indices[i+k]][0] );
}
glEnd();
@@ -492,7 +492,7 @@ static void draw_surface( unsigned int with_state )
} else {
glBegin( GL_TRIANGLES );
for (i = 0 ; i < num_tri_verts ; i++) {
glNormal3fv( &compressed_data[tri_indices[i]][3] );
glColor3fv( &compressed_data[tri_indices[i]][3] );
glVertex3fv( &compressed_data[tri_indices[i]][0] );
}
glEnd();
@@ -506,7 +506,7 @@ static void draw_surface( unsigned int with_state )
*/
glBegin( GL_POINTS );
for ( i = 0 ; i < numuniq ; i++ ) {
glNormal3fv( &compressed_data[i][3] );
glColor3fv( &compressed_data[i][3] );
glVertex3fv( &compressed_data[i][0] );
}
glEnd();
@@ -515,7 +515,7 @@ static void draw_surface( unsigned int with_state )
case (GLVERTEX|STRIPS):
glBegin( GL_TRIANGLE_STRIP );
for (i=0;i<numverts;i++) {
glNormal3fv( &data[i][3] );
glColor3fv( &data[i][0] );
glVertex3fv( &data[i][0] );
}
glEnd();
@@ -595,24 +595,24 @@ static void InitMaterials(void)
static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};
static float lmodel_twoside[] = {GL_FALSE};
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, position0);
glEnable(GL_LIGHT0);
/* glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); */
/* glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); */
/* glLightfv(GL_LIGHT0, GL_POSITION, position0); */
/* glEnable(GL_LIGHT0); */
glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT1, GL_POSITION, position1);
glEnable(GL_LIGHT1);
/* glLightfv(GL_LIGHT1, GL_AMBIENT, ambient); */
/* glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); */
/* glLightfv(GL_LIGHT1, GL_POSITION, position1); */
/* glEnable(GL_LIGHT1); */
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);
/* glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); */
/* glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside); */
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_mat_shininess);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_mat_specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, front_mat_diffuse);
/* glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, front_mat_shininess); */
/* glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, front_mat_specular); */
/* glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, front_mat_diffuse); */
glPolygonStipple (halftone);
/* glPolygonStipple (halftone); */
}
@@ -736,65 +736,6 @@ static void ModeMenu(int m)
print_flags("primitive", state & PRIMITIVE_MASK);
print_flags("render style", state & RENDER_STYLE_MASK);
if ((state & PRIMITIVE_MASK) != STRIPS &&
((state & RENDER_STYLE_MASK) == DRAW_ELTS ||
(state & RENDER_STYLE_MASK) == ARRAY_ELT ||
(state & PRIMITIVE_MASK) == POINTS))
{
fprintf(stderr, "enabling small arrays\n");
/* Rendering any primitive with draw-element/array-element
* --> Can't do strips here as ordering has been lost in
* compaction process...
*/
glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), numuniq,
compressed_data );
glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), numuniq,
&compressed_data[0][3]);
#ifdef GL_EXT_compiled_vertex_array
if (allowed & LOCKED) {
if (state & LOCKED) {
glLockArraysEXT( 0, numuniq );
} else {
glUnlockArraysEXT();
}
}
#endif
}
else if ((state & PRIMITIVE_MASK) == TRIANGLES &&
(state & RENDER_STYLE_MASK) == DRAW_ARRAYS) {
fprintf(stderr, "enabling big arrays\n");
/* Only get here for TRIANGLES and drawarrays
*/
glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), (numverts-2) * 3,
expanded_data );
glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), (numverts-2) * 3,
&expanded_data[0][3]);
#ifdef GL_EXT_compiled_vertex_array
if (allowed & LOCKED) {
if (state & LOCKED) {
glLockArraysEXT( 0, (numverts-2)*3 );
} else {
glUnlockArraysEXT();
}
}
#endif
}
else {
fprintf(stderr, "enabling normal arrays\n");
glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), numverts, data );
glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), numverts, &data[0][3]);
#ifdef GL_EXT_compiled_vertex_array
if (allowed & LOCKED) {
if (state & LOCKED) {
glLockArraysEXT( 0, numverts );
} else {
glUnlockArraysEXT();
}
}
#endif
}
}
#endif
@@ -827,9 +768,9 @@ static void Init(int argc, char *argv[])
plane[3] = 0.0;
glClearColor(0.0, 0.0, 1.0, 0.0);
glEnable( GL_DEPTH_TEST );
glEnable( GL_VERTEX_ARRAY_EXT );
glEnable( GL_NORMAL_ARRAY_EXT );
/* glEnable( GL_DEPTH_TEST ); */
/* glEnable( GL_VERTEX_ARRAY_EXT ); */
/* glEnable( GL_NORMAL_ARRAY_EXT ); */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -837,24 +778,24 @@ static void Init(int argc, char *argv[])
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClipPlane(GL_CLIP_PLANE0, plane);
/* glClipPlane(GL_CLIP_PLANE0, plane); */
InitMaterials();
set_matrix();
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
/* glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); */
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
/* glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); */
/* glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); */
/* Green fog is easy to see */
glFogi(GL_FOG_MODE,GL_EXP2);
glFogfv(GL_FOG_COLOR,fogColor);
glFogf(GL_FOG_DENSITY,0.15);
glHint(GL_FOG_HINT,GL_DONT_CARE);
/* glFogi(GL_FOG_MODE,GL_EXP2); */
/* glFogfv(GL_FOG_COLOR,fogColor); */
/* glFogf(GL_FOG_DENSITY,0.15); */
/* glHint(GL_FOG_HINT,GL_DONT_CARE); */
{
static int firsttime = 1;
@@ -872,7 +813,7 @@ static void Init(int argc, char *argv[])
}
ModeMenu(SHADE_SMOOTH|
LIT|
UNLIT|
POINT_FILTER|
NO_USER_CLIP|
NO_MATERIALS|
@@ -1121,6 +1062,9 @@ int main(int argc, char **argv)
glutSpecialFunc(SpecialKey);
glutDisplayFunc(Display);
/* Benchmark(5,0); */
/* Benchmark(5,0); */
/* Benchmark(5,0); */
glutMainLoop();
return 0;
}

View File

@@ -51,7 +51,7 @@ static GLfloat terraincolor[256 * 256][3];
static int win = 0;
static int fog = 1;
static int fog = 0;
static int bfcull = 1;
static int usetex = 1;
static int poutline = 0;
@@ -105,6 +105,21 @@ calcposobs(void)
obs[1] = 0.0;
}
static void
perspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
{
GLdouble xmin, xmax, ymin, ymax;
ymax = zNear * tan(fovy * M_PI / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
/* don't call glFrustum() because of error semantics (covglu) */
glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}
static void
reshape(int width, int height)
{
@@ -113,7 +128,7 @@ reshape(int width, int height)
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(50.0, ((GLfloat) width / (GLfloat) height),
perspective(50.0, ((GLfloat) width / (GLfloat) height),
lenghtXmnt * stepYmnt * 0.01, lenghtXmnt * stepYmnt * 0.7);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -209,13 +224,25 @@ printstring(void *font, char *string)
glutBitmapCharacter(font, string[i]);
}
static void _subset_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
{
glBegin( GL_QUADS );
glVertex2f( x1, y1 );
glVertex2f( x2, y1 );
glVertex2f( x2, y2 );
glVertex2f( x1, y2 );
glEnd();
}
static void
printhelp(void)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.0, 0.0, 0.0, 0.5);
glRecti(40, 40, 600, 440);
_subset_Rectf(40, 40, 600, 440);
glDisable(GL_BLEND);
glColor3f(1.0, 0.0, 0.0);
@@ -351,6 +378,87 @@ dojoy(void)
#endif
}
static void
lookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
GLfloat centerx, GLfloat centery, GLfloat centerz,
GLfloat upx, GLfloat upy, GLfloat upz)
{
GLfloat m[16];
GLfloat x[3], y[3], z[3];
GLfloat mag;
/* Make rotation matrix */
/* Z vector */
z[0] = eyex - centerx;
z[1] = eyey - centery;
z[2] = eyez - centerz;
mag = sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
if (mag) { /* mpichler, 19950515 */
z[0] /= mag;
z[1] /= mag;
z[2] /= mag;
}
/* Y vector */
y[0] = upx;
y[1] = upy;
y[2] = upz;
/* X vector = Y cross Z */
x[0] = y[1] * z[2] - y[2] * z[1];
x[1] = -y[0] * z[2] + y[2] * z[0];
x[2] = y[0] * z[1] - y[1] * z[0];
/* Recompute Y = Z cross X */
y[0] = z[1] * x[2] - z[2] * x[1];
y[1] = -z[0] * x[2] + z[2] * x[0];
y[2] = z[0] * x[1] - z[1] * x[0];
/* mpichler, 19950515 */
/* cross product gives area of parallelogram, which is < 1.0 for
* non-perpendicular unit-length vectors; so normalize x, y here
*/
mag = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
if (mag) {
x[0] /= mag;
x[1] /= mag;
x[2] /= mag;
}
mag = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
if (mag) {
y[0] /= mag;
y[1] /= mag;
y[2] /= mag;
}
#define M(row,col) m[col*4+row]
M(0, 0) = x[0];
M(0, 1) = x[1];
M(0, 2) = x[2];
M(0, 3) = 0.0;
M(1, 0) = y[0];
M(1, 1) = y[1];
M(1, 2) = y[2];
M(1, 3) = 0.0;
M(2, 0) = z[0];
M(2, 1) = z[1];
M(2, 2) = z[2];
M(2, 3) = 0.0;
M(3, 0) = 0.0;
M(3, 1) = 0.0;
M(3, 2) = 0.0;
M(3, 3) = 1.0;
#undef M
glMultMatrixf(m);
/* Translate Eye to Origin */
glTranslatef(-eyex, -eyey, -eyez);
}
static void
drawscene(void)
{
@@ -359,24 +467,24 @@ drawscene(void)
dojoy();
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
/* glEnable(GL_DEPTH_TEST); */
if (usetex)
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
if (fog)
glEnable(GL_FOG);
else
glDisable(GL_FOG);
/* if (fog) */
/* glEnable(GL_FOG); */
/* else */
/* glDisable(GL_FOG); */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
calcposobs();
gluLookAt(obs[0], obs[1], obs[2],
lookAt(obs[0], obs[1], obs[2],
obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
0.0, 1.0, 0.0);
@@ -384,8 +492,8 @@ drawscene(void)
glPopMatrix();
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
/* glDisable(GL_DEPTH_TEST); */
/* glDisable(GL_FOG); */
glShadeModel(GL_FLAT);
glMatrixMode(GL_PROJECTION);
@@ -549,7 +657,7 @@ calccolor(GLfloat height, GLfloat c[3])
static void
loadpic(void)
{
GLubyte bufferter[256 * 256], terrainpic[256 * 256];
GLubyte bufferter[256 * 256], terrainpic[256 * 256][4];
FILE *FilePic;
int i, tmp;
GLenum gluerr;
@@ -565,25 +673,28 @@ loadpic(void)
terrain[i] = (bufferter[i] * (heightMnt / 255.0f));
calccolor((GLfloat) bufferter[i], terraincolor[i]);
tmp = (((int) bufferter[i]) + 96);
terrainpic[i] = (tmp > 255) ? 255 : tmp;
terrainpic[i][0] = (tmp > 255) ? 255 : tmp;
terrainpic[i][1] = (tmp > 255) ? 255 : tmp;
terrainpic[i][2] = (tmp > 255) ? 255 : tmp;
terrainpic[i][0] = 255;
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if ((gluerr = gluBuild2DMipmaps(GL_TEXTURE_2D, 1, 256, 256, GL_LUMINANCE,
if ((gluerr = gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, 256, 256, GL_RGBA,
GL_UNSIGNED_BYTE,
(GLvoid *) (&terrainpic[0])))) {
(GLvoid *) (&terrainpic[0][0])))) {
fprintf(stderr, "GLULib%s\n", (char *) gluErrorString(gluerr));
exit(-1);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
}
@@ -593,21 +704,21 @@ init(void)
float fogcolor[4] = { 0.6, 0.7, 0.7, 1.0 };
glClearColor(fogcolor[0], fogcolor[1], fogcolor[2], fogcolor[3]);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
/* glClearDepth(1.0); */
/* glDepthFunc(GL_LEQUAL); */
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
/* glEnable(GL_DEPTH_TEST); */
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogfv(GL_FOG_COLOR, fogcolor);
glFogf(GL_FOG_DENSITY, 0.0007);
/* glEnable(GL_FOG); */
/* glFogi(GL_FOG_MODE, GL_EXP2); */
/* glFogfv(GL_FOG_COLOR, fogcolor); */
/* glFogf(GL_FOG_DENSITY, 0.0007); */
#ifdef FX
glHint(GL_FOG_HINT, GL_NICEST);
/* glHint(GL_FOG_HINT, GL_NICEST); */
#endif
reshape(scrwidth, scrheight);

View File

@@ -1,4 +1,4 @@
/* $Id: texobj.c,v 1.6 2002/01/04 21:05:57 brianp Exp $ */
/* $Id: texobj.c,v 1.6.6.1 2003/02/23 19:25:07 keithw Exp $ */
/*
* Example of using the 1.1 texture object functions.
@@ -17,7 +17,7 @@ static GLuint Window = 0;
static GLuint TexObj[2];
static GLfloat Angle = 0.0f;
static GLboolean UseObj = GL_FALSE;
static GLboolean UseObj = GL_TRUE;
#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2)
@@ -34,7 +34,7 @@ static GLboolean UseObj = GL_FALSE;
static void draw( void )
{
glDepthFunc(GL_EQUAL);
/* glDepthFunc(GL_EQUAL); */
/* glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );*/
glClear( GL_COLOR_BUFFER_BIT );
@@ -147,7 +147,7 @@ static void init( void )
0, 0, 2, 2, 2, 2, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
GLubyte tex[64][3];
GLubyte tex[64][4];
GLint i, j;
@@ -156,7 +156,7 @@ static void init( void )
/* Setup texturing */
glEnable( GL_TEXTURE_2D );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
/* glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); */
/* generate texture object IDs */
@@ -174,7 +174,7 @@ static void init( void )
if (UseObj) {
#ifdef TEXTURE_OBJECT
glBindTexture( GL_TEXTURE_2D, TexObj[0] );
assert(glIsTexture(TexObj[0]));
/* assert(glIsTexture(TexObj[0])); */
#endif
}
else {
@@ -190,11 +190,12 @@ static void init( void )
else {
tex[p][0] = 255; tex[p][1] = 255; tex[p][2] = 255;
}
tex[p][3] = 255;
}
}
glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
GL_RGB, GL_UNSIGNED_BYTE, tex );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, tex );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
@@ -208,9 +209,9 @@ static void init( void )
if (UseObj) {
#ifdef TEXTURE_OBJECT
glBindTexture( GL_TEXTURE_2D, TexObj[1] );
assert(glIsTexture(TexObj[1]));
/* assert(glIsTexture(TexObj[1])); */
#endif
assert(!glIsTexture(TexObj[1] + 999));
/* assert(!glIsTexture(TexObj[1] + 999)); */
}
else {
glNewList( TexObj[1], GL_COMPILE );
@@ -227,8 +228,8 @@ static void init( void )
}
}
}
glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
GL_RGB, GL_UNSIGNED_BYTE, tex );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, tex );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );

View File

@@ -498,7 +498,7 @@ main(int ac, char **av)
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_FOG);
/* glEnable(GL_FOG); */
glFogi(GL_FOG_MODE, GL_EXP2);
glFogfv(GL_FOG_COLOR, fogcolor);

28
progs/samples/Makefile Normal file
View File

@@ -0,0 +1,28 @@
PROGS = prim \
star \
line \
point \
depth \
tri \
bitmap1 \
bitmap2
##### RULES #####
.SUFFIXES:
.SUFFIXES: .c
# make executable from .c file:
.c: $(LIB_DEP)
gcc -I../include -g $< -L../lib -lglut -lGL -lm -o $@
default: $(PROGS)
clean:
-rm *.o *~

View File

@@ -104,7 +104,7 @@ static void Init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearIndex(0.0);
/* glClearIndex(0.0); */
}
static void Reshape(int width, int height)
@@ -140,14 +140,14 @@ static void Draw(void)
mapIA[0] = 1.0;
mapIA[1] = 1.0;
glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 2, mapIR);
glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 2, mapI);
glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 2, mapI);
glPixelMapfv(GL_PIXEL_MAP_I_TO_A, 2, mapIA);
glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
/* glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 2, mapIR); */
/* glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 2, mapI); */
/* glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 2, mapI); */
/* glPixelMapfv(GL_PIXEL_MAP_I_TO_A, 2, mapIA); */
/* glPixelTransferi(GL_MAP_COLOR, GL_TRUE); */
SetColor(COLOR_WHITE);
glRasterPos3fv(boxA);
glRasterPos2fv(boxA);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 24);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 8);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 2);
@@ -162,28 +162,28 @@ static void Draw(void)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
SetColor(COLOR_WHITE);
glRasterPos3fv(boxB);
glRasterPos2fv(boxB);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0,
OpenGL_bits1);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0,
OpenGL_bits2);
SetColor(COLOR_YELLOW);
glRasterPos3fv(boxC);
glRasterPos2fv(boxC);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0,
OpenGL_bits1);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0,
OpenGL_bits2);
SetColor(COLOR_CYAN);
glRasterPos3fv(boxD);
glRasterPos2fv(boxD);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0,
OpenGL_bits1);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0,
OpenGL_bits2);
SetColor(COLOR_RED);
glRasterPos3fv(boxE);
glRasterPos2fv(boxE);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0,
OpenGL_bits1);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, OPENGL_WIDTH, 0.0, OPENGL_WIDTH, 0.0,

View File

@@ -620,19 +620,19 @@ static void Init(void)
GLint i;
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearIndex(0.0);
/* glClearIndex(0.0); */
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
for (i = 0; i < 7; i++) {
exp_lists[i] = glGenLists(1);
glNewList(exp_lists[i], GL_COMPILE);
glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]);
glEndList();
/* exp_lists[i] = glGenLists(1); */
/* glNewList(exp_lists[i], GL_COMPILE); */
/* glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]); */
/* glEndList(); */
}
abuse = GL_FALSE;
useLists = GL_TRUE;
useLists = GL_FALSE;
}
static void Reshape(int width, int height)
@@ -696,10 +696,10 @@ static void Draw(void)
SetColor(COLOR_RED);
break;
}
glRasterPos3i((j*3)%5, (j*3)%8, 0);
glRasterPos2i((j*3)%5, (j*3)%8);
if (useLists) {
glCallList(exp_lists[i]);
/* glCallList(exp_lists[i]); */
} else {
glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]);
}
@@ -714,9 +714,9 @@ static void Draw(void)
for (j = 0; j < 40; j++) {
SetColor(COLOR_BLACK);
glRasterPos3i((j*3)%5, (j*3)%8, 0);
glRasterPos2i((j*3)%5, (j*3)%8);
if (useLists) {
glCallList(exp_lists[i]);
/* glCallList(exp_lists[i]); */
} else {
glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]);
}

View File

@@ -147,7 +147,7 @@ static void Draw(void)
glVertex3fv(pntB);
glEnd();
glPointSize(1);
/* glPointSize(1); */
SetColor(COLOR_GREEN);
glBegin(GL_POINTS);

View File

@@ -151,7 +151,7 @@ static void Draw(void)
glDisable(GL_POINT_SMOOTH);
}
glPointSize(size);
/* glPointSize(size); */
if (mode) {
(rgb) ? glColor3f(1.0, 0.0, 0.0) : glIndexf(CI_ANTI_ALIAS_RED);
} else {
@@ -164,7 +164,7 @@ static void Draw(void)
glDisable(GL_POINT_SMOOTH);
glDisable(GL_BLEND);
glPointSize(1);
/* glPointSize(1); */
SetColor(COLOR_GREEN);
glBegin(GL_POINTS);
glVertex3fv(point);

View File

@@ -52,27 +52,27 @@ static void Reshape(int width, int height)
windH = (GLint)height;
}
static void RotateColorMask(void)
static void RotateRestoreColorMask( int rotate )
{
static GLint rotation = 0;
rotation = (rotation + 1) & 0x3;
if (rotate) rotation = (rotation + 1) & 0x3;
switch (rotation) {
case 0:
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glIndexMask( 0xff );
/* glIndexMask( 0xff ); */
break;
case 1:
glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
glIndexMask(0xFE);
/* glIndexMask(0xFE); */
break;
case 2:
glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE);
glIndexMask(0xFD);
/* glIndexMask(0xFD); */
break;
case 3:
glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE);
glIndexMask(0xFB);
/* glIndexMask(0xFB); */
break;
}
}
@@ -90,7 +90,7 @@ static void Key(unsigned char key, int x, int y)
mode2 = !mode2;
break;
case '3':
RotateColorMask();
RotateRestoreColorMask( 1 );
break;
default:
return;
@@ -344,7 +344,7 @@ static void Rect(void)
{
SetColor(COLOR_GREEN);
glRecti(-boxW/4, -boxH/4, boxW/4, boxH/4);
/* glRecti(-boxW/4, -boxH/4, boxW/4, boxH/4); */
}
static void PolygonFunc(void)
@@ -445,15 +445,16 @@ static void Draw(void)
glViewport(0, 0, windW, windH);
glDisable(GL_SCISSOR_TEST);
glPushAttrib(GL_COLOR_BUFFER_BIT);
/* glPushAttrib(GL_COLOR_BUFFER_BIT); */
glColorMask(1, 1, 1, 1);
glIndexMask(~0);
/* glIndexMask(~0); */
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glPopAttrib();
/* glPopAttrib(); */
RotateRestoreColorMask( 0 );
if (mode1) {
glShadeModel(GL_SMOOTH);
@@ -461,11 +462,11 @@ static void Draw(void)
glShadeModel(GL_FLAT);
}
if (mode2) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
} else {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
/* if (mode2) { */
/* glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); */
/* } else { */
/* glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); */
/* } */
Viewport(0, 0); Point();
Viewport(0, 1); Lines();
@@ -478,10 +479,13 @@ static void Draw(void)
Viewport(1, 2); Triangles();
Viewport(1, 3); TriangleStrip();
Viewport(2, 0); Rect();
Viewport(2, 1); PolygonFunc();
Viewport(2, 2); Quads();
Viewport(2, 3); QuadStrip();
if (0) {
}
glFlush();

View File

@@ -279,11 +279,11 @@ static void Draw(void)
if (showVerticies) {
(rgb) ? glColor3fv(RGBMap[COLOR_RED]) : glIndexf(color1);
glRectf(p0[0]-2, p0[1]-2, p0[0]+2, p0[1]+2);
/* glRectf(p0[0]-2, p0[1]-2, p0[0]+2, p0[1]+2); */
(rgb) ? glColor3fv(RGBMap[COLOR_GREEN]) : glIndexf(color2);
glRectf(p1[0]-2, p1[1]-2, p1[0]+2, p1[1]+2);
/* glRectf(p1[0]-2, p1[1]-2, p1[0]+2, p1[1]+2); */
(rgb) ? glColor3fv(RGBMap[COLOR_BLUE]) : glIndexf(color3);
glRectf(p2[0]-2, p2[1]-2, p2[0]+2, p2[1]+2);
/* glRectf(p2[0]-2, p2[1]-2, p2[0]+2, p2[1]+2); */
}
glPopMatrix();
@@ -306,7 +306,7 @@ static void Draw(void)
glScalef(zoom, zoom, zoom);
glRotatef(zRotation, 0,0,1);
glPointSize(10);
/* glPointSize(10); */
glLineWidth(5);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_STIPPLE);
@@ -322,7 +322,7 @@ static void Draw(void)
glVertex3fv(p2);
EndPrim();
glPointSize(1);
/* glPointSize(1); */
glLineWidth(1);
glDisable(GL_POINT_SMOOTH);
glDisable(GL_LINE_STIPPLE);

View File

@@ -6,26 +6,9 @@
CC = gcc
CFLAGS = -g -I../include
LIBS = -L../lib -lglut -lGLU -lGL -L/usr/X11R6/lib -lX11 -lXext -lm
LIBS = -L../lib -lGL -lglut -lm
PROGS = antialias \
cva \
dinoshade \
fogcoord \
getprocaddress \
manytex \
multipal \
projtex \
seccolor \
sharedtex \
stencilwrap \
texline \
texwrap \
vptest1 \
vptest2 \
vptest3 \
vptorus \
vpwarpmesh
PROGS = miniglxtest miniglxsample manytex
##### RULES #####
@@ -45,10 +28,3 @@ clean:
rm -f $(PROGS)
rm -f *.o
# auto code generation
getprocaddress: getprocaddress.c getproclist.h
getproclist.h: ../bin/APIspec getprocaddress.c getprocaddress.py
python getprocaddress.py > getproclist.h

478
progs/tests/glfbdevtest.c Normal file
View File

@@ -0,0 +1,478 @@
/* $Id: glfbdevtest.c,v 1.1.4.5 2002/11/27 00:26:59 brianp Exp $ */
/*
* Test the GLFBDev interface. Only tested with radeonfb driver!!!!
*/
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <linux/fb.h>
#include <linux/kd.h>
#include <linux/vt.h>
#include <GL/glut.h>
#include "GL/glfbdev.h"
#define DEFAULT_DEPTH 8
static struct fb_fix_screeninfo FixedInfo;
static struct fb_var_screeninfo VarInfo, OrigVarInfo;
static int DesiredDepth = 0;
static int OriginalVT = -1;
static int ConsoleFD = -1;
static int FrameBufferFD = -1;
static caddr_t FrameBuffer = (caddr_t) -1;
static caddr_t MMIOAddress = (caddr_t) -1;
static void
print_fixed_info(const struct fb_fix_screeninfo *fixed, const char *s)
{
static const char *visuals[] = {
"MONO01", "MONO10", "TRUECOLOR", "PSEUDOCOLOR",
"DIRECTCOLOR", "STATIC_PSEUDOCOLOR"
};
printf("%s info -----------------------\n", s);
printf("id = %16s\n", fixed->id);
printf("smem_start = 0x%x\n", fixed->smem_start);
printf("smem_len = %d (0x%x)\n", fixed->smem_len, fixed->smem_len);
printf("type = 0x%x\n", fixed->type);
printf("type_aux = 0x%x\n", fixed->type_aux);
printf("visual = 0x%x (%s)\n", fixed->visual, visuals[fixed->visual]);
printf("xpanstep = %d\n", fixed->xpanstep);
printf("ypanstep = %d\n", fixed->ypanstep);
printf("ywrapstep = %d\n", fixed->ywrapstep);
printf("line_length = %d\n", fixed->line_length);
printf("mmio_start = 0x%x\n", fixed->mmio_start);
printf("mmio_len = %d (0x%x)\n", fixed->mmio_len, fixed->mmio_len);
printf("accel = 0x%x\n", fixed->accel);
}
static void
print_var_info(const struct fb_var_screeninfo *var, const char *s)
{
printf("%s info -----------------------\n", s);
printf("xres = %d\n", var->xres);
printf("yres = %d\n", var->yres);
printf("xres_virtual = %d\n", var->xres_virtual);
printf("yres_virtual = %d\n", var->yres_virtual);
printf("xoffset = %d\n", var->xoffset);
printf("yoffset = %d\n", var->yoffset);
printf("bits_per_pixel = %d\n", var->bits_per_pixel);
printf("grayscale = %d\n", var->grayscale);
printf("red.offset = %d length = %d msb_right = %d\n",
var->red.offset, var->red.length, var->red.msb_right);
printf("green.offset = %d length = %d msb_right = %d\n",
var->green.offset, var->green.length, var->green.msb_right);
printf("blue.offset = %d length = %d msb_right = %d\n",
var->blue.offset, var->blue.length, var->blue.msb_right);
printf("transp.offset = %d length = %d msb_right = %d\n",
var->transp.offset, var->transp.length, var->transp.msb_right);
printf("nonstd = %d\n", var->nonstd);
printf("activate = %d\n", var->activate);
printf("height = %d mm\n", var->height);
printf("width = %d mm\n", var->width);
printf("accel_flags = 0x%x\n", var->accel_flags);
printf("pixclock = %d\n", var->pixclock);
printf("left_margin = %d\n", var->left_margin);
printf("right_margin = %d\n", var->right_margin);
printf("upper_margin = %d\n", var->upper_margin);
printf("lower_margin = %d\n", var->lower_margin);
printf("hsync_len = %d\n", var->hsync_len);
printf("vsync_len = %d\n", var->vsync_len);
printf("sync = %d\n", var->sync);
printf("vmode = %d\n", var->vmode);
}
static void
signal_handler(int signumber)
{
signal(signumber, SIG_IGN); /* prevent recursion! */
fprintf(stderr, "error: got signal %d (exiting)\n", signumber);
exit(1);
}
static void
initialize_fbdev( void )
{
char ttystr[1000];
int fd, vtnumber, ttyfd;
int sz;
if (geteuid()) {
fprintf(stderr, "error: you need to be root\n");
exit(1);
}
#if 1
/* open the framebuffer device */
FrameBufferFD = open("/dev/fb0", O_RDWR);
if (FrameBufferFD < 0) {
fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno));
exit(1);
}
#endif
/* open /dev/tty0 and get the vt number */
if ((fd = open("/dev/tty0", O_WRONLY, 0)) < 0) {
fprintf(stderr, "error opening /dev/tty0\n");
exit(1);
}
if (ioctl(fd, VT_OPENQRY, &vtnumber) < 0 || vtnumber < 0) {
fprintf(stderr, "error: couldn't get a free vt\n");
exit(1);
}
close(fd);
/* open the console tty */
sprintf(ttystr, "/dev/tty%d", vtnumber); /* /dev/tty1-64 */
ConsoleFD = open(ttystr, O_RDWR | O_NDELAY, 0);
if (ConsoleFD < 0) {
fprintf(stderr, "error couldn't open console fd\n");
exit(1);
}
/* save current vt number */
{
struct vt_stat vts;
if (ioctl(ConsoleFD, VT_GETSTATE, &vts) == 0)
OriginalVT = vts.v_active;
}
/* disconnect from controlling tty */
ttyfd = open("/dev/tty", O_RDWR);
if (ttyfd >= 0) {
ioctl(ttyfd, TIOCNOTTY, 0);
close(ttyfd);
}
/* some magic to restore the vt when we exit */
{
struct vt_mode vt;
if (ioctl(ConsoleFD, VT_ACTIVATE, vtnumber) != 0)
printf("ioctl VT_ACTIVATE: %s\n", strerror(errno));
if (ioctl(ConsoleFD, VT_WAITACTIVE, vtnumber) != 0)
printf("ioctl VT_WAITACTIVE: %s\n", strerror(errno));
if (ioctl(ConsoleFD, VT_GETMODE, &vt) < 0) {
fprintf(stderr, "error: ioctl VT_GETMODE: %s\n", strerror(errno));
exit(1);
}
vt.mode = VT_PROCESS;
vt.relsig = SIGUSR1;
vt.acqsig = SIGUSR1;
if (ioctl(ConsoleFD, VT_SETMODE, &vt) < 0) {
fprintf(stderr, "error: ioctl(VT_SETMODE) failed: %s\n",
strerror(errno));
exit(1);
}
}
/* go into graphics mode */
if (ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) {
fprintf(stderr, "error: ioctl(KDSETMODE, KD_GRAPHICS) failed: %s\n",
strerror(errno));
exit(1);
}
#if 0
/* open the framebuffer device */
FrameBufferFD = open("/dev/fb0", O_RDWR);
if (FrameBufferFD < 0) {
fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno));
exit(1);
}
#endif
/* Get the fixed screen info */
if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) {
fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
strerror(errno));
exit(1);
}
print_fixed_info(&FixedInfo, "Fixed");
/* get the variable screen info */
if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &OrigVarInfo)) {
fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
strerror(errno));
exit(1);
}
print_var_info(&OrigVarInfo, "Orig Var");
/* operate on a copy */
VarInfo = OrigVarInfo;
/* set the depth, resolution, etc */
DesiredDepth = 32;
if (DesiredDepth)
VarInfo.bits_per_pixel = DesiredDepth;
if (VarInfo.bits_per_pixel == 16) {
VarInfo.red.offset = 11;
VarInfo.green.offset = 5;
VarInfo.blue.offset = 0;
VarInfo.red.length = 5;
VarInfo.green.length = 6;
VarInfo.blue.length = 5;
VarInfo.transp.offset = 0;
VarInfo.transp.length = 0;
}
else if (VarInfo.bits_per_pixel == 32) {
VarInfo.red.offset = 16;
VarInfo.green.offset = 8;
VarInfo.blue.offset = 0;
VarInfo.transp.offset = 24;
VarInfo.red.length = 8;
VarInfo.green.length = 8;
VarInfo.blue.length = 8;
VarInfo.transp.length = 8;
}
/* timing values taken from /etc/fb.modes (1280x1024 @ 75Hz) */
VarInfo.xres_virtual = VarInfo.xres = 1280;
VarInfo.yres_virtual = VarInfo.yres = 1024;
VarInfo.pixclock = 7408;
VarInfo.left_margin = 248;
VarInfo.right_margin = 16;
VarInfo.upper_margin = 38;
VarInfo.lower_margin = 1;
VarInfo.hsync_len = 144;
VarInfo.vsync_len = 3;
VarInfo.xoffset = 0;
VarInfo.yoffset = 0;
VarInfo.nonstd = 0;
VarInfo.vmode &= ~FB_VMODE_YWRAP; /* turn off scrolling */
/* set new variable screen info */
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo)) {
fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
exit(1);
}
print_var_info(&VarInfo, "New Var");
if (FixedInfo.visual != FB_VISUAL_TRUECOLOR &&
FixedInfo.visual != FB_VISUAL_DIRECTCOLOR) {
fprintf(stderr, "non-TRUE/DIRECT-COLOR visuals (0x%x) not supported by this demo.\n", FixedInfo.visual);
exit(1);
}
/* initialize colormap */
if (FixedInfo.visual == FB_VISUAL_DIRECTCOLOR) {
struct fb_cmap cmap;
unsigned short red[256], green[256], blue[256];
int i;
/* we're assuming 256 entries here */
printf("initializing directcolor colormap\n");
cmap.start = 0;
cmap.len = 256;
cmap.red = red;
cmap.green = green;
cmap.blue = blue;
cmap.transp = NULL;
for (i = 0; i < cmap.len; i++) {
red[i] = green[i] = blue[i] = (i << 8) | i;
}
if (ioctl(FrameBufferFD, FBIOPUTCMAP, (void *) &cmap) < 0) {
fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i);
}
}
/*
* fbdev says the frame buffer is at offset zero, and the mmio region
* is immediately after.
*/
/* mmap the framebuffer into our address space */
FrameBuffer = (caddr_t) mmap(0, /* start */
FixedInfo.smem_len, /* bytes */
PROT_READ | PROT_WRITE, /* prot */
MAP_SHARED, /* flags */
FrameBufferFD, /* fd */
0 /* offset */);
if (FrameBuffer == (caddr_t) - 1) {
fprintf(stderr, "error: unable to mmap framebuffer: %s\n",
strerror(errno));
exit(1);
}
printf("FrameBuffer = %p\n", FrameBuffer);
#if 1
/* mmap the MMIO region into our address space */
MMIOAddress = (caddr_t) mmap(0, /* start */
FixedInfo.mmio_len, /* bytes */
PROT_READ | PROT_WRITE, /* prot */
MAP_SHARED, /* flags */
FrameBufferFD, /* fd */
FixedInfo.smem_len /* offset */);
if (MMIOAddress == (caddr_t) - 1) {
fprintf(stderr, "error: unable to mmap mmio region: %s\n",
strerror(errno));
}
printf("MMIOAddress = %p\n", MMIOAddress);
/* try out some simple MMIO register reads */
if (1)
{
typedef unsigned int CARD32;
typedef unsigned char CARD8;
#define RADEON_CONFIG_MEMSIZE 0x00f8
#define RADEON_MEM_SDRAM_MODE_REG 0x0158
#define MMIO_IN32(base, offset) \
*(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
#define INREG(addr) MMIO_IN32(MMIOAddress, addr)
int sz, type;
const char *typeStr[] = {"SDR", "DDR", "64-bit SDR"};
sz = INREG(RADEON_CONFIG_MEMSIZE);
type = INREG(RADEON_MEM_SDRAM_MODE_REG);
printf("RADEON_CONFIG_MEMSIZE = %d (%d MB)\n", sz, sz / 1024 / 1024);
printf("RADEON_MEM_SDRAM_MODE_REG >> 30 = %d (%s)\n",
type >> 30, typeStr[type>>30]);
}
#endif
}
static void
shutdown_fbdev( void )
{
struct vt_mode VT;
printf("cleaning up...\n");
/* restore original variable screen info */
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo)) {
fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
exit(1);
}
munmap(MMIOAddress, FixedInfo.mmio_len);
munmap(FrameBuffer, FixedInfo.smem_len);
close(FrameBufferFD);
/* restore text mode */
ioctl(ConsoleFD, KDSETMODE, KD_TEXT);
/* set vt */
if (ioctl(ConsoleFD, VT_GETMODE, &VT) != -1) {
VT.mode = VT_AUTO;
ioctl(ConsoleFD, VT_SETMODE, &VT);
}
/* restore original vt */
if (OriginalVT >= 0) {
ioctl(ConsoleFD, VT_ACTIVATE, OriginalVT);
OriginalVT = -1;
}
close(ConsoleFD);
}
static void
gltest( void )
{
static const int attribs[] = {
GLFBDEV_DOUBLE_BUFFER,
GLFBDEV_DEPTH_SIZE, 16,
GLFBDEV_NONE
};
GLFBDevContextPtr ctx;
GLFBDevBufferPtr buf;
GLFBDevVisualPtr vis;
int bytes, r, g, b, a;
float ang;
printf("GLFBDEV_VENDOR = %s\n", glFBDevGetString(GLFBDEV_VENDOR));
printf("GLFBDEV_VERSION = %s\n", glFBDevGetString(GLFBDEV_VERSION));
/* framebuffer size */
bytes = VarInfo.xres_virtual * VarInfo.yres_virtual * VarInfo.bits_per_pixel / 8;
vis = glFBDevCreateVisual( &FixedInfo, &VarInfo, attribs );
assert(vis);
buf = glFBDevCreateBuffer( &FixedInfo, &VarInfo, vis, FrameBuffer, NULL, bytes );
assert(buf);
ctx = glFBDevCreateContext( vis, NULL );
assert(buf);
b = glFBDevMakeCurrent( ctx, buf, buf );
assert(b);
/*printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));*/
glGetIntegerv(GL_RED_BITS, &r);
glGetIntegerv(GL_GREEN_BITS, &g);
glGetIntegerv(GL_BLUE_BITS, &b);
glGetIntegerv(GL_ALPHA_BITS, &a);
printf("RED_BITS=%d GREEN_BITS=%d BLUE_BITS=%d ALPHA_BITS=%d\n",
r, g, b, a);
glClearColor(0.5, 0.5, 1.0, 0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1, 1, -1, 1, 2, 30);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -15);
glViewport(0, 0, VarInfo.xres_virtual, VarInfo.yres_virtual);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
for (ang = 0; ang <= 180; ang += 15) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(ang, 1, 0, 0);
glutSolidTorus(1, 3, 40, 20);
glPopMatrix();
glFBDevSwapBuffers(buf);
}
/* clean up */
b = glFBDevMakeCurrent( NULL, NULL, NULL);
assert(b);
glFBDevDestroyContext(ctx);
glFBDevDestroyBuffer(buf);
glFBDevDestroyVisual(vis);
}
int
main( int argc, char *argv[] )
{
signal(SIGUSR1, signal_handler); /* exit if someone tries a vt switch */
signal(SIGSEGV, signal_handler); /* catch segfaults */
initialize_fbdev();
gltest();
shutdown_fbdev();
return 0;
}

125
progs/tests/miniglxsample.c Normal file
View File

@@ -0,0 +1,125 @@
#define USE_MINIGLX 1 /* 1 = use Mini GLX, 0 = use Xlib/GLX */
#include <stdio.h>
#include <stdlib.h>
#include <GL/gl.h>
#if USE_MINIGLX
#include <GL/miniglx.h>
#else
#include <GL/glx.h>
#include <X11/Xlib.h>
#endif
static void _subset_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
{
glBegin( GL_QUADS );
glVertex2f( x1, y1 );
glVertex2f( x2, y1 );
glVertex2f( x2, y2 );
glVertex2f( x1, y2 );
glEnd();
}
/*
* Create a simple double-buffered RGBA window.
*/
static Window
MakeWindow(Display * dpy, unsigned int width, unsigned int height)
{
int visAttributes[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None
};
XSetWindowAttributes attr;
unsigned long attrMask;
Window root;
Window win;
GLXContext ctx;
XVisualInfo *visinfo;
root = RootWindow(dpy, 0);
/* Choose GLX visual / pixel format */
visinfo = glXChooseVisual(dpy, 0, visAttributes);
if (!visinfo) {
printf("Error: couldn't get an RGB, Double-buffered visual\n");
exit(1);
}
/* Create the window */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attrMask = CWBackPixel | CWBorderPixel | CWColormap;
win = XCreateWindow(dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, attrMask, &attr);
if (!win) {
printf("Error: XCreateWindow failed\n");
exit(1);
}
/* Display the window */
XMapWindow(dpy, win);
/* Create GLX rendering context */
ctx = glXCreateContext(dpy, visinfo, NULL, True);
if (!ctx) {
printf("Error: glXCreateContext failed\n");
exit(1);
}
/* Bind the rendering context and window */
glXMakeCurrent(dpy, win, ctx);
return win;
}
/*
* Draw a few frames of a rotating square.
*/
static void
DrawFrames(Display * dpy, Window win)
{
int angle;
glShadeModel(GL_FLAT);
glClearColor(0.5, 0.5, 0.5, 1.0);
for (angle = 0; angle < 360; angle += 10) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 0.0);
glPushMatrix();
glRotatef(angle, 0, 0, 1);
_subset_Rectf(-0.8, -0.8, 0.8, 0.8);
glPopMatrix();
glXSwapBuffers(dpy, win);
sleep(1);
}
}
int
main(int argc, char *argv[])
{
Display *dpy;
Window win;
dpy = XOpenDisplay(NULL);
if (!dpy) {
printf("Error: XOpenDisplay failed\n");
return 1;
}
win = MakeWindow(dpy, 300, 300);
DrawFrames(dpy, win);
return 0;
}

197
progs/tests/miniglxtest.c Normal file
View File

@@ -0,0 +1,197 @@
/* $Id: miniglxtest.c,v 1.1.4.7 2003/02/21 22:18:24 keithw Exp $ */
/*
* Test the mini GLX interface.
*/
#include <stdio.h>
#include <stdlib.h>
#include <GL/gl.h>
#define USE_MINI_GLX 1
#if USE_MINI_GLX
#include <GL/miniglx.h>
#else
#include <GL/glx.h>
#endif
#define FRONTBUFFER 1
#define NR 6
#define DO_SLEEPS 1
#define NR_DISPLAYS 2
GLXContext ctx;
static void _subset_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
{
glBegin( GL_QUADS );
glVertex2f( x1, y1 );
glVertex2f( x2, y1 );
glVertex2f( x2, y2 );
glVertex2f( x1, y2 );
glEnd();
}
static void redraw( Display *dpy, Window w, int rot )
{
printf("Redraw event\n");
#if FRONTBUFFER
glDrawBuffer( GL_FRONT );
#else
/* glDrawBuffer( GL_BACK ); */
#endif
glClearColor( rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX,
1);
glClear( GL_COLOR_BUFFER_BIT );
#if 1
glColor3f( rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX,
rand()/(float)RAND_MAX );
glPushMatrix();
glRotatef(rot, 0, 0, 1);
glScalef(.5, .5, .5);
_subset_Rectf( -1, -1, 1, 1 );
glPopMatrix();
#endif
#if FRONTBUFFER
glFlush();
#else
glXSwapBuffers( dpy, w );
#endif
glFinish();
}
static Window make_rgb_db_window( Display *dpy,
unsigned int width, unsigned int height )
{
int attrib[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
#if !FRONT_BUFFER
GLX_DOUBLEBUFFER,
#endif
None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
Window win;
XVisualInfo *visinfo;
scrnum = 0;
root = RootWindow( dpy, scrnum );
visinfo = glXChooseVisual( dpy, scrnum, attrib );
if (!visinfo) {
printf("Error: couldn't get an RGB, Double-buffered visual\n");
exit(1);
}
ctx = glXCreateContext( dpy, visinfo, NULL, True );
if (!ctx) {
printf("Error: glXCreateContext failed\n");
exit(1);
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr );
if (!win) {
printf("Error: XCreateWindow failed\n");
exit(1);
}
glXMakeCurrent( dpy, win, ctx );
return win;
}
static void event_loop( Display *dpy, Window win )
{
int i;
printf("Hang on... drawing %d frames\n", NR);
for (i = 0; i < NR; i++) {
redraw( dpy, win, i*10 );
if (DO_SLEEPS) {
printf("sleep(1)\n");
sleep(1);
}
}
}
int foo( )
{
Display *dpy;
Window win;
dpy = XOpenDisplay(NULL);
if (!dpy) {
printf("Error: XOpenDisplay failed\n");
return 1;
}
win = make_rgb_db_window( dpy, 800, 600);
srand(getpid());
glShadeModel( GL_FLAT );
glClearColor( 0.5, 0.5, 0.5, 1.0 );
XMapWindow( dpy, win );
#if !USE_MINI_GLX
{
XEvent e;
while (1) {
XNextEvent( dpy, &e );
if (e.type == MapNotify && e.xmap.window == win) {
break;
}
}
}
#endif
event_loop( dpy, win );
glXDestroyContext( dpy, ctx );
XDestroyWindow( dpy, win );
XCloseDisplay( dpy );
return 0;
}
int main()
{
int i;
for (i = 0 ; i < NR_DISPLAYS ; i++) {
if (foo() != 0)
break;
}
return 0;
}

35
progs/xdemos/Makefile Normal file
View File

@@ -0,0 +1,35 @@
# Simple makefile for compiling test programs on Linux
# These programs aren't intended to be included with the normal
# distro. They're not too interesting but they're good for testing.
CC = gcc
CFLAGS = -g -I../include
LIBS = -L../lib -lGL -lm
PROGS = glxgears
##### RULES #####
.SUFFIXES:
.SUFFIXES: .c
.c:
$(CC) $(CFLAGS) $< $(LIBS) -o $@
##### TARGETS #####
default: $(PROGS)
clean:
rm -f $(PROGS)
rm -f *.o

View File

@@ -33,10 +33,16 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/gl.h>
#define USE_MINI_GLX 1
#if USE_MINI_GLX
#include <GL/miniglx.h>
#else
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <GL/gl.h>
#include <GL/glx.h>
#endif
#define BENCHMARK
@@ -346,13 +352,18 @@ make_window( Display *dpy, const char *name,
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
attr.event_mask = StructureNotifyMask | ExposureMask
#if !USE_MINI_GLX
| KeyPressMask
#endif
;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr );
#if !USE_MINI_GLX
/* set hints and properties */
{
XSizeHints sizehints;
@@ -365,6 +376,7 @@ make_window( Display *dpy, const char *name,
XSetStandardProperties(dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
}
#endif
ctx = glXCreateContext( dpy, visinfo, NULL, True );
if (!ctx) {
@@ -382,7 +394,12 @@ make_window( Display *dpy, const char *name,
static void
event_loop(Display *dpy, Window win)
{
#if USE_MINI_GLX
reshape(300, 300);
#endif
while (1) {
#if !USE_MINI_GLX
while (XPending(dpy) > 0) {
XEvent event;
XNextEvent(dpy, &event);
@@ -421,6 +438,7 @@ event_loop(Display *dpy, Window win)
}
}
}
#endif
/* next frame */
angle += 2.0;

37
src/dri-es/Makefile Normal file
View File

@@ -0,0 +1,37 @@
# $Id: Makefile,v 1.1.2.2 2003/03/04 17:29:55 keithw Exp $
# Mesa 3-D graphics library
# Version: 5.0
# Copyright (C) 1995-2002 Brian Paul
MESA = ../..
default: dri.a
include $(MESA)/Makefile.include
INCLUDES = -I/usr/X11R6/include -I/usr/X11R6/include/X11/extensions -I$(MESA)/include -I. -I..
DEFINES =
C_SOURCES = dri_glx.c \
dri_util.c \
xf86drm.c \
xf86drmHash.c \
xf86drmRandom.c \
xf86drmSL.c
ASM_SOURCES =
OBJECTS = $(C_SOURCES:.c=.o) \
$(ASM_SOURCES:.S=.o)
##### TARGETS #####
dri.a: $(OBJECTS) Makefile
rm -f $@ && ar rcv $@ $(OBJECTS) && ranlib $@
##### DEPENDENCIES #####
-include $(C_SOURCES:.c=.d)

472
src/dri-es/dri_glx.c Normal file
View File

@@ -0,0 +1,472 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
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.
**************************************************************************/
/* $XFree86: xc/lib/GL/dri/dri_glx.c,v 1.10 2001/08/27 17:40:57 dawes Exp $ */
/*
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
* Brian Paul <brian@precisioninsight.com>
*
*/
#include <unistd.h>
#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
#include "extutil.h"
#include "glxclient.h"
#include "xf86dri.h"
#include "sarea.h"
#include <stdio.h>
#include <dlfcn.h>
#include "dri_glx.h"
#include <sys/types.h>
#include <stdarg.h>
#ifdef BUILT_IN_DRI_DRIVER
extern void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config);
#else /* BUILT_IN_DRI_DRIVER */
#ifndef DEFAULT_DRIVER_DIR
/* this is normally defined in the Imakefile */
#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
#endif
static __DRIdriver *Drivers = NULL;
/*
* printf wrappers
*/
static void InfoMessageF(const char *f, ...)
{
va_list args;
const char *env;
if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) {
fprintf(stderr, "libGL: ");
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
}
}
static void ErrorMessageF(const char *f, ...)
{
va_list args;
if (getenv("LIBGL_DEBUG")) {
fprintf(stderr, "libGL error: ");
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
}
}
/*
* We'll save a pointer to this function when we couldn't find a
* direct rendering driver for a given screen.
*/
static void *DummyCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config)
{
(void) dpy;
(void) scrn;
(void) psc;
(void) numConfigs;
(void) config;
return NULL;
}
/*
* Extract the ith directory path out of a colon-separated list of
* paths.
* Input:
* index - index of path to extract (starting at zero)
* paths - the colon-separated list of paths
* dirLen - max length of result to store in <dir>
* Output:
* dir - the extracted directory path, dir[0] will be zero when
* extraction fails.
*/
static void ExtractDir(int index, const char *paths, int dirLen, char *dir)
{
int i, len;
const char *start, *end;
/* find ith colon */
start = paths;
i = 0;
while (i < index) {
if (*start == ':') {
i++;
start++;
}
else if (*start == 0) {
/* end of string and couldn't find ith colon */
dir[0] = 0;
return;
}
else {
start++;
}
}
while (*start == ':')
start++;
/* find next colon, or end of string */
end = start + 1;
while (*end != ':' && *end != 0) {
end++;
}
/* copy string between <start> and <end> into result string */
len = end - start;
if (len > dirLen - 1)
len = dirLen - 1;
strncpy(dir, start, len);
dir[len] = 0;
}
/*
* Try to dlopen() the named driver. This function adds the
* "_dri.so" suffix to the driver name and searches the
* directories specified by the LIBGL_DRIVERS_PATH env var
* in order to find the driver.
* Input:
* driverName - a name like "tdfx", "i810", "mga", etc.
* Return:
* handle from dlopen, or NULL if driver file not found.
*/
static __DRIdriver *OpenDriver(const char *driverName)
{
char *libPaths = NULL;
int i;
__DRIdriver *driver;
/* First, search Drivers list to see if we've already opened this driver */
for (driver = Drivers; driver; driver = driver->next) {
if (strcmp(driver->name, driverName) == 0) {
/* found it */
return driver;
}
}
if (geteuid() == getuid()) {
/* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
libPaths = getenv("LIBGL_DRIVERS_PATH");
if (!libPaths)
libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */
}
if (!libPaths)
libPaths = DEFAULT_DRIVER_DIR;
for (i = 0; ; i++) {
char libDir[1000], realDriverName[200];
void *handle;
ExtractDir(i, libPaths, 1000, libDir);
if (!libDir[0])
break; /* ran out of paths to search */
snprintf(realDriverName, 200, "%s/%s_dri.so", libDir, driverName);
InfoMessageF("OpenDriver: trying %s\n", realDriverName);
handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
if (handle) {
/* allocate __DRIdriver struct */
driver = (__DRIdriver *) Xmalloc(sizeof(__DRIdriver));
if (!driver)
return NULL; /* out of memory! */
/* init the struct */
driver->name = __glXstrdup(driverName);
if (!driver->name) {
Xfree(driver);
return NULL; /* out of memory! */
}
driver->createScreenFunc = (CreateScreenFunc)
dlsym(handle, "__driCreateScreen");
if (!driver->createScreenFunc) {
/* If the driver doesn't have this symbol then something's
* really, really wrong.
*/
ErrorMessageF("__driCreateScreen() not defined in %s_dri.so!\n",
driverName);
Xfree(driver);
dlclose(handle);
continue;
}
driver->registerExtensionsFunc = (RegisterExtensionsFunc)
dlsym(handle, "__driRegisterExtensions");
driver->handle = handle;
/* put at head of linked list */
driver->next = Drivers;
Drivers = driver;
return driver;
}
else {
ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
}
}
ErrorMessageF("unable to find driver: %s_dri.so\n", driverName);
return NULL;
}
/*
* Given a display pointer and screen number, determine the name of
* the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
* Return True for success, False for failure.
*/
static Bool GetDriverName(Display *dpy, int scrNum, char **driverName)
{
int directCapable;
Bool b;
int driverMajor, driverMinor, driverPatch;
*driverName = NULL;
if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) {
ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed");
return False;
}
if (!directCapable) {
ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false");
return False;
}
b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor,
&driverPatch, driverName);
if (!b) {
ErrorMessageF("Cannot determine driver name for screen %d\n", scrNum);
return False;
}
InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
driverMajor, driverMinor, driverPatch, *driverName, scrNum);
return True;
}
/*
* Given a display pointer and screen number, return a __DRIdriver handle.
* Return NULL if anything goes wrong.
*/
__DRIdriver *driGetDriver(Display *dpy, int scrNum)
{
char *driverName;
if (GetDriverName(dpy, scrNum, &driverName)) {
return OpenDriver(driverName);
}
return NULL;
}
#endif /* BUILT_IN_DRI_DRIVER */
/* This function isn't currently used.
*/
static void driDestroyDisplay(Display *dpy, void *private)
{
__DRIdisplayPrivate *pdpyp = (__DRIdisplayPrivate *)private;
if (pdpyp) {
const int numScreens = ScreenCount(dpy);
int i;
for (i = 0; i < numScreens; i++) {
if (pdpyp->libraryHandles[i])
dlclose(pdpyp->libraryHandles[i]);
}
Xfree(pdpyp->libraryHandles);
Xfree(pdpyp);
}
}
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
* display pointer.
*/
void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
{
const int numScreens = ScreenCount(dpy);
__DRIdisplayPrivate *pdpyp;
int eventBase, errorBase;
int major, minor, patch;
int scrn;
/* Initialize these fields to NULL in case we fail.
* If we don't do this we may later get segfaults trying to free random
* addresses when the display is closed.
*/
pdisp->private = NULL;
pdisp->destroyDisplay = NULL;
pdisp->createScreen = NULL;
if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) {
return NULL;
}
if (!XF86DRIQueryVersion(dpy, &major, &minor, &patch)) {
return NULL;
}
pdpyp = (__DRIdisplayPrivate *)Xmalloc(sizeof(__DRIdisplayPrivate));
if (!pdpyp) {
return NULL;
}
pdpyp->driMajor = major;
pdpyp->driMinor = minor;
pdpyp->driPatch = patch;
pdisp->destroyDisplay = driDestroyDisplay;
/* allocate array of pointers to createScreen funcs */
pdisp->createScreen = (CreateScreenFunc *) Xmalloc(numScreens * sizeof(void *));
if (!pdisp->createScreen) {
XFree(pdpyp);
return NULL;
}
/* allocate array of library handles */
pdpyp->libraryHandles = (void **) Xmalloc(numScreens * sizeof(void*));
if (!pdpyp->libraryHandles) {
Xfree(pdisp->createScreen);
XFree(pdpyp);
return NULL;
}
#ifdef BUILT_IN_DRI_DRIVER
/* we'll statically bind to the built-in __driCreateScreen function */
for (scrn = 0; scrn < numScreens; scrn++) {
pdisp->createScreen[scrn] = __driCreateScreen;
pdpyp->libraryHandles[scrn] = NULL;
}
#else
/* dynamically discover DRI drivers for all screens, saving each
* driver's "__driCreateScreen" function pointer. That's the bootstrap
* entrypoint for all DRI drivers.
*/
__glXRegisterExtensions();
for (scrn = 0; scrn < numScreens; scrn++) {
__DRIdriver *driver = driGetDriver(dpy, scrn);
if (driver) {
pdisp->createScreen[scrn] = driver->createScreenFunc;
pdpyp->libraryHandles[scrn] = driver->handle;
}
else {
pdisp->createScreen[scrn] = DummyCreateScreen;
pdpyp->libraryHandles[scrn] = NULL;
}
}
#endif
return (void *)pdpyp;
}
/*
** Here we'll query the DRI driver for each screen and let each
** driver register its GL extension functions. We only have to
** do this once.
**
** In older versions of libGL (prior to October 2002) we _always_
** called this function during libGL start-up. Now, we only call
** it from glXGetProcAddress() as a last resort.
**
** Two key things changed along the way:
** 1. _glapi_get_proc_address() now generates new dispatch stub functions
** anytime it gets an unknown "gl*" function name. I.e. we always return
** a valid function address and later patch it up to use the correct
** dispatch offset.
** 2. The GL API dispatch table is a fixed size (with plenty of extra slots).
** This means we don't have to register all new functions before we create
** the first dispatch table.
*/
void
__glXRegisterExtensions(void)
{
#ifndef BUILT_IN_DRI_DRIVER
static GLboolean alreadyCalled = GL_FALSE;
int displayNum, maxDisplays;
if (alreadyCalled)
return;
alreadyCalled = GL_TRUE;
if (getenv("LIBGL_MULTIHEAD")) {
/* we'd like to always take this path but doing so causes a second
* or more of delay while the XOpenDisplay() function times out.
*/
maxDisplays = 10; /* infinity, really */
}
else {
/* just open the :0 display */
maxDisplays = 1;
}
for (displayNum = 0; displayNum < maxDisplays; displayNum++) {
char displayName[200];
Display *dpy;
snprintf(displayName, 199, ":%d.0", displayNum);
dpy = XOpenDisplay(displayName);
if (dpy) {
const int numScreens = ScreenCount(dpy);
int screenNum;
for (screenNum = 0; screenNum < numScreens; screenNum++) {
__DRIdriver *driver = driGetDriver(dpy, screenNum);
if (driver && driver->registerExtensionsFunc) {
(*driver->registerExtensionsFunc)();
}
}
XCloseDisplay(dpy);
}
else {
break;
}
}
#endif
}

59
src/dri-es/dri_glx.h Normal file
View File

@@ -0,0 +1,59 @@
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
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 <kevin@precisioninsight.com>
* Brian Paul <brian@precisioninsight.com>
*
*/
#ifndef _DRI_GLX_H_
#define _DRI_GLX_H_
struct __DRIdisplayPrivateRec {
/*
** XFree86-DRI version information
*/
int driMajor;
int driMinor;
int driPatch;
/*
** Array of library handles [indexed by screen number]
*/
void **libraryHandles;
};
typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
typedef struct __DRIvisualPrivateRec __DRIvisualPrivate;
typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
#endif /* _DRI_GLX_H_ */

1109
src/dri-es/dri_util.c Normal file

File diff suppressed because it is too large Load Diff

375
src/dri-es/dri_util.h Normal file
View File

@@ -0,0 +1,375 @@
/* $XFree86$ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
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 <kevin@precisioninsight.com>
* Brian Paul <brian@precisioninsight.com>
*/
/*
* This module acts as glue between GLX and the actual hardware driver.
* A DRI driver doesn't really _have_ to use any of this - it's optional.
* But, some useful stuff is done here that otherwise would have to be
* duplicated in most drivers.
*
* Basically, these utility functions take care of some of the dirty details
* of screen initialization, context creation, context binding, DRM setup,
* etc.
*
* These functions are compiled into each DRI driver so libGL.so knows
* nothing about them.
*
* Look for more comments in the dri_util.c file.
*/
#ifndef _DRI_UTIL_H_
#define _DRI_UTIL_H_
#define CAPI /* XXX this should be globally defined somewhere */
#include "glxclient.h" /* for GLXDrawable */
#include "xf86dri.h" /* for XF86DRIClipRectPtr */
#include "sarea.h" /* for XF86DRISAREAPtr */
#include "GL/internal/glcore.h" /* for __GLcontextModes */
typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
#define DRI_VALIDATE_DRAWABLE_INFO_ONCE(pDrawPriv) \
do { \
if (*(pDrawPriv->pStamp) != pDrawPriv->lastStamp) { \
__driUtilUpdateDrawableInfo(pDrawPriv); \
} \
} while (0)
#define DRI_VALIDATE_DRAWABLE_INFO(psp, pdp) \
do { \
while (*(pdp->pStamp) != pdp->lastStamp) { \
DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, \
pdp->driContextPriv->hHWContext); \
\
DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
\
DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, \
pdp->driContextPriv->hHWContext); \
} \
} while (0)
/* Each DRI driver must have one of these structs with all the pointers
* set to appropriate functions within the driver.
* When glXCreateContext is called, for example, it'll call a helper
* function dri_util.c which in turn will jump through the CreateContext
* pointer in this structure.
*/
struct __DriverAPIRec {
GLboolean (*InitDriver)(__DRIscreenPrivate *driScrnPriv);
void (*DestroyScreen)(__DRIscreenPrivate *driScrnPriv);
GLboolean (*CreateContext)(const __GLcontextModes *glVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate);
void (*DestroyContext)(__DRIcontextPrivate *driContextPriv);
GLboolean (*CreateBuffer)(__DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *glVis,
GLboolean pixmapBuffer);
void (*DestroyBuffer)(__DRIdrawablePrivate *driDrawPriv);
void (*SwapBuffers)(__DRIdrawablePrivate *driDrawPriv);
GLboolean (*MakeCurrent)(__DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv);
GLboolean (*UnbindContext)(__DRIcontextPrivate *driContextPriv);
GLboolean (*OpenFullScreen)(__DRIcontextPrivate *driContextPriv);
GLboolean (*CloseFullScreen)(__DRIcontextPrivate *driContextPriv);
};
struct __DRIdrawablePrivateRec {
/*
** Kernel drawable handle (not currently used).
*/
drmDrawable hHWDrawable;
/*
** Driver's private drawable information. This structure is opaque.
*/
void *driverPrivate;
/*
** X's drawable ID associated with this private drawable.
*/
GLXDrawable draw;
/*
** Reference count for number of context's currently bound to this
** drawable. Once the refcount reaches 0, the drawable can be
** destroyed. This behavior will change with GLX 1.3.
*/
int refcount;
/*
** Index of this drawable's information in the SAREA.
*/
unsigned int index;
/*
** Pointer to the "drawable has changed ID" stamp in the SAREA.
*/
unsigned int *pStamp;
/*
** Last value of the stamp. If this differs from the value stored
** at *pStamp, then the drawable information has been modified by
** the X server, and the drawable information (below) should be
** retrieved from the X server.
*/
unsigned int lastStamp;
/*
** Drawable information used in software fallbacks.
*/
int x;
int y;
int w;
int h;
int numClipRects;
XF86DRIClipRectPtr pClipRects;
/*
** Information about the back and depthbuffer where different
** from above.
*/
int backX;
int backY;
int backClipRectType;
int numBackClipRects;
XF86DRIClipRectPtr pBackClipRects;
/*
** Pointer to context to which this drawable is currently bound.
*/
__DRIcontextPrivate *driContextPriv;
/*
** Pointer to screen on which this drawable was created.
*/
__DRIscreenPrivate *driScreenPriv;
/*
** Basically just need these for when the locking code needs to call
** __driUtilUpdateDrawableInfo() which calls XF86DRIGetDrawableInfo().
*/
Display *display;
int screen;
/*
** Called via glXSwapBuffers().
*/
void (*swapBuffers)( __DRIdrawablePrivate *dPriv );
};
struct __DRIcontextPrivateRec {
/*
** Kernel context handle used to access the device lock.
*/
XID contextID;
/*
** Kernel context handle used to access the device lock.
*/
drmContext hHWContext;
/*
** Device driver's private context data. This structure is opaque.
*/
void *driverPrivate;
/*
** This context's display pointer.
*/
Display *display;
/*
** Pointer to drawable currently bound to this context.
*/
__DRIdrawablePrivate *driDrawablePriv;
/*
** Pointer to screen on which this context was created.
*/
__DRIscreenPrivate *driScreenPriv;
};
struct __DRIscreenPrivateRec {
/*
** Display for this screen
*/
Display *display;
/*
** Current screen's number
*/
int myNum;
/*
** Callback functions into the hardware-specific DRI driver code.
*/
struct __DriverAPIRec DriverAPI;
/*
** DDX / 2D driver version information.
*/
int ddxMajor;
int ddxMinor;
int ddxPatch;
/*
** DRI X extension version information.
*/
int driMajor;
int driMinor;
int driPatch;
/*
** DRM (kernel module) version information.
*/
int drmMajor;
int drmMinor;
int drmPatch;
/*
** ID used when the client sets the drawable lock. The X server
** uses this value to detect if the client has died while holding
** the drawable lock.
*/
int drawLockID;
/*
** File descriptor returned when the kernel device driver is opened.
** It is used to:
** - authenticate client to kernel
** - map the frame buffer, SAREA, etc.
** - close the kernel device driver
*/
int fd;
/*
** SAREA pointer used to access:
** - the device lock
** - the device-independent per-drawable and per-context(?) information
*/
XF86DRISAREAPtr pSAREA;
/*
** Direct frame buffer access information used for software
** fallbacks.
*/
unsigned char *pFB;
int fbSize;
int fbOrigin;
int fbStride;
int fbWidth;
int fbHeight;
int fbBPP;
/*
** Device-dependent private information (stored in the SAREA). This
** data is accessed by the client driver only.
*/
void *pDevPriv;
int devPrivSize;
/*
** Dummy context to which drawables are bound when not bound to any
** other context. A dummy hHWContext is created for this context,
** and is used by the GL core when a HW lock is required but the
** drawable is not currently bound (e.g., potentially during a
** SwapBuffers request). The dummy context is created when the
** first "real" context is created on this screen.
*/
__DRIcontextPrivate dummyContextPriv;
/*
** Hash table to hold the drawable information for this screen.
*/
void *drawHash;
/*
** Device-dependent private information (not stored in the SAREA).
** This pointer is never touched by the DRI layer.
*/
void *private;
/* If we're in full screen mode (via DRIOpenFullScreen), this points
to the drawable that was bound. Otherwise, this is NULL. */
__DRIdrawablePrivate *fullscreen;
/*
** Number of visuals (configs) for this screen, and a pointer to them.
*/
int numConfigs;
__GLXvisualConfig *configs;
};
extern void
__driUtilMessage(const char *f, ...);
extern void
__driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp);
extern __DRIscreenPrivate *
__driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config,
const struct __DriverAPIRec *driverAPI);
/* This must be implemented in each driver */
extern void *
__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config);
/* This is optionally implemented in each driver */
extern void
__driRegisterExtensions( void );
#endif /* _DRI_UTIL_H_ */

474
src/dri-es/drm.h Normal file
View File

@@ -0,0 +1,474 @@
/* drm.h -- Header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* 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, 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL
* VA LINUX SYSTEMS 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:
* Rickard E. (Rik) Faith <faith@valinux.com>
*
* Acknowledgements:
* Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
*
*/
#ifndef _DRM_H_
#define _DRM_H_
#if defined(__linux__)
#include <linux/config.h>
#include <asm/ioctl.h> /* For _IO* macros */
#define DRM_IOCTL_NR(n) _IOC_NR(n)
#define DRM_IOC_VOID _IOC_NONE
#define DRM_IOC_READ _IOC_READ
#define DRM_IOC_WRITE _IOC_WRITE
#define DRM_IOC_READWRITE _IOC_READ|_IOC_WRITE
#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
#elif defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) && defined(XFree86Server)
/* Prevent name collision when including sys/ioccom.h */
#undef ioctl
#include <sys/ioccom.h>
#define ioctl(a,b,c) xf86ioctl(a,b,c)
#else
#include <sys/ioccom.h>
#endif /* __FreeBSD__ && xf86ioctl */
#define DRM_IOCTL_NR(n) ((n) & 0xff)
#define DRM_IOC_VOID IOC_VOID
#define DRM_IOC_READ IOC_OUT
#define DRM_IOC_WRITE IOC_IN
#define DRM_IOC_READWRITE IOC_INOUT
#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
#endif
#define XFREE86_VERSION(major,minor,patch,snap) \
((major << 16) | (minor << 8) | patch)
#ifndef CONFIG_XFREE86_VERSION
#define CONFIG_XFREE86_VERSION XFREE86_VERSION(4,1,0,0)
#endif
#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
#define DRM_PROC_DEVICES "/proc/devices"
#define DRM_PROC_MISC "/proc/misc"
#define DRM_PROC_DRM "/proc/drm"
#define DRM_DEV_DRM "/dev/drm"
#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
#define DRM_DEV_UID 0
#define DRM_DEV_GID 0
#endif
#if CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4,1,0,0)
#define DRM_MAJOR 226
#define DRM_MAX_MINOR 15
#endif
#define DRM_NAME "drm" /* Name in kernel, /dev, and /proc */
#define DRM_MIN_ORDER 5 /* At least 2^5 bytes = 32 bytes */
#define DRM_MAX_ORDER 22 /* Up to 2^22 bytes = 4MB */
#define DRM_RAM_PERCENT 10 /* How much system ram can we lock? */
#define _DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */
#define _DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */
#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
typedef unsigned long drm_handle_t;
typedef unsigned int drm_context_t;
typedef unsigned int drm_drawable_t;
typedef unsigned int drm_magic_t;
/* Warning: If you change this structure, make sure you change
* XF86DRIClipRectRec in the server as well */
/* KW: Actually it's illegal to change either for
* backwards-compatibility reasons.
*/
typedef struct drm_clip_rect {
unsigned short x1;
unsigned short y1;
unsigned short x2;
unsigned short y2;
} drm_clip_rect_t;
typedef struct drm_tex_region {
unsigned char next;
unsigned char prev;
unsigned char in_use;
unsigned char padding;
unsigned int age;
} drm_tex_region_t;
typedef struct drm_version {
int version_major; /* Major version */
int version_minor; /* Minor version */
int version_patchlevel;/* Patch level */
size_t name_len; /* Length of name buffer */
char *name; /* Name of driver */
size_t date_len; /* Length of date buffer */
char *date; /* User-space buffer to hold date */
size_t desc_len; /* Length of desc buffer */
char *desc; /* User-space buffer to hold desc */
} drm_version_t;
typedef struct drm_unique {
size_t unique_len; /* Length of unique */
char *unique; /* Unique name for driver instantiation */
} drm_unique_t;
typedef struct drm_list {
int count; /* Length of user-space structures */
drm_version_t *version;
} drm_list_t;
typedef struct drm_block {
int unused;
} drm_block_t;
typedef struct drm_control {
enum {
DRM_ADD_COMMAND,
DRM_RM_COMMAND,
DRM_INST_HANDLER,
DRM_UNINST_HANDLER
} func;
int irq;
} drm_control_t;
typedef enum drm_map_type {
_DRM_FRAME_BUFFER = 0, /* WC (no caching), no core dump */
_DRM_REGISTERS = 1, /* no caching, no core dump */
_DRM_SHM = 2, /* shared, cached */
_DRM_AGP = 3, /* AGP/GART */
_DRM_SCATTER_GATHER = 4 /* Scatter/gather memory for PCI DMA */
} drm_map_type_t;
typedef enum drm_map_flags {
_DRM_RESTRICTED = 0x01, /* Cannot be mapped to user-virtual */
_DRM_READ_ONLY = 0x02,
_DRM_LOCKED = 0x04, /* shared, cached, locked */
_DRM_KERNEL = 0x08, /* kernel requires access */
_DRM_WRITE_COMBINING = 0x10, /* use write-combining if available */
_DRM_CONTAINS_LOCK = 0x20, /* SHM page that contains lock */
_DRM_REMOVABLE = 0x40 /* Removable mapping */
} drm_map_flags_t;
typedef struct drm_ctx_priv_map {
unsigned int ctx_id; /* Context requesting private mapping */
void *handle; /* Handle of map */
} drm_ctx_priv_map_t;
typedef struct drm_map {
unsigned long offset; /* Requested physical address (0 for SAREA)*/
unsigned long size; /* Requested physical size (bytes) */
drm_map_type_t type; /* Type of memory to map */
drm_map_flags_t flags; /* Flags */
void *handle; /* User-space: "Handle" to pass to mmap */
/* Kernel-space: kernel-virtual address */
int mtrr; /* MTRR slot used */
/* Private data */
} drm_map_t;
typedef struct drm_client {
int idx; /* Which client desired? */
int auth; /* Is client authenticated? */
unsigned long pid; /* Process id */
unsigned long uid; /* User id */
unsigned long magic; /* Magic */
unsigned long iocs; /* Ioctl count */
} drm_client_t;
typedef enum {
_DRM_STAT_LOCK,
_DRM_STAT_OPENS,
_DRM_STAT_CLOSES,
_DRM_STAT_IOCTLS,
_DRM_STAT_LOCKS,
_DRM_STAT_UNLOCKS,
_DRM_STAT_VALUE, /* Generic value */
_DRM_STAT_BYTE, /* Generic byte counter (1024bytes/K) */
_DRM_STAT_COUNT, /* Generic non-byte counter (1000/k) */
_DRM_STAT_IRQ, /* IRQ */
_DRM_STAT_PRIMARY, /* Primary DMA bytes */
_DRM_STAT_SECONDARY, /* Secondary DMA bytes */
_DRM_STAT_DMA, /* DMA */
_DRM_STAT_SPECIAL, /* Special DMA (e.g., priority or polled) */
_DRM_STAT_MISSED /* Missed DMA opportunity */
/* Add to the *END* of the list */
} drm_stat_type_t;
typedef struct drm_stats {
unsigned long count;
struct {
unsigned long value;
drm_stat_type_t type;
} data[15];
} drm_stats_t;
typedef enum drm_lock_flags {
_DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */
_DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */
_DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */
_DRM_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */
/* These *HALT* flags aren't supported yet
-- they will be used to support the
full-screen DGA-like mode. */
_DRM_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */
_DRM_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */
} drm_lock_flags_t;
typedef struct drm_lock {
int context;
drm_lock_flags_t flags;
} drm_lock_t;
typedef enum drm_dma_flags { /* These values *MUST* match xf86drm.h */
/* Flags for DMA buffer dispatch */
_DRM_DMA_BLOCK = 0x01, /* Block until buffer dispatched.
Note, the buffer may not yet have
been processed by the hardware --
getting a hardware lock with the
hardware quiescent will ensure
that the buffer has been
processed. */
_DRM_DMA_WHILE_LOCKED = 0x02, /* Dispatch while lock held */
_DRM_DMA_PRIORITY = 0x04, /* High priority dispatch */
/* Flags for DMA buffer request */
_DRM_DMA_WAIT = 0x10, /* Wait for free buffers */
_DRM_DMA_SMALLER_OK = 0x20, /* Smaller-than-requested buffers ok */
_DRM_DMA_LARGER_OK = 0x40 /* Larger-than-requested buffers ok */
} drm_dma_flags_t;
typedef struct drm_buf_desc {
int count; /* Number of buffers of this size */
int size; /* Size in bytes */
int low_mark; /* Low water mark */
int high_mark; /* High water mark */
enum {
_DRM_PAGE_ALIGN = 0x01, /* Align on page boundaries for DMA */
_DRM_AGP_BUFFER = 0x02, /* Buffer is in agp space */
_DRM_SG_BUFFER = 0x04 /* Scatter/gather memory buffer */
} flags;
unsigned long agp_start; /* Start address of where the agp buffers
* are in the agp aperture */
} drm_buf_desc_t;
typedef struct drm_buf_info {
int count; /* Entries in list */
drm_buf_desc_t *list;
} drm_buf_info_t;
typedef struct drm_buf_free {
int count;
int *list;
} drm_buf_free_t;
typedef struct drm_buf_pub {
int idx; /* Index into master buflist */
int total; /* Buffer size */
int used; /* Amount of buffer in use (for DMA) */
void *address; /* Address of buffer */
} drm_buf_pub_t;
typedef struct drm_buf_map {
int count; /* Length of buflist */
void *virtual; /* Mmaped area in user-virtual */
drm_buf_pub_t *list; /* Buffer information */
} drm_buf_map_t;
typedef struct drm_dma {
/* Indices here refer to the offset into
buflist in drm_buf_get_t. */
int context; /* Context handle */
int send_count; /* Number of buffers to send */
int *send_indices; /* List of handles to buffers */
int *send_sizes; /* Lengths of data to send */
drm_dma_flags_t flags; /* Flags */
int request_count; /* Number of buffers requested */
int request_size; /* Desired size for buffers */
int *request_indices; /* Buffer information */
int *request_sizes;
int granted_count; /* Number of buffers granted */
} drm_dma_t;
typedef enum {
_DRM_CONTEXT_PRESERVED = 0x01,
_DRM_CONTEXT_2DONLY = 0x02
} drm_ctx_flags_t;
typedef struct drm_ctx {
drm_context_t handle;
drm_ctx_flags_t flags;
} drm_ctx_t;
typedef struct drm_ctx_res {
int count;
drm_ctx_t *contexts;
} drm_ctx_res_t;
typedef struct drm_draw {
drm_drawable_t handle;
} drm_draw_t;
typedef struct drm_auth {
drm_magic_t magic;
} drm_auth_t;
typedef struct drm_irq_busid {
int irq;
int busnum;
int devnum;
int funcnum;
} drm_irq_busid_t;
typedef enum {
_DRM_VBLANK_ABSOLUTE = 0x0, /* Wait for specific vblank sequence number */
_DRM_VBLANK_RELATIVE = 0x1, /* Wait for given number of vblanks */
_DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */
} drm_vblank_seq_type_t;
#define _DRM_VBLANK_FLAGS_MASK _DRM_VBLANK_SIGNAL
struct drm_wait_vblank_request {
drm_vblank_seq_type_t type;
unsigned int sequence;
unsigned long signal;
};
struct drm_wait_vblank_reply {
drm_vblank_seq_type_t type;
unsigned int sequence;
long tval_sec;
long tval_usec;
};
typedef union drm_wait_vblank {
struct drm_wait_vblank_request request;
struct drm_wait_vblank_reply reply;
} drm_wait_vblank_t;
typedef struct drm_agp_mode {
unsigned long mode;
} drm_agp_mode_t;
/* For drm_agp_alloc -- allocated a buffer */
typedef struct drm_agp_buffer {
unsigned long size; /* In bytes -- will round to page boundary */
unsigned long handle; /* Used for BIND/UNBIND ioctls */
unsigned long type; /* Type of memory to allocate */
unsigned long physical; /* Physical used by i810 */
} drm_agp_buffer_t;
/* For drm_agp_bind */
typedef struct drm_agp_binding {
unsigned long handle; /* From drm_agp_buffer */
unsigned long offset; /* In bytes -- will round to page boundary */
} drm_agp_binding_t;
typedef struct drm_agp_info {
int agp_version_major;
int agp_version_minor;
unsigned long mode;
unsigned long aperture_base; /* physical address */
unsigned long aperture_size; /* bytes */
unsigned long memory_allowed; /* bytes */
unsigned long memory_used;
/* PCI information */
unsigned short id_vendor;
unsigned short id_device;
} drm_agp_info_t;
typedef struct drm_scatter_gather {
unsigned long size; /* In bytes -- will round to page boundary */
unsigned long handle; /* Used for mapping / unmapping */
} drm_scatter_gather_t;
#define DRM_IOCTL_BASE 'd'
#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
#define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type)
#define DRM_IOW(nr,type) _IOW(DRM_IOCTL_BASE,nr,type)
#define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type)
#define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t)
#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t)
#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, drm_auth_t)
#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t)
#define DRM_IOCTL_GET_MAP DRM_IOWR(0x04, drm_map_t)
#define DRM_IOCTL_GET_CLIENT DRM_IOWR(0x05, drm_client_t)
#define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, drm_stats_t)
#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t)
#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t)
#define DRM_IOCTL_BLOCK DRM_IOWR(0x12, drm_block_t)
#define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, drm_block_t)
#define DRM_IOCTL_CONTROL DRM_IOW( 0x14, drm_control_t)
#define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, drm_map_t)
#define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, drm_buf_desc_t)
#define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, drm_buf_desc_t)
#define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm_buf_info_t)
#define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm_buf_map_t)
#define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm_buf_free_t)
#define DRM_IOCTL_RM_MAP DRM_IOW( 0x1b, drm_map_t)
#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, drm_ctx_priv_map_t)
#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, drm_ctx_priv_map_t)
#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t)
#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t)
#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, drm_ctx_t)
#define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, drm_ctx_t)
#define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, drm_ctx_t)
#define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, drm_ctx_t)
#define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, drm_ctx_res_t)
#define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, drm_draw_t)
#define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, drm_draw_t)
#define DRM_IOCTL_DMA DRM_IOWR(0x29, drm_dma_t)
#define DRM_IOCTL_LOCK DRM_IOW( 0x2a, drm_lock_t)
#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t)
#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t)
#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, drm_agp_mode_t)
#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, drm_agp_info_t)
#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, drm_agp_buffer_t)
#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, drm_agp_buffer_t)
#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t)
#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t)
#define DRM_IOCTL_SG_ALLOC DRM_IOW( 0x38, drm_scatter_gather_t)
#define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, drm_scatter_gather_t)
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, drm_wait_vblank_t)
/* Device specfic ioctls should only be in their respective headers
* The device specific ioctl range is 0x40 to 0x79. */
#define DRM_COMMAND_BASE 0x40
#endif

224
src/dri-es/extutil.h Normal file
View File

@@ -0,0 +1,224 @@
/*
* $Xorg: extutil.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $
*
Copyright 1989, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
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
OPEN GROUP 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 of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* Author: Jim Fulton, MIT The Open Group
*
* Xlib Extension-Writing Utilities
*
* This package contains utilities for writing the client API for various
* protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
* ARE SUBJECT TO CHANGE!
*/
/* $XFree86: xc/include/extensions/extutil.h,v 1.9 2001/12/14 19:53:28 dawes Exp $ */
#ifndef _EXTUTIL_H_
#define _EXTUTIL_H_
#include <X11/extensions/Xext.h>
/*
* We need to keep a list of open displays since the Xlib display list isn't
* public. We also have to per-display info in a separate block since it isn't
* stored directly in the Display structure.
*/
typedef struct _XExtDisplayInfo {
struct _XExtDisplayInfo *next; /* keep a linked list */
Display *display; /* which display this is */
XExtCodes *codes; /* the extension protocol codes */
XPointer data; /* extra data for extension to use */
} XExtDisplayInfo;
typedef struct _XExtensionInfo {
XExtDisplayInfo *head; /* start of list */
XExtDisplayInfo *cur; /* most recently used */
int ndisplays; /* number of displays */
} XExtensionInfo;
typedef struct _XExtensionHooks {
int (*create_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*copy_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*flush_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*free_gc)(
#if NeedNestedPrototypes
Display* /* display */,
GC /* gc */,
XExtCodes* /* codes */
#endif
);
int (*create_font)(
#if NeedNestedPrototypes
Display* /* display */,
XFontStruct* /* fs */,
XExtCodes* /* codes */
#endif
);
int (*free_font)(
#if NeedNestedPrototypes
Display* /* display */,
XFontStruct* /* fs */,
XExtCodes* /* codes */
#endif
);
int (*close_display)(
#if NeedNestedPrototypes
Display* /* display */,
XExtCodes* /* codes */
#endif
);
Bool (*wire_to_event)(
#if NeedNestedPrototypes
Display* /* display */,
XEvent* /* re */,
xEvent* /* event */
#endif
);
Status (*event_to_wire)(
#if NeedNestedPrototypes
Display* /* display */,
XEvent* /* re */,
xEvent* /* event */
#endif
);
int (*error)(
#if NeedNestedPrototypes
Display* /* display */,
xError* /* err */,
XExtCodes* /* codes */,
int* /* ret_code */
#endif
);
char *(*error_string)(
#if NeedNestedPrototypes
Display* /* display */,
int /* code */,
XExtCodes* /* codes */,
char* /* buffer */,
int /* nbytes */
#endif
);
} XExtensionHooks;
extern XExtensionInfo *XextCreateExtension(
#if NeedFunctionPrototypes
void
#endif
);
extern void XextDestroyExtension(
#if NeedFunctionPrototypes
XExtensionInfo* /* info */
#endif
);
extern XExtDisplayInfo *XextAddDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */,
char* /* ext_name */,
XExtensionHooks* /* hooks */,
int /* nevents */,
XPointer /* data */
#endif
);
extern int XextRemoveDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */
#endif
);
extern XExtDisplayInfo *XextFindDisplay(
#if NeedFunctionPrototypes
XExtensionInfo* /* extinfo */,
Display* /* dpy */
#endif
);
#define XextHasExtension(i) ((i) && ((i)->codes))
#define XextCheckExtension(dpy,i,name,val) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
#define XextSimpleCheckExtension(dpy,i,name) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
/*
* helper macros to generate code that is common to all extensions; caller
* should prefix it with static if extension source is in one file; this
* could be a utility function, but have to stack 6 unused arguments for
* something that is called many, many times would be bad.
*/
#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
XExtDisplayInfo *proc (Display *dpy) \
{ \
XExtDisplayInfo *dpyinfo; \
if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
return dpyinfo; \
}
#define XEXT_FIND_DISPLAY_PROTO(proc) \
XExtDisplayInfo *proc(Display *dpy)
#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
int proc (Display *dpy, XExtCodes *codes) \
{ \
return XextRemoveDisplay (extinfo, dpy); \
}
#define XEXT_CLOSE_DISPLAY_PROTO(proc) \
int proc(Display *dpy, XExtCodes *codes)
#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
{ \
code -= codes->first_error; \
if (code >= 0 && code < nerr) { \
char tmp[256]; \
sprintf (tmp, "%s.%d", extname, code); \
XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
return buf; \
} \
return (char *)0; \
}
#define XEXT_ERROR_STRING_PROTO(proc) \
char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
#endif

678
src/dri-es/glxclient.h Normal file
View File

@@ -0,0 +1,678 @@
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
*/
/* $XFree86: xc/lib/GL/glx/glxclient.h,v 1.14 2002/02/22 21:32:53 dawes Exp $ */
/*
* Direct rendering support added by Precision Insight, Inc.
*
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
*
*/
#ifndef _GLX_client_h_
#define _GLX_client_h_
#define NEED_REPLIES
#define NEED_EVENTS
#include <X11/Xproto.h>
#include <X11/Xlibint.h>
#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>
#include <string.h>
#include <stdlib.h>
#include "GL/glxint.h"
#include "GL/glxproto.h"
#include "glapitable.h"
#ifdef NEED_GL_FUNCS_WRAPPED
#include "indirect.h"
#endif
#ifdef XTHREADS
#include "Xthreads.h"
#endif
#ifdef GLX_BUILT_IN_XMESA
#include "realglx.h" /* just silences prototype warnings */
#endif
#define GLX_MAJOR_VERSION 1 /* current version numbers */
#define GLX_MINOR_VERSION 2
#define __GL_BOOLEAN_ARRAY (GL_BYTE - 1)
#define __GLX_MAX_TEXTURE_UNITS 32
typedef struct __GLXcontextRec __GLXcontext;
typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate;
typedef struct _glapi_table __GLapi;
/************************************************************************/
/*
** The following structures define the interface between the GLX client
** side library and the DRI (direct rendering infrastructure).
*/
typedef struct __DRIdisplayRec __DRIdisplay;
typedef struct __DRIscreenRec __DRIscreen;
typedef struct __DRIcontextRec __DRIcontext;
typedef struct __DRIdrawableRec __DRIdrawable;
typedef struct __DRIdriverRec __DRIdriver;
extern __DRIscreen *__glXFindDRIScreen(Display *dpy, int scrn);
/*
** Display dependent methods. This structure is initialized during the
** driCreateDisplay() call.
*/
struct __DRIdisplayRec {
/*
** Method to destroy the private DRI display data.
*/
void (*destroyDisplay)(Display *dpy, void *displayPrivate);
/*
** Methods to create the private DRI screen data and initialize the
** screen dependent methods.
** This is an array [indexed by screen number] of function pointers.
*/
void *(**createScreen)(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config);
/*
** Opaque pointer to private per display direct rendering data.
** NULL if direct rendering is not supported on this display. Never
** dereferenced in libGL.
*/
void *private;
};
/*
** Screen dependent methods. This structure is initialized during the
** (*createScreen)() call.
*/
struct __DRIscreenRec {
/*
** Method to destroy the private DRI screen data.
*/
void (*destroyScreen)(Display *dpy, int scrn, void *screenPrivate);
/*
** Method to create the private DRI context data and initialize the
** context dependent methods.
*/
void *(*createContext)(Display *dpy, XVisualInfo *vis, void *sharedPrivate,
__DRIcontext *pctx);
/*
** Method to create the private DRI drawable data and initialize the
** drawable dependent methods.
*/
void *(*createDrawable)(Display *dpy, int scrn, GLXDrawable draw,
VisualID vid, __DRIdrawable *pdraw);
/*
** Method to return a pointer to the DRI drawable data.
*/
__DRIdrawable *(*getDrawable)(Display *dpy, GLXDrawable draw,
void *drawablePrivate);
/*
** XXX in the future, implement this:
void *(*createPBuffer)(Display *dpy, int scrn, GLXPbuffer pbuffer,
GLXFBConfig config, __DRIdrawable *pdraw);
**/
/*
** Opaque pointer to private per screen direct rendering data. NULL
** if direct rendering is not supported on this screen. Never
** dereferenced in libGL.
*/
void *private;
};
/*
** Context dependent methods. This structure is initialized during the
** (*createContext)() call.
*/
struct __DRIcontextRec {
/*
** Method to destroy the private DRI context data.
*/
void (*destroyContext)(Display *dpy, int scrn, void *contextPrivate);
/*
** Method to bind a DRI drawable to a DRI graphics context.
** XXX in the future, also pass a 'read' GLXDrawable for
** glXMakeCurrentReadSGI() and GLX 1.3's glXMakeContextCurrent().
*/
Bool (*bindContext)(Display *dpy, int scrn, GLXDrawable draw,
GLXContext gc);
/*
** Method to unbind a DRI drawable to a DRI graphics context.
*/
Bool (*unbindContext)(Display *dpy, int scrn, GLXDrawable draw,
GLXContext gc, int will_rebind);
/*
** Opaque pointer to private per context direct rendering data.
** NULL if direct rendering is not supported on the display or
** screen used to create this context. Never dereferenced in libGL.
*/
void *private;
};
/*
** Drawable dependent methods. This structure is initialized during the
** (*createDrawable)() call. createDrawable() is not called by libGL at
** this time. It's currently used via the dri_util.c utility code instead.
*/
struct __DRIdrawableRec {
/*
** Method to destroy the private DRI drawable data.
*/
void (*destroyDrawable)(Display *dpy, void *drawablePrivate);
/*
** Method to swap the front and back buffers.
*/
void (*swapBuffers)(Display *dpy, void *drawablePrivate);
/*
** Opaque pointer to private per drawable direct rendering data.
** NULL if direct rendering is not supported on the display or
** screen used to create this drawable. Never dereferenced in libGL.
*/
void *private;
};
typedef void *(*CreateScreenFunc)(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config);
typedef void *(*RegisterExtensionsFunc)(void);
/*
** We keep a linked list of these structures, one per DRI device driver.
*/
struct __DRIdriverRec {
const char *name;
void *handle;
CreateScreenFunc createScreenFunc;
RegisterExtensionsFunc registerExtensionsFunc;
struct __DRIdriverRec *next;
};
/*
** Function to create and DRI display data and initialize the display
** dependent methods.
*/
extern void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp);
extern __DRIdriver *driGetDriver(Display *dpy, int scrNum);
extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
/************************************************************************/
#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
typedef struct __GLXpixelStoreModeRec {
GLboolean swapEndian;
GLboolean lsbFirst;
GLuint rowLength;
GLuint imageHeight;
GLuint imageDepth;
GLuint skipRows;
GLuint skipPixels;
GLuint skipImages;
GLuint alignment;
} __GLXpixelStoreMode;
typedef struct __GLXvertexArrayPointerStateRec {
GLboolean enable;
void (*proc)(const void *);
const GLubyte *ptr;
GLsizei skip;
GLint size;
GLenum type;
GLsizei stride;
} __GLXvertexArrayPointerState;
typedef struct __GLXvertArrayStateRec {
__GLXvertexArrayPointerState vertex;
__GLXvertexArrayPointerState normal;
__GLXvertexArrayPointerState color;
__GLXvertexArrayPointerState index;
__GLXvertexArrayPointerState texCoord[__GLX_MAX_TEXTURE_UNITS];
__GLXvertexArrayPointerState edgeFlag;
GLint maxElementsVertices;
GLint maxElementsIndices;
GLint activeTexture;
} __GLXvertArrayState;
typedef struct __GLXattributeRec {
GLuint mask;
/*
** Pixel storage state. Most of the pixel store mode state is kept
** here and used by the client code to manage the packing and
** unpacking of data sent to/received from the server.
*/
__GLXpixelStoreMode storePack, storeUnpack;
/*
** Vertex Array storage state. The vertex array component
** state is stored here and is used to manage the packing of
** DrawArrays data sent to the server.
*/
__GLXvertArrayState vertArray;
} __GLXattribute;
typedef struct __GLXattributeMachineRec {
__GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
__GLXattribute **stackPointer;
} __GLXattributeMachine;
/*
** GLX state that needs to be kept on the client. One of these records
** exist for each context that has been made current by this client.
*/
struct __GLXcontextRec {
/*
** Drawing command buffer. Drawing commands are packed into this
** buffer before being sent as a single GLX protocol request. The
** buffer is sent when it overflows or is flushed by
** __glXFlushRenderBuffer. "pc" is the next location in the buffer
** to be filled. "limit" is described above in the buffer slop
** discussion.
**
** Commands that require large amounts of data to be transfered will
** also use this buffer to hold a header that describes the large
** command.
**
** These must be the first 6 fields since they are static initialized
** in the dummy context in glxext.c
*/
GLubyte *buf;
GLubyte *pc;
GLubyte *limit;
GLubyte *bufEnd;
GLint bufSize;
/*
** The XID of this rendering context. When the context is created a
** new XID is allocated. This is set to None when the context is
** destroyed but is still current to some thread. In this case the
** context will be freed on next MakeCurrent.
*/
XID xid;
/*
** The XID of the shareList context.
*/
XID share_xid;
/*
** Visual id.
*/
VisualID vid;
/*
** screen number.
*/
GLint screen;
/*
** GL_TRUE if the context was created with ImportContext, which
** means the server-side context was created by another X client.
*/
GLboolean imported;
/*
** The context tag returned by MakeCurrent when this context is made
** current. This tag is used to identify the context that a thread has
** current so that proper server context management can be done. It is
** used for all context specific commands (i.e., Render, RenderLarge,
** WaitX, WaitGL, UseXFont, and MakeCurrent (for the old context)).
*/
GLXContextTag currentContextTag;
/*
** The rendering mode is kept on the client as well as the server.
** When glRenderMode() is called, the buffer associated with the
** previous rendering mode (feedback or select) is filled.
*/
GLenum renderMode;
GLfloat *feedbackBuf;
GLuint *selectBuf;
/*
** This is GL_TRUE if the pixel unpack modes are such that an image
** can be unpacked from the clients memory by just copying. It may
** still be true that the server will have to do some work. This
** just promises that a straight copy will fetch the correct bytes.
*/
GLboolean fastImageUnpack;
/*
** Fill newImage with the unpacked form of oldImage getting it
** ready for transport to the server.
*/
void (*fillImage)(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
GLenum, const GLvoid*, GLubyte*, GLubyte*);
/*
** Client side attribs.
*/
__GLXattribute state;
__GLXattributeMachine attributes;
/*
** Client side error code. This is set when client side gl API
** routines need to set an error because of a bad enumerant or
** running out of memory, etc.
*/
GLenum error;
/*
** Whether this context does direct rendering.
*/
Bool isDirect;
/*
** dpy of current display for this context. Will be NULL if not
** current to any display, or if this is the "dummy context".
*/
Display *currentDpy;
/*
** The current drawable for this context. Will be None if this
** context is not current to any drawable.
*/
GLXDrawable currentDrawable;
/*
** Constant strings that describe the server implementation
** These pertain to GL attributes, not to be confused with
** GLX versioning attributes.
*/
GLubyte *vendor;
GLubyte *renderer;
GLubyte *version;
GLubyte *extensions;
/* Record the dpy this context was created on for later freeing */
Display *createDpy;
/*
** Maximum small render command size. This is the smaller of 64k and
** the size of the above buffer.
*/
GLint maxSmallRenderCommandSize;
/*
** Major opcode for the extension. Copied here so a lookup isn't
** needed.
*/
GLint majorOpcode;
/*
** Per context direct rendering interface functions and data.
*/
__DRIcontext driContext;
};
#define __glXSetError(gc,code) \
if (!(gc)->error) { \
(gc)->error = code; \
}
extern void __glFreeAttributeState(__GLXcontext *);
/************************************************************************/
/*
** The size of the largest drawing command known to the implementation
** that will use the GLXRender glx command. In this case it is
** glPolygonStipple.
*/
#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
/*
** To keep the implementation fast, the code uses a "limit" pointer
** to determine when the drawing command buffer is too full to hold
** another fixed size command. This constant defines the amount of
** space that must always be available in the drawing command buffer
** at all times for the implementation to work. It is important that
** the number be just large enough, but not so large as to reduce the
** efficacy of the buffer. The "+32" is just to keep the code working
** in case somebody counts wrong.
*/
#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
/*
** This implementation uses a smaller threshold for switching
** to the RenderLarge protocol than the protcol requires so that
** large copies don't occur.
*/
#define __GLX_RENDER_CMD_SIZE_LIMIT 4096
/*
** One of these records exists per screen of the display. It contains
** a pointer to the config data for that screen (if the screen supports GL).
*/
typedef struct __GLXscreenConfigsRec {
__GLXvisualConfig *configs;
int numConfigs;
const char *serverGLXexts;
char *effectiveGLXexts;
/*
** Per screen direct rendering interface functions and data.
*/
__DRIscreen driScreen;
} __GLXscreenConfigs;
/*
** Per display private data. One of these records exists for each display
** that is using the OpenGL (GLX) extension.
*/
struct __GLXdisplayPrivateRec {
/*
** Back pointer to the display
*/
Display *dpy;
/*
** The majorOpcode is common to all connections to the same server.
** It is also copied into the context structure.
*/
int majorOpcode;
/*
** Major and minor version returned by the server during initialization.
*/
int majorVersion, minorVersion;
/* Storage for the servers GLX vendor and versions strings. These
** are the same for all screens on this display. These fields will
** be filled in on demand.
*/
char *serverGLXvendor;
char *serverGLXversion;
/*
** Configurations of visuals for all screens on this display.
** Also, per screen data which now includes the server GLX_EXTENSION
** string.
*/
__GLXscreenConfigs *screenConfigs;
/*
** Per display direct rendering interface functions and data.
*/
__DRIdisplay driDisplay;
};
void __glXFreeContext(__GLXcontext*);
extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
const GLvoid *, GLint);
/* Initialize the GLX extension for dpy */
extern __GLXdisplayPrivate *__glXInitialize(Display*);
/* Query drivers for dynamically registered extensions */
extern void __glXRegisterExtensions(void);
/* Functions for extending the GLX API: */
extern void *__glXRegisterGLXFunction(const char *funcName, void *funcAddr);
extern void __glXRegisterGLXExtensionString(const char *extName);
/************************************************************************/
extern int __glXDebug;
/* This is per-thread storage in an MT environment */
#if defined(XTHREADS)
extern __GLXcontext *__glXGetCurrentContext(void);
extern void __glXSetCurrentContext(__GLXcontext *c);
#else
extern __GLXcontext *__glXcurrentContext;
#define __glXGetCurrentContext() __glXcurrentContext
#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
#endif
/*
** Global lock for all threads in this address space using the GLX
** extension
*/
#if defined(XTHREADS)
extern xmutex_rec __glXmutex;
#define __glXLock() xmutex_lock(&__glXmutex)
#define __glXUnlock() xmutex_unlock(&__glXmutex)
#else
#define __glXLock()
#define __glXUnlock()
#endif
/*
** Setup for a command. Initialize the extension for dpy if necessary.
*/
extern CARD8 __glXSetupForCommand(Display *dpy);
/************************************************************************/
/*
** Data conversion and packing support.
*/
/* Return the size, in bytes, of some pixel data */
extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum);
/* Return the k value for a given map target */
extern GLint __glEvalComputeK(GLenum);
/*
** Fill the transport buffer with the data from the users buffer,
** applying some of the pixel store modes (unpack modes) to the data
** first. As a side effect of this call, the "modes" field is
** updated to contain the modes needed by the server to decode the
** sent data.
*/
extern void __glFillImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
GLenum, const GLvoid*, GLubyte*, GLubyte*);
/* Copy map data with a stride into a packed buffer */
extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
const GLfloat *, GLfloat *);
extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
const GLdouble *, GLdouble *);
/*
** Empty an image out of the reply buffer into the clients memory applying
** the pack modes to pack back into the clients requested format.
*/
extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
GLenum, const GLubyte *, GLvoid *);
/*
** Allocate and Initialize Vertex Array client state
*/
extern void __glXInitVertexArrayState(__GLXcontext*);
/*
** Inform the Server of the major and minor numbers and of the client
** libraries extension string.
*/
extern void __glXClientInfo ( Display *dpy, int opcode );
/************************************************************************/
/*
** Declarations that should be in Xlib
*/
#ifdef __GL_USE_OUR_PROTOTYPES
extern void _XFlush(Display*);
extern Status _XReply(Display*, xReply*, int, Bool);
extern void _XRead(Display*, void*, long);
extern void _XSend(Display*, const void*, long);
#endif
/*
** GLX_BUILT_IN_XMESA controls whether libGL has a built-in verions of
** Mesa that can render to non-GLX displays.
*/
#ifdef GLX_BUILT_IN_XMESA
#define GLX_PREFIX(function) _real_##function
#else
#define GLX_PREFIX(function) function
#endif
extern char *__glXstrdup(const char *str);
extern int __glXGetInternalVersion(void);
extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
#endif /* !__GLX_client_h__ */

80
src/dri-es/sarea.h Normal file
View File

@@ -0,0 +1,80 @@
/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.10 2001/10/04 18:28:20 alanh Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, 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 <kevin@precisioninsight.com>
* Jens Owen <jens@tungstengraphics.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
#ifndef _SAREA_H_
#define _SAREA_H_
#include "xf86drm.h"
/* SAREA area needs to be at least a page */
#if defined(__alpha__)
#define SAREA_MAX 0x2000
#elif defined(__ia64__)
#define SAREA_MAX 0x10000 /* 64kB */
#else
/* Intel 830M driver needs at least 8k SAREA */
#define SAREA_MAX 0x2000
#endif
#define SAREA_MAX_DRAWABLES 256
#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000
typedef struct _XF86DRISAREADrawable {
unsigned int stamp;
unsigned int flags;
} XF86DRISAREADrawableRec, *XF86DRISAREADrawablePtr;
typedef struct _XF86DRISAREAFrame {
unsigned int x;
unsigned int y;
unsigned int width;
unsigned int height;
unsigned int fullscreen;
} XF86DRISAREAFrameRec, *XF86DRISAREAFramePtr;
typedef struct _XF86DRISAREA {
/* first thing is always the drm locking structure */
drmLock lock;
/* NOT_DONE: Use readers/writer lock for drawable_lock */
drmLock drawable_lock;
XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES];
XF86DRISAREAFrameRec frame;
drmContext dummy_context;
} XF86DRISAREARec, *XF86DRISAREAPtr;
#endif

227
src/dri-es/xf86dri.h Normal file
View File

@@ -0,0 +1,227 @@
/* $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.
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@tungstengraphics.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
#ifndef _XF86DRI_H_
#define _XF86DRI_H_
#include <X11/Xfuncproto.h>
#include <xf86drm.h>
#define X_XF86DRIQueryVersion 0
#define X_XF86DRIQueryDirectRenderingCapable 1
#define X_XF86DRIOpenConnection 2
#define X_XF86DRICloseConnection 3
#define X_XF86DRIGetClientDriverName 4
#define X_XF86DRICreateContext 5
#define X_XF86DRIDestroyContext 6
#define X_XF86DRICreateDrawable 7
#define X_XF86DRIDestroyDrawable 8
#define X_XF86DRIGetDrawableInfo 9
#define X_XF86DRIGetDeviceInfo 10
#define X_XF86DRIAuthConnection 11
#define X_XF86DRIOpenFullScreen 12
#define X_XF86DRICloseFullScreen 13
#define XF86DRINumberEvents 0
#define XF86DRIClientNotLocal 0
#define XF86DRIOperationNotSupported 1
#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
/* Warning : Do not change XF86DRIClipRect without changing the kernel
* structure! */
typedef struct _XF86DRIClipRect {
unsigned short x1; /* Upper left: inclusive */
unsigned short y1;
unsigned short x2; /* Lower right: exclusive */
unsigned short y2;
} XF86DRIClipRectRec, *XF86DRIClipRectPtr;
#ifndef _XF86DRI_SERVER_
_XFUNCPROTOBEGIN
Bool XF86DRIQueryExtension(
#if NeedFunctionPrototypes
Display* /* dpy */,
int* /* event_base */,
int* /* error_base */
#endif
);
Bool XF86DRIQueryVersion(
#if NeedFunctionPrototypes
Display* /* dpy */,
int* /* majorVersion */,
int* /* minorVersion */,
int* /* patchVersion */
#endif
);
Bool XF86DRIQueryDirectRenderingCapable(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
Bool* /* isCapable */
#endif
);
Bool XF86DRIOpenConnection(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
drmHandlePtr /* hSAREA */,
char** /* busIDString */
#endif
);
Bool XF86DRIAuthConnection(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
drmMagic /* magic */
#endif
);
Bool XF86DRICloseConnection(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */
#endif
);
Bool XF86DRIGetClientDriverName(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
int* /* ddxDriverMajorVersion */,
int* /* ddxDriverMinorVersion */,
int* /* ddxDriverPatchVersion */,
char** /* clientDriverName */
#endif
);
Bool XF86DRICreateContext(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
Visual* /* visual */,
XID* /* ptr to returned context id */,
drmContextPtr /* hHWContext */
#endif
);
Bool XF86DRIDestroyContext(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
XID /* context id */
#endif
);
Bool XF86DRICreateDrawable(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
Drawable /* drawable */,
drmDrawablePtr /* hHWDrawable */
#endif
);
Bool XF86DRIDestroyDrawable(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
Drawable /* drawable */
#endif
);
Bool XF86DRIGetDrawableInfo(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
Drawable /* drawable */,
unsigned int* /* index */,
unsigned int* /* stamp */,
int* /* X */,
int* /* Y */,
int* /* W */,
int* /* H */,
int* /* numClipRects */,
XF86DRIClipRectPtr*,/* pClipRects */
int* /* backX */,
int* /* backY */,
int* /* numBackClipRects */,
XF86DRIClipRectPtr* /* pBackClipRects */
#endif
);
Bool XF86DRIGetDeviceInfo(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
drmHandlePtr /* hFrameBuffer */,
int* /* fbOrigin */,
int* /* fbSize */,
int* /* fbStride */,
int* /* devPrivateSize */,
void** /* pDevPrivate */
#endif
);
Bool XF86DRIOpenFullScreen(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
Drawable /* drawable */
#endif
);
Bool XF86DRICloseFullScreen(
#if NeedFunctionPrototypes
Display* /* dpy */,
int /* screen */,
Drawable /* drawable */
#endif
);
_XFUNCPROTOEND
#endif /* _XF86DRI_SERVER_ */
#endif /* _XF86DRI_H_ */

343
src/dri-es/xf86dristr.h Normal file
View File

@@ -0,0 +1,343 @@
/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.9 2001/03/21 16:01:08 dawes Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, 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@tungstengraphics.com>
* Rickard E. (Rik) Fiath <faith@valinux.com>
*
*/
#ifndef _XF86DRISTR_H_
#define _XF86DRISTR_H_
#include "xf86dri.h"
#define XF86DRINAME "XFree86-DRI"
/* The DRI version number. This was originally set to be the same of the
* XFree86 version number. However, this version is really indepedent of
* the XFree86 version.
*
* Version History:
* 4.0.0: Original
* 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02
* 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02
*/
#define XF86DRI_MAJOR_VERSION 4
#define XF86DRI_MINOR_VERSION 1
#define XF86DRI_PATCH_VERSION 0
typedef struct _XF86DRIQueryVersion {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIQueryVersion */
CARD16 length B16;
} xXF86DRIQueryVersionReq;
#define sz_xXF86DRIQueryVersionReq 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;
} xXF86DRIQueryVersionReply;
#define sz_xXF86DRIQueryVersionReply 32
typedef struct _XF86DRIQueryDirectRenderingCapable {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRIQueryDirectRenderingCapableReq;
#define sz_xXF86DRIQueryDirectRenderingCapableReq 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;
} xXF86DRIQueryDirectRenderingCapableReply;
#define sz_xXF86DRIQueryDirectRenderingCapableReply 32
typedef struct _XF86DRIOpenConnection {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIOpenConnection */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRIOpenConnectionReq;
#define sz_xXF86DRIOpenConnectionReq 8
typedef struct {
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 hSAREALow B32;
CARD32 hSAREAHigh B32;
CARD32 busIdStringLength B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
CARD32 pad8 B32;
} xXF86DRIOpenConnectionReply;
#define sz_xXF86DRIOpenConnectionReply 32
typedef struct _XF86DRIAuthConnection {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseConnection */
CARD16 length B16;
CARD32 screen B32;
CARD32 magic B32;
} xXF86DRIAuthConnectionReq;
#define sz_xXF86DRIAuthConnectionReq 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;
} xXF86DRIAuthConnectionReply;
#define zx_xXF86DRIAuthConnectionReply 32
typedef struct _XF86DRICloseConnection {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseConnection */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRICloseConnectionReq;
#define sz_xXF86DRICloseConnectionReq 8
typedef struct _XF86DRIGetClientDriverName {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIGetClientDriverName */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRIGetClientDriverNameReq;
#define sz_xXF86DRIGetClientDriverNameReq 8
typedef struct {
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 ddxDriverMajorVersion B32;
CARD32 ddxDriverMinorVersion B32;
CARD32 ddxDriverPatchVersion B32;
CARD32 clientDriverNameLength B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRIGetClientDriverNameReply;
#define sz_xXF86DRIGetClientDriverNameReply 32
typedef struct _XF86DRICreateContext {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICreateContext */
CARD16 length B16;
CARD32 screen B32;
CARD32 visual B32;
CARD32 context B32;
} xXF86DRICreateContextReq;
#define sz_xXF86DRICreateContextReq 16
typedef struct {
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 hHWContext B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRICreateContextReply;
#define sz_xXF86DRICreateContextReply 32
typedef struct _XF86DRIDestroyContext {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIDestroyContext */
CARD16 length B16;
CARD32 screen B32;
CARD32 context B32;
} xXF86DRIDestroyContextReq;
#define sz_xXF86DRIDestroyContextReq 12
typedef struct _XF86DRICreateDrawable {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICreateDrawable */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRICreateDrawableReq;
#define sz_xXF86DRICreateDrawableReq 12
typedef struct {
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 hHWDrawable B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRICreateDrawableReply;
#define sz_xXF86DRICreateDrawableReply 32
typedef struct _XF86DRIDestroyDrawable {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIDestroyDrawable */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRIDestroyDrawableReq;
#define sz_xXF86DRIDestroyDrawableReq 12
typedef struct _XF86DRIGetDrawableInfo {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIGetDrawableInfo */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRIGetDrawableInfoReq;
#define sz_xXF86DRIGetDrawableInfoReq 12
typedef struct {
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 drawableTableIndex B32;
CARD32 drawableTableStamp B32;
INT16 drawableX B16;
INT16 drawableY B16;
INT16 drawableWidth B16;
INT16 drawableHeight B16;
CARD32 numClipRects B32;
INT16 backX B16;
INT16 backY B16;
CARD32 numBackClipRects B32;
} xXF86DRIGetDrawableInfoReply;
#define sz_xXF86DRIGetDrawableInfoReply 36
typedef struct _XF86DRIGetDeviceInfo {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIGetDeviceInfo */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRIGetDeviceInfoReq;
#define sz_xXF86DRIGetDeviceInfoReq 8
typedef struct {
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 hFrameBufferLow B32;
CARD32 hFrameBufferHigh B32;
CARD32 framebufferOrigin B32;
CARD32 framebufferSize B32;
CARD32 framebufferStride B32;
CARD32 devPrivateSize B32;
} xXF86DRIGetDeviceInfoReply;
#define sz_xXF86DRIGetDeviceInfoReply 32
typedef struct _XF86DRIOpenFullScreen {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIOpenFullScreen */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRIOpenFullScreenReq;
#define sz_xXF86DRIOpenFullScreenReq 12
typedef struct {
BYTE type;
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 isFullScreen B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRIOpenFullScreenReply;
#define sz_xXF86DRIOpenFullScreenReply 32
typedef struct _XF86DRICloseFullScreen {
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseFullScreen */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRICloseFullScreenReq;
#define sz_xXF86DRICloseFullScreenReq 12
typedef struct {
BYTE type;
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xXF86DRICloseFullScreenReply;
#define sz_xXF86DRICloseFullScreenReply 32
#endif /* _XF86DRISTR_H_ */

1500
src/dri-es/xf86drm.c Normal file

File diff suppressed because it is too large Load Diff

607
src/dri-es/xf86drm.h Normal file
View File

@@ -0,0 +1,607 @@
/* xf86drm.h -- OS-independent header for DRM user-level library interface
* Created: Tue Jan 5 08:17:23 1999 by faith@precisioninsight.com
*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* 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, 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 (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 NONINFRINGEMENT. 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.
*
* Author: Rickard E. (Rik) Faith <faith@valinux.com>
*
* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h,v 1.17 2002/10/16 01:26:48 dawes Exp $
*
*/
#ifndef _XF86DRM_H_
#define _XF86DRM_H_
/* Defaults, if nothing set in xf86config */
#define DRM_DEV_UID 0
#define DRM_DEV_GID 0
/* Default /dev/dri directory permissions 0755 */
#define DRM_DEV_DIRMODE \
(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
#define DRM_DIR_NAME "/dev/dri"
#define DRM_DEV_NAME "%s/card%d"
#define DRM_PROC_NAME "/proc/dri/" /* For backware Linux compatibility */
#define DRM_ERR_NO_DEVICE (-1001)
#define DRM_ERR_NO_ACCESS (-1002)
#define DRM_ERR_NOT_ROOT (-1003)
#define DRM_ERR_INVALID (-1004)
#define DRM_ERR_NO_FD (-1005)
typedef unsigned long drmHandle, *drmHandlePtr; /* To mapped regions */
typedef unsigned int drmSize, *drmSizePtr; /* For mapped regions */
typedef void *drmAddress, **drmAddressPtr; /* For mapped regions */
typedef unsigned int drmContext, *drmContextPtr; /* GLXContext handle */
typedef unsigned int drmDrawable, *drmDrawablePtr; /* Unused */
typedef unsigned int drmMagic, *drmMagicPtr; /* Magic for auth */
typedef struct _drmVersion {
int version_major; /* Major version */
int version_minor; /* Minor version */
int version_patchlevel; /* Patch level */
int name_len; /* Length of name buffer */
char *name; /* Name of driver */
int date_len; /* Length of date buffer */
char *date; /* User-space buffer to hold date */
int desc_len; /* Length of desc buffer */
char *desc; /* User-space buffer to hold desc */
} drmVersion, *drmVersionPtr;
typedef struct _drmStats {
unsigned long count; /* Number of data */
struct {
unsigned long value; /* Value from kernel */
const char *long_format; /* Suggested format for long_name */
const char *long_name; /* Long name for value */
const char *rate_format; /* Suggested format for rate_name */
const char *rate_name; /* Short name for value per second */
int isvalue; /* True if value (vs. counter) */
const char *mult_names; /* Multiplier names (e.g., "KGM") */
int mult; /* Multiplier value (e.g., 1024) */
int verbose; /* Suggest only in verbose output */
} data[15];
} drmStatsT;
/* All of these enums *MUST* match with the
kernel implementation -- so do *NOT*
change them! (The drmlib implementation
will just copy the flags instead of
translating them.) */
typedef enum {
DRM_FRAME_BUFFER = 0, /* WC, no caching, no core dump */
DRM_REGISTERS = 1, /* no caching, no core dump */
DRM_SHM = 2, /* shared, cached */
DRM_AGP = 3, /* AGP/GART */
DRM_SCATTER_GATHER = 4 /* PCI scatter/gather */
} drmMapType;
typedef enum {
DRM_RESTRICTED = 0x0001, /* Cannot be mapped to client-virtual */
DRM_READ_ONLY = 0x0002, /* Read-only in client-virtual */
DRM_LOCKED = 0x0004, /* Physical pages locked */
DRM_KERNEL = 0x0008, /* Kernel requires access */
DRM_WRITE_COMBINING = 0x0010, /* Use write-combining, if available */
DRM_CONTAINS_LOCK = 0x0020, /* SHM page that contains lock */
DRM_REMOVABLE = 0x0040 /* Removable mapping */
} drmMapFlags;
typedef enum { /* These values *MUST* match drm.h */
/* Flags for DMA buffer dispatch */
DRM_DMA_BLOCK = 0x01, /* Block until buffer dispatched. Note,
the buffer may not yet have been
processed by the hardware -- getting a
hardware lock with the hardware
quiescent will ensure that the buffer
has been processed. */
DRM_DMA_WHILE_LOCKED = 0x02, /* Dispatch while lock held */
DRM_DMA_PRIORITY = 0x04, /* High priority dispatch */
/* Flags for DMA buffer request */
DRM_DMA_WAIT = 0x10, /* Wait for free buffers */
DRM_DMA_SMALLER_OK = 0x20, /* Smaller-than-requested buffers ok */
DRM_DMA_LARGER_OK = 0x40 /* Larger-than-requested buffers ok */
} drmDMAFlags;
typedef enum {
DRM_PAGE_ALIGN = 0x01,
DRM_AGP_BUFFER = 0x02,
DRM_SG_BUFFER = 0x04
} drmBufDescFlags;
typedef enum {
DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */
DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */
DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */
DRM_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */
/* These *HALT* flags aren't supported yet
-- they will be used to support the
full-screen DGA-like mode. */
DRM_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */
DRM_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */
} drmLockFlags;
typedef enum {
DRM_CONTEXT_PRESERVED = 0x01, /* This context is preserved and
never swapped. */
DRM_CONTEXT_2DONLY = 0x02 /* This context is for 2D rendering only. */
} drmContextFlags, *drmContextFlagsPtr;
typedef struct _drmBufDesc {
int count; /* Number of buffers of this size */
int size; /* Size in bytes */
int low_mark; /* Low water mark */
int high_mark; /* High water mark */
} drmBufDesc, *drmBufDescPtr;
typedef struct _drmBufInfo {
int count; /* Number of buffers described in list */
drmBufDescPtr list; /* List of buffer descriptions */
} drmBufInfo, *drmBufInfoPtr;
typedef struct _drmBuf {
int idx; /* Index into master buflist */
int total; /* Buffer size */
int used; /* Amount of buffer in use (for DMA) */
drmAddress address; /* Address */
} drmBuf, *drmBufPtr;
typedef struct _drmBufMap {
int count; /* Number of buffers mapped */
drmBufPtr list; /* Buffers */
} drmBufMap, *drmBufMapPtr;
typedef struct _drmLock {
volatile unsigned int lock;
char padding[60];
/* This is big enough for most current (and future?) architectures:
DEC Alpha: 32 bytes
Intel Merced: ?
Intel P5/PPro/PII/PIII: 32 bytes
Intel StrongARM: 32 bytes
Intel i386/i486: 16 bytes
MIPS: 32 bytes (?)
Motorola 68k: 16 bytes
Motorola PowerPC: 32 bytes
Sun SPARC: 32 bytes
*/
} drmLock, *drmLockPtr;
typedef struct _drmDMAReq {
/* Indices here refer to the offset into
list in drmBufInfo */
drmContext context; /* Context handle */
int send_count; /* Number of buffers to send */
int *send_list; /* List of handles to buffers */
int *send_sizes; /* Lengths of data to send, in bytes */
drmDMAFlags flags; /* Flags */
int request_count; /* Number of buffers requested */
int request_size; /* Desired size of buffers requested */
int *request_list; /* Buffer information */
int *request_sizes; /* Minimum acceptable sizes */
int granted_count; /* Number of buffers granted at this size */
} drmDMAReq, *drmDMAReqPtr;
typedef struct _drmRegion {
drmHandle handle;
unsigned int offset;
drmSize size;
drmAddress map;
} drmRegion, *drmRegionPtr;
typedef struct _drmTextureRegion {
unsigned char next;
unsigned char prev;
unsigned char in_use;
unsigned char padding; /* Explicitly pad this out */
unsigned int age;
} drmTextureRegion, *drmTextureRegionPtr;
typedef struct _drmClipRect {
unsigned short x1; /* Upper left: inclusive */
unsigned short y1;
unsigned short x2; /* Lower right: exclusive */
unsigned short y2;
} drmClipRect, *drmClipRectPtr;
typedef enum {
DRM_VBLANK_ABSOLUTE = 0x0, /* Wait for specific vblank sequence number */
DRM_VBLANK_RELATIVE = 0x1, /* Wait for given number of vblanks */
DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */
} drmVBlankSeqType;
typedef struct _drmVBlankReq {
drmVBlankSeqType type;
unsigned int sequence;
unsigned long signal;
} drmVBlankReq, *drmVBlankReqPtr;
typedef struct _drmVBlankReply {
drmVBlankSeqType type;
unsigned int sequence;
long tval_sec;
long tval_usec;
} drmVBlankReply, *drmVBlankReplyPtr;
typedef union _drmVBlank {
drmVBlankReq request;
drmVBlankReply reply;
} drmVBlank, *drmVBlankPtr;
#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
#define DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */
#define DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */
#if __GNUC__ >= 2
# if defined(__i386) || defined(__x86_64__)
/* Reflect changes here to drmP.h */
#define DRM_CAS(lock,old,new,__ret) \
do { \
int __dummy; /* Can't mark eax as clobbered */ \
__asm__ __volatile__( \
"lock ; cmpxchg %4,%1\n\t" \
"setnz %0" \
: "=d" (__ret), \
"=m" (__drm_dummy_lock(lock)), \
"=a" (__dummy) \
: "2" (old), \
"r" (new)); \
} while (0)
#elif defined(__alpha__)
#define DRM_CAS(lock, old, new, ret) \
do { \
int old32; \
int cur32; \
__asm__ __volatile__( \
" mb\n" \
" zap %4, 0xF0, %0\n" \
" ldl_l %1, %2\n" \
" zap %1, 0xF0, %1\n" \
" cmpeq %0, %1, %1\n" \
" beq %1, 1f\n" \
" bis %5, %5, %1\n" \
" stl_c %1, %2\n" \
"1: xor %1, 1, %1\n" \
" stl %1, %3" \
: "+r" (old32), \
"+&r" (cur32), \
"=m" (__drm_dummy_lock(lock)),\
"=m" (ret) \
: "r" (old), \
"r" (new)); \
} while(0)
#elif defined(__sparc__)
#define DRM_CAS(lock,old,new,__ret) \
do { register unsigned int __old __asm("o0"); \
register unsigned int __new __asm("o1"); \
register volatile unsigned int *__lock __asm("o2"); \
__old = old; \
__new = new; \
__lock = (volatile unsigned int *)lock; \
__asm__ __volatile__( \
/*"cas [%2], %3, %0"*/ \
".word 0xd3e29008\n\t" \
/*"membar #StoreStore | #StoreLoad"*/ \
".word 0x8143e00a" \
: "=&r" (__new) \
: "0" (__new), \
"r" (__lock), \
"r" (__old) \
: "memory"); \
__ret = (__new != __old); \
} while(0)
#elif defined(__ia64__)
#if 0
/* this currently generates bad code (missing stop bits)... */
#include <ia64intrin.h>
#define DRM_CAS(lock,old,new,__ret) \
do { \
__ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
(old), (new)) \
!= (old)); \
} while (0)
#else
#define DRM_CAS(lock,old,new,__ret) \
do { \
unsigned int __result, __old = (old); \
__asm__ __volatile__( \
"mf\n" \
"mov ar.ccv=%2\n" \
";;\n" \
"cmpxchg4.acq %0=%1,%3,ar.ccv" \
: "=r" (__result), "=m" (__drm_dummy_lock(lock)) \
: "r" (__old), "r" (new) \
: "memory"); \
__ret = (__result) != (__old); \
} while (0)
#endif
#elif defined(__powerpc__)
#define DRM_CAS(lock,old,new,__ret) \
do { \
__asm__ __volatile__( \
"sync;" \
"0: lwarx %0,0,%1;" \
" xor. %0,%3,%0;" \
" bne 1f;" \
" stwcx. %2,0,%1;" \
" bne- 0b;" \
"1: " \
"sync;" \
: "=&r"(__ret) \
: "r"(lock), "r"(new), "r"(old) \
: "cr0", "memory"); \
} while (0)
#endif /* architecture */
#endif /* __GNUC__ >= 2 */
#ifndef DRM_CAS
#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
#endif
#if defined(__alpha__) || defined(__powerpc__)
#define DRM_CAS_RESULT(_result) int _result
#else
#define DRM_CAS_RESULT(_result) char _result
#endif
#define DRM_LIGHT_LOCK(fd,lock,context) \
do { \
DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
if (__ret) drmGetLock(fd,context,0); \
} while(0)
/* This one counts fast locks -- for
benchmarking only. */
#define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \
do { \
DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
if (__ret) drmGetLock(fd,context,0); \
else ++count; \
} while(0)
#define DRM_LOCK(fd,lock,context,flags) \
do { \
if (flags) drmGetLock(fd,context,flags); \
else DRM_LIGHT_LOCK(fd,lock,context); \
} while(0)
#define DRM_UNLOCK(fd,lock,context) \
do { \
DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \
if (__ret) drmUnlock(fd,context); \
} while(0)
/* Simple spin locks */
#define DRM_SPINLOCK(spin,val) \
do { \
DRM_CAS_RESULT(__ret); \
do { \
DRM_CAS(spin,0,val,__ret); \
if (__ret) while ((spin)->lock); \
} while (__ret); \
} while(0)
#define DRM_SPINLOCK_TAKE(spin,val) \
do { \
DRM_CAS_RESULT(__ret); \
int cur; \
do { \
cur = (*spin).lock; \
DRM_CAS(spin,cur,val,__ret); \
} while (__ret); \
} while(0)
#define DRM_SPINLOCK_COUNT(spin,val,count,__ret) \
do { \
int __i; \
__ret = 1; \
for (__i = 0; __ret && __i < count; __i++) { \
DRM_CAS(spin,0,val,__ret); \
if (__ret) for (;__i < count && (spin)->lock; __i++); \
} \
} while(0)
#define DRM_SPINUNLOCK(spin,val) \
do { \
DRM_CAS_RESULT(__ret); \
if ((*spin).lock == val) { /* else server stole lock */ \
do { \
DRM_CAS(spin,val,0,__ret); \
} while (__ret); \
} \
} while(0)
/* General user-level programmer's API: unprivileged */
extern int drmAvailable(void);
extern int drmOpen(const char *name, const char *busid);
extern int drmClose(int fd);
extern drmVersionPtr drmGetVersion(int fd);
extern drmVersionPtr drmGetLibVersion(int fd);
extern void drmFreeVersion(drmVersionPtr);
extern int drmGetMagic(int fd, drmMagicPtr magic);
extern char *drmGetBusid(int fd);
extern int drmGetInterruptFromBusID(int fd, int busnum, int devnum,
int funcnum);
extern int drmGetMap(int fd, int idx, drmHandle *offset,
drmSize *size, drmMapType *type,
drmMapFlags *flags, drmHandle *handle,
int *mtrr);
extern int drmGetClient(int fd, int idx, int *auth, int *pid,
int *uid, unsigned long *magic,
unsigned long *iocs);
extern int drmGetStats(int fd, drmStatsT *stats);
extern int drmCommandNone(int fd, unsigned long drmCommandIndex);
extern int drmCommandRead(int fd, unsigned long drmCommandIndex,
void *data, unsigned long size);
extern int drmCommandWrite(int fd, unsigned long drmCommandIndex,
void *data, unsigned long size);
extern int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
void *data, unsigned long size);
/* General user-level programmer's API: X server (root) only */
extern void drmFreeBusid(const char *busid);
extern int drmSetBusid(int fd, const char *busid);
extern int drmAuthMagic(int fd, drmMagic magic);
extern int drmAddMap(int fd,
drmHandle offset,
drmSize size,
drmMapType type,
drmMapFlags flags,
drmHandlePtr handle);
extern int drmRmMap(int fd, drmHandle handle);
extern int drmAddContextPrivateMapping(int fd, drmContext ctx_id,
drmHandle handle);
extern int drmAddBufs(int fd, int count, int size,
drmBufDescFlags flags,
int agp_offset);
extern int drmMarkBufs(int fd, double low, double high);
extern int drmCreateContext(int fd, drmContextPtr handle);
extern int drmSetContextFlags(int fd, drmContext context,
drmContextFlags flags);
extern int drmGetContextFlags(int fd, drmContext context,
drmContextFlagsPtr flags);
extern int drmAddContextTag(int fd, drmContext context, void *tag);
extern int drmDelContextTag(int fd, drmContext context);
extern void *drmGetContextTag(int fd, drmContext context);
extern drmContextPtr drmGetReservedContextList(int fd, int *count);
extern void drmFreeReservedContextList(drmContextPtr);
extern int drmSwitchToContext(int fd, drmContext context);
extern int drmDestroyContext(int fd, drmContext handle);
extern int drmCreateDrawable(int fd, drmDrawablePtr handle);
extern int drmDestroyDrawable(int fd, drmDrawable handle);
extern int drmCtlInstHandler(int fd, int irq);
extern int drmCtlUninstHandler(int fd);
extern int drmInstallSIGIOHandler(int fd,
void (*f)(int fd,
void *oldctx,
void *newctx));
extern int drmRemoveSIGIOHandler(int fd);
/* General user-level programmer's API: authenticated client and/or X */
extern int drmMap(int fd,
drmHandle handle,
drmSize size,
drmAddressPtr address);
extern int drmUnmap(drmAddress address, drmSize size);
extern drmBufInfoPtr drmGetBufInfo(int fd);
extern drmBufMapPtr drmMapBufs(int fd);
extern int drmUnmapBufs(drmBufMapPtr bufs);
extern int drmDMA(int fd, drmDMAReqPtr request);
extern int drmFreeBufs(int fd, int count, int *list);
extern int drmGetLock(int fd,
drmContext context,
drmLockFlags flags);
extern int drmUnlock(int fd, drmContext context);
extern int drmFinish(int fd, int context, drmLockFlags flags);
extern int drmGetContextPrivateMapping(int fd, drmContext ctx_id,
drmHandlePtr handle);
/* AGP/GART support: X server (root) only */
extern int drmAgpAcquire(int fd);
extern int drmAgpRelease(int fd);
extern int drmAgpEnable(int fd, unsigned long mode);
extern int drmAgpAlloc(int fd, unsigned long size,
unsigned long type, unsigned long *address,
unsigned long *handle);
extern int drmAgpFree(int fd, unsigned long handle);
extern int drmAgpBind(int fd, unsigned long handle,
unsigned long offset);
extern int drmAgpUnbind(int fd, unsigned long handle);
/* AGP/GART info: authenticated client and/or X */
extern int drmAgpVersionMajor(int fd);
extern int drmAgpVersionMinor(int fd);
extern unsigned long drmAgpGetMode(int fd);
extern unsigned long drmAgpBase(int fd); /* Physical location */
extern unsigned long drmAgpSize(int fd); /* Bytes */
extern unsigned long drmAgpMemoryUsed(int fd);
extern unsigned long drmAgpMemoryAvail(int fd);
extern unsigned int drmAgpVendorId(int fd);
extern unsigned int drmAgpDeviceId(int fd);
/* PCI scatter/gather support: X server (root) only */
extern int drmScatterGatherAlloc(int fd, unsigned long size,
unsigned long *handle);
extern int drmScatterGatherFree(int fd, unsigned long handle);
extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
/* Support routines */
extern int drmError(int err, const char *label);
extern void *drmMalloc(int size);
extern void drmFree(void *pt);
/* Hash table routines */
extern void *drmHashCreate(void);
extern int drmHashDestroy(void *t);
extern int drmHashLookup(void *t, unsigned long key, void **value);
extern int drmHashInsert(void *t, unsigned long key, void *value);
extern int drmHashDelete(void *t, unsigned long key);
extern int drmHashFirst(void *t, unsigned long *key, void **value);
extern int drmHashNext(void *t, unsigned long *key, void **value);
/* PRNG routines */
extern void *drmRandomCreate(unsigned long seed);
extern int drmRandomDestroy(void *state);
extern unsigned long drmRandom(void *state);
extern double drmRandomDouble(void *state);
/* Skip list routines */
extern void *drmSLCreate(void);
extern int drmSLDestroy(void *l);
extern int drmSLLookup(void *l, unsigned long key, void **value);
extern int drmSLInsert(void *l, unsigned long key, void *value);
extern int drmSLDelete(void *l, unsigned long key);
extern int drmSLNext(void *l, unsigned long *key, void **value);
extern int drmSLFirst(void *l, unsigned long *key, void **value);
extern void drmSLDump(void *l);
extern int drmSLLookupNeighbors(void *l, unsigned long key,
unsigned long *prev_key, void **prev_value,
unsigned long *next_key, void **next_value);
#endif

435
src/dri-es/xf86drmHash.c Normal file
View File

@@ -0,0 +1,435 @@
/* xf86drmHash.c -- Small hash table support for integer -> integer mapping
* Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* 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, 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 (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 NONINFRINGEMENT. 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: Rickard E. (Rik) Faith <faith@valinux.com>
*
* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.4 2001/03/21 18:08:54 dawes Exp $
*
* DESCRIPTION
*
* This file contains a straightforward implementation of a fixed-sized
* hash table using self-organizing linked lists [Knuth73, pp. 398-399] for
* collision resolution. There are two potentially interesting things
* about this implementation:
*
* 1) The table is power-of-two sized. Prime sized tables are more
* traditional, but do not have a significant advantage over power-of-two
* sized table, especially when double hashing is not used for collision
* resolution.
*
* 2) The hash computation uses a table of random integers [Hanson97,
* pp. 39-41].
*
* FUTURE ENHANCEMENTS
*
* With a table size of 512, the current implementation is sufficient for a
* few hundred keys. Since this is well above the expected size of the
* tables for which this implementation was designed, the implementation of
* dynamic hash tables was postponed until the need arises. A common (and
* naive) approach to dynamic hash table implementation simply creates a
* new hash table when necessary, rehashes all the data into the new table,
* and destroys the old table. The approach in [Larson88] is superior in
* two ways: 1) only a portion of the table is expanded when needed,
* distributing the expansion cost over several insertions, and 2) portions
* of the table can be locked, enabling a scalable thread-safe
* implementation.
*
* REFERENCES
*
* [Hanson97] David R. Hanson. C Interfaces and Implementations:
* Techniques for Creating Reusable Software. Reading, Massachusetts:
* Addison-Wesley, 1997.
*
* [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3:
* Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973.
*
* [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April
* 1988, pp. 446-457.
*
*/
#define HASH_MAIN 0
#if HASH_MAIN
# include <stdio.h>
# include <stdlib.h>
#else
# include "xf86drm.h"
# ifdef XFree86LOADER
# include "xf86.h"
# include "xf86_ansic.h"
# else
# include <stdio.h>
# include <stdlib.h>
# endif
#endif
#define N(x) drm##x
#define HASH_MAGIC 0xdeadbeef
#define HASH_DEBUG 0
#define HASH_SIZE 512 /* Good for about 100 entries */
/* If you change this value, you probably
have to change the HashHash hashing
function! */
#if HASH_MAIN
#define HASH_ALLOC malloc
#define HASH_FREE free
#define HASH_RANDOM_DECL
#define HASH_RANDOM_INIT(seed) srandom(seed)
#define HASH_RANDOM random()
#else
#define HASH_ALLOC drmMalloc
#define HASH_FREE drmFree
#define HASH_RANDOM_DECL void *state
#define HASH_RANDOM_INIT(seed) state = drmRandomCreate(seed)
#define HASH_RANDOM drmRandom(state)
#endif
typedef struct HashBucket {
unsigned long key;
void *value;
struct HashBucket *next;
} HashBucket, *HashBucketPtr;
typedef struct HashTable {
unsigned long magic;
unsigned long entries;
unsigned long hits; /* At top of linked list */
unsigned long partials; /* Not at top of linked list */
unsigned long misses; /* Not in table */
HashBucketPtr buckets[HASH_SIZE];
int p0;
HashBucketPtr p1;
} HashTable, *HashTablePtr;
#if HASH_MAIN
extern void *N(HashCreate)(void);
extern int N(HashDestroy)(void *t);
extern int N(HashLookup)(void *t, unsigned long key, unsigned long *value);
extern int N(HashInsert)(void *t, unsigned long key, unsigned long value);
extern int N(HashDelete)(void *t, unsigned long key);
#endif
static unsigned long HashHash(unsigned long key)
{
unsigned long hash = 0;
unsigned long tmp = key;
static int init = 0;
static unsigned long scatter[256];
int i;
if (!init) {
HASH_RANDOM_DECL;
HASH_RANDOM_INIT(37);
for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM;
++init;
}
while (tmp) {
hash = (hash << 1) + scatter[tmp & 0xff];
tmp >>= 8;
}
hash %= HASH_SIZE;
#if HASH_DEBUG
printf( "Hash(%d) = %d\n", key, hash);
#endif
return hash;
}
void *N(HashCreate)(void)
{
HashTablePtr table;
int i;
table = HASH_ALLOC(sizeof(*table));
if (!table) return NULL;
table->magic = HASH_MAGIC;
table->entries = 0;
table->hits = 0;
table->partials = 0;
table->misses = 0;
for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL;
return table;
}
int N(HashDestroy)(void *t)
{
HashTablePtr table = (HashTablePtr)t;
HashBucketPtr bucket;
HashBucketPtr next;
int i;
if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
for (i = 0; i < HASH_SIZE; i++) {
for (bucket = table->buckets[i]; bucket;) {
next = bucket->next;
HASH_FREE(bucket);
bucket = next;
}
}
HASH_FREE(table);
return 0;
}
/* Find the bucket and organize the list so that this bucket is at the
top. */
static HashBucketPtr HashFind(HashTablePtr table,
unsigned long key, unsigned long *h)
{
unsigned long hash = HashHash(key);
HashBucketPtr prev = NULL;
HashBucketPtr bucket;
if (h) *h = hash;
for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
if (bucket->key == key) {
if (prev) {
/* Organize */
prev->next = bucket->next;
bucket->next = table->buckets[hash];
table->buckets[hash] = bucket;
++table->partials;
} else {
++table->hits;
}
return bucket;
}
prev = bucket;
}
++table->misses;
return NULL;
}
int N(HashLookup)(void *t, unsigned long key, void **value)
{
HashTablePtr table = (HashTablePtr)t;
HashBucketPtr bucket;
if (!table || table->magic != HASH_MAGIC) return -1; /* Bad magic */
bucket = HashFind(table, key, NULL);
if (!bucket) return 1; /* Not found */
*value = bucket->value;
return 0; /* Found */
}
int N(HashInsert)(void *t, unsigned long key, void *value)
{
HashTablePtr table = (HashTablePtr)t;
HashBucketPtr bucket;
unsigned long hash;
if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
if (HashFind(table, key, &hash)) return 1; /* Already in table */
bucket = HASH_ALLOC(sizeof(*bucket));
if (!bucket) return -1; /* Error */
bucket->key = key;
bucket->value = value;
bucket->next = table->buckets[hash];
table->buckets[hash] = bucket;
#if HASH_DEBUG
printf("Inserted %d at %d/%p\n", key, hash, bucket);
#endif
return 0; /* Added to table */
}
int N(HashDelete)(void *t, unsigned long key)
{
HashTablePtr table = (HashTablePtr)t;
unsigned long hash;
HashBucketPtr bucket;
if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
bucket = HashFind(table, key, &hash);
if (!bucket) return 1; /* Not found */
table->buckets[hash] = bucket->next;
HASH_FREE(bucket);
return 0;
}
int N(HashNext)(void *t, unsigned long *key, void **value)
{
HashTablePtr table = (HashTablePtr)t;
for (; table->p0 < HASH_SIZE;
++table->p0, table->p1 = table->buckets[table->p0]) {
if (table->p1) {
*key = table->p1->key;
*value = table->p1->value;
table->p1 = table->p1->next;
return 1;
}
}
return 0;
}
int N(HashFirst)(void *t, unsigned long *key, void **value)
{
HashTablePtr table = (HashTablePtr)t;
if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
table->p0 = 0;
table->p1 = table->buckets[0];
return N(HashNext)(table, key, value);
}
#if HASH_MAIN
#define DIST_LIMIT 10
static int dist[DIST_LIMIT];
static void clear_dist(void) {
int i;
for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0;
}
static int count_entries(HashBucketPtr bucket)
{
int count = 0;
for (; bucket; bucket = bucket->next) ++count;
return count;
}
static void update_dist(int count)
{
if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1];
else ++dist[count];
}
static void compute_dist(HashTablePtr table)
{
int i;
HashBucketPtr bucket;
printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n",
table->entries, table->hits, table->partials, table->misses);
clear_dist();
for (i = 0; i < HASH_SIZE; i++) {
bucket = table->buckets[i];
update_dist(count_entries(bucket));
}
for (i = 0; i < DIST_LIMIT; i++) {
if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]);
else printf("other %10d\n", dist[i]);
}
}
static void check_table(HashTablePtr table,
unsigned long key, unsigned long value)
{
unsigned long retval = 0;
int retcode = N(HashLookup)(table, key, &retval);
switch (retcode) {
case -1:
printf("Bad magic = 0x%08lx:"
" key = %lu, expected = %lu, returned = %lu\n",
table->magic, key, value, retval);
break;
case 1:
printf("Not found: key = %lu, expected = %lu returned = %lu\n",
key, value, retval);
break;
case 0:
if (value != retval)
printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
key, value, retval);
break;
default:
printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
retcode, key, value, retval);
break;
}
}
int main(void)
{
HashTablePtr table;
int i;
printf("\n***** 256 consecutive integers ****\n");
table = N(HashCreate)();
for (i = 0; i < 256; i++) N(HashInsert)(table, i, i);
for (i = 0; i < 256; i++) check_table(table, i, i);
for (i = 256; i >= 0; i--) check_table(table, i, i);
compute_dist(table);
N(HashDestroy)(table);
printf("\n***** 1024 consecutive integers ****\n");
table = N(HashCreate)();
for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i);
for (i = 0; i < 1024; i++) check_table(table, i, i);
for (i = 1024; i >= 0; i--) check_table(table, i, i);
compute_dist(table);
N(HashDestroy)(table);
printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
table = N(HashCreate)();
for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i);
for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
compute_dist(table);
N(HashDestroy)(table);
printf("\n***** 1024 random integers ****\n");
table = N(HashCreate)();
srandom(0xbeefbeef);
for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 1024; i++) check_table(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 1024; i++) check_table(table, random(), i);
compute_dist(table);
N(HashDestroy)(table);
printf("\n***** 5000 random integers ****\n");
table = N(HashCreate)();
srandom(0xbeefbeef);
for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 5000; i++) check_table(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 5000; i++) check_table(table, random(), i);
compute_dist(table);
N(HashDestroy)(table);
return 0;
}
#endif

219
src/dri-es/xf86drmRandom.c Normal file
View File

@@ -0,0 +1,219 @@
/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation
* Created: Mon Apr 19 08:28:13 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* 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, 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 (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 NONINFRINGEMENT. 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: Rickard E. (Rik) Faith <faith@valinux.com>
*
* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c,v 1.4 2000/06/17 00:03:34 martin Exp $
*
* DESCRIPTION
*
* This file contains a simple, straightforward implementation of the Park
* & Miller "Minimal Standard" PRNG [PM88, PMS93], which is a Lehmer
* multiplicative linear congruential generator (MLCG) with a period of
* 2^31-1.
*
* This implementation is intended to provide a reliable, portable PRNG
* that is suitable for testing a hash table implementation and for
* implementing skip lists.
*
* FUTURE ENHANCEMENTS
*
* If initial seeds are not selected randomly, two instances of the PRNG
* can be correlated. [Knuth81, pp. 32-33] describes a shuffling technique
* that can eliminate this problem.
*
* If PRNGs are used for simulation, the period of the current
* implementation may be too short. [LE88] discusses methods of combining
* MLCGs to produce much longer periods, and suggests some alternative
* values for A and M. [LE90 and Sch92] also provide information on
* long-period PRNGs.
*
* REFERENCES
*
* [Knuth81] Donald E. Knuth. The Art of Computer Programming. Volume 2:
* Seminumerical Algorithms. Reading, Massachusetts: Addison-Wesley, 1981.
*
* [LE88] Pierre L'Ecuyer. "Efficient and Portable Combined Random Number
* Generators". CACM 31(6), June 1988, pp. 742-774.
*
* [LE90] Pierre L'Ecuyer. "Random Numbers for Simulation". CACM 33(10,
* October 1990, pp. 85-97.
*
* [PM88] Stephen K. Park and Keith W. Miller. "Random Number Generators:
* Good Ones are Hard to Find". CACM 31(10), October 1988, pp. 1192-1201.
*
* [Sch92] Bruce Schneier. "Pseudo-Ransom Sequence Generator for 32-Bit
* CPUs". Dr. Dobb's Journal 17(2), February 1992, pp. 34, 37-38, 40.
*
* [PMS93] Stephen K. Park, Keith W. Miller, and Paul K. Stockmeyer. In
* "Technical Correspondence: Remarks on Choosing and Implementing Random
* Number Generators". CACM 36(7), July 1993, pp. 105-110.
*
*/
#define RANDOM_MAIN 0
#if RANDOM_MAIN
# include <stdio.h>
# include <stdlib.h>
#else
# include "xf86drm.h"
# ifdef XFree86LOADER
# include "xf86.h"
# include "xf86_ansic.h"
# else
# include <stdio.h>
# include <stdlib.h>
# endif
#endif
#define N(x) drm##x
#define RANDOM_MAGIC 0xfeedbeef
#define RANDOM_DEBUG 0
#if RANDOM_MAIN
#define RANDOM_ALLOC malloc
#define RANDOM_FREE free
#else
#define RANDOM_ALLOC drmMalloc
#define RANDOM_FREE drmFree
#endif
typedef struct RandomState {
unsigned long magic;
unsigned long a;
unsigned long m;
unsigned long q; /* m div a */
unsigned long r; /* m mod a */
unsigned long check;
long seed;
} RandomState;
#if RANDOM_MAIN
extern void *N(RandomCreate)(unsigned long seed);
extern int N(RandomDestroy)(void *state);
extern unsigned long N(Random)(void *state);
extern double N(RandomDouble)(void *state);
#endif
void *N(RandomCreate)(unsigned long seed)
{
RandomState *state;
state = RANDOM_ALLOC(sizeof(*state));
if (!state) return NULL;
state->magic = RANDOM_MAGIC;
#if 0
/* Park & Miller, October 1988 */
state->a = 16807;
state->m = 2147483647;
state->check = 1043618065; /* After 10000 iterations */
#else
/* Park, Miller, and Stockmeyer, July 1993 */
state->a = 48271;
state->m = 2147483647;
state->check = 399268537; /* After 10000 iterations */
#endif
state->q = state->m / state->a;
state->r = state->m % state->a;
state->seed = seed;
/* Check for illegal boundary conditions,
and choose closest legal value. */
if (state->seed <= 0) state->seed = 1;
if (state->seed >= state->m) state->seed = state->m - 1;
return state;
}
int N(RandomDestroy)(void *state)
{
RANDOM_FREE(state);
return 0;
}
unsigned long N(Random)(void *state)
{
RandomState *s = (RandomState *)state;
long hi;
long lo;
hi = s->seed / s->q;
lo = s->seed % s->q;
s->seed = s->a * lo - s->r * hi;
if (s->seed <= 0) s->seed += s->m;
return s->seed;
}
double N(RandomDouble)(void *state)
{
RandomState *s = (RandomState *)state;
return (double)N(Random)(state)/(double)s->m;
}
#if RANDOM_MAIN
static void check_period(long seed)
{
unsigned long count = 0;
unsigned long initial;
void *state;
state = N(RandomCreate)(seed);
initial = N(Random)(state);
++count;
while (initial != N(Random)(state)) {
if (!++count) break;
}
printf("With seed of %10ld, period = %10lu (0x%08lx)\n",
seed, count, count);
N(RandomDestroy)(state);
}
int main(void)
{
RandomState *state;
int i;
unsigned long rand;
state = N(RandomCreate)(1);
for (i = 0; i < 10000; i++) {
rand = N(Random)(state);
}
printf("After 10000 iterations: %lu (%lu expected): %s\n",
rand, state->check,
rand - state->check ? "*INCORRECT*" : "CORRECT");
N(RandomDestroy)(state);
printf("Checking periods...\n");
check_period(1);
check_period(2);
check_period(31415926);
return 0;
}
#endif

490
src/dri-es/xf86drmSL.c Normal file
View File

@@ -0,0 +1,490 @@
/* xf86drmSL.c -- Skip list support
* Created: Mon May 10 09:28:13 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* 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, 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 (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 NONINFRINGEMENT. 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: Rickard E. (Rik) Faith <faith@valinux.com>
*
* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c,v 1.3 2000/06/17 00:03:34 martin Exp $
*
* DESCRIPTION
*
* This file contains a straightforward skip list implementation.n
*
* FUTURE ENHANCEMENTS
*
* REFERENCES
*
* [Pugh90] William Pugh. Skip Lists: A Probabilistic Alternative to
* Balanced Trees. CACM 33(6), June 1990, pp. 668-676.
*
*/
#define SL_MAIN 0
#if SL_MAIN
# include <stdio.h>
# include <stdlib.h>
# include <sys/time.h>
#else
# include "xf86drm.h"
# ifdef XFree86LOADER
# include "xf86.h"
# include "xf86_ansic.h"
# else
# include <stdio.h>
# include <stdlib.h>
# endif
#endif
#define N(x) drm##x
#define SL_LIST_MAGIC 0xfacade00LU
#define SL_ENTRY_MAGIC 0x00fab1edLU
#define SL_FREED_MAGIC 0xdecea5edLU
#define SL_MAX_LEVEL 16
#define SL_DEBUG 0
#define SL_RANDOM_SEED 0xc01055a1LU
#if SL_MAIN
#define SL_ALLOC malloc
#define SL_FREE free
#define SL_RANDOM_DECL static int state = 0;
#define SL_RANDOM_INIT(seed) if (!state) { srandom(seed); ++state; }
#define SL_RANDOM random()
#else
#define SL_ALLOC drmMalloc
#define SL_FREE drmFree
#define SL_RANDOM_DECL static void *state = NULL
#define SL_RANDOM_INIT(seed) if (!state) state = drmRandomCreate(seed)
#define SL_RANDOM drmRandom(state)
#endif
typedef struct SLEntry {
unsigned long magic; /* SL_ENTRY_MAGIC */
unsigned long key;
void *value;
int levels;
struct SLEntry *forward[1]; /* variable sized array */
} SLEntry, *SLEntryPtr;
typedef struct SkipList {
unsigned long magic; /* SL_LIST_MAGIC */
int level;
int count;
SLEntryPtr head;
SLEntryPtr p0; /* Position for iteration */
} SkipList, *SkipListPtr;
#if SL_MAIN
extern void *N(SLCreate)(void);
extern int N(SLDestroy)(void *l);
extern int N(SLLookup)(void *l, unsigned long key, void **value);
extern int N(SLInsert)(void *l, unsigned long key, void *value);
extern int N(SLDelete)(void *l, unsigned long key);
extern int N(SLNext)(void *l, unsigned long *key, void **value);
extern int N(SLFirst)(void *l, unsigned long *key, void **value);
extern void N(SLDump)(void *l);
extern int N(SLLookupNeighbors)(void *l, unsigned long key,
unsigned long *prev_key, void **prev_value,
unsigned long *next_key, void **next_value);
#endif
static SLEntryPtr SLCreateEntry(int max_level, unsigned long key, void *value)
{
SLEntryPtr entry;
if (max_level < 0 || max_level > SL_MAX_LEVEL) max_level = SL_MAX_LEVEL;
entry = SL_ALLOC(sizeof(*entry)
+ (max_level + 1) * sizeof(entry->forward[0]));
if (!entry) return NULL;
entry->magic = SL_ENTRY_MAGIC;
entry->key = key;
entry->value = value;
entry->levels = max_level + 1;
return entry;
}
static int SLRandomLevel(void)
{
int level = 1;
SL_RANDOM_DECL;
SL_RANDOM_INIT(SL_RANDOM_SEED);
while ((SL_RANDOM & 0x01) && level < SL_MAX_LEVEL) ++level;
return level;
}
void *N(SLCreate)(void)
{
SkipListPtr list;
int i;
list = SL_ALLOC(sizeof(*list));
if (!list) return NULL;
list->magic = SL_LIST_MAGIC;
list->level = 0;
list->head = SLCreateEntry(SL_MAX_LEVEL, 0, NULL);
list->count = 0;
for (i = 0; i <= SL_MAX_LEVEL; i++) list->head->forward[i] = NULL;
return list;
}
int N(SLDestroy)(void *l)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
SLEntryPtr next;
if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
for (entry = list->head; entry; entry = next) {
if (entry->magic != SL_ENTRY_MAGIC) return -1; /* Bad magic */
next = entry->forward[0];
entry->magic = SL_FREED_MAGIC;
SL_FREE(entry);
}
list->magic = SL_FREED_MAGIC;
SL_FREE(list);
return 0;
}
static SLEntryPtr SLLocate(void *l, unsigned long key, SLEntryPtr *update)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
int i;
if (list->magic != SL_LIST_MAGIC) return NULL;
for (i = list->level, entry = list->head; i >= 0; i--) {
while (entry->forward[i] && entry->forward[i]->key < key)
entry = entry->forward[i];
update[i] = entry;
}
return entry->forward[0];
}
int N(SLInsert)(void *l, unsigned long key, void *value)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
SLEntryPtr update[SL_MAX_LEVEL + 1];
int level;
int i;
if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
entry = SLLocate(list, key, update);
if (entry && entry->key == key) return 1; /* Already in list */
level = SLRandomLevel();
if (level > list->level) {
level = ++list->level;
update[level] = list->head;
}
entry = SLCreateEntry(level, key, value);
/* Fix up forward pointers */
for (i = 0; i <= level; i++) {
entry->forward[i] = update[i]->forward[i];
update[i]->forward[i] = entry;
}
++list->count;
return 0; /* Added to table */
}
int N(SLDelete)(void *l, unsigned long key)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr update[SL_MAX_LEVEL + 1];
SLEntryPtr entry;
int i;
if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
entry = SLLocate(list, key, update);
if (!entry || entry->key != key) return 1; /* Not found */
/* Fix up forward pointers */
for (i = 0; i <= list->level; i++) {
if (update[i]->forward[i] == entry)
update[i]->forward[i] = entry->forward[i];
}
entry->magic = SL_FREED_MAGIC;
SL_FREE(entry);
while (list->level && !list->head->forward[list->level]) --list->level;
--list->count;
return 0;
}
int N(SLLookup)(void *l, unsigned long key, void **value)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr update[SL_MAX_LEVEL + 1];
SLEntryPtr entry;
entry = SLLocate(list, key, update);
if (entry && entry->key == key) {
*value = entry;
return 0;
}
*value = NULL;
return -1;
}
int N(SLLookupNeighbors)(void *l, unsigned long key,
unsigned long *prev_key, void **prev_value,
unsigned long *next_key, void **next_value)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr update[SL_MAX_LEVEL + 1];
SLEntryPtr entry;
int retcode = 0;
entry = SLLocate(list, key, update);
*prev_key = *next_key = key;
*prev_value = *next_value = NULL;
if (update[0]) {
*prev_key = update[0]->key;
*prev_value = update[0]->value;
++retcode;
if (update[0]->forward[0]) {
*next_key = update[0]->forward[0]->key;
*next_value = update[0]->forward[0]->value;
++retcode;
}
}
return retcode;
}
int N(SLNext)(void *l, unsigned long *key, void **value)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
entry = list->p0;
if (entry) {
list->p0 = entry->forward[0];
*key = entry->key;
*value = entry->value;
return 1;
}
list->p0 = NULL;
return 0;
}
int N(SLFirst)(void *l, unsigned long *key, void **value)
{
SkipListPtr list = (SkipListPtr)l;
if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
list->p0 = list->head->forward[0];
return N(SLNext)(list, key, value);
}
/* Dump internal data structures for debugging. */
void N(SLDump)(void *l)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
int i;
if (list->magic != SL_LIST_MAGIC) {
printf("Bad magic: 0x%08lx (expected 0x%08lx)\n",
list->magic, SL_LIST_MAGIC);
return;
}
printf("Level = %d, count = %d\n", list->level, list->count);
for (entry = list->head; entry; entry = entry->forward[0]) {
if (entry->magic != SL_ENTRY_MAGIC) {
printf("Bad magic: 0x%08lx (expected 0x%08lx)\n",
list->magic, SL_ENTRY_MAGIC);
}
printf("\nEntry %p <0x%08lx, %p> has %2d levels\n",
entry, entry->key, entry->value, entry->levels);
for (i = 0; i < entry->levels; i++) {
if (entry->forward[i]) {
printf(" %2d: %p <0x%08lx, %p>\n",
i,
entry->forward[i],
entry->forward[i]->key,
entry->forward[i]->value);
} else {
printf(" %2d: %p\n", i, entry->forward[i]);
}
}
}
}
#if SL_MAIN
static void print(SkipListPtr list)
{
unsigned long key;
void *value;
if (N(SLFirst)(list, &key, &value)) {
do {
printf("key = %5lu, value = %p\n", key, value);
} while (N(SLNext)(list, &key, &value));
}
}
static double do_time(int size, int iter)
{
SkipListPtr list;
int i, j;
unsigned long keys[1000000];
unsigned long previous;
unsigned long key;
void *value;
struct timeval start, stop;
double usec;
SL_RANDOM_DECL;
SL_RANDOM_INIT(12345);
list = N(SLCreate)();
for (i = 0; i < size; i++) {
keys[i] = SL_RANDOM;
N(SLInsert)(list, keys[i], NULL);
}
previous = 0;
if (N(SLFirst)(list, &key, &value)) {
do {
if (key <= previous) {
printf( "%lu !< %lu\n", previous, key);
}
previous = key;
} while (N(SLNext)(list, &key, &value));
}
gettimeofday(&start, NULL);
for (j = 0; j < iter; j++) {
for (i = 0; i < size; i++) {
if (N(SLLookup)(list, keys[i], &value))
printf("Error %lu %d\n", keys[i], i);
}
}
gettimeofday(&stop, NULL);
usec = (double)(stop.tv_sec * 1000000 + stop.tv_usec
- start.tv_sec * 1000000 - start.tv_usec) / (size * iter);
printf("%0.2f microseconds for list length %d\n", usec, size);
N(SLDestroy)(list);
return usec;
}
static void print_neighbors(void *list, unsigned long key)
{
unsigned long prev_key = 0;
unsigned long next_key = 0;
void *prev_value;
void *next_value;
int retval;
retval = drmSLLookupNeighbors(list, key,
&prev_key, &prev_value,
&next_key, &next_value);
printf("Neighbors of %5lu: %d %5lu %5lu\n",
key, retval, prev_key, next_key);
}
int main(void)
{
SkipListPtr list;
double usec, usec2, usec3, usec4;
list = N(SLCreate)();
printf( "list at %p\n", list);
print(list);
printf("\n==============================\n\n");
N(SLInsert)(list, 123, NULL);
N(SLInsert)(list, 213, NULL);
N(SLInsert)(list, 50, NULL);
print(list);
printf("\n==============================\n\n");
print_neighbors(list, 0);
print_neighbors(list, 50);
print_neighbors(list, 51);
print_neighbors(list, 123);
print_neighbors(list, 200);
print_neighbors(list, 213);
print_neighbors(list, 256);
printf("\n==============================\n\n");
N(SLDelete)(list, 50);
print(list);
printf("\n==============================\n\n");
N(SLDump)(list);
N(SLDestroy)(list);
printf("\n==============================\n\n");
usec = do_time(100, 10000);
usec2 = do_time(1000, 500);
printf("Table size increased by %0.2f, search time increased by %0.2f\n",
1000.0/100.0, usec2 / usec);
usec3 = do_time(10000, 50);
printf("Table size increased by %0.2f, search time increased by %0.2f\n",
10000.0/100.0, usec3 / usec);
usec4 = do_time(100000, 4);
printf("Table size increased by %0.2f, search time increased by %0.2f\n",
100000.0/100.0, usec4 / usec);
return 0;
}
#endif

2
src/glut/mini/.cvsignore Normal file
View File

@@ -0,0 +1,2 @@
*.d
libglut.so*

98
src/glut/mini/Makefile Normal file
View File

@@ -0,0 +1,98 @@
# Mesa 3-D graphics library
# Version: 4.0
#
# Copyright (C) 1999 Brian Paul 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, 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
# BRIAN PAUL 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.
# DOS/DJGPP glut makefile v1.1 for Mesa 4.0
#
# Copyright (C) 2002 - Borca Daniel
# Email : dborca@yahoo.com
# Web : http://www.geocities.com/dborca
.PHONY: all clean
TOP = ../..
MARK = $(TOP)/src-glut
LIBDIR = $(TOP)/lib
GLUT_LIB = libglut.so
CC = gcc
INCLUDES = -I$(TOP)/include -I$(MARK)
CFLAGS = -c -g $(INCLUDES) -MD
CORE_SOURCES = \
bitmap.c \
callback.c \
color.c \
globals.c \
init.c \
menu.c \
models.c \
overlay.c \
state.c \
teapot.c \
window.c
MARK_SOURCES = \
$(MARK)/glut_8x13.c \
$(MARK)/glut_9x15.c \
$(MARK)/glut_hel10.c \
$(MARK)/glut_hel12.c \
$(MARK)/glut_hel18.c \
$(MARK)/glut_tr10.c \
$(MARK)/glut_tr24.c
SOURCES = $(CORE_SOURCES) $(MARK_SOURCES)
OBJS = $(addsuffix .o,$(basename $(SOURCES)))
LIBS=-L$(TOP)/lib -lGL -lGLU -lm
.c.o:
$(CC) -o $@ -c $(CFLAGS) $<
.S.o:
$(CC) -o $@ -c $(CFLAGS) $<
default: libglut.so.3.7 install
libglut.so.3.7: $(OBJS) Makefile
gcc -shared -Wl,-soname,libglut.so -Wl,-Bsymbolic $(OBJS) $(LIBS) -o $@
install:
rm -f $(TOP)/lib/libglut.so*
install -D libglut.so.3.7 $(TOP)/lib/libglut.so.3.7
ln -s libglut.so.3.7 $(TOP)/lib/libglut.so.3
ln -s libglut.so.3 $(TOP)/lib/libglut.so
clean:
rm -f *~ .*~ *.o libglut.so* *.d
-include $(SOURCES:.c=.d)
.SUFFIXES: .c .d
.c.d:
$(CC) -M $(INCLUDES) $< > $@

56
src/glut/mini/bitmap.c Normal file
View File

@@ -0,0 +1,56 @@
/* Copyright (c) Mark J. Kilgard, 1994. */
/* This program is freely distributable without licensing fees
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */
#include "glutbitmap.h"
void APIENTRY
glutBitmapCharacter(GLUTbitmapFont font, int c)
{
const BitmapCharRec *ch;
BitmapFontPtr fontinfo;
GLint swapbytes, lsbfirst, rowlength;
GLint skiprows, skippixels, alignment;
#if defined(_WIN32)
fontinfo = (BitmapFontPtr) __glutFont(font);
#else
fontinfo = (BitmapFontPtr) font;
#endif
if (c < fontinfo->first ||
c >= fontinfo->first + fontinfo->num_chars)
return;
ch = fontinfo->ch[c - fontinfo->first];
if (ch) {
/* Save current modes. */
glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
/* Little endian machines (DEC Alpha for example) could
benefit from setting GL_UNPACK_LSB_FIRST to GL_TRUE
instead of GL_FALSE, but this would require changing the
generated bitmaps too. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
ch->advance, 0, ch->bitmap);
/* Restore saved modes. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
}
}

152
src/glut/mini/callback.c Normal file
View File

@@ -0,0 +1,152 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include "internal.h"
void APIENTRY glutDisplayFunc (void (GLUTCALLBACK *func) (void))
{
display_func = func;
}
void APIENTRY glutReshapeFunc (void (GLUTCALLBACK *func) (int width, int height))
{
reshape_func = func;
}
void APIENTRY glutKeyboardFunc (void (GLUTCALLBACK *func) (unsigned char key, int x, int y))
{
keyboard_func = func;
}
void APIENTRY glutMouseFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))
{
mouse_func = func;
}
void APIENTRY glutMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
{
motion_func = func;
}
void APIENTRY glutPassiveMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
{
passive_motion_func = func;
}
void APIENTRY glutEntryFunc (void (GLUTCALLBACK *func) (int state))
{
entry_func = func;
}
void APIENTRY glutVisibilityFunc (void (GLUTCALLBACK *func) (int state))
{
visibility_func = func;
}
void APIENTRY glutIdleFunc (void (GLUTCALLBACK *func) (void))
{
idle_func = func;
}
void APIENTRY glutTimerFunc (unsigned int millis, void (GLUTCALLBACK *func) (int value), int value)
{
}
void APIENTRY glutMenuStateFunc (void (GLUTCALLBACK *func) (int state))
{
menu_state_func = func;
}
void APIENTRY glutSpecialFunc (void (GLUTCALLBACK *func) (int key, int x, int y))
{
special_func = func;
}
void APIENTRY glutSpaceballMotionFunc (void (GLUTCALLBACK *func) (int x, int y, int z))
{
}
void APIENTRY glutSpaceballRotateFunc (void (GLUTCALLBACK *func) (int x, int y, int z))
{
}
void APIENTRY glutSpaceballButtonFunc (void (GLUTCALLBACK *func) (int button, int state))
{
}
void APIENTRY glutButtonBoxFunc (void (GLUTCALLBACK *func) (int button, int state))
{
}
void APIENTRY glutDialsFunc (void (GLUTCALLBACK *func) (int dial, int value))
{
}
void APIENTRY glutTabletMotionFunc (void (GLUTCALLBACK *func) (int x, int y))
{
}
void APIENTRY glutTabletButtonFunc (void (GLUTCALLBACK *func) (int button, int state, int x, int y))
{
}
void APIENTRY glutMenuStatusFunc (void (GLUTCALLBACK *func) (int status, int x, int y))
{
}
void APIENTRY glutOverlayDisplayFunc (void (GLUTCALLBACK *func) (void))
{
}
void APIENTRY glutWindowStatusFunc (void (GLUTCALLBACK *func) (int state))
{
}

46
src/glut/mini/color.c Normal file
View File

@@ -0,0 +1,46 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
void APIENTRY glutSetColor (int ndx, GLfloat red, GLfloat green, GLfloat blue)
{
}
GLfloat APIENTRY glutGetColor (int ndx, int component)
{
return 0.0;
}
void APIENTRY glutCopyColormap (int win)
{
}

61
src/glut/mini/globals.c Normal file
View File

@@ -0,0 +1,61 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include "internal.h"
GLenum g_display_mode = 0;
GLuint g_width = DEFAULT_WIDTH;
GLuint g_height = DEFAULT_HEIGHT;
GLint g_mouse = GL_FALSE;
GLboolean g_redisplay = GL_FALSE;
GLint g_xpos = 0;
GLint g_ypos = 0;
void (GLUTCALLBACK *display_func) (void) = 0;
void (GLUTCALLBACK *reshape_func) (int width, int height) = 0;
void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y) = 0;
void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y) = 0;
void (GLUTCALLBACK *motion_func) (int x, int y) = 0;
void (GLUTCALLBACK *passive_motion_func) (int x, int y) = 0;
void (GLUTCALLBACK *entry_func) (int state) = 0;
void (GLUTCALLBACK *visibility_func) (int state) = 0;
void (GLUTCALLBACK *idle_func) (void) = 0;
void (GLUTCALLBACK *menu_state_func) (int state) = 0;
void (GLUTCALLBACK *special_func) (int key, int x, int y) = 0;
void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z) = 0;
void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z) = 0;
void (GLUTCALLBACK *spaceball_button_func) (int button, int state) = 0;
void (GLUTCALLBACK *button_box_func) (int button, int state) = 0;
void (GLUTCALLBACK *dials_func) (int dial, int value) = 0;
void (GLUTCALLBACK *tablet_motion_func) (int x, int y) = 0;
void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y) = 0;
void (GLUTCALLBACK *menu_status_func) (int status, int x, int y) = 0;
void (GLUTCALLBACK *overlay_display_func) (void) = 0;
void (GLUTCALLBACK *window_status_func) (int state) = 0;

162
src/glut/mini/init.c Normal file
View File

@@ -0,0 +1,162 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include "internal.h"
void APIENTRY glutInit (int *argcp, char **argv)
{
glutGet(GLUT_ELAPSED_TIME);
}
void APIENTRY glutInitDisplayMode (unsigned int mode)
{
g_display_mode = mode;
/* pc_install_keyb(); */
/* g_mouse = pc_install_mouse(); */
}
void APIENTRY glutInitWindowPosition (int x, int y)
{
g_xpos = x;
g_ypos = y;
}
void APIENTRY glutInitWindowSize (int width, int height)
{
g_width = width;
g_height = height;
}
void APIENTRY glutMainLoop (void)
{
GLboolean idle;
static int old_mouse_x = 0;
static int old_mouse_y = 0;
static int old_mouse_b = 0;
glutPostRedisplay();
if (reshape_func) reshape_func(g_width, g_height);
if (visibility_func) visibility_func(GLUT_VISIBLE);
/* if (g_mouse) pc_show_mouse(); */
while (GL_TRUE) {
idle = GL_TRUE;
if (g_redisplay && display_func) {
idle = GL_FALSE;
g_redisplay = GL_FALSE;
/* if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_scare_mouse(); */
display_func();
/* if (g_mouse && !(g_display_mode & GLUT_DOUBLE)) pc_unscare_mouse(); */
}
#if 0
if (pc_keypressed()) {
int key;
idle = GL_FALSE;
key = pc_readkey();
switch (key>>16) {
case KEY_F1: if (special_func) special_func(GLUT_KEY_F1, 0, 0); break;
case KEY_F2: if (special_func) special_func(GLUT_KEY_F2, 0, 0); break;
case KEY_F3: if (special_func) special_func(GLUT_KEY_F3, 0, 0); break;
case KEY_F4: if (special_func) special_func(GLUT_KEY_F4, 0, 0); break;
case KEY_F5: if (special_func) special_func(GLUT_KEY_F5, 0, 0); break;
case KEY_F6: if (special_func) special_func(GLUT_KEY_F6, 0, 0); break;
case KEY_F7: if (special_func) special_func(GLUT_KEY_F7, 0, 0); break;
case KEY_F8: if (special_func) special_func(GLUT_KEY_F8, 0, 0); break;
case KEY_F9: if (special_func) special_func(GLUT_KEY_F9, 0, 0); break;
case KEY_F10: if (special_func) special_func(GLUT_KEY_F10, 0, 0); break;
case KEY_F11: if (special_func) special_func(GLUT_KEY_F11, 0, 0); break;
case KEY_F12: if (special_func) special_func(GLUT_KEY_F12, 0, 0); break;
case KEY_LEFT: if (special_func) special_func(GLUT_KEY_LEFT, 0, 0); break;
case KEY_UP: if (special_func) special_func(GLUT_KEY_UP, 0, 0); break;
case KEY_RIGHT: if (special_func) special_func(GLUT_KEY_RIGHT, 0, 0); break;
case KEY_DOWN: if (special_func) special_func(GLUT_KEY_DOWN, 0, 0); break;
case KEY_PGUP: if (special_func) special_func(GLUT_KEY_PAGE_UP, 0, 0); break;
case KEY_PGDN: if (special_func) special_func(GLUT_KEY_PAGE_DOWN, 0, 0); break;
case KEY_HOME: if (special_func) special_func(GLUT_KEY_HOME, 0, 0); break;
case KEY_END: if (special_func) special_func(GLUT_KEY_END, 0, 0); break;
case KEY_INSERT: if (special_func) special_func(GLUT_KEY_INSERT, 0, 0); break;
default: if (keyboard_func) keyboard_func(key & 0xFF, 0, 0);
}
}
if (g_mouse) {
int mouse_x;
int mouse_y;
int mouse_b;
mouse_b = pc_query_mouse(&mouse_x, &mouse_y);
if (motion_func && ((mouse_x != old_mouse_x) || (mouse_y != old_mouse_y))) {
idle = GL_FALSE;
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
motion_func(old_mouse_x, old_mouse_y);
}
if (mouse_func && (mouse_b != old_mouse_b)) {
int new_mouse_b = mouse_b;
if ((old_mouse_b & 1) && !(new_mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_UP, mouse_x, mouse_y);
else if (!(old_mouse_b & 1) && (new_mouse_b & 1))
mouse_func(GLUT_LEFT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
if ((old_mouse_b & 2) && !(new_mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_UP, mouse_x, mouse_y);
else if (!(old_mouse_b & 2) && (new_mouse_b & 2))
mouse_func(GLUT_RIGHT_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
if ((old_mouse_b & 4) && !(new_mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_UP, mouse_x, mouse_y);
else if (!(old_mouse_b & 3) && (new_mouse_b & 4))
mouse_func(GLUT_MIDDLE_BUTTON, GLUT_DOWN, mouse_x, mouse_y);
idle = GL_FALSE;
old_mouse_b = new_mouse_b;
}
}
#endif
if (idle && idle_func)
idle_func();
}
}

78
src/glut/mini/internal.h Normal file
View File

@@ -0,0 +1,78 @@
/*
* Mesa 3-D graphics library
* Version: 4.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#ifndef INTERNAL_H_included
#define INTERNAL_H_included
#include "GL/glut.h"
/* #include "pc_hw/pc_hw.h" */
#define MAX_WINDOWS 4
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
#define DEFAULT_BPP 16
#define DEPTH_SIZE 16
#define STENCIL_SIZE 8
#define ACCUM_SIZE 16
extern GLenum g_display_mode;
extern GLuint g_width;
extern GLuint g_height;
extern GLint g_mouse;
extern GLboolean g_redisplay;
extern GLint g_xpos;
extern GLint g_ypos;
extern void (GLUTCALLBACK *display_func) (void);
extern void (GLUTCALLBACK *reshape_func) (int width, int height);
extern void (GLUTCALLBACK *keyboard_func) (unsigned char key, int x, int y);
extern void (GLUTCALLBACK *mouse_func) (int button, int state, int x, int y);
extern void (GLUTCALLBACK *motion_func) (int x, int y);
extern void (GLUTCALLBACK *passive_motion_func) (int x, int y);
extern void (GLUTCALLBACK *entry_func) (int state);
extern void (GLUTCALLBACK *visibility_func) (int state);
extern void (GLUTCALLBACK *idle_func) (void);
extern void (GLUTCALLBACK *menu_state_func) (int state);
extern void (GLUTCALLBACK *special_func) (int key, int x, int y);
extern void (GLUTCALLBACK *spaceball_motion_func) (int x, int y, int z);
extern void (GLUTCALLBACK *spaceball_rotate_func) (int x, int y, int z);
extern void (GLUTCALLBACK *spaceball_button_func) (int button, int state);
extern void (GLUTCALLBACK *button_box_func) (int button, int state);
extern void (GLUTCALLBACK *dials_func) (int dial, int value);
extern void (GLUTCALLBACK *tablet_motion_func) (int x, int y);
extern void (GLUTCALLBACK *tabled_button_func) (int button, int state, int x, int y);
extern void (GLUTCALLBACK *menu_status_func) (int status, int x, int y);
extern void (GLUTCALLBACK *overlay_display_func) (void);
extern void (GLUTCALLBACK *window_status_func) (int state);
#endif

86
src/glut/mini/menu.c Normal file
View File

@@ -0,0 +1,86 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
int APIENTRY glutCreateMenu (void (GLUTCALLBACK *func) (int))
{
return 0;
}
void APIENTRY glutDestroyMenu (int menu)
{
}
int APIENTRY glutGetMenu (void)
{
return 0;
}
void APIENTRY glutSetMenu (int menu)
{
}
void APIENTRY glutAddMenuEntry (const char *label, int value)
{
}
void APIENTRY glutAddSubMenu (const char *label, int submenu)
{
}
void APIENTRY glutChangeToMenuEntry (int item, const char *label, int value)
{
}
void APIENTRY glutChangeToSubMenu (int item, const char *label, int submenu)
{
}
void APIENTRY glutRemoveMenuItem (int item)
{
}
void APIENTRY glutAttachMenu (int button)
{
}
void APIENTRY glutDetachMenu (int button)
{
}

598
src/glut/mini/models.c Normal file
View File

@@ -0,0 +1,598 @@
/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
/**
(c) Copyright 1993, Silicon Graphics, Inc.
ALL RIGHTS RESERVED
Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that
both the copyright notice and this permission notice appear in
supporting documentation, and that the name of Silicon
Graphics, Inc. not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission.
THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
PERFORMANCE OF THIS SOFTWARE.
US Government Users Restricted Rights
Use, duplication, or disclosure by the Government is subject to
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer
Software clause at DFARS 252.227-7013 and/or in similar or
successor clauses in the FAR or the DOD or NASA FAR
Supplement. Unpublished-- rights reserved under the copyright
laws of the United States. Contractor/manufacturer is Silicon
Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
94039-7311.
OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <math.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "GL/glut.h"
/* Some <math.h> files do not define M_PI... */
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
static GLUquadricObj *quadObj;
#define QUAD_OBJ_INIT() { if(!quadObj) initQuadObj(); }
static void
initQuadObj(void)
{
quadObj = gluNewQuadric();
/* if (!quadObj)
__glutFatalError("out of memory."); */
}
/* CENTRY */
void APIENTRY
glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}
void APIENTRY
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}
void APIENTRY
glutWireCone(GLdouble base, GLdouble height,
GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_LINE);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
}
void APIENTRY
glutSolidCone(GLdouble base, GLdouble height,
GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluCylinder(quadObj, base, 0.0, height, slices, stacks);
}
/* ENDCENTRY */
static void
drawBox(GLfloat size, GLenum type)
{
static GLfloat n[6][3] =
{
{-1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{1.0, 0.0, 0.0},
{0.0, -1.0, 0.0},
{0.0, 0.0, 1.0},
{0.0, 0.0, -1.0}
};
static GLint faces[6][4] =
{
{0, 1, 2, 3},
{3, 2, 6, 7},
{7, 6, 5, 4},
{4, 5, 1, 0},
{5, 6, 2, 1},
{7, 4, 0, 3}
};
GLfloat v[8][3];
GLint i;
v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
for (i = 5; i >= 0; i--) {
glBegin(type);
glNormal3fv(&n[i][0]);
glVertex3fv(&v[faces[i][0]][0]);
glVertex3fv(&v[faces[i][1]][0]);
glVertex3fv(&v[faces[i][2]][0]);
glVertex3fv(&v[faces[i][3]][0]);
glEnd();
}
}
/* CENTRY */
void APIENTRY
glutWireCube(GLdouble size)
{
drawBox(size, GL_LINE_LOOP);
}
void APIENTRY
glutSolidCube(GLdouble size)
{
drawBox(size, GL_QUADS);
}
/* ENDCENTRY */
static void
doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
{
int i, j;
GLfloat theta, phi, theta1;
GLfloat cosTheta, sinTheta;
GLfloat cosTheta1, sinTheta1;
GLfloat ringDelta, sideDelta;
ringDelta = 2.0 * M_PI / rings;
sideDelta = 2.0 * M_PI / nsides;
theta = 0.0;
cosTheta = 1.0;
sinTheta = 0.0;
for (i = rings - 1; i >= 0; i--) {
theta1 = theta + ringDelta;
cosTheta1 = cos(theta1);
sinTheta1 = sin(theta1);
glBegin(GL_QUAD_STRIP);
phi = 0.0;
for (j = nsides; j >= 0; j--) {
GLfloat cosPhi, sinPhi, dist;
phi += sideDelta;
cosPhi = cos(phi);
sinPhi = sin(phi);
dist = R + r * cosPhi;
glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
}
glEnd();
theta = theta1;
cosTheta = cosTheta1;
sinTheta = sinTheta1;
}
}
/* CENTRY */
void APIENTRY
glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
GLint nsides, GLint rings)
{
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
doughnut(innerRadius, outerRadius, nsides, rings);
glPopAttrib();
}
void APIENTRY
glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius,
GLint nsides, GLint rings)
{
doughnut(innerRadius, outerRadius, nsides, rings);
}
/* ENDCENTRY */
static GLfloat dodec[20][3];
static void
initDodecahedron(void)
{
GLfloat alpha, beta;
alpha = sqrt(2.0 / (3.0 + sqrt(5.0)));
beta = 1.0 + sqrt(6.0 / (3.0 + sqrt(5.0)) -
2.0 + 2.0 * sqrt(2.0 / (3.0 + sqrt(5.0))));
/* *INDENT-OFF* */
dodec[0][0] = -alpha; dodec[0][1] = 0; dodec[0][2] = beta;
dodec[1][0] = alpha; dodec[1][1] = 0; dodec[1][2] = beta;
dodec[2][0] = -1; dodec[2][1] = -1; dodec[2][2] = -1;
dodec[3][0] = -1; dodec[3][1] = -1; dodec[3][2] = 1;
dodec[4][0] = -1; dodec[4][1] = 1; dodec[4][2] = -1;
dodec[5][0] = -1; dodec[5][1] = 1; dodec[5][2] = 1;
dodec[6][0] = 1; dodec[6][1] = -1; dodec[6][2] = -1;
dodec[7][0] = 1; dodec[7][1] = -1; dodec[7][2] = 1;
dodec[8][0] = 1; dodec[8][1] = 1; dodec[8][2] = -1;
dodec[9][0] = 1; dodec[9][1] = 1; dodec[9][2] = 1;
dodec[10][0] = beta; dodec[10][1] = alpha; dodec[10][2] = 0;
dodec[11][0] = beta; dodec[11][1] = -alpha; dodec[11][2] = 0;
dodec[12][0] = -beta; dodec[12][1] = alpha; dodec[12][2] = 0;
dodec[13][0] = -beta; dodec[13][1] = -alpha; dodec[13][2] = 0;
dodec[14][0] = -alpha; dodec[14][1] = 0; dodec[14][2] = -beta;
dodec[15][0] = alpha; dodec[15][1] = 0; dodec[15][2] = -beta;
dodec[16][0] = 0; dodec[16][1] = beta; dodec[16][2] = alpha;
dodec[17][0] = 0; dodec[17][1] = beta; dodec[17][2] = -alpha;
dodec[18][0] = 0; dodec[18][1] = -beta; dodec[18][2] = alpha;
dodec[19][0] = 0; dodec[19][1] = -beta; dodec[19][2] = -alpha;
/* *INDENT-ON* */
}
#define DIFF3(_a,_b,_c) { \
(_c)[0] = (_a)[0] - (_b)[0]; \
(_c)[1] = (_a)[1] - (_b)[1]; \
(_c)[2] = (_a)[2] - (_b)[2]; \
}
static void
crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])
{
GLfloat p[3]; /* in case prod == v1 or v2 */
p[0] = v1[1] * v2[2] - v2[1] * v1[2];
p[1] = v1[2] * v2[0] - v2[2] * v1[0];
p[2] = v1[0] * v2[1] - v2[0] * v1[1];
prod[0] = p[0];
prod[1] = p[1];
prod[2] = p[2];
}
static void
normalize(GLfloat v[3])
{
GLfloat d;
d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
if (d == 0.0) {
// __glutWarning("normalize: zero length vector");
v[0] = d = 1.0;
}
d = 1 / d;
v[0] *= d;
v[1] *= d;
v[2] *= d;
}
static void
pentagon(int a, int b, int c, int d, int e, GLenum shadeType)
{
GLfloat n0[3], d1[3], d2[3];
DIFF3(dodec[a], dodec[b], d1);
DIFF3(dodec[b], dodec[c], d2);
crossprod(d1, d2, n0);
normalize(n0);
glBegin(shadeType);
glNormal3fv(n0);
glVertex3fv(&dodec[a][0]);
glVertex3fv(&dodec[b][0]);
glVertex3fv(&dodec[c][0]);
glVertex3fv(&dodec[d][0]);
glVertex3fv(&dodec[e][0]);
glEnd();
}
static void
dodecahedron(GLenum type)
{
static int inited = 0;
if (inited == 0) {
inited = 1;
initDodecahedron();
}
pentagon(0, 1, 9, 16, 5, type);
pentagon(1, 0, 3, 18, 7, type);
pentagon(1, 7, 11, 10, 9, type);
pentagon(11, 7, 18, 19, 6, type);
pentagon(8, 17, 16, 9, 10, type);
pentagon(2, 14, 15, 6, 19, type);
pentagon(2, 13, 12, 4, 14, type);
pentagon(2, 19, 18, 3, 13, type);
pentagon(3, 0, 5, 12, 13, type);
pentagon(6, 15, 8, 10, 11, type);
pentagon(4, 17, 8, 15, 14, type);
pentagon(4, 12, 5, 16, 17, type);
}
/* CENTRY */
void APIENTRY
glutWireDodecahedron(void)
{
dodecahedron(GL_LINE_LOOP);
}
void APIENTRY
glutSolidDodecahedron(void)
{
dodecahedron(GL_TRIANGLE_FAN);
}
/* ENDCENTRY */
static void
recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,
GLenum shadeType)
{
GLfloat q0[3], q1[3];
DIFF3(n1, n2, q0);
DIFF3(n2, n3, q1);
crossprod(q0, q1, q1);
normalize(q1);
glBegin(shadeType);
glNormal3fv(q1);
glVertex3fv(n1);
glVertex3fv(n2);
glVertex3fv(n3);
glEnd();
}
static void
subdivide(GLfloat * v0, GLfloat * v1, GLfloat * v2,
GLenum shadeType)
{
int depth;
GLfloat w0[3], w1[3], w2[3];
GLfloat l;
int i, j, k, n;
depth = 1;
for (i = 0; i < depth; i++) {
for (j = 0; i + j < depth; j++) {
k = depth - i - j;
for (n = 0; n < 3; n++) {
w0[n] = (i * v0[n] + j * v1[n] + k * v2[n]) / depth;
w1[n] = ((i + 1) * v0[n] + j * v1[n] + (k - 1) * v2[n])
/ depth;
w2[n] = (i * v0[n] + (j + 1) * v1[n] + (k - 1) * v2[n])
/ depth;
}
l = sqrt(w0[0] * w0[0] + w0[1] * w0[1] + w0[2] * w0[2]);
w0[0] /= l;
w0[1] /= l;
w0[2] /= l;
l = sqrt(w1[0] * w1[0] + w1[1] * w1[1] + w1[2] * w1[2]);
w1[0] /= l;
w1[1] /= l;
w1[2] /= l;
l = sqrt(w2[0] * w2[0] + w2[1] * w2[1] + w2[2] * w2[2]);
w2[0] /= l;
w2[1] /= l;
w2[2] /= l;
recorditem(w1, w0, w2, shadeType);
}
}
}
static void
drawtriangle(int i, GLfloat data[][3], int ndx[][3],
GLenum shadeType)
{
GLfloat *x0, *x1, *x2;
x0 = data[ndx[i][0]];
x1 = data[ndx[i][1]];
x2 = data[ndx[i][2]];
subdivide(x0, x1, x2, shadeType);
}
/* octahedron data: The octahedron produced is centered at the
origin and has radius 1.0 */
static GLfloat odata[6][3] =
{
{1.0, 0.0, 0.0},
{-1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, -1.0, 0.0},
{0.0, 0.0, 1.0},
{0.0, 0.0, -1.0}
};
static int ondex[8][3] =
{
{0, 4, 2},
{1, 2, 4},
{0, 3, 4},
{1, 4, 3},
{0, 2, 5},
{1, 5, 2},
{0, 5, 3},
{1, 3, 5}
};
static void
octahedron(GLenum shadeType)
{
int i;
for (i = 7; i >= 0; i--) {
drawtriangle(i, odata, ondex, shadeType);
}
}
/* CENTRY */
void APIENTRY
glutWireOctahedron(void)
{
octahedron(GL_LINE_LOOP);
}
void APIENTRY
glutSolidOctahedron(void)
{
octahedron(GL_TRIANGLES);
}
/* ENDCENTRY */
/* icosahedron data: These numbers are rigged to make an
icosahedron of radius 1.0 */
#define X .525731112119133606
#define Z .850650808352039932
static GLfloat idata[12][3] =
{
{-X, 0, Z},
{X, 0, Z},
{-X, 0, -Z},
{X, 0, -Z},
{0, Z, X},
{0, Z, -X},
{0, -Z, X},
{0, -Z, -X},
{Z, X, 0},
{-Z, X, 0},
{Z, -X, 0},
{-Z, -X, 0}
};
static int index[20][3] =
{
{0, 4, 1},
{0, 9, 4},
{9, 5, 4},
{4, 5, 8},
{4, 8, 1},
{8, 10, 1},
{8, 3, 10},
{5, 3, 8},
{5, 2, 3},
{2, 7, 3},
{7, 10, 3},
{7, 6, 10},
{7, 11, 6},
{11, 0, 6},
{0, 1, 6},
{6, 1, 10},
{9, 0, 11},
{9, 11, 2},
{9, 2, 5},
{7, 2, 11},
};
static void
icosahedron(GLenum shadeType)
{
int i;
for (i = 19; i >= 0; i--) {
drawtriangle(i, idata, index, shadeType);
}
}
/* CENTRY */
void APIENTRY
glutWireIcosahedron(void)
{
icosahedron(GL_LINE_LOOP);
}
void APIENTRY
glutSolidIcosahedron(void)
{
icosahedron(GL_TRIANGLES);
}
/* ENDCENTRY */
/* tetrahedron data: */
#define T 1.73205080756887729
static GLfloat tdata[4][3] =
{
{T, T, T},
{T, -T, -T},
{-T, T, -T},
{-T, -T, T}
};
static int tndex[4][3] =
{
{0, 1, 3},
{2, 1, 0},
{3, 2, 0},
{1, 2, 3}
};
static void
tetrahedron(GLenum shadeType)
{
int i;
for (i = 3; i >= 0; i--)
drawtriangle(i, tdata, tndex, shadeType);
}
/* CENTRY */
void APIENTRY
glutWireTetrahedron(void)
{
tetrahedron(GL_LINE_LOOP);
}
void APIENTRY
glutSolidTetrahedron(void)
{
tetrahedron(GL_TRIANGLES);
}
/* ENDCENTRY */

60
src/glut/mini/overlay.c Normal file
View File

@@ -0,0 +1,60 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
void APIENTRY glutEstablishOverlay (void)
{
}
void APIENTRY glutRemoveOverlay (void)
{
}
void APIENTRY glutUseLayer (GLenum layer)
{
}
void APIENTRY glutPostOverlayRedisplay (void)
{
}
void APIENTRY glutShowOverlay (void)
{
}
void APIENTRY glutHideOverlay (void)
{
}

70
src/glut/mini/state.c Normal file
View File

@@ -0,0 +1,70 @@
/*
* Mesa 3-D graphics library
* Version: 3.4
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.0 for Mesa 4.0
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include "GL/glut.h"
#include <sys/time.h>
#define TIMEDELTA(dest, src1, src2) { \
if(((dest).tv_usec = (src1).tv_usec - (src2).tv_usec) < 0) { \
(dest).tv_usec += 1000000; \
(dest).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
} else { \
(dest).tv_sec = (src1).tv_sec - (src2).tv_sec; \
} \
}
int APIENTRY glutGet (GLenum type)
{
switch (type) {
case GLUT_WINDOW_RGBA:
return 1;
case GLUT_ELAPSED_TIME: {
static int inited = 0;
static struct timeval elapsed, beginning, now;
if (!inited) {
gettimeofday(&beginning, 0);
inited = 1;
}
gettimeofday(&now, 0);
TIMEDELTA(elapsed, now, beginning);
/* Return elapsed milliseconds. */
return (int) ((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000));
}
default:
return 0;
}
}
int APIENTRY glutDeviceGet (GLenum type)
{
return 0;
}

212
src/glut/mini/teapot.c Normal file
View File

@@ -0,0 +1,212 @@
/* Copyright (c) Mark J. Kilgard, 1994. */
/**
(c) Copyright 1993, Silicon Graphics, Inc.
ALL RIGHTS RESERVED
Permission to use, copy, modify, and distribute this software
for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that
both the copyright notice and this permission notice appear in
supporting documentation, and that the name of Silicon
Graphics, Inc. not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission.
THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
"AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
PERFORMANCE OF THIS SOFTWARE.
US Government Users Restricted Rights
Use, duplication, or disclosure by the Government is subject to
restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer
Software clause at DFARS 252.227-7013 and/or in similar or
successor clauses in the FAR or the DOD or NASA FAR
Supplement. Unpublished-- rights reserved under the copyright
laws of the United States. Contractor/manufacturer is Silicon
Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
94039-7311.
OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <GL/gl.h>
#include <GL/glu.h>
#include "GL/glut.h"
/* Rim, body, lid, and bottom data must be reflected in x and
y; handle and spout data across the y axis only. */
static int patchdata[][16] =
{
/* rim */
{102, 103, 104, 105, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15},
/* body */
{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27},
{24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40},
/* lid */
{96, 96, 96, 96, 97, 98, 99, 100, 101, 101, 101,
101, 0, 1, 2, 3,},
{0, 1, 2, 3, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117},
/* bottom */
{118, 118, 118, 118, 124, 122, 119, 121, 123, 126,
125, 120, 40, 39, 38, 37},
/* handle */
{41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
53, 54, 55, 56},
{53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
28, 65, 66, 67},
/* spout */
{68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83},
{80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95}
};
/* *INDENT-OFF* */
static float cpdata[][3] =
{
{0.2, 0, 2.7}, {0.2, -0.112, 2.7}, {0.112, -0.2, 2.7}, {0,
-0.2, 2.7}, {1.3375, 0, 2.53125}, {1.3375, -0.749, 2.53125},
{0.749, -1.3375, 2.53125}, {0, -1.3375, 2.53125}, {1.4375,
0, 2.53125}, {1.4375, -0.805, 2.53125}, {0.805, -1.4375,
2.53125}, {0, -1.4375, 2.53125}, {1.5, 0, 2.4}, {1.5, -0.84,
2.4}, {0.84, -1.5, 2.4}, {0, -1.5, 2.4}, {1.75, 0, 1.875},
{1.75, -0.98, 1.875}, {0.98, -1.75, 1.875}, {0, -1.75,
1.875}, {2, 0, 1.35}, {2, -1.12, 1.35}, {1.12, -2, 1.35},
{0, -2, 1.35}, {2, 0, 0.9}, {2, -1.12, 0.9}, {1.12, -2,
0.9}, {0, -2, 0.9}, {-2, 0, 0.9}, {2, 0, 0.45}, {2, -1.12,
0.45}, {1.12, -2, 0.45}, {0, -2, 0.45}, {1.5, 0, 0.225},
{1.5, -0.84, 0.225}, {0.84, -1.5, 0.225}, {0, -1.5, 0.225},
{1.5, 0, 0.15}, {1.5, -0.84, 0.15}, {0.84, -1.5, 0.15}, {0,
-1.5, 0.15}, {-1.6, 0, 2.025}, {-1.6, -0.3, 2.025}, {-1.5,
-0.3, 2.25}, {-1.5, 0, 2.25}, {-2.3, 0, 2.025}, {-2.3, -0.3,
2.025}, {-2.5, -0.3, 2.25}, {-2.5, 0, 2.25}, {-2.7, 0,
2.025}, {-2.7, -0.3, 2.025}, {-3, -0.3, 2.25}, {-3, 0,
2.25}, {-2.7, 0, 1.8}, {-2.7, -0.3, 1.8}, {-3, -0.3, 1.8},
{-3, 0, 1.8}, {-2.7, 0, 1.575}, {-2.7, -0.3, 1.575}, {-3,
-0.3, 1.35}, {-3, 0, 1.35}, {-2.5, 0, 1.125}, {-2.5, -0.3,
1.125}, {-2.65, -0.3, 0.9375}, {-2.65, 0, 0.9375}, {-2,
-0.3, 0.9}, {-1.9, -0.3, 0.6}, {-1.9, 0, 0.6}, {1.7, 0,
1.425}, {1.7, -0.66, 1.425}, {1.7, -0.66, 0.6}, {1.7, 0,
0.6}, {2.6, 0, 1.425}, {2.6, -0.66, 1.425}, {3.1, -0.66,
0.825}, {3.1, 0, 0.825}, {2.3, 0, 2.1}, {2.3, -0.25, 2.1},
{2.4, -0.25, 2.025}, {2.4, 0, 2.025}, {2.7, 0, 2.4}, {2.7,
-0.25, 2.4}, {3.3, -0.25, 2.4}, {3.3, 0, 2.4}, {2.8, 0,
2.475}, {2.8, -0.25, 2.475}, {3.525, -0.25, 2.49375},
{3.525, 0, 2.49375}, {2.9, 0, 2.475}, {2.9, -0.15, 2.475},
{3.45, -0.15, 2.5125}, {3.45, 0, 2.5125}, {2.8, 0, 2.4},
{2.8, -0.15, 2.4}, {3.2, -0.15, 2.4}, {3.2, 0, 2.4}, {0, 0,
3.15}, {0.8, 0, 3.15}, {0.8, -0.45, 3.15}, {0.45, -0.8,
3.15}, {0, -0.8, 3.15}, {0, 0, 2.85}, {1.4, 0, 2.4}, {1.4,
-0.784, 2.4}, {0.784, -1.4, 2.4}, {0, -1.4, 2.4}, {0.4, 0,
2.55}, {0.4, -0.224, 2.55}, {0.224, -0.4, 2.55}, {0, -0.4,
2.55}, {1.3, 0, 2.55}, {1.3, -0.728, 2.55}, {0.728, -1.3,
2.55}, {0, -1.3, 2.55}, {1.3, 0, 2.4}, {1.3, -0.728, 2.4},
{0.728, -1.3, 2.4}, {0, -1.3, 2.4}, {0, 0, 0}, {1.425,
-0.798, 0}, {1.5, 0, 0.075}, {1.425, 0, 0}, {0.798, -1.425,
0}, {0, -1.5, 0.075}, {0, -1.425, 0}, {1.5, -0.84, 0.075},
{0.84, -1.5, 0.075}
};
static float tex[2][2][2] =
{
{ {0, 0},
{1, 0}},
{ {0, 1},
{1, 1}}
};
/* *INDENT-ON* */
static void
teapot(GLint grid, GLdouble scale, GLenum type)
{
float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
long i, j, k, l;
glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_MAP2_TEXTURE_COORD_2);
glPushMatrix();
glRotatef(270.0, 1.0, 0.0, 0.0);
glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
glTranslatef(0.0, 0.0, -1.5);
for (i = 0; i < 10; i++) {
for (j = 0; j < 4; j++) {
for (k = 0; k < 4; k++) {
for (l = 0; l < 3; l++) {
p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 1)
q[j][k][l] *= -1.0;
if (i < 6) {
r[j][k][l] =
cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 0)
r[j][k][l] *= -1.0;
s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
if (l == 0)
s[j][k][l] *= -1.0;
if (l == 1)
s[j][k][l] *= -1.0;
}
}
}
}
glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2,
&tex[0][0][0]);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&p[0][0][0]);
glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0);
glEvalMesh2(type, 0, grid, 0, grid);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&q[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
if (i < 6) {
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&r[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4,
&s[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid);
}
}
glPopMatrix();
glPopAttrib();
}
/* CENTRY */
void APIENTRY
glutSolidTeapot(GLdouble scale)
{
teapot(7, scale, GL_FILL);
}
void APIENTRY
glutWireTeapot(GLdouble scale)
{
teapot(10, scale, GL_LINE);
}
/* ENDCENTRY */

220
src/glut/mini/window.c Normal file
View File

@@ -0,0 +1,220 @@
/*
* Mesa 3-D graphics library
* Version: 4.1
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* DOS/DJGPP glut driver v1.2 for Mesa 4.1
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
#include <stdio.h>
#include <GL/gl.h>
#include "GL/glut.h"
#include "internal.h"
#define USE_MINI_GLX 1
#if USE_MINI_GLX
#include "GL/miniglx.h"
#else
#include <GL/glx.h>
#endif
static GLXContext context = 0;
static Window win;
static XVisualInfo *visinfo = 0;
static Display *dpy = 0;
int APIENTRY glutCreateWindow (const char *title)
{
XSetWindowAttributes attr;
unsigned long mask;
GLXContext ctx;
int scrnum = 0;
Window root = RootWindow( dpy, scrnum );
if (win)
return 0;
if (!dpy) {
dpy = XOpenDisplay(NULL);
if (!dpy) {
printf("Error: XOpenDisplay failed\n");
exit(1);
}
}
if (!visinfo) {
int attrib[] = {GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
visinfo = glXChooseVisual( dpy, scrnum, attrib );
if (!visinfo) {
printf("Error: couldn't get an RGB, Double-buffered visual\n");
exit(1);
}
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( dpy, root, 0, 0, g_width, g_height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr );
if (!win) {
printf("Error: XCreateWindow failed\n");
exit(1);
}
ctx = glXCreateContext( dpy, visinfo, NULL, True );
if (!ctx) {
printf("Error: glXCreateContext failed\n");
exit(1);
}
if (!glXMakeCurrent( dpy, win, ctx )) {
printf("Error: glXMakeCurrent failed\n");
exit(1);
}
if (!(g_display_mode & GLUT_DOUBLE))
glDrawBuffer( GL_FRONT );
XMapWindow( dpy, win );
#if !USE_MINI_GLX
{
XEvent e;
while (1) {
XNextEvent( dpy, &e );
if (e.type == MapNotify && e.xmap.window == win) {
break;
}
}
}
#endif
return 1;
}
int APIENTRY glutCreateSubWindow (int win, int x, int y, int width, int height)
{
return GL_FALSE;
}
void APIENTRY glutDestroyWindow (int idx)
{
if (dpy && win)
XDestroyWindow( dpy, win );
if (dpy)
XCloseDisplay( dpy );
win = 0;
dpy = 0;
}
void APIENTRY glutPostRedisplay (void)
{
g_redisplay = GL_TRUE;
}
void APIENTRY glutSwapBuffers (void)
{
/* if (g_mouse) pc_scare_mouse(); */
if (dpy && win) glXSwapBuffers( dpy, win );
/* if (g_mouse) pc_unscare_mouse(); */
}
int APIENTRY glutGetWindow (void)
{
return 0;
}
void APIENTRY glutSetWindow (int win)
{
}
void APIENTRY glutSetWindowTitle (const char *title)
{
}
void APIENTRY glutSetIconTitle (const char *title)
{
}
void APIENTRY glutPositionWindow (int x, int y)
{
}
void APIENTRY glutReshapeWindow (int width, int height)
{
}
void APIENTRY glutPopWindow (void)
{
}
void APIENTRY glutPushWindow (void)
{
}
void APIENTRY glutIconifyWindow (void)
{
}
void APIENTRY glutShowWindow (void)
{
}
void APIENTRY glutHideWindow (void)
{
}

View File

@@ -0,0 +1,2 @@
linux
video

View File

@@ -0,0 +1,129 @@
#
# Makefile for building the radeonfb module standalone.
#
# Modelled closely on the drm kernel Makefile.linux in the XFree86 source
# tree.
#
# $TG: radeonfb/GNUmakefile,v 1.5 2002/12/18 14:54:08 dawes Exp $
#
.SUFFIXES:
MODS = radeonfb.o
PROGS =
FBHEADERS =
FBLINHEADERS =
FBOBJS =
WARNINGS = -Wall -Wwrite-strings -Wpointer-arith -Wcast-align \
-Wstrict-prototypes -Wnested-externs \
-Wpointer-arith
CFLAGS = -O2 $(WARNINGS)
MODCFLAGS = $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer
# First, locate correct tree for this kernel version. If we find a
# matching tree, we assume that we can rely on that tree's autoconf.h.
# This may not be correct, but it is the best assumption we can make.
VERSION := $(shell uname -r)
# For Red Hat...
RHVERS := $(shell uname -r)custom
A := /lib/modules/$(VERSION)/build/include
B := /usr/src/linux-$(VERSION)/include
C := /usr/src/linux/include
D := /usr/include
all::; @echo $(RHVERS)
V := $(shell gcc -E -nostdinc -I$A picker.c 2>/dev/null \
| grep -s 'RELEASE = ' | cut -d' ' -f3)
ifeq ($(V),"$(VERSION)")
TREE := $A
else
ifeq ($(V),"$(RHVERS)")
TREE := $A
else
V := $(shell gcc -E -nostdinc -I$B picker.c 2>/dev/null \
| grep -s 'RELEASE = ' | cut -d' ' -f3)
ifeq ($(V),"$(VERSION)")
TREE := $B
else
ifeq ($(V),"$(RHVERS)")
TREE := $B
else
V := $(shell gcc -E -nostdinc -I$C picker.c 2>/dev/null \
| grep -s 'RELEASE = ' | cut -d' ' -f3)
ifeq ($(V),"$(VERSION)")
TREE := $C
else
V := $(shell gcc -E -nostdinc -I$D picker.c 2>/dev/null \
| grep -s 'RELEASE = ' | cut -d' ' -f3)
ifeq ($(V),"$(VERSION)")
TREE := $D
else
TREE := 0
endif
endif
endif
endif
endif
endif
ifeq ($(TREE),0)
all::; @echo Error: Could not locate kernel tree in $A $B $C $D
else
SMP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'SMP = ' | cut -d' ' -f3)
MODULES := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'MODULES = ' | cut -d' ' -f3)
MODVERSIONS := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'MODVERSIONS = ' | cut -d' ' -f3)
MACHINE := $(shell echo `uname -m`)
endif
all::;@echo === KERNEL HEADERS IN $(TREE)
all::;@echo === SMP=${SMP} MODULES=${MODULES} MODVERSIONS=${MODVERSIONS}
all::;@echo === Compiling for machine $(MACHINE)
ifeq ($(MODULES),0)
all::;@echo
all::;@echo "*** Kernel modules must be configured. Build aborted."
all::;@echo
else
all:: linux video $(MODS) $(PROGS)
endif
ifeq ($(SMP),1)
MODCFLAGS += -D__SMP__
endif
ifeq ($(MODVERSIONS),1)
MODCFLAGS += -DMODVERSIONS -include $(TREE)/linux/modversions.h
endif
# radeonfb.o: radeonfb_be.o radeonfb_fe.o
# $(LD) -r $^ -o $@
%.o: %.c
$(CC) $(MODCFLAGS) -DEXPORT_SYMTAB -I. -I$(TREE) -c $< -o $@
$(AGPOBJS): $(AGPHEADERS)
linux:
rm -f linux
ln -s . linux
video:
rm -f video
ln -s . video
clean:
rm -f *.o
rm -f linux
rm -f $(PROGS)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
#include <linux/config.h>
#include <linux/version.h>
#ifndef CONFIG_SMP
#define CONFIG_SMP 0
#endif
#ifndef CONFIG_MODULES
#define CONFIG_MODULES 0
#endif
#ifndef CONFIG_MODVERSIONS
#define CONFIG_MODVERSIONS 0
#endif
#ifndef CONFIG_AGP_MODULE
#define CONFIG_AGP_MODULE 0
#endif
#ifndef CONFIG_AGP
#define CONFIG_AGP 0
#endif
SMP = CONFIG_SMP
MODULES = CONFIG_MODULES
MODVERSIONS = CONFIG_MODVERSIONS
AGP = CONFIG_AGP
AGP_MODULE = CONFIG_AGP_MODULE
RELEASE = UTS_RELEASE

View File

@@ -0,0 +1,787 @@
#ifndef _RADEON_H
#define _RADEON_H
#define RADEON_REGSIZE 0x4000
#define MM_INDEX 0x0000
#define MM_DATA 0x0004
#define BUS_CNTL 0x0030
#define HI_STAT 0x004C
#define BUS_CNTL1 0x0034
#define I2C_CNTL_1 0x0094
#define CONFIG_CNTL 0x00E0
#define CONFIG_MEMSIZE 0x00F8
#define CONFIG_APER_0_BASE 0x0100
#define CONFIG_APER_1_BASE 0x0104
#define CONFIG_APER_SIZE 0x0108
#define CONFIG_REG_1_BASE 0x010C
#define CONFIG_REG_APER_SIZE 0x0110
#define PAD_AGPINPUT_DELAY 0x0164
#define PAD_CTLR_STRENGTH 0x0168
#define PAD_CTLR_UPDATE 0x016C
#define AGP_CNTL 0x0174
#define BM_STATUS 0x0160
#define CAP0_TRIG_CNTL 0x0950
#define VIPH_CONTROL 0x0C40
#define VENDOR_ID 0x0F00
#define DEVICE_ID 0x0F02
#define COMMAND 0x0F04
#define STATUS 0x0F06
#define REVISION_ID 0x0F08
#define REGPROG_INF 0x0F09
#define SUB_CLASS 0x0F0A
#define BASE_CODE 0x0F0B
#define CACHE_LINE 0x0F0C
#define LATENCY 0x0F0D
#define HEADER 0x0F0E
#define BIST 0x0F0F
#define REG_MEM_BASE 0x0F10
#define REG_IO_BASE 0x0F14
#define REG_REG_BASE 0x0F18
#define ADAPTER_ID 0x0F2C
#define BIOS_ROM 0x0F30
#define CAPABILITIES_PTR 0x0F34
#define INTERRUPT_LINE 0x0F3C
#define INTERRUPT_PIN 0x0F3D
#define MIN_GRANT 0x0F3E
#define MAX_LATENCY 0x0F3F
#define ADAPTER_ID_W 0x0F4C
#define PMI_CAP_ID 0x0F50
#define PMI_NXT_CAP_PTR 0x0F51
#define PMI_PMC_REG 0x0F52
#define PM_STATUS 0x0F54
#define PMI_DATA 0x0F57
#define AGP_CAP_ID 0x0F58
#define AGP_STATUS 0x0F5C
#define AGP_COMMAND 0x0F60
#define AIC_CTRL 0x01D0
#define AIC_STAT 0x01D4
#define AIC_PT_BASE 0x01D8
#define AIC_LO_ADDR 0x01DC
#define AIC_HI_ADDR 0x01E0
#define AIC_TLB_ADDR 0x01E4
#define AIC_TLB_DATA 0x01E8
#define DAC_CNTL 0x0058
#define CRTC_GEN_CNTL 0x0050
#define MEM_CNTL 0x0140
#define EXT_MEM_CNTL 0x0144
#define MC_AGP_LOCATION 0x014C
#define MEM_IO_CNTL_A0 0x0178
#define MEM_INIT_LATENCY_TIMER 0x0154
#define MEM_SDRAM_MODE_REG 0x0158
#define AGP_BASE 0x0170
#define MEM_IO_CNTL_A1 0x017C
#define MEM_IO_CNTL_B0 0x0180
#define MEM_IO_CNTL_B1 0x0184
#define MC_DEBUG 0x0188
#define MC_STATUS 0x0150
#define MEM_IO_OE_CNTL 0x018C
#define MC_FB_LOCATION 0x0148
#define HOST_PATH_CNTL 0x0130
#define MEM_VGA_WP_SEL 0x0038
#define MEM_VGA_RP_SEL 0x003C
#define HDP_DEBUG 0x0138
#define SW_SEMAPHORE 0x013C
#define CRTC2_GEN_CNTL 0x03f8
#define CRTC2_DISPLAY_BASE_ADDR 0x033c
#define SURFACE_CNTL 0x0B00
#define SURFACE0_LOWER_BOUND 0x0B04
#define SURFACE1_LOWER_BOUND 0x0B14
#define SURFACE2_LOWER_BOUND 0x0B24
#define SURFACE3_LOWER_BOUND 0x0B34
#define SURFACE4_LOWER_BOUND 0x0B44
#define SURFACE5_LOWER_BOUND 0x0B54
#define SURFACE6_LOWER_BOUND 0x0B64
#define SURFACE7_LOWER_BOUND 0x0B74
#define SURFACE0_UPPER_BOUND 0x0B08
#define SURFACE1_UPPER_BOUND 0x0B18
#define SURFACE2_UPPER_BOUND 0x0B28
#define SURFACE3_UPPER_BOUND 0x0B38
#define SURFACE4_UPPER_BOUND 0x0B48
#define SURFACE5_UPPER_BOUND 0x0B58
#define SURFACE6_UPPER_BOUND 0x0B68
#define SURFACE7_UPPER_BOUND 0x0B78
#define SURFACE0_INFO 0x0B0C
#define SURFACE1_INFO 0x0B1C
#define SURFACE2_INFO 0x0B2C
#define SURFACE3_INFO 0x0B3C
#define SURFACE4_INFO 0x0B4C
#define SURFACE5_INFO 0x0B5C
#define SURFACE6_INFO 0x0B6C
#define SURFACE7_INFO 0x0B7C
#define SURFACE_ACCESS_FLAGS 0x0BF8
#define SURFACE_ACCESS_CLR 0x0BFC
#define GEN_INT_CNTL 0x0040
#define GEN_INT_STATUS 0x0044
#define CRTC_EXT_CNTL 0x0054
#define RB3D_CNTL 0x1C3C
#define WAIT_UNTIL 0x1720
#define ISYNC_CNTL 0x1724
#define RBBM_GUICNTL 0x172C
#define RBBM_STATUS 0x0E40
#define RBBM_STATUS_alt_1 0x1740
#define RBBM_CNTL 0x00EC
#define RBBM_CNTL_alt_1 0x0E44
#define RBBM_SOFT_RESET 0x00F0
#define RBBM_SOFT_RESET_alt_1 0x0E48
#define NQWAIT_UNTIL 0x0E50
#define RBBM_DEBUG 0x0E6C
#define RBBM_CMDFIFO_ADDR 0x0E70
#define RBBM_CMDFIFO_DATAL 0x0E74
#define RBBM_CMDFIFO_DATAH 0x0E78
#define RBBM_CMDFIFO_STAT 0x0E7C
#define CRTC_STATUS 0x005C
#define GPIO_VGA_DDC 0x0060
#define GPIO_DVI_DDC 0x0064
#define GPIO_MONID 0x0068
#define PALETTE_INDEX 0x00B0
#define PALETTE_DATA 0x00B4
#define PALETTE_30_DATA 0x00B8
#define CRTC_H_TOTAL_DISP 0x0200
#define CRTC_H_SYNC_STRT_WID 0x0204
#define CRTC_V_TOTAL_DISP 0x0208
#define CRTC_V_SYNC_STRT_WID 0x020C
#define CRTC_VLINE_CRNT_VLINE 0x0210
#define CRTC_CRNT_FRAME 0x0214
#define CRTC_GUI_TRIG_VLINE 0x0218
#define CRTC_DEBUG 0x021C
#define CRTC_OFFSET_RIGHT 0x0220
#define CRTC_OFFSET 0x0224
#define CRTC_OFFSET_CNTL 0x0228
#define CRTC_PITCH 0x022C
#define OVR_CLR 0x0230
#define OVR_WID_LEFT_RIGHT 0x0234
#define OVR_WID_TOP_BOTTOM 0x0238
#define DISPLAY_BASE_ADDR 0x023C
#define SNAPSHOT_VH_COUNTS 0x0240
#define SNAPSHOT_F_COUNT 0x0244
#define N_VIF_COUNT 0x0248
#define SNAPSHOT_VIF_COUNT 0x024C
#define FP_CRTC_H_TOTAL_DISP 0x0250
#define FP_CRTC_V_TOTAL_DISP 0x0254
#define CRT_CRTC_H_SYNC_STRT_WID 0x0258
#define CRT_CRTC_V_SYNC_STRT_WID 0x025C
#define CUR_OFFSET 0x0260
#define CUR_HORZ_VERT_POSN 0x0264
#define CUR_HORZ_VERT_OFF 0x0268
#define CUR_CLR0 0x026C
#define CUR_CLR1 0x0270
#define FP_HORZ_VERT_ACTIVE 0x0278
#define CRTC_MORE_CNTL 0x027C
#define DAC_EXT_CNTL 0x0280
#define FP_GEN_CNTL 0x0284
#define FP_HORZ_STRETCH 0x028C
#define FP_VERT_STRETCH 0x0290
#define FP_H_SYNC_STRT_WID 0x02C4
#define FP_V_SYNC_STRT_WID 0x02C8
#define AUX_WINDOW_HORZ_CNTL 0x02D8
#define AUX_WINDOW_VERT_CNTL 0x02DC
#define DDA_CONFIG 0x02e0
#define DDA_ON_OFF 0x02e4
#define GRPH_BUFFER_CNTL 0x02F0
#define VGA_BUFFER_CNTL 0x02F4
#define OV0_Y_X_START 0x0400
#define OV0_Y_X_END 0x0404
#define OV0_PIPELINE_CNTL 0x0408
#define OV0_REG_LOAD_CNTL 0x0410
#define OV0_SCALE_CNTL 0x0420
#define OV0_V_INC 0x0424
#define OV0_P1_V_ACCUM_INIT 0x0428
#define OV0_P23_V_ACCUM_INIT 0x042C
#define OV0_P1_BLANK_LINES_AT_TOP 0x0430
#define OV0_P23_BLANK_LINES_AT_TOP 0x0434
#define OV0_BASE_ADDR 0x043C
#define OV0_VID_BUF0_BASE_ADRS 0x0440
#define OV0_VID_BUF1_BASE_ADRS 0x0444
#define OV0_VID_BUF2_BASE_ADRS 0x0448
#define OV0_VID_BUF3_BASE_ADRS 0x044C
#define OV0_VID_BUF4_BASE_ADRS 0x0450
#define OV0_VID_BUF5_BASE_ADRS 0x0454
#define OV0_VID_BUF_PITCH0_VALUE 0x0460
#define OV0_VID_BUF_PITCH1_VALUE 0x0464
#define OV0_AUTO_FLIP_CNTRL 0x0470
#define OV0_DEINTERLACE_PATTERN 0x0474
#define OV0_SUBMIT_HISTORY 0x0478
#define OV0_H_INC 0x0480
#define OV0_STEP_BY 0x0484
#define OV0_P1_H_ACCUM_INIT 0x0488
#define OV0_P23_H_ACCUM_INIT 0x048C
#define OV0_P1_X_START_END 0x0494
#define OV0_P2_X_START_END 0x0498
#define OV0_P3_X_START_END 0x049C
#define OV0_FILTER_CNTL 0x04A0
#define OV0_FOUR_TAP_COEF_0 0x04B0
#define OV0_FOUR_TAP_COEF_1 0x04B4
#define OV0_FOUR_TAP_COEF_2 0x04B8
#define OV0_FOUR_TAP_COEF_3 0x04BC
#define OV0_FOUR_TAP_COEF_4 0x04C0
#define OV0_FLAG_CNTRL 0x04DC
#define OV0_SLICE_CNTL 0x04E0
#define OV0_VID_KEY_CLR_LOW 0x04E4
#define OV0_VID_KEY_CLR_HIGH 0x04E8
#define OV0_GRPH_KEY_CLR_LOW 0x04EC
#define OV0_GRPH_KEY_CLR_HIGH 0x04F0
#define OV0_KEY_CNTL 0x04F4
#define OV0_TEST 0x04F8
#define SUBPIC_CNTL 0x0540
#define SUBPIC_DEFCOLCON 0x0544
#define SUBPIC_Y_X_START 0x054C
#define SUBPIC_Y_X_END 0x0550
#define SUBPIC_V_INC 0x0554
#define SUBPIC_H_INC 0x0558
#define SUBPIC_BUF0_OFFSET 0x055C
#define SUBPIC_BUF1_OFFSET 0x0560
#define SUBPIC_LC0_OFFSET 0x0564
#define SUBPIC_LC1_OFFSET 0x0568
#define SUBPIC_PITCH 0x056C
#define SUBPIC_BTN_HLI_COLCON 0x0570
#define SUBPIC_BTN_HLI_Y_X_START 0x0574
#define SUBPIC_BTN_HLI_Y_X_END 0x0578
#define SUBPIC_PALETTE_INDEX 0x057C
#define SUBPIC_PALETTE_DATA 0x0580
#define SUBPIC_H_ACCUM_INIT 0x0584
#define SUBPIC_V_ACCUM_INIT 0x0588
#define DISP_MISC_CNTL 0x0D00
#define DAC_MACRO_CNTL 0x0D04
#define DISP_PWR_MAN 0x0D08
#define DISP_TEST_DEBUG_CNTL 0x0D10
#define DISP_HW_DEBUG 0x0D14
#define DAC_CRC_SIG1 0x0D18
#define DAC_CRC_SIG2 0x0D1C
#define OV0_LIN_TRANS_A 0x0D20
#define OV0_LIN_TRANS_B 0x0D24
#define OV0_LIN_TRANS_C 0x0D28
#define OV0_LIN_TRANS_D 0x0D2C
#define OV0_LIN_TRANS_E 0x0D30
#define OV0_LIN_TRANS_F 0x0D34
#define OV0_GAMMA_0_F 0x0D40
#define OV0_GAMMA_10_1F 0x0D44
#define OV0_GAMMA_20_3F 0x0D48
#define OV0_GAMMA_40_7F 0x0D4C
#define OV0_GAMMA_380_3BF 0x0D50
#define OV0_GAMMA_3C0_3FF 0x0D54
#define DISP_MERGE_CNTL 0x0D60
#define DISP_OUTPUT_CNTL 0x0D64
#define DISP_LIN_TRANS_GRPH_A 0x0D80
#define DISP_LIN_TRANS_GRPH_B 0x0D84
#define DISP_LIN_TRANS_GRPH_C 0x0D88
#define DISP_LIN_TRANS_GRPH_D 0x0D8C
#define DISP_LIN_TRANS_GRPH_E 0x0D90
#define DISP_LIN_TRANS_GRPH_F 0x0D94
#define DISP_LIN_TRANS_VID_A 0x0D98
#define DISP_LIN_TRANS_VID_B 0x0D9C
#define DISP_LIN_TRANS_VID_C 0x0DA0
#define DISP_LIN_TRANS_VID_D 0x0DA4
#define DISP_LIN_TRANS_VID_E 0x0DA8
#define DISP_LIN_TRANS_VID_F 0x0DAC
#define RMX_HORZ_FILTER_0TAP_COEF 0x0DB0
#define RMX_HORZ_FILTER_1TAP_COEF 0x0DB4
#define RMX_HORZ_FILTER_2TAP_COEF 0x0DB8
#define RMX_HORZ_PHASE 0x0DBC
#define DAC_EMBEDDED_SYNC_CNTL 0x0DC0
#define DAC_BROAD_PULSE 0x0DC4
#define DAC_SKEW_CLKS 0x0DC8
#define DAC_INCR 0x0DCC
#define DAC_NEG_SYNC_LEVEL 0x0DD0
#define DAC_POS_SYNC_LEVEL 0x0DD4
#define DAC_BLANK_LEVEL 0x0DD8
#define CLOCK_CNTL_INDEX 0x0008
#define CLOCK_CNTL_DATA 0x000C
#define CP_RB_CNTL 0x0704
#define CP_RB_BASE 0x0700
#define CP_RB_RPTR_ADDR 0x070C
#define CP_RB_RPTR 0x0710
#define CP_RB_WPTR 0x0714
#define CP_RB_WPTR_DELAY 0x0718
#define CP_IB_BASE 0x0738
#define CP_IB_BUFSZ 0x073C
#define SCRATCH_REG0 0x15E0
#define GUI_SCRATCH_REG0 0x15E0
#define SCRATCH_REG1 0x15E4
#define GUI_SCRATCH_REG1 0x15E4
#define SCRATCH_REG2 0x15E8
#define GUI_SCRATCH_REG2 0x15E8
#define SCRATCH_REG3 0x15EC
#define GUI_SCRATCH_REG3 0x15EC
#define SCRATCH_REG4 0x15F0
#define GUI_SCRATCH_REG4 0x15F0
#define SCRATCH_REG5 0x15F4
#define GUI_SCRATCH_REG5 0x15F4
#define SCRATCH_UMSK 0x0770
#define SCRATCH_ADDR 0x0774
#define DP_BRUSH_FRGD_CLR 0x147C
#define DP_BRUSH_BKGD_CLR 0x1478
#define DST_LINE_START 0x1600
#define DST_LINE_END 0x1604
#define SRC_OFFSET 0x15AC
#define SRC_PITCH 0x15B0
#define SRC_TILE 0x1704
#define SRC_PITCH_OFFSET 0x1428
#define SRC_X 0x1414
#define SRC_Y 0x1418
#define SRC_X_Y 0x1590
#define SRC_Y_X 0x1434
#define DST_Y_X 0x1438
#define DST_WIDTH_HEIGHT 0x1598
#define DST_HEIGHT_WIDTH 0x143c
#define DST_OFFSET 0x1404
#define SRC_CLUT_ADDRESS 0x1780
#define SRC_CLUT_DATA 0x1784
#define SRC_CLUT_DATA_RD 0x1788
#define HOST_DATA0 0x17C0
#define HOST_DATA1 0x17C4
#define HOST_DATA2 0x17C8
#define HOST_DATA3 0x17CC
#define HOST_DATA4 0x17D0
#define HOST_DATA5 0x17D4
#define HOST_DATA6 0x17D8
#define HOST_DATA7 0x17DC
#define HOST_DATA_LAST 0x17E0
#define DP_SRC_ENDIAN 0x15D4
#define DP_SRC_FRGD_CLR 0x15D8
#define DP_SRC_BKGD_CLR 0x15DC
#define SC_LEFT 0x1640
#define SC_RIGHT 0x1644
#define SC_TOP 0x1648
#define SC_BOTTOM 0x164C
#define SRC_SC_RIGHT 0x1654
#define SRC_SC_BOTTOM 0x165C
#define DP_CNTL 0x16C0
#define DP_CNTL_XDIR_YDIR_YMAJOR 0x16D0
#define DP_DATATYPE 0x16C4
#define DP_MIX 0x16C8
#define DP_WRITE_MSK 0x16CC
#define DP_XOP 0x17F8
#define CLR_CMP_CLR_SRC 0x15C4
#define CLR_CMP_CLR_DST 0x15C8
#define CLR_CMP_CNTL 0x15C0
#define CLR_CMP_MSK 0x15CC
#define DSTCACHE_MODE 0x1710
#define DSTCACHE_CTLSTAT 0x1714
#define DEFAULT_PITCH_OFFSET 0x16E0
#define DEFAULT_SC_BOTTOM_RIGHT 0x16E8
#define DP_GUI_MASTER_CNTL 0x146C
#define SC_TOP_LEFT 0x16EC
#define SC_BOTTOM_RIGHT 0x16F0
#define SRC_SC_BOTTOM_RIGHT 0x16F4
#define RB2D_DSTCACHE_MODE 0x3428
#define RB2D_DSTCACHE_CTLSTAT 0x342C
#define LVDS_GEN_CNTL 0x02d0
#define LVDS_PLL_CNTL 0x02d4
#define TMDS_CRC 0x02a0
#define TMDS_TRANSMITTER_CNTL 0x02a4
#define RADEON_BASE_CODE 0x0f0b
#define RADEON_BIOS_0_SCRATCH 0x0010
#define RADEON_BIOS_1_SCRATCH 0x0014
#define RADEON_BIOS_2_SCRATCH 0x0018
#define RADEON_BIOS_3_SCRATCH 0x001c
#define RADEON_BIOS_4_SCRATCH 0x0020
#define RADEON_BIOS_5_SCRATCH 0x0024
#define RADEON_BIOS_6_SCRATCH 0x0028
#define RADEON_BIOS_7_SCRATCH 0x002c
#define CLK_PIN_CNTL 0x0001
#define PPLL_CNTL 0x0002
#define PPLL_REF_DIV 0x0003
#define PPLL_DIV_0 0x0004
#define PPLL_DIV_1 0x0005
#define PPLL_DIV_2 0x0006
#define PPLL_DIV_3 0x0007
#define VCLK_ECP_CNTL 0x0008
#define HTOTAL_CNTL 0x0009
#define M_SPLL_REF_FB_DIV 0x000a
#define AGP_PLL_CNTL 0x000b
#define SPLL_CNTL 0x000c
#define SCLK_CNTL 0x000d
#define MPLL_CNTL 0x000e
#define MDLL_CKO 0x000f
#define MCLK_CNTL 0x0012
#define AGP_PLL_CNTL 0x000b
#define PLL_TEST_CNTL 0x0013
/* MCLK_CNTL bit constants */
#define FORCEON_MCLKA (1 << 16)
#define FORCEON_MCLKB (1 << 17)
#define FORCEON_YCLKA (1 << 18)
#define FORCEON_YCLKB (1 << 19)
#define FORCEON_MC (1 << 20)
#define FORCEON_AIC (1 << 21)
/* BUS_CNTL bit constants */
#define BUS_DBL_RESYNC 0x00000001
#define BUS_MSTR_RESET 0x00000002
#define BUS_FLUSH_BUF 0x00000004
#define BUS_STOP_REQ_DIS 0x00000008
#define BUS_ROTATION_DIS 0x00000010
#define BUS_MASTER_DIS 0x00000040
#define BUS_ROM_WRT_EN 0x00000080
#define BUS_DIS_ROM 0x00001000
#define BUS_PCI_READ_RETRY_EN 0x00002000
#define BUS_AGP_AD_STEPPING_EN 0x00004000
#define BUS_PCI_WRT_RETRY_EN 0x00008000
#define BUS_MSTR_RD_MULT 0x00100000
#define BUS_MSTR_RD_LINE 0x00200000
#define BUS_SUSPEND 0x00400000
#define LAT_16X 0x00800000
#define BUS_RD_DISCARD_EN 0x01000000
#define BUS_RD_ABORT_EN 0x02000000
#define BUS_MSTR_WS 0x04000000
#define BUS_PARKING_DIS 0x08000000
#define BUS_MSTR_DISCONNECT_EN 0x10000000
#define BUS_WRT_BURST 0x20000000
#define BUS_READ_BURST 0x40000000
#define BUS_RDY_READ_DLY 0x80000000
/* CLOCK_CNTL_INDEX bit constants */
#define PLL_WR_EN 0x00000080
/* CONFIG_CNTL bit constants */
#define CFG_VGA_RAM_EN 0x00000100
/* CRTC_EXT_CNTL bit constants */
#define VGA_ATI_LINEAR 0x00000008
#define VGA_128KAP_PAGING 0x00000010
#define XCRT_CNT_EN (1 << 6)
#define CRTC_HSYNC_DIS (1 << 8)
#define CRTC_VSYNC_DIS (1 << 9)
#define CRTC_DISPLAY_DIS (1 << 10)
#define CRTC_CRT_ON (1 << 15)
/* DSTCACHE_CTLSTAT bit constants */
#define RB2D_DC_FLUSH (3 << 0)
#define RB2D_DC_FLUSH_ALL 0xf
#define RB2D_DC_BUSY (1 << 31)
/* CRTC_GEN_CNTL bit constants */
#define CRTC_DBL_SCAN_EN 0x00000001
#define CRTC_CUR_EN 0x00010000
#define CRTC_INTERLACE_EN (1 << 1)
#define CRTC_EXT_DISP_EN (1 << 24)
#define CRTC_EN (1 << 25)
#define CRTC_DISP_REQ_EN_B (1 << 26)
/* CRTC_STATUS bit constants */
#define CRTC_VBLANK 0x00000001
/* CRTC2_GEN_CNTL bit constants */
#define CRT2_ON (1 << 7)
#define CRTC2_DISPLAY_DIS (1 << 23)
#define CRTC2_EN (1 << 25)
#define CRTC2_DISP_REQ_EN_B (1 << 26)
/* CUR_OFFSET, CUR_HORZ_VERT_POSN, CUR_HORZ_VERT_OFF bit constants */
#define CUR_LOCK 0x80000000
/* FP bit constants */
#define FP_CRTC_H_TOTAL_MASK 0x000003ff
#define FP_CRTC_H_DISP_MASK 0x01ff0000
#define FP_CRTC_V_TOTAL_MASK 0x00000fff
#define FP_CRTC_V_DISP_MASK 0x0fff0000
#define FP_H_SYNC_STRT_CHAR_MASK 0x00001ff8
#define FP_H_SYNC_WID_MASK 0x003f0000
#define FP_V_SYNC_STRT_MASK 0x00000fff
#define FP_V_SYNC_WID_MASK 0x001f0000
#define FP_CRTC_H_TOTAL_SHIFT 0x00000000
#define FP_CRTC_H_DISP_SHIFT 0x00000010
#define FP_CRTC_V_TOTAL_SHIFT 0x00000000
#define FP_CRTC_V_DISP_SHIFT 0x00000010
#define FP_H_SYNC_STRT_CHAR_SHIFT 0x00000003
#define FP_H_SYNC_WID_SHIFT 0x00000010
#define FP_V_SYNC_STRT_SHIFT 0x00000000
#define FP_V_SYNC_WID_SHIFT 0x00000010
/* FP_GEN_CNTL bit constants */
#define FP_FPON (1 << 0)
#define FP_TMDS_EN (1 << 2)
#define FP_EN_TMDS (1 << 7)
#define FP_DETECT_SENSE (1 << 8)
#define FP_SEL_CRTC2 (1 << 13)
#define FP_CRTC_DONT_SHADOW_HPAR (1 << 15)
#define FP_CRTC_DONT_SHADOW_VPAR (1 << 16)
#define FP_CRTC_DONT_SHADOW_HEND (1 << 17)
#define FP_CRTC_USE_SHADOW_VEND (1 << 18)
#define FP_RMX_HVSYNC_CONTROL_EN (1 << 20)
#define FP_DFP_SYNC_SEL (1 << 21)
#define FP_CRTC_LOCK_8DOT (1 << 22)
#define FP_CRT_SYNC_SEL (1 << 23)
#define FP_USE_SHADOW_EN (1 << 24)
#define FP_CRT_SYNC_ALT (1 << 26)
/* LVDS_GEN_CNTL bit constants */
#define LVDS_ON (1 << 0)
#define LVDS_DISPLAY_DIS (1 << 1)
#define LVDS_PANEL_TYPE (1 << 2)
#define LVDS_PANEL_FORMAT (1 << 3)
#define LVDS_EN (1 << 7)
#define LVDS_BL_MOD_LEVEL_MASK 0x0000ff00
#define LVDS_BL_MOD_LEVEL_SHIFT 8
#define LVDS_BL_MOD_EN (1 << 16)
#define LVDS_DIGON (1 << 18)
#define LVDS_BLON (1 << 19)
#define LVDS_SEL_CRTC2 (1 << 23)
#define LVDS_STATE_MASK \
(LVDS_ON | LVDS_DISPLAY_DIS | LVDS_BL_MOD_LEVEL_MASK | \
LVDS_EN | LVDS_DIGON | LVDS_BLON)
/* LVDS_PLL_CNTL bit constatns */
#define HSYNC_DELAY_SHIFT 0x1c
#define HSYNC_DELAY_MASK (0xf << 0x1c)
/* TMDS_TRANSMITTER_CNTL bit constants */
#define TMDS_PLL_EN (1 << 0)
#define TMDS_PLLRST (1 << 1)
#define TMDS_RAN_PAT_RST (1 << 7)
#define ICHCSEL (1 << 28)
/* FP_HORZ_STRETCH bit constants */
#define HORZ_STRETCH_RATIO_MASK 0xffff
#define HORZ_STRETCH_RATIO_MAX 4096
#define HORZ_PANEL_SIZE (0x1ff << 16)
#define HORZ_PANEL_SHIFT 16
#define HORZ_STRETCH_PIXREP (0 << 25)
#define HORZ_STRETCH_BLEND (1 << 26)
#define HORZ_STRETCH_ENABLE (1 << 25)
#define HORZ_AUTO_RATIO (1 << 27)
#define HORZ_FP_LOOP_STRETCH (0x7 << 28)
#define HORZ_AUTO_RATIO_INC (1 << 31)
/* FP_VERT_STRETCH bit constants */
#define VERT_STRETCH_RATIO_MASK 0xfff
#define VERT_STRETCH_RATIO_MAX 4096
#define VERT_PANEL_SIZE (0xfff << 12)
#define VERT_PANEL_SHIFT 12
#define VERT_STRETCH_LINREP (0 << 26)
#define VERT_STRETCH_BLEND (1 << 26)
#define VERT_STRETCH_ENABLE (1 << 25)
#define VERT_AUTO_RATIO_EN (1 << 27)
#define VERT_FP_LOOP_STRETCH (0x7 << 28)
#define VERT_STRETCH_RESERVED 0xf1000000
/* DAC_CNTL bit constants */
#define DAC_8BIT_EN 0x00000100
#define DAC_4BPP_PIX_ORDER 0x00000200
#define DAC_CRC_EN 0x00080000
#define DAC_MASK_ALL (0xff << 24)
#define DAC_EXPAND_MODE (1 << 14)
#define DAC_VGA_ADR_EN (1 << 13)
#define DAC_RANGE_CNTL (3 << 0)
#define DAC_BLANKING (1 << 2)
/* GEN_RESET_CNTL bit constants */
#define SOFT_RESET_GUI 0x00000001
#define SOFT_RESET_VCLK 0x00000100
#define SOFT_RESET_PCLK 0x00000200
#define SOFT_RESET_ECP 0x00000400
#define SOFT_RESET_DISPENG_XCLK 0x00000800
/* MEM_CNTL bit constants */
#define MEM_CTLR_STATUS_IDLE 0x00000000
#define MEM_CTLR_STATUS_BUSY 0x00100000
#define MEM_SEQNCR_STATUS_IDLE 0x00000000
#define MEM_SEQNCR_STATUS_BUSY 0x00200000
#define MEM_ARBITER_STATUS_IDLE 0x00000000
#define MEM_ARBITER_STATUS_BUSY 0x00400000
#define MEM_REQ_UNLOCK 0x00000000
#define MEM_REQ_LOCK 0x00800000
/* RBBM_SOFT_RESET bit constants */
#define SOFT_RESET_CP (1 << 0)
#define SOFT_RESET_HI (1 << 1)
#define SOFT_RESET_SE (1 << 2)
#define SOFT_RESET_RE (1 << 3)
#define SOFT_RESET_PP (1 << 4)
#define SOFT_RESET_E2 (1 << 5)
#define SOFT_RESET_RB (1 << 6)
#define SOFT_RESET_HDP (1 << 7)
/* SURFACE_CNTL bit consants */
#define SURF_TRANSLATION_DIS (1 << 8)
#define NONSURF_AP0_SWP_16BPP (1 << 20)
#define NONSURF_AP0_SWP_32BPP (1 << 21)
/* DEFAULT_SC_BOTTOM_RIGHT bit constants */
#define DEFAULT_SC_RIGHT_MAX (0x1fff << 0)
#define DEFAULT_SC_BOTTOM_MAX (0x1fff << 16)
/* MM_INDEX bit constants */
#define MM_APER 0x80000000
/* CLR_CMP_CNTL bit constants */
#define COMPARE_SRC_FALSE 0x00000000
#define COMPARE_SRC_TRUE 0x00000001
#define COMPARE_SRC_NOT_EQUAL 0x00000004
#define COMPARE_SRC_EQUAL 0x00000005
#define COMPARE_SRC_EQUAL_FLIP 0x00000007
#define COMPARE_DST_FALSE 0x00000000
#define COMPARE_DST_TRUE 0x00000100
#define COMPARE_DST_NOT_EQUAL 0x00000400
#define COMPARE_DST_EQUAL 0x00000500
#define COMPARE_DESTINATION 0x00000000
#define COMPARE_SOURCE 0x01000000
#define COMPARE_SRC_AND_DST 0x02000000
/* DP_CNTL bit constants */
#define DST_X_RIGHT_TO_LEFT 0x00000000
#define DST_X_LEFT_TO_RIGHT 0x00000001
#define DST_Y_BOTTOM_TO_TOP 0x00000000
#define DST_Y_TOP_TO_BOTTOM 0x00000002
#define DST_X_MAJOR 0x00000000
#define DST_Y_MAJOR 0x00000004
#define DST_X_TILE 0x00000008
#define DST_Y_TILE 0x00000010
#define DST_LAST_PEL 0x00000020
#define DST_TRAIL_X_RIGHT_TO_LEFT 0x00000000
#define DST_TRAIL_X_LEFT_TO_RIGHT 0x00000040
#define DST_TRAP_FILL_RIGHT_TO_LEFT 0x00000000
#define DST_TRAP_FILL_LEFT_TO_RIGHT 0x00000080
#define DST_BRES_SIGN 0x00000100
#define DST_HOST_BIG_ENDIAN_EN 0x00000200
#define DST_POLYLINE_NONLAST 0x00008000
#define DST_RASTER_STALL 0x00010000
#define DST_POLY_EDGE 0x00040000
/* DP_CNTL_YDIR_XDIR_YMAJOR bit constants (short version of DP_CNTL) */
#define DST_X_MAJOR_S 0x00000000
#define DST_Y_MAJOR_S 0x00000001
#define DST_Y_BOTTOM_TO_TOP_S 0x00000000
#define DST_Y_TOP_TO_BOTTOM_S 0x00008000
#define DST_X_RIGHT_TO_LEFT_S 0x00000000
#define DST_X_LEFT_TO_RIGHT_S 0x80000000
/* DP_DATATYPE bit constants */
#define DST_8BPP 0x00000002
#define DST_15BPP 0x00000003
#define DST_16BPP 0x00000004
#define DST_24BPP 0x00000005
#define DST_32BPP 0x00000006
#define DST_8BPP_RGB332 0x00000007
#define DST_8BPP_Y8 0x00000008
#define DST_8BPP_RGB8 0x00000009
#define DST_16BPP_VYUY422 0x0000000b
#define DST_16BPP_YVYU422 0x0000000c
#define DST_32BPP_AYUV444 0x0000000e
#define DST_16BPP_ARGB4444 0x0000000f
#define BRUSH_SOLIDCOLOR 0x00000d00
#define SRC_MONO 0x00000000
#define SRC_MONO_LBKGD 0x00010000
#define SRC_DSTCOLOR 0x00030000
#define BYTE_ORDER_MSB_TO_LSB 0x00000000
#define BYTE_ORDER_LSB_TO_MSB 0x40000000
#define DP_CONVERSION_TEMP 0x80000000
#define HOST_BIG_ENDIAN_EN (1 << 29)
/* DP_GUI_MASTER_CNTL bit constants */
#define GMC_SRC_PITCH_OFFSET_DEFAULT 0x00000000
#define GMC_SRC_PITCH_OFFSET_LEAVE 0x00000001
#define GMC_DST_PITCH_OFFSET_DEFAULT 0x00000000
#define GMC_DST_PITCH_OFFSET_LEAVE 0x00000002
#define GMC_SRC_CLIP_DEFAULT 0x00000000
#define GMC_SRC_CLIP_LEAVE 0x00000004
#define GMC_DST_CLIP_DEFAULT 0x00000000
#define GMC_DST_CLIP_LEAVE 0x00000008
#define GMC_BRUSH_8x8MONO 0x00000000
#define GMC_BRUSH_8x8MONO_LBKGD 0x00000010
#define GMC_BRUSH_8x1MONO 0x00000020
#define GMC_BRUSH_8x1MONO_LBKGD 0x00000030
#define GMC_BRUSH_1x8MONO 0x00000040
#define GMC_BRUSH_1x8MONO_LBKGD 0x00000050
#define GMC_BRUSH_32x1MONO 0x00000060
#define GMC_BRUSH_32x1MONO_LBKGD 0x00000070
#define GMC_BRUSH_32x32MONO 0x00000080
#define GMC_BRUSH_32x32MONO_LBKGD 0x00000090
#define GMC_BRUSH_8x8COLOR 0x000000a0
#define GMC_BRUSH_8x1COLOR 0x000000b0
#define GMC_BRUSH_1x8COLOR 0x000000c0
#define GMC_BRUSH_SOLID_COLOR 0x000000d0
#define GMC_DST_8BPP 0x00000200
#define GMC_DST_15BPP 0x00000300
#define GMC_DST_16BPP 0x00000400
#define GMC_DST_24BPP 0x00000500
#define GMC_DST_32BPP 0x00000600
#define GMC_DST_8BPP_RGB332 0x00000700
#define GMC_DST_8BPP_Y8 0x00000800
#define GMC_DST_8BPP_RGB8 0x00000900
#define GMC_DST_16BPP_VYUY422 0x00000b00
#define GMC_DST_16BPP_YVYU422 0x00000c00
#define GMC_DST_32BPP_AYUV444 0x00000e00
#define GMC_DST_16BPP_ARGB4444 0x00000f00
#define GMC_SRC_MONO 0x00000000
#define GMC_SRC_MONO_LBKGD 0x00001000
#define GMC_SRC_DSTCOLOR 0x00003000
#define GMC_BYTE_ORDER_MSB_TO_LSB 0x00000000
#define GMC_BYTE_ORDER_LSB_TO_MSB 0x00004000
#define GMC_DP_CONVERSION_TEMP_9300 0x00008000
#define GMC_DP_CONVERSION_TEMP_6500 0x00000000
#define GMC_DP_SRC_RECT 0x02000000
#define GMC_DP_SRC_HOST 0x03000000
#define GMC_DP_SRC_HOST_BYTEALIGN 0x04000000
#define GMC_3D_FCN_EN_CLR 0x00000000
#define GMC_3D_FCN_EN_SET 0x08000000
#define GMC_DST_CLR_CMP_FCN_LEAVE 0x00000000
#define GMC_DST_CLR_CMP_FCN_CLEAR 0x10000000
#define GMC_AUX_CLIP_LEAVE 0x00000000
#define GMC_AUX_CLIP_CLEAR 0x20000000
#define GMC_WRITE_MASK_LEAVE 0x00000000
#define GMC_WRITE_MASK_SET 0x40000000
#define GMC_CLR_CMP_CNTL_DIS (1 << 28)
#define GMC_SRC_DATATYPE_COLOR (3 << 12)
#define ROP3_S 0x00cc0000
#define ROP3_SRCCOPY 0x00cc0000
#define ROP3_P 0x00f00000
#define ROP3_PATCOPY 0x00f00000
#define DP_SRC_SOURCE_MASK (7 << 24)
#define GMC_BRUSH_NONE (15 << 4)
#define DP_SRC_SOURCE_MEMORY (2 << 24)
#define GMC_BRUSH_SOLIDCOLOR 0x000000d0
/* DP_MIX bit constants */
#define DP_SRC_RECT 0x00000200
#define DP_SRC_HOST 0x00000300
#define DP_SRC_HOST_BYTEALIGN 0x00000400
/* MPLL_CNTL bit constants */
#define MPLL_RESET 0x00000001
/* MDLL_CKO bit constants */
#define MDLL_CKO__MCKOA_RESET 0x00000002
/* VCLK_ECP_CNTL constants */
#define PIXCLK_ALWAYS_ONb 0x00000040
#define PIXCLK_DAC_ALWAYS_ONb 0x00000080
/* masks */
#define CONFIG_MEMSIZE_MASK 0x1f000000
#define MEM_CFG_TYPE 0x40000000
#define DST_OFFSET_MASK 0x003fffff
#define DST_PITCH_MASK 0x3fc00000
#define DEFAULT_TILE_MASK 0xc0000000
#define PPLL_DIV_SEL_MASK 0x00000300
#define PPLL_RESET 0x00000001
#define PPLL_ATOMIC_UPDATE_EN 0x00010000
#define PPLL_REF_DIV_MASK 0x000003ff
#define PPLL_FB3_DIV_MASK 0x000007ff
#define PPLL_POST3_DIV_MASK 0x00070000
#define PPLL_ATOMIC_UPDATE_R 0x00008000
#define PPLL_ATOMIC_UPDATE_W 0x00008000
#define PPLL_VGA_ATOMIC_UPDATE_EN 0x00020000
#define GUI_ACTIVE 0x80000000
#endif /* _RADEON_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
#ifndef __LINUX_RADEONFB_H__
#define __LINUX_RADEONFB_H__
#include <asm/ioctl.h>
#include <asm/types.h>
#define ATY_RADEON_LCD_ON 0x00000001
#define ATY_RADEON_CRT_ON 0x00000002
#define FBIO_RADEON_GET_MIRROR _IOR('@', 3, sizeof(__u32*))
#define FBIO_RADEON_SET_MIRROR _IOW('@', 4, sizeof(__u32*))
#endif

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.X11,v 1.72 2002/10/29 23:09:40 brianp Exp $
# $Id: Makefile.X11,v 1.72.4.1 2002/11/21 14:59:05 brianp Exp $
# Mesa 3-D graphics library
# Version: 5.0
@@ -144,6 +144,8 @@ CORE_SOURCES = \
DRIVER_SOURCES = \
fbdev/glfbdev.c \
miniglx/miniglx.c \
FX/fxapi.c \
FX/fxdd.c \
FX/fxddspan.c \

View File

@@ -1,8 +1,8 @@
/* $Id: acache.h,v 1.4 2002/10/29 20:28:58 brianp Exp $ */
/* $Id: acache.h,v 1.4.4.1 2003/01/10 21:57:42 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.1
* Version: 5.0
*
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
@@ -23,10 +23,23 @@
* 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:
* Keith Whitwell <keith@tungstengraphics.com>
*/
/**
* \mainpage Mesa array_cache Module
*
* The array cache module is used for caching vertex arrays.
*/
/**
* \file array_cache/acache.h
* \brief Array cache functions (for vertex arrays).
* \author Keith Whitwell
*/
#ifndef _ARRAYCACHE_H
#define _ARRAYCACHE_H

View File

@@ -1,8 +1,8 @@
/* $Id: GLView.cpp,v 1.7 2002/10/17 14:25:30 brianp Exp $ */
/* $Id: GLView.cpp,v 1.7.2.1 2002/11/13 22:21:47 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.1
* Version: 5.0
*
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
@@ -38,7 +38,6 @@ extern "C" {
#include "extensions.h"
#include "macros.h"
#include "matrix.h"
#include "mem.h"
#include "mmath.h"
#include "mtypes.h"
#include "texformat.h"
@@ -276,9 +275,7 @@ BGLView::BGLView(BRect rect, char *name,
);
// create core context
__GLimports imports;
_mesa_init_default_imports(&imports, md);
GLcontext * ctx = _mesa_create_context( visual, NULL, &imports);
GLcontext * ctx = _mesa_create_context(visual, NULL, md, GL_FALSE);
// create core framebuffer
@@ -648,7 +645,7 @@ void MesaDriver::UnlockGL()
void MesaDriver::SwapBuffers() const
{
// _mesa_swap_buffers();
// _mesa_notifySwapBuffers(m_glcontext);
if (m_bitmap) {
m_bglview->LockLooper();

View File

@@ -0,0 +1,176 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/common/depthtmp.h,v 1.5 2001/03/21 16:14:20 dawes Exp $ */
#ifndef DBG
#define DBG 0
#endif
#ifndef HAVE_HW_DEPTH_SPANS
#define HAVE_HW_DEPTH_SPANS 0
#endif
#ifndef HAVE_HW_DEPTH_PIXELS
#define HAVE_HW_DEPTH_PIXELS 0
#endif
#ifndef HW_READ_LOCK
#define HW_READ_LOCK() HW_LOCK()
#endif
#ifndef HW_READ_UNLOCK
#define HW_READ_UNLOCK() HW_UNLOCK()
#endif
static void TAG(WriteDepthSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLdepth *depth,
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_DEPTH_VARS;
y = Y_FLIP( y );
#if HAVE_HW_DEPTH_SPANS
(void) x1; (void) n1;
if ( DBG ) fprintf( stderr, "WriteDepthSpan 0..%d (x1 %d)\n",
(int)n, (int)x );
WRITE_DEPTH_SPAN();
#else
HW_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN( x, y, n, x1, n1, i );
if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
(int)i, (int)n1, (int)x1 );
if ( mask ) {
for ( ; i < n1 ; i++, x1++ ) {
if ( mask[i] ) WRITE_DEPTH( x1, y, depth[i] );
}
} else {
for ( ; i < n1 ; i++, x1++ ) {
WRITE_DEPTH( x1, y, depth[i] );
}
}
}
HW_ENDCLIPLOOP();
#endif
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteDepthPixels)( GLcontext *ctx,
GLuint n,
const GLint x[],
const GLint y[],
const GLdepth depth[],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_DEPTH_VARS;
if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" );
#if HAVE_HW_DEPTH_PIXELS
(void) i;
WRITE_DEPTH_PIXELS();
#else
HW_CLIPLOOP()
{
for ( i = 0 ; i < n ; i++ ) {
if ( mask[i] ) {
const int fy = Y_FLIP( y[i] );
if ( CLIPPIXEL( x[i], fy ) )
WRITE_DEPTH( x[i], fy, depth[i] );
}
}
}
HW_ENDCLIPLOOP();
#endif
}
HW_WRITE_UNLOCK();
}
/* Read depth spans and pixels
*/
static void TAG(ReadDepthSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLdepth depth[] )
{
HW_READ_LOCK()
{
GLint x1, n1;
LOCAL_DEPTH_VARS;
y = Y_FLIP( y );
if ( DBG ) fprintf( stderr, "ReadDepthSpan\n" );
#if HAVE_HW_DEPTH_SPANS
(void) x1; (void) n1;
READ_DEPTH_SPAN();
#else
HW_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN( x, y, n, x1, n1, i );
for ( ; i < n1 ; i++ )
READ_DEPTH( depth[i], (x1+i), y );
}
HW_ENDCLIPLOOP();
#endif
}
HW_READ_UNLOCK();
}
static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
GLdepth depth[] )
{
HW_READ_LOCK()
{
GLint i;
LOCAL_DEPTH_VARS;
if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" );
#if HAVE_HW_DEPTH_PIXELS
(void) i;
READ_DEPTH_PIXELS();
#else
HW_CLIPLOOP()
{
for ( i = 0 ; i < n ;i++ ) {
int fy = Y_FLIP( y[i] );
if ( CLIPPIXEL( x[i], fy ) )
READ_DEPTH( depth[i], x[i], fy );
}
}
HW_ENDCLIPLOOP();
#endif
}
HW_READ_UNLOCK();
}
#if HAVE_HW_DEPTH_SPANS
#undef WRITE_DEPTH_SPAN
#undef WRITE_DEPTH_PIXELS
#undef READ_DEPTH_SPAN
#undef READ_DEPTH_PIXELS
#else
#undef WRITE_DEPTH
#undef READ_DEPTH
#endif
#undef TAG

View File

@@ -0,0 +1,142 @@
/*
* GLX Hardware Device Driver common code
*
* Based on the original MGA G200 driver (c) 1999 Wittawat Yamwong
*
* 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
* WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS 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.
*
*
* Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/common/hwlog.c,v 1.3 2001/08/18 02:51:03 dawes Exp $ */
#include "hwlog.h"
hwlog_t hwlog = { 0,0,0, "[???] "};
/* Should be shared, but is this a good place for it?
*/
#include <sys/time.h>
#include <stdarg.h>
int usec( void )
{
struct timeval tv;
struct timezone tz;
gettimeofday( &tv, &tz );
return (tv.tv_sec & 2047) * 1000000 + tv.tv_usec;
}
#ifdef HW_LOG_ENABLED
int hwOpenLog(const char *filename, char *prefix)
{
hwCloseLog();
hwSetLogLevel(0);
hwlog.prefix=prefix;
if (!filename)
return -1;
if ((hwlog.file = fopen(filename,"w")) == NULL)
return -1;
return 0;
}
void hwCloseLog()
{
if (hwlog.file) {
fclose(hwlog.file);
hwlog.file = NULL;
}
}
int hwIsLogReady()
{
return (hwlog.file != NULL);
}
void hwSetLogLevel(int level)
{
hwlog.level = level;
}
int hwGetLogLevel()
{
return hwlog.level;
}
void hwLog(int level, const char *format, ...)
{
va_list ap;
va_start(ap,format);
hwLogv(level,format,ap);
va_end(ap);
}
void hwLogv(int l, const char *format, va_list ap)
{
if (hwlog.file && (l <= hwlog.level)) {
vfprintf(hwlog.file,format,ap);
fflush(hwlog.file);
}
}
void hwMsg(int l, const char *format, ...)
{
va_list ap;
va_start(ap, format);
if (l <= hwlog.level) {
if (hwIsLogReady()) {
int t = usec();
hwLog(l, "%6i:", t - hwlog.timeTemp);
hwlog.timeTemp = t;
hwLogv(l, format, ap);
} else {
fprintf(stderr, hwlog.prefix);
vfprintf(stderr, format, ap);
}
}
va_end(ap);
}
#else /* ifdef HW_LOG_ENABLED */
int hwlogdummy()
{
return 0;
}
#endif
void hwError(const char *format, ...)
{
va_list ap;
va_start(ap, format);
fprintf(stderr, hwlog.prefix);
vfprintf(stderr, format, ap);
hwLogv(0, format, ap);
va_end(ap);
}

View File

@@ -0,0 +1,101 @@
/*
* GLX Hardware Device Driver common code
*
* Based on the original MGA G200 driver (c) 1999 Wittawat Yamwong
*
* 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
* WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS 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.
*
*
* Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/common/hwlog.h,v 1.5 2001/10/31 23:22:57 tsi Exp $ */
/* Usage:
* - use mgaError for error messages. Always write to X error and log file.
* - use mgaMsg for debugging. Can be disabled by undefining MGA_LOG_ENABLED.
*/
#ifndef HWLOG_INC
#define HWLOG_INC
#include <stdarg.h>
#include <stdio.h>
#define DBG_LEVEL_BASE 1
#define DBG_LEVEL_VERBOSE 10
#define DBG_LEVEL_ENTEREXIT 20
typedef struct
{
FILE *file;
int level;
unsigned int timeTemp;
char *prefix;
} hwlog_t;
extern hwlog_t hwlog;
#ifdef HW_LOG_ENABLED
/* open and close log file. */
int hwOpenLog(const char *filename, char *prefix);
void hwCloseLog(void);
/* return 1 if log file is succesfully opened */
int hwIsLogReady(void);
/* set current log level to 'level'. Messages with level less than or equal
the current log level will be written to the log file. */
void hwSetLogLevel(int level);
int hwGetLogLevel(void);
/* hwLog and hwLogv write a message to the log file. */
/* do not call these directly, use hwMsg() instead */
void hwLog(int level, const char *format, ...);
void hwLogv(int level, const char *format, va_list ap);
int usec( void );
/* hwMsg writes a message to the log file or to the standard X error file. */
void hwMsg(int level, const char *format, ...);
#else
static __inline__ int hwOpenLog(const char *f, char *prefix) { hwlog.prefix=prefix; return -1; }
#define hwIsLogReady() (0)
#define hwGetLogLevel() (-1)
#define hwLogLevel(n) (0)
#define hwLog()
#define hwMsg()
#define hwCloseLog()
#define hwSetLogLevel(x)
#define hwLogv(l,f,a)
#endif
void hwError(const char *format, ...);
#endif

View File

@@ -0,0 +1,294 @@
/**
* \file mm.c
* \brief Memory block management.
*/
/*
* Copyright (C) 1999 Keith Whitwell
*
* 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
* KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/common/mm.c,v 1.3 2001/08/18 02:51:03 dawes Exp $ */
#include <stdlib.h>
#include <stdio.h>
#include "mm.h"
/* KW: I don't know who the author of this code is, but it wasn't me
* despite what the copyright says...
*/
/**
* \brief Dump memory information about the heap.
*
* \param heap memory heap.
*
* \note For debugging purposes.
*
* \internal
* Prints the offset, size and flags for each block.
*/
void mmDumpMemInfo( memHeap_t *heap )
{
TMemBlock *p;
fprintf(stderr, "Memory heap %p:\n", heap);
if (heap == 0) {
fprintf(stderr, " heap == 0\n");
} else {
p = (TMemBlock *)heap;
while (p) {
fprintf(stderr, " Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size,
p->free ? '.':'U',
p->reserved ? 'R':'.');
p = p->next;
}
}
fprintf(stderr, "End of memory blocks\n");
}
/**
* \brief Memory heap initialization.
*
* \param offset offset in bytes.
* \param size total size in bytes
*
* \return a heap pointer on success, or NULL on failure.
*
* \internal
* Allocate a mem_block_t structure and initialize it with the heap
* information.
*/
memHeap_t *mmInit(int ofs,
int size)
{
PMemBlock blocks;
if (size <= 0) {
return 0;
}
blocks = (TMemBlock *) calloc(1,sizeof(TMemBlock));
if (blocks) {
blocks->ofs = ofs;
blocks->size = size;
blocks->free = 1;
return (memHeap_t *)blocks;
} else
return 0;
}
/**
* \brief Slice a free memory block.
*
* \param p memory block.
* \param startofs slice start offset.
* \param size slice size.
* \param reserved reserved flag.
* \param alignment slice alignment.
*
* \return pointer to the slice block on success, or NULL on failure.
*
* \internal
* Creates a new block to the left with the memory before the slice start (if
* any), a block to the right with the memory after the slice (if any), and
* returns the reduced memory block itself as the slice.
*/
static TMemBlock* SliceBlock(TMemBlock *p,
int startofs, int size,
int reserved, int alignment)
{
TMemBlock *newblock;
/* break left */
if (startofs > p->ofs) {
newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock));
if (!newblock)
return NULL;
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
newblock->free = 1;
newblock->next = p->next;
p->size -= newblock->size;
p->next = newblock;
p = newblock;
}
/* break right */
if (size < p->size) {
newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock));
if (!newblock)
return NULL;
newblock->ofs = startofs + size;
newblock->size = p->size - size;
newblock->free = 1;
newblock->next = p->next;
p->size = size;
p->next = newblock;
}
/* p = middle block */
p->align = alignment;
p->free = 0;
p->reserved = reserved;
return p;
}
/**
* \brief Allocate a memory block.
*
* Allocate \p size bytes with a \p 2^align2 bytes alignment, restricting the
* search to free memory after \p startSearch. Depth and back buffers should
* be in different 4MB banks to get better page hits if possible.
*
* \param heap memory heap.
* \param size size to allocate in bytes.
* \param align2 base 2 log of the block alignment in bytes.
* \param startSearch linear offset from start of the heap to begin the
* search.
*
* \return pointer to the allocated block on success, or NULL on failure.
*
* \internal
* Walks through the free blocks on the heap and if it finds one above
* \p startSearch and large enough slices it via SliceBlock() and returns the
* result.
*/
PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch)
{
int mask,startofs,endofs;
TMemBlock *p;
if (!heap || align2 < 0 || size <= 0)
return NULL;
mask = (1 << align2)-1;
startofs = 0;
p = (TMemBlock *)heap;
while (p) {
if ((p)->free) {
startofs = (p->ofs + mask) & ~mask;
if ( startofs < startSearch ) {
startofs = startSearch;
}
endofs = startofs+size;
if (endofs <= (p->ofs+p->size))
break;
}
p = p->next;
}
if (!p)
return NULL;
p = SliceBlock(p,startofs,size,0,mask+1);
p->heap = heap;
return p;
}
/**
* \brief Join two successive free memory blocks.
*
* \param p pointer to first memory block.
*
* \return 1 on success, or 0 on failure.
*
* \internal
* Adds the size of the second block to the first and frees its data structure.
*/
static __inline__ int Join2Blocks(TMemBlock *p)
{
if (p->free && p->next && p->next->free) {
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
free(q);
return 1;
}
return 0;
}
/**
* \brief Free a memory block.
*
* \param pointer to a block.
*
* \return 0 on success, or -1 on failure.
*
* \internal
* Search the given block on the heap, mark it as free and attempt to join it
* with the next one via Join2Blocks().
*/
int mmFreeMem(PMemBlock b)
{
TMemBlock *p,*prev;
if (!b)
return 0;
if (!b->heap) {
fprintf(stderr, "no heap\n");
return -1;
}
p = b->heap;
prev = NULL;
while (p && p != b) {
prev = p;
p = p->next;
}
if (!p || p->free || p->reserved) {
if (!p)
fprintf(stderr, "block not found in heap\n");
else if (p->free)
fprintf(stderr, "block already free\n");
else
fprintf(stderr, "block is reserved\n");
return -1;
}
p->free = 1;
Join2Blocks(p);
if (prev)
Join2Blocks(prev);
return 0;
}
/**
* \brief Destroy the memory heap.
*
* \param heap memory heap.
*
* \internal
* Frees each block in the heap.
*/
void mmDestroy(memHeap_t *heap)
{
TMemBlock *p,*q;
if (!heap)
return;
p = (TMemBlock *)heap;
while (p) {
q = p->next;
free(p);
p = q;
}
}

View File

@@ -0,0 +1,85 @@
/**
* \file mm.h
* \brief Memory block management.
*/
/*
* Copyright (C) 1999 Keith Whitwell
*
* 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
* KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
*
*/
#ifndef MM_INC
#define MM_INC
/**
* \brief Memory block/heap.
*/
struct mem_block_t {
struct mem_block_t *next; /**< \brief pointer to next block in the heap */
struct mem_block_t *heap; /**< \brief pointer to the heap (first block) */
int ofs; /**< \brief offset */
int size; /**< \brief size */
int align; /**< \brief alignment */
int free:1; /**< \brief free flag */
int reserved:1; /**< \brief reserved flag */
};
/**
* \brief Memory block.
*/
typedef struct mem_block_t TMemBlock;
/**
* \brief Memory block pointer.
*/
typedef struct mem_block_t *PMemBlock;
/**
* \brief Memory heap.
*
* \note A heap is just the first block in a chain
*/
typedef struct mem_block_t memHeap_t;
/**
* \brief Get Memory block size.
*/
static __inline__ int mmBlockSize(PMemBlock b)
{ return b->size; }
/**
* \brief Get Memory block offset.
*/
static __inline__ int mmOffset(PMemBlock b)
{ return b->ofs; }
memHeap_t *mmInit( int ofs, int size );
PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2,
int startSearch );
int mmFreeMem( PMemBlock b );
void mmDestroy( memHeap_t *heap );
void mmDumpMemInfo( memHeap_t *heap );
#endif

View File

@@ -0,0 +1,259 @@
#ifndef DBG
#define DBG 0
#endif
#ifndef HW_WRITE_LOCK
#define HW_WRITE_LOCK() HW_LOCK()
#endif
#ifndef HW_WRITE_UNLOCK
#define HW_WRITE_UNLOCK() HW_UNLOCK()
#endif
#ifndef HW_READ_LOCK
#define HW_READ_LOCK() HW_LOCK()
#endif
#ifndef HW_READ_UNLOCK
#define HW_READ_UNLOCK() HW_UNLOCK()
#endif
#ifndef HW_READ_CLIPLOOP
#define HW_READ_CLIPLOOP() HW_CLIPLOOP()
#endif
#ifndef HW_WRITE_CLIPLOOP
#define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
#endif
static void TAG(WriteRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][4],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_VARS;
y = Y_FLIP(y);
HW_WRITE_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n",
(int)i, (int)n1, (int)x1);
if (mask)
{
for (;n1>0;i++,x1++,n1--)
if (mask[i])
WRITE_RGBA( x1, y,
rgba[i][0], rgba[i][1],
rgba[i][2], rgba[i][3] );
}
else
{
for (;n1>0;i++,x1++,n1--)
WRITE_RGBA( x1, y,
rgba[i][0], rgba[i][1],
rgba[i][2], rgba[i][3] );
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteRGBSpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgb[][3],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_VARS;
y = Y_FLIP(y);
HW_WRITE_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
if (DBG) fprintf(stderr, "WriteRGBSpan %d..%d (x1 %d)\n",
(int)i, (int)n1, (int)x1);
if (mask)
{
for (;n1>0;i++,x1++,n1--)
if (mask[i])
WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
}
else
{
for (;n1>0;i++,x1++,n1--)
WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
GLuint n,
const GLint x[],
const GLint y[],
const GLubyte rgba[][4],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_VARS;
if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
HW_WRITE_CLIPLOOP()
{
for (i=0;i<n;i++)
{
if (mask[i]) {
const int fy = Y_FLIP(y[i]);
if (CLIPPIXEL(x[i],fy))
WRITE_RGBA( x[i], fy,
rgba[i][0], rgba[i][1],
rgba[i][2], rgba[i][3] );
}
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLchan color[4],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_VARS;
INIT_MONO_PIXEL(p, color);
y = Y_FLIP( y );
if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
HW_WRITE_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
for (;n1>0;i++,x1++,n1--)
if (mask[i])
WRITE_PIXEL( x1, y, p );
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
GLuint n,
const GLint x[], const GLint y[],
const GLchan color[],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_VARS;
INIT_MONO_PIXEL(p, color);
if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
HW_WRITE_CLIPLOOP()
{
for (i=0;i<n;i++)
if (mask[i]) {
int fy = Y_FLIP(y[i]);
if (CLIPPIXEL( x[i], fy ))
WRITE_PIXEL( x[i], fy, p );
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(ReadRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte rgba[][4])
{
HW_READ_LOCK()
{
GLint x1,n1;
LOCAL_VARS;
y = Y_FLIP(y);
if (DBG) fprintf(stderr, "ReadRGBASpan\n");
HW_READ_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
for (;n1>0;i++,x1++,n1--)
READ_RGBA( rgba[i], x1, y );
}
HW_ENDCLIPLOOP();
}
HW_READ_UNLOCK();
}
static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[] )
{
HW_READ_LOCK()
{
GLint i;
LOCAL_VARS;
if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
HW_READ_CLIPLOOP()
{
for (i=0;i<n;i++)
if (mask[i]) {
int fy = Y_FLIP( y[i] );
if (CLIPPIXEL( x[i], fy ))
READ_RGBA( rgba[i], x[i], fy );
}
}
HW_ENDCLIPLOOP();
}
HW_READ_UNLOCK();
}
#undef WRITE_PIXEL
#undef WRITE_RGBA
#undef READ_RGBA
#undef TAG

View File

@@ -0,0 +1,147 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.3 2001/03/21 16:14:20 dawes Exp $ */
#ifndef DBG
#define DBG 0
#endif
#ifndef HW_WRITE_LOCK
#define HW_WRITE_LOCK() HW_LOCK()
#endif
#ifndef HW_WRITE_UNLOCK
#define HW_WRITE_UNLOCK() HW_UNLOCK()
#endif
#ifndef HW_READ_LOCK
#define HW_READ_LOCK() HW_LOCK()
#endif
#ifndef HW_READ_UNLOCK
#define HW_READ_UNLOCK() HW_UNLOCK()
#endif
static void TAG(WriteStencilSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLstencil *stencil,
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_STENCIL_VARS;
y = Y_FLIP(y);
HW_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
(int)i, (int)n1, (int)x1);
if (mask)
{
for (;i<n1;i++,x1++)
if (mask[i])
WRITE_STENCIL( x1, y, stencil[i] );
}
else
{
for (;i<n1;i++,x1++)
WRITE_STENCIL( x1, y, stencil[i] );
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteStencilPixels)( GLcontext *ctx,
GLuint n,
const GLint x[],
const GLint y[],
const GLstencil stencil[],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_STENCIL_VARS;
if (DBG) fprintf(stderr, "WriteStencilPixels\n");
HW_CLIPLOOP()
{
for (i=0;i<n;i++)
{
if (mask[i]) {
const int fy = Y_FLIP(y[i]);
if (CLIPPIXEL(x[i],fy))
WRITE_STENCIL( x[i], fy, stencil[i] );
}
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
/* Read stencil spans and pixels
*/
static void TAG(ReadStencilSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLstencil stencil[])
{
HW_READ_LOCK()
{
GLint x1,n1;
LOCAL_STENCIL_VARS;
y = Y_FLIP(y);
if (DBG) fprintf(stderr, "ReadStencilSpan\n");
HW_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
for (;i<n1;i++)
READ_STENCIL( stencil[i], (x1+i), y );
}
HW_ENDCLIPLOOP();
}
HW_READ_UNLOCK();
}
static void TAG(ReadStencilPixels)( GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
GLstencil stencil[] )
{
HW_READ_LOCK()
{
GLint i;
LOCAL_STENCIL_VARS;
if (DBG) fprintf(stderr, "ReadStencilPixels\n");
HW_CLIPLOOP()
{
for (i=0;i<n;i++) {
int fy = Y_FLIP( y[i] );
if (CLIPPIXEL( x[i], fy ))
READ_STENCIL( stencil[i], x[i], fy );
}
}
HW_ENDCLIPLOOP();
}
HW_READ_UNLOCK();
}
#undef WRITE_STENCIL
#undef READ_STENCIL
#undef TAG

View File

@@ -1,4 +1,4 @@
/* $Id: t_dd_vertex.h,v 1.13 2002/10/29 20:29:05 brianp Exp $ */
/* $Id: t_dd_vertex.h,v 1.13.4.1 2003/01/10 21:57:43 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -27,6 +27,16 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
/**
* \mainpage Mesa TNL Device Driver Module
*
* This module contains functions useful for hardware device drivers.
* For example, building D3D-style vertex buffers.
*/
typedef struct {
GLfloat x, y, z, w;
} TAG(_coord_t);

View File

@@ -0,0 +1,176 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/common/depthtmp.h,v 1.5 2001/03/21 16:14:20 dawes Exp $ */
#ifndef DBG
#define DBG 0
#endif
#ifndef HAVE_HW_DEPTH_SPANS
#define HAVE_HW_DEPTH_SPANS 0
#endif
#ifndef HAVE_HW_DEPTH_PIXELS
#define HAVE_HW_DEPTH_PIXELS 0
#endif
#ifndef HW_READ_LOCK
#define HW_READ_LOCK() HW_LOCK()
#endif
#ifndef HW_READ_UNLOCK
#define HW_READ_UNLOCK() HW_UNLOCK()
#endif
static void TAG(WriteDepthSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLdepth *depth,
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_DEPTH_VARS;
y = Y_FLIP( y );
#if HAVE_HW_DEPTH_SPANS
(void) x1; (void) n1;
if ( DBG ) fprintf( stderr, "WriteDepthSpan 0..%d (x1 %d)\n",
(int)n, (int)x );
WRITE_DEPTH_SPAN();
#else
HW_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN( x, y, n, x1, n1, i );
if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
(int)i, (int)n1, (int)x1 );
if ( mask ) {
for ( ; i < n1 ; i++, x1++ ) {
if ( mask[i] ) WRITE_DEPTH( x1, y, depth[i] );
}
} else {
for ( ; i < n1 ; i++, x1++ ) {
WRITE_DEPTH( x1, y, depth[i] );
}
}
}
HW_ENDCLIPLOOP();
#endif
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteDepthPixels)( GLcontext *ctx,
GLuint n,
const GLint x[],
const GLint y[],
const GLdepth depth[],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_DEPTH_VARS;
if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" );
#if HAVE_HW_DEPTH_PIXELS
(void) i;
WRITE_DEPTH_PIXELS();
#else
HW_CLIPLOOP()
{
for ( i = 0 ; i < n ; i++ ) {
if ( mask[i] ) {
const int fy = Y_FLIP( y[i] );
if ( CLIPPIXEL( x[i], fy ) )
WRITE_DEPTH( x[i], fy, depth[i] );
}
}
}
HW_ENDCLIPLOOP();
#endif
}
HW_WRITE_UNLOCK();
}
/* Read depth spans and pixels
*/
static void TAG(ReadDepthSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLdepth depth[] )
{
HW_READ_LOCK()
{
GLint x1, n1;
LOCAL_DEPTH_VARS;
y = Y_FLIP( y );
if ( DBG ) fprintf( stderr, "ReadDepthSpan\n" );
#if HAVE_HW_DEPTH_SPANS
(void) x1; (void) n1;
READ_DEPTH_SPAN();
#else
HW_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN( x, y, n, x1, n1, i );
for ( ; i < n1 ; i++ )
READ_DEPTH( depth[i], (x1+i), y );
}
HW_ENDCLIPLOOP();
#endif
}
HW_READ_UNLOCK();
}
static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
GLdepth depth[] )
{
HW_READ_LOCK()
{
GLint i;
LOCAL_DEPTH_VARS;
if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" );
#if HAVE_HW_DEPTH_PIXELS
(void) i;
READ_DEPTH_PIXELS();
#else
HW_CLIPLOOP()
{
for ( i = 0 ; i < n ;i++ ) {
int fy = Y_FLIP( y[i] );
if ( CLIPPIXEL( x[i], fy ) )
READ_DEPTH( depth[i], x[i], fy );
}
}
HW_ENDCLIPLOOP();
#endif
}
HW_READ_UNLOCK();
}
#if HAVE_HW_DEPTH_SPANS
#undef WRITE_DEPTH_SPAN
#undef WRITE_DEPTH_PIXELS
#undef READ_DEPTH_SPAN
#undef READ_DEPTH_PIXELS
#else
#undef WRITE_DEPTH
#undef READ_DEPTH
#endif
#undef TAG

View File

@@ -0,0 +1,142 @@
/*
* GLX Hardware Device Driver common code
*
* Based on the original MGA G200 driver (c) 1999 Wittawat Yamwong
*
* 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
* WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS 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.
*
*
* Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/common/hwlog.c,v 1.3 2001/08/18 02:51:03 dawes Exp $ */
#include "hwlog.h"
hwlog_t hwlog = { 0,0,0, "[???] "};
/* Should be shared, but is this a good place for it?
*/
#include <sys/time.h>
#include <stdarg.h>
int usec( void )
{
struct timeval tv;
struct timezone tz;
gettimeofday( &tv, &tz );
return (tv.tv_sec & 2047) * 1000000 + tv.tv_usec;
}
#ifdef HW_LOG_ENABLED
int hwOpenLog(const char *filename, char *prefix)
{
hwCloseLog();
hwSetLogLevel(0);
hwlog.prefix=prefix;
if (!filename)
return -1;
if ((hwlog.file = fopen(filename,"w")) == NULL)
return -1;
return 0;
}
void hwCloseLog()
{
if (hwlog.file) {
fclose(hwlog.file);
hwlog.file = NULL;
}
}
int hwIsLogReady()
{
return (hwlog.file != NULL);
}
void hwSetLogLevel(int level)
{
hwlog.level = level;
}
int hwGetLogLevel()
{
return hwlog.level;
}
void hwLog(int level, const char *format, ...)
{
va_list ap;
va_start(ap,format);
hwLogv(level,format,ap);
va_end(ap);
}
void hwLogv(int l, const char *format, va_list ap)
{
if (hwlog.file && (l <= hwlog.level)) {
vfprintf(hwlog.file,format,ap);
fflush(hwlog.file);
}
}
void hwMsg(int l, const char *format, ...)
{
va_list ap;
va_start(ap, format);
if (l <= hwlog.level) {
if (hwIsLogReady()) {
int t = usec();
hwLog(l, "%6i:", t - hwlog.timeTemp);
hwlog.timeTemp = t;
hwLogv(l, format, ap);
} else {
fprintf(stderr, hwlog.prefix);
vfprintf(stderr, format, ap);
}
}
va_end(ap);
}
#else /* ifdef HW_LOG_ENABLED */
int hwlogdummy()
{
return 0;
}
#endif
void hwError(const char *format, ...)
{
va_list ap;
va_start(ap, format);
fprintf(stderr, hwlog.prefix);
vfprintf(stderr, format, ap);
hwLogv(0, format, ap);
va_end(ap);
}

View File

@@ -0,0 +1,101 @@
/*
* GLX Hardware Device Driver common code
*
* Based on the original MGA G200 driver (c) 1999 Wittawat Yamwong
*
* 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
* WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS 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.
*
*
* Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/common/hwlog.h,v 1.5 2001/10/31 23:22:57 tsi Exp $ */
/* Usage:
* - use mgaError for error messages. Always write to X error and log file.
* - use mgaMsg for debugging. Can be disabled by undefining MGA_LOG_ENABLED.
*/
#ifndef HWLOG_INC
#define HWLOG_INC
#include <stdarg.h>
#include <stdio.h>
#define DBG_LEVEL_BASE 1
#define DBG_LEVEL_VERBOSE 10
#define DBG_LEVEL_ENTEREXIT 20
typedef struct
{
FILE *file;
int level;
unsigned int timeTemp;
char *prefix;
} hwlog_t;
extern hwlog_t hwlog;
#ifdef HW_LOG_ENABLED
/* open and close log file. */
int hwOpenLog(const char *filename, char *prefix);
void hwCloseLog(void);
/* return 1 if log file is succesfully opened */
int hwIsLogReady(void);
/* set current log level to 'level'. Messages with level less than or equal
the current log level will be written to the log file. */
void hwSetLogLevel(int level);
int hwGetLogLevel(void);
/* hwLog and hwLogv write a message to the log file. */
/* do not call these directly, use hwMsg() instead */
void hwLog(int level, const char *format, ...);
void hwLogv(int level, const char *format, va_list ap);
int usec( void );
/* hwMsg writes a message to the log file or to the standard X error file. */
void hwMsg(int level, const char *format, ...);
#else
static __inline__ int hwOpenLog(const char *f, char *prefix) { hwlog.prefix=prefix; return -1; }
#define hwIsLogReady() (0)
#define hwGetLogLevel() (-1)
#define hwLogLevel(n) (0)
#define hwLog()
#define hwMsg()
#define hwCloseLog()
#define hwSetLogLevel(x)
#define hwLogv(l,f,a)
#endif
void hwError(const char *format, ...);
#endif

View File

@@ -0,0 +1,294 @@
/**
* \file mm.c
* \brief Memory block management.
*/
/*
* Copyright (C) 1999 Keith Whitwell
*
* 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
* KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/common/mm.c,v 1.3 2001/08/18 02:51:03 dawes Exp $ */
#include <stdlib.h>
#include <stdio.h>
#include "mm.h"
/* KW: I don't know who the author of this code is, but it wasn't me
* despite what the copyright says...
*/
/**
* \brief Dump memory information about the heap.
*
* \param heap memory heap.
*
* \note For debugging purposes.
*
* \internal
* Prints the offset, size and flags for each block.
*/
void mmDumpMemInfo( memHeap_t *heap )
{
TMemBlock *p;
fprintf(stderr, "Memory heap %p:\n", heap);
if (heap == 0) {
fprintf(stderr, " heap == 0\n");
} else {
p = (TMemBlock *)heap;
while (p) {
fprintf(stderr, " Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size,
p->free ? '.':'U',
p->reserved ? 'R':'.');
p = p->next;
}
}
fprintf(stderr, "End of memory blocks\n");
}
/**
* \brief Memory heap initialization.
*
* \param offset offset in bytes.
* \param size total size in bytes
*
* \return a heap pointer on success, or NULL on failure.
*
* \internal
* Allocate a mem_block_t structure and initialize it with the heap
* information.
*/
memHeap_t *mmInit(int ofs,
int size)
{
PMemBlock blocks;
if (size <= 0) {
return 0;
}
blocks = (TMemBlock *) calloc(1,sizeof(TMemBlock));
if (blocks) {
blocks->ofs = ofs;
blocks->size = size;
blocks->free = 1;
return (memHeap_t *)blocks;
} else
return 0;
}
/**
* \brief Slice a free memory block.
*
* \param p memory block.
* \param startofs slice start offset.
* \param size slice size.
* \param reserved reserved flag.
* \param alignment slice alignment.
*
* \return pointer to the slice block on success, or NULL on failure.
*
* \internal
* Creates a new block to the left with the memory before the slice start (if
* any), a block to the right with the memory after the slice (if any), and
* returns the reduced memory block itself as the slice.
*/
static TMemBlock* SliceBlock(TMemBlock *p,
int startofs, int size,
int reserved, int alignment)
{
TMemBlock *newblock;
/* break left */
if (startofs > p->ofs) {
newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock));
if (!newblock)
return NULL;
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
newblock->free = 1;
newblock->next = p->next;
p->size -= newblock->size;
p->next = newblock;
p = newblock;
}
/* break right */
if (size < p->size) {
newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock));
if (!newblock)
return NULL;
newblock->ofs = startofs + size;
newblock->size = p->size - size;
newblock->free = 1;
newblock->next = p->next;
p->size = size;
p->next = newblock;
}
/* p = middle block */
p->align = alignment;
p->free = 0;
p->reserved = reserved;
return p;
}
/**
* \brief Allocate a memory block.
*
* Allocate \p size bytes with a \p 2^align2 bytes alignment, restricting the
* search to free memory after \p startSearch. Depth and back buffers should
* be in different 4MB banks to get better page hits if possible.
*
* \param heap memory heap.
* \param size size to allocate in bytes.
* \param align2 base 2 log of the block alignment in bytes.
* \param startSearch linear offset from start of the heap to begin the
* search.
*
* \return pointer to the allocated block on success, or NULL on failure.
*
* \internal
* Walks through the free blocks on the heap and if it finds one above
* \p startSearch and large enough slices it via SliceBlock() and returns the
* result.
*/
PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch)
{
int mask,startofs,endofs;
TMemBlock *p;
if (!heap || align2 < 0 || size <= 0)
return NULL;
mask = (1 << align2)-1;
startofs = 0;
p = (TMemBlock *)heap;
while (p) {
if ((p)->free) {
startofs = (p->ofs + mask) & ~mask;
if ( startofs < startSearch ) {
startofs = startSearch;
}
endofs = startofs+size;
if (endofs <= (p->ofs+p->size))
break;
}
p = p->next;
}
if (!p)
return NULL;
p = SliceBlock(p,startofs,size,0,mask+1);
p->heap = heap;
return p;
}
/**
* \brief Join two successive free memory blocks.
*
* \param p pointer to first memory block.
*
* \return 1 on success, or 0 on failure.
*
* \internal
* Adds the size of the second block to the first and frees its data structure.
*/
static __inline__ int Join2Blocks(TMemBlock *p)
{
if (p->free && p->next && p->next->free) {
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
free(q);
return 1;
}
return 0;
}
/**
* \brief Free a memory block.
*
* \param pointer to a block.
*
* \return 0 on success, or -1 on failure.
*
* \internal
* Search the given block on the heap, mark it as free and attempt to join it
* with the next one via Join2Blocks().
*/
int mmFreeMem(PMemBlock b)
{
TMemBlock *p,*prev;
if (!b)
return 0;
if (!b->heap) {
fprintf(stderr, "no heap\n");
return -1;
}
p = b->heap;
prev = NULL;
while (p && p != b) {
prev = p;
p = p->next;
}
if (!p || p->free || p->reserved) {
if (!p)
fprintf(stderr, "block not found in heap\n");
else if (p->free)
fprintf(stderr, "block already free\n");
else
fprintf(stderr, "block is reserved\n");
return -1;
}
p->free = 1;
Join2Blocks(p);
if (prev)
Join2Blocks(prev);
return 0;
}
/**
* \brief Destroy the memory heap.
*
* \param heap memory heap.
*
* \internal
* Frees each block in the heap.
*/
void mmDestroy(memHeap_t *heap)
{
TMemBlock *p,*q;
if (!heap)
return;
p = (TMemBlock *)heap;
while (p) {
q = p->next;
free(p);
p = q;
}
}

View File

@@ -0,0 +1,85 @@
/**
* \file mm.h
* \brief Memory block management.
*/
/*
* Copyright (C) 1999 Keith Whitwell
*
* 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
* KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
*
*/
#ifndef MM_INC
#define MM_INC
/**
* \brief Memory block/heap.
*/
struct mem_block_t {
struct mem_block_t *next; /**< \brief pointer to next block in the heap */
struct mem_block_t *heap; /**< \brief pointer to the heap (first block) */
int ofs; /**< \brief offset */
int size; /**< \brief size */
int align; /**< \brief alignment */
int free:1; /**< \brief free flag */
int reserved:1; /**< \brief reserved flag */
};
/**
* \brief Memory block.
*/
typedef struct mem_block_t TMemBlock;
/**
* \brief Memory block pointer.
*/
typedef struct mem_block_t *PMemBlock;
/**
* \brief Memory heap.
*
* \note A heap is just the first block in a chain
*/
typedef struct mem_block_t memHeap_t;
/**
* \brief Get Memory block size.
*/
static __inline__ int mmBlockSize(PMemBlock b)
{ return b->size; }
/**
* \brief Get Memory block offset.
*/
static __inline__ int mmOffset(PMemBlock b)
{ return b->ofs; }
memHeap_t *mmInit( int ofs, int size );
PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2,
int startSearch );
int mmFreeMem( PMemBlock b );
void mmDestroy( memHeap_t *heap );
void mmDumpMemInfo( memHeap_t *heap );
#endif

View File

@@ -0,0 +1,259 @@
#ifndef DBG
#define DBG 0
#endif
#ifndef HW_WRITE_LOCK
#define HW_WRITE_LOCK() HW_LOCK()
#endif
#ifndef HW_WRITE_UNLOCK
#define HW_WRITE_UNLOCK() HW_UNLOCK()
#endif
#ifndef HW_READ_LOCK
#define HW_READ_LOCK() HW_LOCK()
#endif
#ifndef HW_READ_UNLOCK
#define HW_READ_UNLOCK() HW_UNLOCK()
#endif
#ifndef HW_READ_CLIPLOOP
#define HW_READ_CLIPLOOP() HW_CLIPLOOP()
#endif
#ifndef HW_WRITE_CLIPLOOP
#define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
#endif
static void TAG(WriteRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][4],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_VARS;
y = Y_FLIP(y);
HW_WRITE_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n",
(int)i, (int)n1, (int)x1);
if (mask)
{
for (;n1>0;i++,x1++,n1--)
if (mask[i])
WRITE_RGBA( x1, y,
rgba[i][0], rgba[i][1],
rgba[i][2], rgba[i][3] );
}
else
{
for (;n1>0;i++,x1++,n1--)
WRITE_RGBA( x1, y,
rgba[i][0], rgba[i][1],
rgba[i][2], rgba[i][3] );
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteRGBSpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLubyte rgb[][3],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_VARS;
y = Y_FLIP(y);
HW_WRITE_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
if (DBG) fprintf(stderr, "WriteRGBSpan %d..%d (x1 %d)\n",
(int)i, (int)n1, (int)x1);
if (mask)
{
for (;n1>0;i++,x1++,n1--)
if (mask[i])
WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
}
else
{
for (;n1>0;i++,x1++,n1--)
WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
GLuint n,
const GLint x[],
const GLint y[],
const GLubyte rgba[][4],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_VARS;
if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
HW_WRITE_CLIPLOOP()
{
for (i=0;i<n;i++)
{
if (mask[i]) {
const int fy = Y_FLIP(y[i]);
if (CLIPPIXEL(x[i],fy))
WRITE_RGBA( x[i], fy,
rgba[i][0], rgba[i][1],
rgba[i][2], rgba[i][3] );
}
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLchan color[4],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_VARS;
INIT_MONO_PIXEL(p, color);
y = Y_FLIP( y );
if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
HW_WRITE_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
for (;n1>0;i++,x1++,n1--)
if (mask[i])
WRITE_PIXEL( x1, y, p );
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
GLuint n,
const GLint x[], const GLint y[],
const GLchan color[],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_VARS;
INIT_MONO_PIXEL(p, color);
if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
HW_WRITE_CLIPLOOP()
{
for (i=0;i<n;i++)
if (mask[i]) {
int fy = Y_FLIP(y[i]);
if (CLIPPIXEL( x[i], fy ))
WRITE_PIXEL( x[i], fy, p );
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(ReadRGBASpan)( const GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLubyte rgba[][4])
{
HW_READ_LOCK()
{
GLint x1,n1;
LOCAL_VARS;
y = Y_FLIP(y);
if (DBG) fprintf(stderr, "ReadRGBASpan\n");
HW_READ_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
for (;n1>0;i++,x1++,n1--)
READ_RGBA( rgba[i], x1, y );
}
HW_ENDCLIPLOOP();
}
HW_READ_UNLOCK();
}
static void TAG(ReadRGBAPixels)( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[] )
{
HW_READ_LOCK()
{
GLint i;
LOCAL_VARS;
if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
HW_READ_CLIPLOOP()
{
for (i=0;i<n;i++)
if (mask[i]) {
int fy = Y_FLIP( y[i] );
if (CLIPPIXEL( x[i], fy ))
READ_RGBA( rgba[i], x[i], fy );
}
}
HW_ENDCLIPLOOP();
}
HW_READ_UNLOCK();
}
#undef WRITE_PIXEL
#undef WRITE_RGBA
#undef READ_RGBA
#undef TAG

View File

@@ -0,0 +1,147 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.3 2001/03/21 16:14:20 dawes Exp $ */
#ifndef DBG
#define DBG 0
#endif
#ifndef HW_WRITE_LOCK
#define HW_WRITE_LOCK() HW_LOCK()
#endif
#ifndef HW_WRITE_UNLOCK
#define HW_WRITE_UNLOCK() HW_UNLOCK()
#endif
#ifndef HW_READ_LOCK
#define HW_READ_LOCK() HW_LOCK()
#endif
#ifndef HW_READ_UNLOCK
#define HW_READ_UNLOCK() HW_UNLOCK()
#endif
static void TAG(WriteStencilSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLstencil *stencil,
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint x1;
GLint n1;
LOCAL_STENCIL_VARS;
y = Y_FLIP(y);
HW_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
(int)i, (int)n1, (int)x1);
if (mask)
{
for (;i<n1;i++,x1++)
if (mask[i])
WRITE_STENCIL( x1, y, stencil[i] );
}
else
{
for (;i<n1;i++,x1++)
WRITE_STENCIL( x1, y, stencil[i] );
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
static void TAG(WriteStencilPixels)( GLcontext *ctx,
GLuint n,
const GLint x[],
const GLint y[],
const GLstencil stencil[],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_STENCIL_VARS;
if (DBG) fprintf(stderr, "WriteStencilPixels\n");
HW_CLIPLOOP()
{
for (i=0;i<n;i++)
{
if (mask[i]) {
const int fy = Y_FLIP(y[i]);
if (CLIPPIXEL(x[i],fy))
WRITE_STENCIL( x[i], fy, stencil[i] );
}
}
}
HW_ENDCLIPLOOP();
}
HW_WRITE_UNLOCK();
}
/* Read stencil spans and pixels
*/
static void TAG(ReadStencilSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
GLstencil stencil[])
{
HW_READ_LOCK()
{
GLint x1,n1;
LOCAL_STENCIL_VARS;
y = Y_FLIP(y);
if (DBG) fprintf(stderr, "ReadStencilSpan\n");
HW_CLIPLOOP()
{
GLint i = 0;
CLIPSPAN(x,y,n,x1,n1,i);
for (;i<n1;i++)
READ_STENCIL( stencil[i], (x1+i), y );
}
HW_ENDCLIPLOOP();
}
HW_READ_UNLOCK();
}
static void TAG(ReadStencilPixels)( GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
GLstencil stencil[] )
{
HW_READ_LOCK()
{
GLint i;
LOCAL_STENCIL_VARS;
if (DBG) fprintf(stderr, "ReadStencilPixels\n");
HW_CLIPLOOP()
{
for (i=0;i<n;i++) {
int fy = Y_FLIP( y[i] );
if (CLIPPIXEL( x[i], fy ))
READ_STENCIL( stencil[i], x[i], fy );
}
}
HW_ENDCLIPLOOP();
}
HW_READ_UNLOCK();
}
#undef WRITE_STENCIL
#undef READ_STENCIL
#undef TAG

View File

@@ -0,0 +1 @@
*.d

View File

@@ -0,0 +1,135 @@
# $Id: Makefile,v 1.1.2.26 2003/03/04 17:29:56 keithw Exp $
# Mesa 3-D graphics library
# Version: 5.0
# Copyright (C) 1995-2002 Brian Paul
MESA = ../../..
default: radeon_dri.so
include $(MESA)/Makefile.include
SHARED_INCLUDES= -I$(MESABUILDDIR) -I$(MESA)/include -I. -I../common -Iserver
MINIGLX_INCLUDES = -I$(MESABUILDDIR)/miniglx
DRI_INCLUDES = -I$(MESABUILDDIR)/dri
ifeq ($(FULL_DRIVER),true)
DEFINES = \
-D_HAVE_SWRAST=1 \
-D_HAVE_SWTNL=1 \
-D_HAVE_SANITY=1 \
-D_HAVE_CODEGEN=1 \
-D_HAVE_LIGHTING=1 \
-D_HAVE_TEXGEN=1 \
-D_HAVE_USERCLIP=1 \
-D_HAVE_FULL_GL=1
else
DEFINES = \
-D_HAVE_SWRAST=0 \
-D_HAVE_SWTNL=0 \
-D_HAVE_SANITY=0 \
-D_HAVE_CODEGEN=0 \
-D_HAVE_LIGHTING=0 \
-D_HAVE_TEXGEN=0 \
-D_HAVE_USERCLIP=0 \
-D_HAVE_FULL_GL=0
endif
# The .a files for each mesa module required by this driver:
#
FULL_MESA = $(MESABUILDDIR)/swrast_setup/swrast_setup.a \
$(MESABUILDDIR)/tnl/tnl.a \
$(MESABUILDDIR)/math/math.a \
$(MESABUILDDIR)/array_cache/array_cache.a \
$(MESABUILDDIR)/swrast/swrast.a \
$(MESABUILDDIR)/mesa.a \
$(MESABUILDDIR)/math/math.a #kludge
SUBSET_MESA = $(MESABUILDDIR)/mesa.a \
$(MESABUILDDIR)/math/math.a
MINIGLX_SOURCES = server/radeon_dri.c
DRIVER_SOURCES = radeon_context.c \
radeon_ioctl.c \
radeon_lock.c \
radeon_screen.c \
radeon_state.c \
radeon_state_init.c \
../common/mm.c
SUBSET_DRIVER_SOURCES = \
radeon_subset_bitmap.c \
radeon_subset_readpix.c \
radeon_subset_select.c \
radeon_subset_tex.c \
radeon_subset_vtx.c
FULL_DRIVER_SOURCES = \
radeon_tex.c \
radeon_texmem.c \
radeon_texstate.c \
radeon_texcombine.c \
radeon_lighting.c \
radeon_userclip.c \
radeon_texgen.c \
radeon_tcl.c \
radeon_swtcl.c \
radeon_span.c \
radeon_maos.c \
radeon_sanity.c \
radeon_compat.c \
radeon_vtxfmt.c \
radeon_vtxfmt_c.c \
radeon_vtxfmt_sse.c \
radeon_vtxfmt_x86.c
INCLUDES = $(MINIGLX_INCLUDES) \
$(SHARED_INCLUDES)
ifeq ($(FULL_DRIVER),true)
C_SOURCES = $(DRIVER_SOURCES) \
$(FULL_DRIVER_SOURCES) \
$(MINIGLX_SOURCES)
MESA_MODULES = $(FULL_MESA)
else
C_SOURCES = $(DRIVER_SOURCES) \
$(SUBSET_DRIVER_SOURCES) \
$(MINIGLX_SOURCES)
MESA_MODULES = $(FULL_MESA)
endif
ifeq ($(WINDOW_SYSTEM),dri)
WINOBJ=$(MESABUILDDIR)/dri/dri.a
WINLIB=
else
WINOBJ=
WINLIB=-L$(MESA)/src/miniglx
endif
ASM_SOURCES =
OBJECTS = $(C_SOURCES:.c=.o) \
$(ASM_SOURCES:.S=.o)
##### TARGETS #####
# Build the subset or full driver?
#
radeon_dri.so: $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile
rm -f $@ && gcc -o $@ -shared $(OBJECTS) $(MESA_MODULES) $(WINOBJ) $(WINLIB) -lGL -lc -lm
rm -f $(MESA)/lib/radeon_dri.so && \
install radeon_dri.so $(MESA)/lib/radeon_dri.so
##### DEPENDENCIES #####
-include $(C_SOURCES:.c=.d)

View File

@@ -0,0 +1,307 @@
/* $XFree86$ */
/**************************************************************************
Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
Tungsten Graphics Inc., Austin, Texas.
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
ATI, TUNGSTEN GRAPHICS 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.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
*
*/
#if _HAVE_SWTNL
#include "glheader.h"
#include "imports.h"
#include "radeon_context.h"
#include "radeon_state.h"
#include "radeon_ioctl.h"
static struct {
int start;
int len;
const char *name;
} packet[RADEON_MAX_STATE_PACKETS] = {
{ RADEON_PP_MISC,7,"RADEON_PP_MISC" },
{ RADEON_PP_CNTL,3,"RADEON_PP_CNTL" },
{ RADEON_RB3D_COLORPITCH,1,"RADEON_RB3D_COLORPITCH" },
{ RADEON_RE_LINE_PATTERN,2,"RADEON_RE_LINE_PATTERN" },
{ RADEON_SE_LINE_WIDTH,1,"RADEON_SE_LINE_WIDTH" },
{ RADEON_PP_LUM_MATRIX,1,"RADEON_PP_LUM_MATRIX" },
{ RADEON_PP_ROT_MATRIX_0,2,"RADEON_PP_ROT_MATRIX_0" },
{ RADEON_RB3D_STENCILREFMASK,3,"RADEON_RB3D_STENCILREFMASK" },
{ RADEON_SE_VPORT_XSCALE,6,"RADEON_SE_VPORT_XSCALE" },
{ RADEON_SE_CNTL,2,"RADEON_SE_CNTL" },
{ RADEON_SE_CNTL_STATUS,1,"RADEON_SE_CNTL_STATUS" },
{ RADEON_RE_MISC,1,"RADEON_RE_MISC" },
{ RADEON_PP_TXFILTER_0,6,"RADEON_PP_TXFILTER_0" },
{ RADEON_PP_BORDER_COLOR_0,1,"RADEON_PP_BORDER_COLOR_0" },
{ RADEON_PP_TXFILTER_1,6,"RADEON_PP_TXFILTER_1" },
{ RADEON_PP_BORDER_COLOR_1,1,"RADEON_PP_BORDER_COLOR_1" },
{ RADEON_PP_TXFILTER_2,6,"RADEON_PP_TXFILTER_2" },
{ RADEON_PP_BORDER_COLOR_2,1,"RADEON_PP_BORDER_COLOR_2" },
{ RADEON_SE_ZBIAS_FACTOR,2,"RADEON_SE_ZBIAS_FACTOR" },
{ RADEON_SE_TCL_OUTPUT_VTX_FMT,11,"RADEON_SE_TCL_OUTPUT_VTX_FMT" },
{ RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED,17,"RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED" },
};
static void radeonCompatEmitPacket( radeonContextPtr rmesa,
struct radeon_state_atom *state )
{
RADEONSAREAPrivPtr sarea = rmesa->sarea;
radeon_context_regs_t *ctx = &sarea->ContextState;
radeon_texture_regs_t *tex0 = &sarea->TexState[0];
radeon_texture_regs_t *tex1 = &sarea->TexState[1];
int i;
int *buf = state->cmd;
for ( i = 0 ; i < state->cmd_size ; ) {
drmRadeonCmdHeader *header = (drmRadeonCmdHeader *)&buf[i++];
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s %d: %s\n", __FUNCTION__, header->packet.packet_id,
packet[(int)header->packet.packet_id].name);
switch (header->packet.packet_id) {
case RADEON_EMIT_PP_MISC:
ctx->pp_misc = buf[i++];
ctx->pp_fog_color = buf[i++];
ctx->re_solid_color = buf[i++];
ctx->rb3d_blendcntl = buf[i++];
ctx->rb3d_depthoffset = buf[i++];
ctx->rb3d_depthpitch = buf[i++];
ctx->rb3d_zstencilcntl = buf[i++];
sarea->dirty |= RADEON_UPLOAD_CONTEXT;
break;
case RADEON_EMIT_PP_CNTL:
ctx->pp_cntl = buf[i++];
ctx->rb3d_cntl = buf[i++];
ctx->rb3d_coloroffset = buf[i++];
sarea->dirty |= RADEON_UPLOAD_CONTEXT;
break;
case RADEON_EMIT_RB3D_COLORPITCH:
ctx->rb3d_colorpitch = buf[i++];
sarea->dirty |= RADEON_UPLOAD_CONTEXT;
break;
case RADEON_EMIT_RE_LINE_PATTERN:
ctx->re_line_pattern = buf[i++];
ctx->re_line_state = buf[i++];
sarea->dirty |= RADEON_UPLOAD_LINE;
break;
case RADEON_EMIT_SE_LINE_WIDTH:
ctx->se_line_width = buf[i++];
sarea->dirty |= RADEON_UPLOAD_LINE;
break;
case RADEON_EMIT_PP_LUM_MATRIX:
ctx->pp_lum_matrix = buf[i++];
sarea->dirty |= RADEON_UPLOAD_BUMPMAP;
break;
case RADEON_EMIT_PP_ROT_MATRIX_0:
ctx->pp_rot_matrix_0 = buf[i++];
ctx->pp_rot_matrix_1 = buf[i++];
sarea->dirty |= RADEON_UPLOAD_BUMPMAP;
break;
case RADEON_EMIT_RB3D_STENCILREFMASK:
ctx->rb3d_stencilrefmask = buf[i++];
ctx->rb3d_ropcntl = buf[i++];
ctx->rb3d_planemask = buf[i++];
sarea->dirty |= RADEON_UPLOAD_MASKS;
break;
case RADEON_EMIT_SE_VPORT_XSCALE:
ctx->se_vport_xscale = buf[i++];
ctx->se_vport_xoffset = buf[i++];
ctx->se_vport_yscale = buf[i++];
ctx->se_vport_yoffset = buf[i++];
ctx->se_vport_zscale = buf[i++];
ctx->se_vport_zoffset = buf[i++];
sarea->dirty |= RADEON_UPLOAD_VIEWPORT;
break;
case RADEON_EMIT_SE_CNTL:
ctx->se_cntl = buf[i++];
ctx->se_coord_fmt = buf[i++];
sarea->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_VERTFMT;
break;
case RADEON_EMIT_SE_CNTL_STATUS:
ctx->se_cntl_status = buf[i++];
sarea->dirty |= RADEON_UPLOAD_SETUP;
break;
case RADEON_EMIT_RE_MISC:
ctx->re_misc = buf[i++];
sarea->dirty |= RADEON_UPLOAD_MISC;
break;
case RADEON_EMIT_PP_TXFILTER_0:
tex0->pp_txfilter = buf[i++];
tex0->pp_txformat = buf[i++];
tex0->pp_txoffset = buf[i++];
tex0->pp_txcblend = buf[i++];
tex0->pp_txablend = buf[i++];
tex0->pp_tfactor = buf[i++];
sarea->dirty |= RADEON_UPLOAD_TEX0;
break;
case RADEON_EMIT_PP_BORDER_COLOR_0:
tex0->pp_border_color = buf[i++];
sarea->dirty |= RADEON_UPLOAD_TEX0;
break;
case RADEON_EMIT_PP_TXFILTER_1:
tex1->pp_txfilter = buf[i++];
tex1->pp_txformat = buf[i++];
tex1->pp_txoffset = buf[i++];
tex1->pp_txcblend = buf[i++];
tex1->pp_txablend = buf[i++];
tex1->pp_tfactor = buf[i++];
sarea->dirty |= RADEON_UPLOAD_TEX1;
break;
case RADEON_EMIT_PP_BORDER_COLOR_1:
tex1->pp_border_color = buf[i++];
sarea->dirty |= RADEON_UPLOAD_TEX1;
break;
case RADEON_EMIT_SE_ZBIAS_FACTOR:
i++;
i++;
break;
case RADEON_EMIT_PP_TXFILTER_2:
case RADEON_EMIT_PP_BORDER_COLOR_2:
case RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT:
case RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED:
default:
/* These states aren't understood by radeon drm 1.1 */
fprintf(stderr, "Tried to emit unsupported state\n");
return;
}
}
}
static void radeonCompatEmitStateLocked( radeonContextPtr rmesa )
{
struct radeon_state_atom *state, *tmp;
if (RADEON_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
fprintf(stderr, "%s\n", __FUNCTION__);
if (rmesa->lost_context) {
if (RADEON_DEBUG & (DEBUG_STATE|DEBUG_PRIMS|DEBUG_IOCTL))
fprintf(stderr, "%s - lost context\n", __FUNCTION__);
foreach_s( state, tmp, &(rmesa->hw.clean) )
move_to_tail(&(rmesa->hw.dirty), state );
rmesa->lost_context = 0;
}
foreach_s( state, tmp, &(rmesa->hw.dirty) ) {
if (!state->is_tcl)
radeonCompatEmitPacket( rmesa, state );
move_to_head( &(rmesa->hw.clean), state );
}
}
static void radeonCompatEmitPrimitiveLocked( radeonContextPtr rmesa,
GLuint hw_primitive,
GLuint nverts,
XF86DRIClipRectPtr pbox,
GLuint nbox )
{
int i;
for ( i = 0 ; i < nbox ; ) {
int nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, nbox );
XF86DRIClipRectPtr b = rmesa->sarea->boxes;
drmRadeonVertex vtx;
rmesa->sarea->dirty |= RADEON_UPLOAD_CLIPRECTS;
rmesa->sarea->nbox = nr - i;
for ( ; i < nr ; i++)
*b++ = pbox[i];
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr,
"RadeonFlushVertexBuffer: prim %x buf %d verts %d "
"disc %d nbox %d\n",
hw_primitive,
rmesa->dma.current.buf->buf->idx,
nverts,
nr == nbox,
rmesa->sarea->nbox );
vtx.prim = hw_primitive;
vtx.idx = rmesa->dma.current.buf->buf->idx;
vtx.count = nverts;
vtx.discard = (nr == nbox);
drmCommandWrite( rmesa->dri.fd,
DRM_RADEON_VERTEX,
&vtx, sizeof(vtx));
}
}
/* No 'start' for 1.1 vertices ioctl: only one vertex prim/buffer!
*/
void radeonCompatEmitPrimitive( radeonContextPtr rmesa,
GLuint vertex_format,
GLuint hw_primitive,
GLuint nrverts )
{
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s\n", __FUNCTION__);
LOCK_HARDWARE( rmesa );
radeonCompatEmitStateLocked( rmesa );
rmesa->sarea->vc_format = vertex_format;
if (rmesa->state.scissor.enabled) {
radeonCompatEmitPrimitiveLocked( rmesa,
hw_primitive,
nrverts,
rmesa->state.scissor.pClipRects,
rmesa->state.scissor.numClipRects );
}
else {
radeonCompatEmitPrimitiveLocked( rmesa,
hw_primitive,
nrverts,
rmesa->pClipRects,
rmesa->numClipRects );
}
UNLOCK_HARDWARE( rmesa );
}
#endif

View File

@@ -0,0 +1,805 @@
/**
* \file radeon_context.c
* \brief Device specific context initialization.
*
* \author Kevin E. Martin <martin@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
/*
* Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
* VA Linux Systems Inc., Fremont, California.
*
* 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
* ATI, VA LINUX SYSTEMS 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.
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.c,v 1.4 2002/09/10 00:39:39 dawes Exp $ */
#include "glheader.h"
#include "imports.h"
#include "api_arrayelt.h"
#include "context.h"
#include "simple_list.h"
#include "matrix.h"
#include "extensions.h"
#include "radeon_context.h"
#include "radeon_ioctl.h"
#include "radeon_state.h"
#if _HAVE_FULL_GL
#include "radeon_tcl.h"
#include "radeon_vtxfmt.h"
#include "radeon_tex.h"
#include "radeon_span.h"
#include "radeon_maos.h"
#else
#include "radeon_subset.h"
#endif
#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#endif
#define RADEON_DATE "20021125"
#ifndef RADEON_DEBUG
int RADEON_DEBUG = (0);
#endif
/**
* \brief Return the width and height of the given buffer.
*
* \param buffer frame buffer. Not used.
* \param width will hold the width of the buffer.
* \param height will hold the height of the buffer.
*
* Returns the width and height of the current drawable while holding the
* hardware lock.
*/
static void radeonGetBufferSize( GLframebuffer *buffer,
GLuint *width, GLuint *height )
{
GET_CURRENT_CONTEXT(ctx);
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
LOCK_HARDWARE( rmesa );
*width = rmesa->dri.drawable->w;
*height = rmesa->dri.drawable->h;
UNLOCK_HARDWARE( rmesa );
}
/**
* \brief Return various strings for glGetString().
*
* \param ctx GL context.
* \param name name of the string to return.
*
* \param pointer to a static string describing the aspect specified by \p
* name.
*
* \sa glGetString().
*
* Returns the wanted string, appending miscellaneous information (such as AGP
* mode, processor abilities, TCL support, etc.) for the GL_RENDERER aspect.
*/
static const GLubyte *radeonGetString( GLcontext *ctx, GLenum name )
{
static char buffer[128];
switch ( name ) {
case GL_VENDOR:
return (GLubyte *)"Tungsten Graphics, Inc.";
case GL_RENDERER:
sprintf( buffer, "Mesa DRI Radeon SUBSET " RADEON_DATE);
return (GLubyte *)buffer;
default:
return NULL;
}
}
/**
* \brief Device specific extension names exported by the R100 driver.
*
* \note None in the case of the subset driver.
*/
static const char * const radeon_extensions[] =
{
#if _HAVE_FULL_GL
"GL_ARB_multisample",
"GL_ARB_multitexture",
"GL_ARB_texture_border_clamp",
"GL_ARB_texture_compression",
"GL_ARB_texture_env_add",
"GL_ARB_texture_env_combine",
"GL_ARB_texture_env_dot3",
"GL_ARB_texture_mirrored_repeat",
"GL_EXT_blend_logic_op",
"GL_EXT_blend_subtract",
/* "GL_EXT_fog_coord", */
"GL_EXT_secondary_color",
"GL_EXT_texture_env_add",
"GL_EXT_texture_env_combine",
"GL_EXT_texture_env_dot3",
"GL_EXT_texture_filter_anisotropic",
"GL_EXT_texture_lod_bias",
"GL_ATI_texture_mirror_once",
"GL_IBM_texture_mirrored_repeat",
"GL_NV_blend_square",
"GL_SGIS_generate_mipmap",
"GL_SGIS_texture_border_clamp",
#endif
NULL
};
/**
* \brief Initialize the extensions supported by this driver.
*
* \param ctx GL context.
*
* Enables the imaging extensions plus every extension specified in in the
* ::radeon_extensions table.
*/
static void radeonInitExtensions( GLcontext *ctx )
{
unsigned i;
_mesa_enable_imaging_extensions( ctx );
for ( i = 0 ; radeon_extensions[i] != NULL ; i++ ) {
_mesa_enable_extension( ctx, radeon_extensions[i] );
}
}
/**
* \brief Resize the buffers.
*
* \param buffer frame buffer to be resized.
*
* Informs the software rasterizer (if enabled at compile time) of the buffer
* resizing.
*/
static void ResizeBuffers( GLframebuffer *buffer )
{
#if _HAVE_SWRAST
_swrast_alloc_buffers( buffer );
#endif
}
/**
* \brief Initialize the driver miscellaneous function callbacks.
*
* \param ctx GL context.
*/
static void radeonInitDriverFuncs( GLcontext *ctx )
{
ctx->Driver.GetBufferSize = radeonGetBufferSize;
ctx->Driver.GetString = radeonGetString;
ctx->Driver.ResizeBuffers = ResizeBuffers;
ctx->Driver.Error = NULL;
ctx->Driver.DrawPixels = NULL;
#if !_HAVE_SWRAST
ctx->Driver.Bitmap = radeonPointsBitmap;
ctx->Driver.ReadPixels = radeonReadPixels;
#endif
}
/**
* \brief Create the device specific context.
*
* \param glVisual visual information.
* \param driContextPriv DRI specific context data.
* \param sharedContextPrivate shared context.
*
* \return GL_TRUE if successful, or GL_FALSE otherwise.
*
* Allocates a Radeon context and initializes it, adding a Mesa context. Fills
* in with information from the Radeon specific screen data in
* __DRIscreenPrivateRec::private, such as the SAREA pointer, DMA buffers
* addresses and texture heaps.
*
* Calls the \c radeonInit* functions to populate the driver callback
* functions. Among these are radeonInitState(), radeonInitExtensions(),
* radeonInitDriverFuncs(), radeonInitIoctlFuncs(), radeonInitStateFuncs(),
* radeonInitTextureFuncs() and radeonInitSelect().
*
* If compiled with debug support, reads the RADEON_DEBUG environment variable
* and sets the debugging flags accordingly.
*/
static GLboolean
radeonCreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
{
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
radeonScreenPtr radeonScreen = (radeonScreenPtr)(sPriv->private);
radeonContextPtr rmesa;
GLcontext *ctx, *shareCtx;
int i, nr;
assert(glVisual);
assert(driContextPriv);
assert(radeonScreen);
/* Allocate the Radeon context */
rmesa = (radeonContextPtr) CALLOC( sizeof(*rmesa) );
if ( !rmesa )
return GL_FALSE;
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((radeonContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa,
GL_TRUE);
if (!rmesa->glCtx) {
FREE(rmesa);
return GL_FALSE;
}
driContextPriv->driverPrivate = rmesa;
/* Init radeon context data */
rmesa->dri.context = driContextPriv;
rmesa->dri.screen = sPriv;
rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
rmesa->dri.hwContext = driContextPriv->hHWContext;
rmesa->dri.hwLock = &sPriv->pSAREA->lock;
rmesa->dri.fd = sPriv->fd;
/* If we don't have 1.3, fallback to the 1.1 interfaces.
*/
if (getenv("RADEON_COMPAT") || sPriv->drmMinor < 3 )
rmesa->dri.drmMinor = 1;
else
rmesa->dri.drmMinor = sPriv->drmMinor;
rmesa->radeonScreen = radeonScreen;
rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
radeonScreen->sarea_priv_offset);
rmesa->dma.buf0_address = rmesa->radeonScreen->buffers->list[0].address;
for ( i = 0 ; i < radeonScreen->numTexHeaps ; i++ ) {
make_empty_list( &rmesa->texture.objects[i] );
rmesa->texture.heap[i] = mmInit( 0, radeonScreen->texSize[i] );
rmesa->texture.age[i] = -1;
}
rmesa->texture.numHeaps = radeonScreen->numTexHeaps;
make_empty_list( &rmesa->texture.swapped );
rmesa->lost_context = 1;
rmesa->tcl.tcl_flag = RADEON_CP_VC_CNTL_TCL_ENABLE;
/* KW: Set the maximum texture size small enough that we can
* guarentee that both texture units can bind a maximal texture
* and have them both in on-card memory at once.
* Test for 2 textures * 4 bytes/texel * size * size.
*/
ctx = rmesa->glCtx;
#if _HAVE_FULL_GL
nr = 2;
#else
nr = 1;
#endif
ctx->Const.MaxTextureUnits = nr;
if (radeonScreen->texSize[RADEON_CARD_HEAP] >= nr * 4 * 2048 * 2048) {
ctx->Const.MaxTextureLevels = 12; /* 2048x2048 */
}
else if (radeonScreen->texSize[RADEON_CARD_HEAP] >= nr * 4 * 1024 * 1024) {
ctx->Const.MaxTextureLevels = 11; /* 1024x1024 */
}
else if (radeonScreen->texSize[RADEON_CARD_HEAP] >= nr * 4 * 512 * 512) {
ctx->Const.MaxTextureLevels = 10; /* 512x512 */
}
else {
ctx->Const.MaxTextureLevels = 9; /* 256x256 */
}
ctx->Const.MaxTextureMaxAnisotropy = 16.0;
/* No wide points.
*/
ctx->Const.MinPointSize = 1.0;
ctx->Const.MinPointSizeAA = 1.0;
ctx->Const.MaxPointSize = 1.0;
ctx->Const.MaxPointSizeAA = 1.0;
ctx->Const.MinLineWidth = 1.0;
ctx->Const.MinLineWidthAA = 1.0;
ctx->Const.MaxLineWidth = 10.0;
ctx->Const.MaxLineWidthAA = 10.0;
ctx->Const.LineWidthGranularity = 0.0625;
#if _HAVE_SWRAST
radeonCreateSwrastContext( ctx );
#endif
#if _HAVE_SWTNL
radeonCreateTnlContext( ctx );
#endif
radeonInitState( rmesa );
#if _HAVE_TEXGEN
radeonInitTexTransform( ctx );
#endif
#if _HAVE_LIGHTING
radeonInitLightStateFuncs( ctx );
#endif
radeonInitExtensions( ctx );
radeonInitDriverFuncs( ctx );
radeonInitIoctlFuncs( ctx );
radeonInitStateFuncs( ctx );
#if _HAVE_SWRAST
radeonInitSpanFuncs( ctx );
#endif
radeonInitTextureFuncs( ctx );
#if _HAVE_SWTNL
radeonInitSwtcl( ctx );
#endif
#if !_HAVE_FULL_GL
radeonInitSelect( ctx );
#endif
rmesa->do_irqs = (rmesa->radeonScreen->irq && !getenv("RADEON_NO_IRQS"));
rmesa->irqsEmitted = 0;
rmesa->iw.irq_seq = -1;
rmesa->do_usleeps = !getenv("RADEON_NO_USLEEPS");
#if DO_DEBUG
if (getenv("RADEON_DEBUG"))
{
const char *debug = getenv("RADEON_DEBUG");
if (strstr(debug, "fall"))
RADEON_DEBUG |= DEBUG_FALLBACKS;
if (strstr(debug, "tex"))
RADEON_DEBUG |= DEBUG_TEXTURE;
if (strstr(debug, "ioctl"))
RADEON_DEBUG |= DEBUG_IOCTL;
if (strstr(debug, "prim"))
RADEON_DEBUG |= DEBUG_PRIMS;
if (strstr(debug, "vert"))
RADEON_DEBUG |= DEBUG_VERTS;
if (strstr(debug, "state"))
RADEON_DEBUG |= DEBUG_STATE;
if (strstr(debug, "code"))
RADEON_DEBUG |= DEBUG_CODEGEN;
if (strstr(debug, "vfmt") || strstr(debug, "vtxf"))
RADEON_DEBUG |= DEBUG_VFMT;
if (strstr(debug, "verb"))
RADEON_DEBUG |= DEBUG_VERBOSE;
if (strstr(debug, "dri"))
RADEON_DEBUG |= DEBUG_DRI;
if (strstr(debug, "dma"))
RADEON_DEBUG |= DEBUG_DMA;
if (strstr(debug, "san"))
RADEON_DEBUG |= DEBUG_SANITY;
}
#endif
#if _HAVE_SWRAST && _HAVE_SWTNL
if (getenv("RADEON_NO_RAST")) {
fprintf(stderr, "disabling 3D acceleration\n");
FALLBACK(rmesa, RADEON_FALLBACK_DISABLE, 1);
}
else if (getenv("RADEON_TCL_FORCE_ENABLE")) {
fprintf(stderr, "Enabling TCL support... this will probably crash\n");
fprintf(stderr, " your card if it isn't capable of TCL!\n");
rmesa->radeonScreen->chipset |= RADEON_CHIPSET_TCL;
} else if (getenv("RADEON_TCL_FORCE_DISABLE") ||
rmesa->dri.drmMinor < 3 ||
!(rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL)) {
rmesa->radeonScreen->chipset &= ~RADEON_CHIPSET_TCL;
fprintf(stderr, "disabling TCL support\n");
TCL_FALLBACK(rmesa->glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
}
if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL) {
if (!getenv("RADEON_NO_VTXFMT"))
radeonVtxfmtInit( ctx );
_tnl_need_dlist_norm_lengths( ctx, GL_FALSE );
}
#else
radeonVtxfmtInit( ctx );
#endif
return GL_TRUE;
}
/**
* \brief Destroy the device specific context data.
*
* \param driContextPriv DRI specific context data.
*
* If destroying the currently bound context, fires the vertices and unbinds it
* first.
*
* Frees the radeon context resources, freeing the Mesa context. Frees the
* private texture object from the shared context data if its reference count
* reaches zero.
*/
static void
radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
{
GET_CURRENT_CONTEXT(ctx);
radeonContextPtr rmesa = (radeonContextPtr) driContextPriv->driverPrivate;
radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;
/* check if we're deleting the currently bound context */
if (rmesa == current) {
RADEON_FIREVERTICES( rmesa );
_mesa_make_current2(NULL, NULL, NULL);
}
/* Free radeon context resources */
assert(rmesa); /* should never be null */
if ( rmesa ) {
if (rmesa->glCtx->Shared->RefCount == 1) {
/* This share group is about to go away, free our private
* texture object data.
*/
radeonTexObjPtr t, next_t;
int i;
for ( i = 0 ; i < rmesa->texture.numHeaps ; i++ ) {
foreach_s ( t, next_t, &rmesa->texture.objects[i] ) {
radeonDestroyTexObj( rmesa, t );
}
mmDestroy( rmesa->texture.heap[i] );
rmesa->texture.heap[i] = NULL;
}
foreach_s ( t, next_t, &rmesa->texture.swapped ) {
radeonDestroyTexObj( rmesa, t );
}
}
#if _HAVE_SWRAST
_swsetup_DestroyContext( rmesa->glCtx );
_swrast_DestroyContext( rmesa->glCtx );
#endif
#if _HAVE_SWTNL
_tnl_DestroyContext( rmesa->glCtx );
_ac_DestroyContext( rmesa->glCtx );
radeonDestroySwtcl( rmesa->glCtx );
radeonReleaseArrays( rmesa->glCtx, ~0 );
#endif
if (rmesa->dma.current.buf) {
radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
radeonFlushCmdBuf( rmesa, __FUNCTION__ );
}
#if _HAVE_FULL_GL
if (!rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
if (!getenv("RADEON_NO_VTXFMT"))
radeonVtxfmtDestroy( rmesa->glCtx );
#endif
/* free the Mesa context */
rmesa->glCtx->DriverCtx = NULL;
_mesa_destroy_context( rmesa->glCtx );
if (rmesa->state.scissor.pClipRects) {
FREE(rmesa->state.scissor.pClipRects);
rmesa->state.scissor.pClipRects = 0;
}
FREE( rmesa );
}
}
/**
* \brief Create and initialize the Mesa and device specific pixmap buffer
* data.
*
* \param driScrnPriv DRI specific screen data.
* \param driDrawPriv DRI specific drawable data.
* \param mesaVis visual.
* \param isPixmap must be GL_FALSE. Not implemented.
*
* Calls _mesa_create_framebuffer() to create the framebuffer.
*/
static GLboolean
radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
GLboolean swDepth = GL_FALSE;
GLboolean swAlpha = GL_FALSE;
GLboolean swAccum = mesaVis->accumRedBits > 0;
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
mesaVis->depthBits != 24);
#if !_HAVE_SWRAST
/* Don't allow these if we don't have fallback support.
*/
swAccum = swStencil = GL_FALSE;
#endif
driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer( mesaVis,
swDepth,
swStencil,
swAccum,
swAlpha );
return (driDrawPriv->driverPrivate != NULL);
}
}
/**
* \brief Destroy device specific pixmap data.
*
* \param driDrawPriv DRI specific drawable data.
*
* Calls _mesa_destroy_framebuffer() to destroy Mesa framebuffer.
*/
static void
radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
{
_mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
}
/**
* \brief Swap buffers.
*
* \param dPriv DRI specific drawable data.
*
* If in double buffer mode then it dispatches the call to radeonCopyBuffer()
* or radeonPageFlip() if page flipping is also enabled.
*/
static void
radeonSwapBuffers( __DRIdrawablePrivate *dPriv )
{
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
radeonContextPtr rmesa;
GLcontext *ctx;
rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
ctx = rmesa->glCtx;
if (ctx->Visual.doubleBufferMode) {
_mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
if ( rmesa->doPageFlip ) {
radeonPageFlip( dPriv );
}
else {
radeonCopyBuffer( dPriv );
}
}
}
else {
/* XXX this shouldn't be an error but we can't handle it for now */
_mesa_problem(NULL, "radeonSwapBuffers: drawable has no context!\n");
}
}
/**
* \brief Set the current context.
*
* \param driContextPriv DRI specific context data to be activated.
* \param driDrawPriv DRI specific drawable data, to which the context is to be
* associated for writing.
* \param driReadPriv DRI specific drawable data, to which the context is to be
* associated for reading.
*
* \return GL_TRUE on success, or GL_FALSE on failure.
*
* If drawables differ form the current ones then update the window and
* viewport information. Calls _mesa_make_current2() to set the context.
*/
static GLboolean
radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv )
{
if ( driContextPriv ) {
radeonContextPtr newRadeonCtx =
(radeonContextPtr) driContextPriv->driverPrivate;
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, newRadeonCtx->glCtx);
if ( newRadeonCtx->dri.drawable != driDrawPriv ) {
newRadeonCtx->dri.drawable = driDrawPriv;
radeonUpdateWindow( newRadeonCtx->glCtx );
radeonUpdateViewportOffset( newRadeonCtx->glCtx );
}
_mesa_make_current2( newRadeonCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
if ( !newRadeonCtx->glCtx->Viewport.Width ) {
_mesa_set_viewport( newRadeonCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h );
}
#if _HAVE_FULL_GL
if (newRadeonCtx->vb.enabled)
radeonVtxfmtMakeCurrent( newRadeonCtx->glCtx );
#endif
} else {
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, NULL);
_mesa_make_current( 0, 0 );
}
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "End %s\n", __FUNCTION__);
return GL_TRUE;
}
/**
* \brief Unbind context from its buffer.
*
* \param driContextPriv DRI specifc context data.
*
* \returns always GL_TRUE.
*
* Calls radeonVtxfmtUnbindContext().
*/
static GLboolean
radeonUnbindContext( __DRIcontextPrivate *driContextPriv )
{
radeonContextPtr rmesa = (radeonContextPtr) driContextPriv->driverPrivate;
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, rmesa->glCtx);
radeonVtxfmtUnbindContext( rmesa->glCtx );
return GL_TRUE;
}
/**
* \brief Open/close fullscreen mode.
*
* \note Fullscreen mode isn't used for much - it could be a way to shrink
* front/back buffers and get more texture memory if the client has changed the
* video resolution.
*
* \par
* Pageflipping is now done automatically whenever there is a single 3D client.
*
* \param driContextPriv DRI specific context data. Not used.
*
* \return always GL_TRUE.
*
* This function is a no-op.
*/
static GLboolean
radeonOpenCloseFullScreen( __DRIcontextPrivate *driContextPriv )
{
return GL_TRUE;
}
void
__driRegisterExtensions( void )
{
/* See r200 driver for info */
}
/**
* \brief Initialize the driver specific screen private data.
*
* \param sPriv DRI specific screen data.
*
* \return GL_TRUE on success or GL_FALSE on faillure.
*
* Calls radeonCreateScreen() and if it fails calls radeonDestroyScreen()
* before returning.
*/
static GLboolean
radeonInitDriver( __DRIscreenPrivate *sPriv )
{
sPriv->private = (void *) radeonCreateScreen( sPriv );
if ( !sPriv->private ) {
radeonDestroyScreen( sPriv );
return GL_FALSE;
}
return GL_TRUE;
}
/**
* \brief Driver interface structure
*
* Holds the DRI driver callbacks.
*/
static struct __DriverAPIRec radeonAPI = {
radeonInitDriver,
radeonDestroyScreen,
radeonCreateContext,
radeonDestroyContext,
radeonCreateBuffer,
radeonDestroyBuffer,
radeonSwapBuffers,
radeonMakeCurrent,
radeonUnbindContext,
radeonOpenCloseFullScreen,
radeonOpenCloseFullScreen
};
/**
* \brief Bootstrap function for the driver.
*
* The \e __driCreateScreen name is the symbol that libGL.so fetches.
*
* \return pointer to a ::__DRIscreenPrivate structure.
*
* Calls __driUtilCreateScreen() with ::radeonAPI.
*/
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config)
{
__DRIscreenPrivate *psp;
psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &radeonAPI);
return (void *) psp;
}

View File

@@ -0,0 +1,782 @@
/**
* \file radeon_context.h
* \brief Radeon OpenGL context definition.
*
* \author Kevin E. Martin <martin@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
* \author Keith Whitwell <keith@tungstengraphics.com>
*/
/*
* Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
* VA Linux Systems Inc., Fremont, California.
*
* 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
* ATI, VA LINUX SYSTEMS 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.
*
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.h,v 1.4 2002/09/10 00:39:39 dawes Exp $ */
#ifndef __RADEON_CONTEXT_H__
#define __RADEON_CONTEXT_H__
struct radeon_context;
typedef struct radeon_context radeonContextRec;
typedef struct radeon_context *radeonContextPtr;
#include "mtypes.h"
#include "macros.h"
#include "radeon_lock.h"
#include "radeon_screen.h"
#include "mm.h"
/**
* \brief Reference counting on DMA buffers.
*/
struct radeon_dma_buffer {
int refcount; /**< \brief number of retained regions in radeon_dma_buffer::buf */
drmBufPtr buf; /**< \brief DMA buffer */
};
/**
* \brief Get the start of a DMA region.
*
* \param rvb pointer to a radeon_dma_region structure.
*
* \return pointer to the region start.
*/
#define GET_START(rvb) (rmesa->radeonScreen->agp_buffer_offset + \
(rvb)->address - rmesa->dma.buf0_address + \
(rvb)->start)
/**
* \brief A retained DMA region.
*
* e.g. vertices for indexed vertices.
*/
struct radeon_dma_region {
struct radeon_dma_buffer *buf; /**< \brief DMA buffer */
char *address; /**< \brief buf->address */
int start; /**< \brief start offset from start of radeon_dma_region::buf */
int end; /**< \brief end offset from start of radeon_dma_region::buf */
int ptr; /**< \brief offsets from start of radeon_dma_region::buf */
int aos_start; /**< \brief array of structures start */
int aos_stride; /**< \brief array of structures stride */
int aos_size; /**< \brief array of structures size */
};
#if _HAVE_SWTNL
#include "radeon_swtcl.h"
#endif
#if _HAVE_FULL_GL
#include "radeon_vtxfmt.h"
#endif
/**
* \brief Color buffer state.
*/
struct radeon_colorbuffer_state {
GLuint clear; /**< \brief Clear value */
GLint drawOffset; /**< \brief Drawing offset */
GLint drawPitch; /**< \brief Drawing pitch */
};
/**
* \brief Depth buffer state.
*/
struct radeon_depthbuffer_state {
GLuint clear; /**< \brief Clear value */
GLfloat scale; /**< \brief Depth scale */
};
/**
* \brief Pixel state.
*/
struct radeon_pixel_state {
GLint readOffset; /**< \brief Reading offset */
GLint readPitch; /**< \brief Reading pitch */
};
/**
* \brief Scissor state.
*/
struct radeon_scissor_state {
XF86DRIClipRectRec rect;
GLboolean enabled; /**< \brief Whether scissoring enable */
GLuint numClipRects; /**< \brief Number of active cliprects */
GLuint numAllocedClipRects; /**< \brief Number of available cliprects */
XF86DRIClipRectPtr pClipRects; /**< \brief Cliprects */
};
/**
* \brief Stencil buffer state.
*/
struct radeon_stencilbuffer_state {
GLboolean hwBuffer; /**< \brief Hardware buffer available? */
GLuint clear; /**< \brief rb3d_stencilrefmask value */
};
/**
* \brief Stipple state.
*/
struct radeon_stipple_state {
GLuint mask[32]; /**< \brief Mask */
};
#define TEX_0 0x1
#define TEX_1 0x2
#define TEX_ALL 0x3
typedef struct radeon_tex_obj radeonTexObj; /**< \brief Alias for radeon_tex_obj. */
typedef struct radeon_tex_obj *radeonTexObjPtr; /**< \brief Alias for radeon_tex_obj. */
/**
* \brief Texture object in locally shared texture space.
*/
struct radeon_tex_obj {
radeonTexObjPtr next, prev;
/** \brief Mesa texture object */
struct gl_texture_object *tObj;
/** \brief Memory block containing texture */
PMemBlock memBlock;
/** \brief Offset to start of locally shared texture block */
GLuint bufAddr;
/**
* \brief Flags for whether or not images need to be uploaded to local or AGP
* texture space
*/
GLuint dirty_images;
/**
* \brief Flags (one per texture unit) for whether or not this texture
* object has dirty hardware state (\c pp_*) that needs to be brought into
* the texunit.
*/
GLuint dirty_state;
/** \brief Texture heap currently stored in */
GLint heap;
/** \brief Texture images */
drmRadeonTexImage image[RADEON_MAX_TEXTURE_LEVELS];
/** \brief Total size of the texture including all mipmap levels */
GLint totalSize;
/**
* \name Hardware register values.
*/
/*@{*/
GLuint pp_txfilter;
GLuint pp_txformat;
GLuint pp_txoffset;
GLuint pp_border_color;
/*@}*/
/**
* \name Images to upload
*
* texObj->Image[firstLevel] through texObj->Image[lastLevel] are the
* images to upload.
*/
/*@{*/
GLint firstLevel;
GLint lastLevel;
/*@}*/
};
/**
* \brief Texture environment state.
*/
struct radeon_texture_env_state {
radeonTexObjPtr texobj; /**< \brief texture object */
GLenum format; /**< \brief format */
GLenum envMode; /**< \brief environment mode */
};
/**
* \brief Texture state
*/
struct radeon_texture_state {
struct radeon_texture_env_state unit[RADEON_MAX_TEXTURE_UNITS]; /**< \brief for each unit */
};
/**
* \brief Radeon state atom double-linked list.
*/
struct radeon_state_atom {
struct radeon_state_atom *next, *prev;
const char *name; /**< \brief for debugging purposes */
int cmd_size; /**< \brief size in bytes */
GLuint is_tcl; /**< \brief whether is associated with TCL */
int *cmd; /**< \brief one or more cmd's */
int *lastcmd; /**< \brief one or more cmd's */
GLboolean (*check)( GLcontext * ); /**< \brief callback to determin whether this state is active */
};
/* Trying to keep these relatively short as the variables are becoming
* extravagently long. Drop the RADEON_ off the front of everything -
* I think we know we're in the radeon driver by now, and keep the
* prefix to 3 letters unless absolutely impossible.
*/
#define CTX_CMD_0 0
#define CTX_PP_MISC 1
#define CTX_PP_FOG_COLOR 2
#define CTX_RE_SOLID_COLOR 3
#define CTX_RB3D_BLENDCNTL 4
#define CTX_RB3D_DEPTHOFFSET 5
#define CTX_RB3D_DEPTHPITCH 6
#define CTX_RB3D_ZSTENCILCNTL 7
#define CTX_CMD_1 8
#define CTX_PP_CNTL 9
#define CTX_RB3D_CNTL 10
#define CTX_RB3D_COLOROFFSET 11
#define CTX_CMD_2 12
#define CTX_RB3D_COLORPITCH 13
#define CTX_STATE_SIZE 14
#define SET_CMD_0 0
#define SET_SE_CNTL 1
#define SET_SE_COORDFMT 2
#define SET_CMD_1 3
#define SET_SE_CNTL_STATUS 4
#define SET_STATE_SIZE 5
#define LIN_CMD_0 0
#define LIN_RE_LINE_PATTERN 1
#define LIN_RE_LINE_STATE 2
#define LIN_CMD_1 3
#define LIN_SE_LINE_WIDTH 4
#define LIN_STATE_SIZE 5
#define MSK_CMD_0 0
#define MSK_RB3D_STENCILREFMASK 1
#define MSK_RB3D_ROPCNTL 2
#define MSK_RB3D_PLANEMASK 3
#define MSK_STATE_SIZE 4
#define VPT_CMD_0 0
#define VPT_SE_VPORT_XSCALE 1
#define VPT_SE_VPORT_XOFFSET 2
#define VPT_SE_VPORT_YSCALE 3
#define VPT_SE_VPORT_YOFFSET 4
#define VPT_SE_VPORT_ZSCALE 5
#define VPT_SE_VPORT_ZOFFSET 6
#define VPT_STATE_SIZE 7
#define MSC_CMD_0 0
#define MSC_RE_MISC 1
#define MSC_STATE_SIZE 2
#define TEX_CMD_0 0
#define TEX_PP_TXFILTER 1
#define TEX_PP_TXFORMAT 2
#define TEX_PP_TXOFFSET 3
#define TEX_PP_TXCBLEND 4
#define TEX_PP_TXABLEND 5
#define TEX_PP_TFACTOR 6
#define TEX_CMD_1 7
#define TEX_PP_BORDER_COLOR 8
#define TEX_STATE_SIZE 9
#define ZBS_CMD_0 0
#define ZBS_SE_ZBIAS_FACTOR 1
#define ZBS_SE_ZBIAS_CONSTANT 2
#define ZBS_STATE_SIZE 3
#define TCL_CMD_0 0
#define TCL_OUTPUT_VTXFMT 1
#define TCL_OUTPUT_VTXSEL 2
#define TCL_MATRIX_SELECT_0 3
#define TCL_MATRIX_SELECT_1 4
#define TCL_UCP_VERT_BLEND_CTL 5
#define TCL_TEXTURE_PROC_CTL 6
#define TCL_LIGHT_MODEL_CTL 7
#define TCL_PER_LIGHT_CTL_0 8
#define TCL_PER_LIGHT_CTL_1 9
#define TCL_PER_LIGHT_CTL_2 10
#define TCL_PER_LIGHT_CTL_3 11
#define TCL_STATE_SIZE 12
#define MTL_CMD_0 0
#define MTL_EMMISSIVE_RED 1
#define MTL_EMMISSIVE_GREEN 2
#define MTL_EMMISSIVE_BLUE 3
#define MTL_EMMISSIVE_ALPHA 4
#define MTL_AMBIENT_RED 5
#define MTL_AMBIENT_GREEN 6
#define MTL_AMBIENT_BLUE 7
#define MTL_AMBIENT_ALPHA 8
#define MTL_DIFFUSE_RED 9
#define MTL_DIFFUSE_GREEN 10
#define MTL_DIFFUSE_BLUE 11
#define MTL_DIFFUSE_ALPHA 12
#define MTL_SPECULAR_RED 13
#define MTL_SPECULAR_GREEN 14
#define MTL_SPECULAR_BLUE 15
#define MTL_SPECULAR_ALPHA 16
#define MTL_SHININESS 17
#define MTL_STATE_SIZE 18
#define VTX_CMD_0 0
#define VTX_SE_COORD_FMT 1
#define VTX_STATE_SIZE 2
#define MAT_CMD_0 0
#define MAT_ELT_0 1
#define MAT_STATE_SIZE 17
#define GRD_CMD_0 0
#define GRD_VERT_GUARD_CLIP_ADJ 1
#define GRD_VERT_GUARD_DISCARD_ADJ 2
#define GRD_HORZ_GUARD_CLIP_ADJ 3
#define GRD_HORZ_GUARD_DISCARD_ADJ 4
#define GRD_STATE_SIZE 5
/* position changes frequently when lighting in modelpos - separate
* out to new state item?
*/
#define LIT_CMD_0 0
#define LIT_AMBIENT_RED 1
#define LIT_AMBIENT_GREEN 2
#define LIT_AMBIENT_BLUE 3
#define LIT_AMBIENT_ALPHA 4
#define LIT_DIFFUSE_RED 5
#define LIT_DIFFUSE_GREEN 6
#define LIT_DIFFUSE_BLUE 7
#define LIT_DIFFUSE_ALPHA 8
#define LIT_SPECULAR_RED 9
#define LIT_SPECULAR_GREEN 10
#define LIT_SPECULAR_BLUE 11
#define LIT_SPECULAR_ALPHA 12
#define LIT_POSITION_X 13
#define LIT_POSITION_Y 14
#define LIT_POSITION_Z 15
#define LIT_POSITION_W 16
#define LIT_DIRECTION_X 17
#define LIT_DIRECTION_Y 18
#define LIT_DIRECTION_Z 19
#define LIT_DIRECTION_W 20
#define LIT_ATTEN_CONST 21
#define LIT_ATTEN_LINEAR 22
#define LIT_ATTEN_QUADRATIC 23
#define LIT_ATTEN_XXX 24
#define LIT_CMD_1 25
#define LIT_SPOT_DCD 26
#define LIT_SPOT_EXPONENT 27
#define LIT_SPOT_CUTOFF 28
#define LIT_SPECULAR_THRESH 29
#define LIT_RANGE_CUTOFF 30 /* ? */
#define LIT_RANGE_ATTEN 31 /* ? */
#define LIT_STATE_SIZE 32
/* Fog
*/
#define FOG_CMD_0 0
#define FOG_R 1
#define FOG_C 2
#define FOG_D 3
#define FOG_PAD 4
#define FOG_STATE_SIZE 5
/* UCP
*/
#define UCP_CMD_0 0
#define UCP_X 1
#define UCP_Y 2
#define UCP_Z 3
#define UCP_W 4
#define UCP_STATE_SIZE 5
/* GLT - Global ambient
*/
#define GLT_CMD_0 0
#define GLT_RED 1
#define GLT_GREEN 2
#define GLT_BLUE 3
#define GLT_ALPHA 4
#define GLT_STATE_SIZE 5
/* EYE
*/
#define EYE_CMD_0 0
#define EYE_X 1
#define EYE_Y 2
#define EYE_Z 3
#define EYE_RESCALE_FACTOR 4
#define EYE_STATE_SIZE 5
#define SHN_CMD_0 0
#define SHN_SHININESS 1
#define SHN_STATE_SIZE 2
/**
* \brief Hardware state management.
*/
struct radeon_hw_state {
/**
* \name State
*
* All state should be on one of these lists
*/
/*@{*/
struct radeon_state_atom dirty; /**< \brief dirty list head placeholder */
struct radeon_state_atom clean; /**< \brief clean list head placeholder */
/*@}*/
/**
* \name Hardware state
*
* Stored as cmdbuf commands:
* - Need to doublebuffer for
* - reviving state after loss of context
* - eliding no-op statechange loops? (except line stipple count)
*/
/*@{*/
struct radeon_state_atom ctx;
struct radeon_state_atom set;
struct radeon_state_atom lin;
struct radeon_state_atom msk;
struct radeon_state_atom vpt;
struct radeon_state_atom tcl; /**< \ brief TCL */
struct radeon_state_atom msc;
struct radeon_state_atom tex[2];
struct radeon_state_atom zbs;
struct radeon_state_atom mtl;
struct radeon_state_atom mat[5]; /**< \brief matrix transformations */
#if _HAVE_LIGHTING
struct radeon_state_atom lit[8]; /**< \brief includes vec, scl commands */
#endif
#if _HAVE_USERCLIP
struct radeon_state_atom ucp[6];
#endif
struct radeon_state_atom eye; /**< \brief eye pos */
struct radeon_state_atom grd; /**< \brief guard band clipping */
struct radeon_state_atom fog; /**< \brief fog */
struct radeon_state_atom glt;
/*@}*/
};
/**
* \brief Derived state for internal purposes:
*/
struct radeon_state {
struct radeon_colorbuffer_state color; /**< \brief Color buffer */
struct radeon_depthbuffer_state depth; /**< \brief Depth buffer */
struct radeon_pixel_state pixel; /**< \brief Pixel */
struct radeon_scissor_state scissor; /**< \brief Scissor */
struct radeon_stencilbuffer_state stencil; /**< \brief Stencil buffer */
struct radeon_stipple_state stipple; /**< \brief Stipple */
struct radeon_texture_state texture; /**< \brief Textures */
};
/**
* \brief Texture information
*/
struct radeon_texture {
radeonTexObj objects[RADEON_NR_TEX_HEAPS]; /**< \brief texture objects */
radeonTexObj swapped; /**< \brief swapped texture */
memHeap_t *heap[RADEON_NR_TEX_HEAPS]; /**< \brief texture heaps */
GLint age[RADEON_NR_TEX_HEAPS]; /**< \brief aging */
GLint numHeaps; /**< \brief number of active heaps */
};
/**
* \brief DMA information
*/
struct radeon_dma {
/**
* \brief Active DMA region.
*
* Allocations for vertices and retained regions come from here. Also used
* for emitting random vertices, these may be flushed by calling
* radeon_dma::flush.
*/
struct radeon_dma_region current;
/**
* \brief Callback to flush the vertices in radeon_dma::current.
*/
void (*flush)( radeonContextPtr );
char *buf0_address; /**< \brief start of buf[0], for index calculations */
GLuint nr_released_bufs; /**< \brief flush after so many buffers released */
};
/**
* \brief Mirror some DRI context.
*/
struct radeon_dri_mirror {
__DRIcontextPrivate *context; /**< \brief DRI context */
__DRIscreenPrivate *screen; /**< \brief DRI screen */
__DRIdrawablePrivate *drawable; /**< \brief DRI drawable bound to this context */
drmContext hwContext;
drmLock *hwLock; /**< \brief hardware lock */
int fd; /**< \brief DRM device file descriptor */
int drmMinor; /**< \brief DRM device minor number */
};
/**
* \brief Command buffer size
*/
#define RADEON_CMD_BUF_SZ (8*1024)
/**
* \brief Command buffering.
*/
struct radeon_store {
GLuint statenr; /**< \brief state number */
GLuint primnr; /**< \brief primitive number */
char cmd_buf[RADEON_CMD_BUF_SZ]; /**< \brief command buffer */
int cmd_used; /**< \brief used commands */
int elts_start;
};
/**
* \brief TCL information.
*/
struct radeon_tcl_info {
GLuint vertex_format;
GLint last_offset;
GLuint hw_primitive;
GLuint tcl_flag; /**< \brief Whether TCL is inabled */
struct radeon_dma_region *aos_components[8];
GLuint nr_aos_components;
GLuint *Elts;
struct radeon_dma_region indexed_verts;
struct radeon_dma_region obj;
struct radeon_dma_region rgba;
struct radeon_dma_region spec;
struct radeon_dma_region fog;
struct radeon_dma_region tex[RADEON_MAX_TEXTURE_UNITS];
struct radeon_dma_region norm;
};
/**
* \brief Retained buffer.
*/
struct radeon_ioctl {
GLuint vertex_offset; /**< \brief offset of the vertex buffer */
GLuint vertex_size; /**< \brief size of the vertex buffer */
};
/**
* \brief Radeon GL context.
*/
struct radeon_context {
/**
* \brief Mesa context.
*/
GLcontext *glCtx;
/**
* \name Driver and hardware state management
*/
/*@{*/
struct radeon_hw_state hw; /**< \brief Hardware state */
struct radeon_state state; /**< \brief Internal state */
/*@}*/
/**
* \brief Texture object bookkeeping
*/
struct radeon_texture texture;
/**
* \name Rasterization and vertex state
*/
/*@{*/
GLuint TclFallback;
GLuint Fallback;
GLuint NewGLState;
/*@}*/
/**
* \name Temporaries for translating away float colors
*/
/*@{*/
struct gl_client_array UbyteColor;
struct gl_client_array UbyteSecondaryColor;
/*@}*/
/**
* \name Vertex buffers
*/
/*@{*/
struct radeon_ioctl ioctl; /**< \brief Retained vertex buffer */
struct radeon_dma dma; /**< \brief DMA information */
struct radeon_store store; /**< \brief Command buffer */
/*@}*/
/**
* \brief Page flipping
*/
GLuint doPageFlip;
/**
* \name Busy waiting
*/
/*@{*/
GLuint do_usleeps;
GLuint do_irqs; /**< \brief Do IRQs */
GLuint irqsEmitted; /**< \brief IRQ transition counter.
* \sa radeonWaitForFrameCompletion(). */
drmRadeonIrqWait iw;
/*@}*/
/**
* \name Drawable, cliprect and scissor information
*/
/*@{*/
GLuint numClipRects; /**< \brief Number of cliprects */
XF86DRIClipRectPtr pClipRects; /**< \brief cliprects for the draw buffer */
unsigned int lastStamp;
GLboolean lost_context; /**< \brief re-emit all state */
radeonScreenPtr radeonScreen; /**< \brief Screen private DRI data */
RADEONSAREAPrivPtr sarea; /**< \brief Private SAREA data */
/*@}*/
/**
* \name TCL stuff
*/
/*@{*/
GLmatrix TexGenMatrix[RADEON_MAX_TEXTURE_UNITS];
GLboolean recheck_texgen[RADEON_MAX_TEXTURE_UNITS];
GLboolean TexGenNeedNormals[RADEON_MAX_TEXTURE_UNITS];
GLuint TexMatEnabled;
GLuint TexGenEnabled;
GLmatrix tmpmat;
GLuint last_ReallyEnabled;
/*@}*/
/**
* \brief VBI
*/
GLuint vbl_seq;
/* radeon_tcl.c
*/
struct radeon_tcl_info tcl;
/* radeon_swtcl.c
*/
#if _HAVE_SWTNL
struct radeon_swtcl_info swtcl;
#endif
/* radeon_vtxfmt.c
*/
#if _HAVE_FULL_GL
struct radeon_vbinfo vb;
#endif
/**
* \brief Mirrors of some DRI state
*/
struct radeon_dri_mirror dri;
};
/**
* \brief Get the pointer to the Radeon context from the GL context.
*/
#define RADEON_CONTEXT(ctx) ((radeonContextPtr)(ctx->DriverCtx))
/**
* \brief Pack color.
*
* \param cpp desired characters (bytes) per pixel. Shouble be either 2 or 4.
* \param r red color component.
* \param r green color component.
* \param b blue color component.
* \param a alpha color component.
*
* \return the packed color, or zero if \p cpp is not supported.
*/
static __inline GLuint radeonPackColor( GLuint cpp,
GLubyte r, GLubyte g,
GLubyte b, GLubyte a )
{
switch ( cpp ) {
case 2:
return PACK_COLOR_565( r, g, b );
case 4:
return PACK_COLOR_8888( a, r, g, b );
default:
return 0;
}
}
/******************************************************************
* Debugging:
*/
#define DO_DEBUG 1
#if DO_DEBUG
extern int RADEON_DEBUG;
#else
#define RADEON_DEBUG 0
#endif
#define DEBUG_TEXTURE 0x001
#define DEBUG_STATE 0x002
#define DEBUG_IOCTL 0x004
#define DEBUG_PRIMS 0x008
#define DEBUG_VERTS 0x010
#define DEBUG_FALLBACKS 0x020
#define DEBUG_VFMT 0x040
#define DEBUG_CODEGEN 0x080
#define DEBUG_VERBOSE 0x100
#define DEBUG_DRI 0x200
#define DEBUG_DMA 0x400
#define DEBUG_SANITY 0x800
#endif /* __RADEON_CONTEXT_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,191 @@
/**
* \file radeon_ioctl.h
* \brief DRM interface functions.
*
* \author Kevin E. Martin <martin@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
* VA Linux Systems Inc., Fremont, California.
*
* 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
* ATI, VA LINUX SYSTEMS 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.
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h,v 1.4 2002/09/16 18:05:20 eich Exp $ */
#ifndef __RADEON_IOCTL_H__
#define __RADEON_IOCTL_H__
#include "simple_list.h"
#include "radeon_lock.h"
extern void radeonEmitState( radeonContextPtr rmesa );
extern void radeonEmitVertexAOS( radeonContextPtr rmesa,
GLuint vertex_size,
GLuint offset );
extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
GLuint vertex_format,
GLuint primitive,
GLuint vertex_nr );
extern void radeonFlushElts( radeonContextPtr rmesa );
extern GLushort *radeonAllocEltsOpenEnded( radeonContextPtr rmesa,
GLuint vertex_format,
GLuint primitive,
GLuint min_nr );
extern void radeonEmitAOS( radeonContextPtr rmesa,
struct radeon_dma_region **regions,
GLuint n,
GLuint offset );
extern void radeonFlushCmdBuf( radeonContextPtr rmesa, const char * );
extern void radeonRefillCurrentDmaRegion( radeonContextPtr rmesa );
extern void radeonAllocDmaRegion( radeonContextPtr rmesa,
struct radeon_dma_region *region,
int bytes,
int alignment );
extern void radeonAllocDmaRegionVerts( radeonContextPtr rmesa,
struct radeon_dma_region *region,
int numverts,
int vertsize,
int alignment );
extern void radeonReleaseDmaRegion( radeonContextPtr rmesa,
struct radeon_dma_region *region,
const char *caller );
extern void radeonCopyBuffer( const __DRIdrawablePrivate *drawable );
extern void radeonPageFlip( const __DRIdrawablePrivate *drawable );
extern void radeonFlush( GLcontext *ctx );
extern void radeonFinish( GLcontext *ctx );
extern void radeonWaitForIdleLocked( radeonContextPtr rmesa );
extern void radeonWaitForVBlank( radeonContextPtr rmesa );
extern void radeonInitIoctlFuncs( GLcontext *ctx );
extern void radeonGetAllParams( radeonContextPtr rmesa );
/* radeon_compat.c:
*/
extern void radeonCompatEmitPrimitive( radeonContextPtr rmesa,
GLuint vertex_format,
GLuint hw_primitive,
GLuint nrverts );
/* ================================================================
* Helper macros:
*/
/**
* \brief Close off the last primitive, if it exists.
*
* \param rmesa Radeon context.
*/
#define RADEON_NEWPRIM( rmesa ) \
do { \
if ( rmesa->dma.flush ) \
rmesa->dma.flush( rmesa ); \
} while (0)
/**
* Can accomodate several state changes and primitive changes without
* actually firing the buffer.
*
* \param rmesa Radeon context.
* \param ATOM state atom variable name.
*/
#define RADEON_STATECHANGE( rmesa, ATOM ) \
do { \
RADEON_NEWPRIM( rmesa ); \
move_to_head( &(rmesa->hw.dirty), &(rmesa->hw.ATOM)); \
} while (0)
#define RADEON_DB_STATE( ATOM ) \
memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
rmesa->hw.ATOM.cmd_size * 4)
static __inline int RADEON_DB_STATECHANGE(
radeonContextPtr rmesa,
struct radeon_state_atom *atom )
{
if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size*4)) {
int *tmp;
RADEON_NEWPRIM( rmesa );
move_to_head( &(rmesa->hw.dirty), atom );
tmp = atom->cmd;
atom->cmd = atom->lastcmd;
atom->lastcmd = tmp;
return 1;
}
else
return 0;
}
/**
* \brief Fire the buffered vertices no matter what.
*
* \param rmesa Radeon context.
*/
#define RADEON_FIREVERTICES( rmesa ) \
do { \
if ( rmesa->store.cmd_used || rmesa->dma.flush ) { \
radeonFlush( rmesa->glCtx ); \
} \
} while (0)
/**
* \brief Allocate space in the command buffer.
*
* \param rmesa Radeon context.
* \param bytes number of bytes to allocate.
* \param where Not used.
*
* If there isn't enough space available flush the command buffer, otherwise
* just advance the buffer head the requested ammount.
*/
static __inline char *radeonAllocCmdBuf( radeonContextPtr rmesa,
int bytes, const char *where )
{
if (rmesa->store.cmd_used + bytes > RADEON_CMD_BUF_SZ)
radeonFlushCmdBuf( rmesa, __FUNCTION__ );
assert(rmesa->dri.drmMinor >= 3);
{
char *head = rmesa->store.cmd_buf + rmesa->store.cmd_used;
rmesa->store.cmd_used += bytes;
return head;
}
}
#endif /* __RADEON_IOCTL_H__ */

View File

@@ -0,0 +1,682 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_state.c,v 1.5 2002/09/16 18:05:20 eich Exp $ */
/*
* Copyright 2000, 2001 VA Linux Systems Inc., Fremont, California.
*
* 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
* VA LINUX SYSTEMS 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:
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "glheader.h"
#include "imports.h"
#include "api_arrayelt.h"
#include "mmath.h"
#include "enums.h"
#include "colormac.h"
#include "radeon_context.h"
#include "radeon_ioctl.h"
#include "radeon_state.h"
#include "radeon_tcl.h"
#include "radeon_tex.h"
#include "radeon_vtxfmt.h"
/* =============================================================
* Materials
*/
/* Update on colormaterial, material emmissive/ambient,
* lightmodel.globalambient
*/
void update_global_ambient( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
float *fcmd = (float *)RADEON_DB_STATE( glt );
/* Need to do more if both emmissive & ambient are PREMULT:
*/
if ((rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &
((3 << RADEON_EMISSIVE_SOURCE_SHIFT) |
(3 << RADEON_AMBIENT_SOURCE_SHIFT))) == 0)
{
COPY_3V( &fcmd[GLT_RED],
ctx->Light.Material[0].Emission);
ACC_SCALE_3V( &fcmd[GLT_RED],
ctx->Light.Model.Ambient,
ctx->Light.Material[0].Ambient);
}
else
{
COPY_3V( &fcmd[GLT_RED], ctx->Light.Model.Ambient );
}
RADEON_DB_STATECHANGE(rmesa, &rmesa->hw.glt);
}
/* Update on change to
* - light[p].colors
* - light[p].enabled
* - material,
* - colormaterial enabled
* - colormaterial bitmask
*/
void update_light_colors( GLcontext *ctx, GLuint p )
{
struct gl_light *l = &ctx->Light.Light[p];
/* fprintf(stderr, "%s\n", __FUNCTION__); */
if (l->Enabled) {
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
float *fcmd = (float *)RADEON_DB_STATE( lit[p] );
GLuint bitmask = ctx->Light.ColorMaterialBitmask;
struct gl_material *mat = &ctx->Light.Material[0];
COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient );
COPY_4V( &fcmd[LIT_DIFFUSE_RED], l->Diffuse );
COPY_4V( &fcmd[LIT_SPECULAR_RED], l->Specular );
if (!ctx->Light.ColorMaterialEnabled)
bitmask = 0;
if ((bitmask & FRONT_AMBIENT_BIT) == 0)
SELF_SCALE_3V( &fcmd[LIT_AMBIENT_RED], mat->Ambient );
if ((bitmask & FRONT_DIFFUSE_BIT) == 0)
SELF_SCALE_3V( &fcmd[LIT_DIFFUSE_RED], mat->Diffuse );
if ((bitmask & FRONT_SPECULAR_BIT) == 0)
SELF_SCALE_3V( &fcmd[LIT_SPECULAR_RED], mat->Specular );
RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
}
}
/* Also fallback for asym colormaterial mode in twoside lighting...
*/
void check_twoside_fallback( GLcontext *ctx )
{
GLboolean fallback = GL_FALSE;
if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
if (memcmp( &ctx->Light.Material[0],
&ctx->Light.Material[1],
sizeof(struct gl_material)) != 0)
fallback = GL_TRUE;
else if (ctx->Light.ColorMaterialEnabled &&
(ctx->Light.ColorMaterialBitmask & BACK_MATERIAL_BITS) !=
((ctx->Light.ColorMaterialBitmask & FRONT_MATERIAL_BITS)<<1))
fallback = GL_TRUE;
}
TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_LIGHT_TWOSIDE, fallback );
}
void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
{
if (ctx->Light.ColorMaterialEnabled) {
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
GLuint light_model_ctl = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL];
GLuint mask = ctx->Light.ColorMaterialBitmask;
/* Default to PREMULT:
*/
light_model_ctl &= ~((3 << RADEON_EMISSIVE_SOURCE_SHIFT) |
(3 << RADEON_AMBIENT_SOURCE_SHIFT) |
(3 << RADEON_DIFFUSE_SOURCE_SHIFT) |
(3 << RADEON_SPECULAR_SOURCE_SHIFT));
if (mask & FRONT_EMISSION_BIT) {
light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
RADEON_EMISSIVE_SOURCE_SHIFT);
}
if (mask & FRONT_AMBIENT_BIT) {
light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
RADEON_AMBIENT_SOURCE_SHIFT);
}
if (mask & FRONT_DIFFUSE_BIT) {
light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
RADEON_DIFFUSE_SOURCE_SHIFT);
}
if (mask & FRONT_SPECULAR_BIT) {
light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
RADEON_SPECULAR_SOURCE_SHIFT);
}
if (light_model_ctl != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]) {
GLuint p;
RADEON_STATECHANGE( rmesa, tcl );
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = light_model_ctl;
for (p = 0 ; p < MAX_LIGHTS; p++)
update_light_colors( ctx, p );
update_global_ambient( ctx );
}
}
check_twoside_fallback( ctx );
}
void radeonUpdateMaterial( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( mtl );
GLuint p;
GLuint mask = ~0;
if (ctx->Light.ColorMaterialEnabled)
mask &= ~ctx->Light.ColorMaterialBitmask;
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s\n", __FUNCTION__);
if (mask & FRONT_EMISSION_BIT) {
fcmd[MTL_EMMISSIVE_RED] = ctx->Light.Material[0].Emission[0];
fcmd[MTL_EMMISSIVE_GREEN] = ctx->Light.Material[0].Emission[1];
fcmd[MTL_EMMISSIVE_BLUE] = ctx->Light.Material[0].Emission[2];
fcmd[MTL_EMMISSIVE_ALPHA] = ctx->Light.Material[0].Emission[3];
}
if (mask & FRONT_AMBIENT_BIT) {
fcmd[MTL_AMBIENT_RED] = ctx->Light.Material[0].Ambient[0];
fcmd[MTL_AMBIENT_GREEN] = ctx->Light.Material[0].Ambient[1];
fcmd[MTL_AMBIENT_BLUE] = ctx->Light.Material[0].Ambient[2];
fcmd[MTL_AMBIENT_ALPHA] = ctx->Light.Material[0].Ambient[3];
}
if (mask & FRONT_DIFFUSE_BIT) {
fcmd[MTL_DIFFUSE_RED] = ctx->Light.Material[0].Diffuse[0];
fcmd[MTL_DIFFUSE_GREEN] = ctx->Light.Material[0].Diffuse[1];
fcmd[MTL_DIFFUSE_BLUE] = ctx->Light.Material[0].Diffuse[2];
fcmd[MTL_DIFFUSE_ALPHA] = ctx->Light.Material[0].Diffuse[3];
}
if (mask & FRONT_SPECULAR_BIT) {
fcmd[MTL_SPECULAR_RED] = ctx->Light.Material[0].Specular[0];
fcmd[MTL_SPECULAR_GREEN] = ctx->Light.Material[0].Specular[1];
fcmd[MTL_SPECULAR_BLUE] = ctx->Light.Material[0].Specular[2];
fcmd[MTL_SPECULAR_ALPHA] = ctx->Light.Material[0].Specular[3];
}
if (mask & FRONT_SHININESS_BIT) {
fcmd[MTL_SHININESS] = ctx->Light.Material[0].Shininess;
}
if (RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.mtl )) {
for (p = 0 ; p < MAX_LIGHTS; p++)
update_light_colors( ctx, p );
check_twoside_fallback( ctx );
update_global_ambient( ctx );
}
else if (RADEON_DEBUG & (DEBUG_PRIMS|DEBUG_STATE))
fprintf(stderr, "%s: Elided noop material call\n", __FUNCTION__);
}
/* _NEW_LIGHT
* _NEW_MODELVIEW
* _MESA_NEW_NEED_EYE_COORDS
*
* Uses derived state from mesa:
* _VP_inf_norm
* _h_inf_norm
* _Position
* _NormDirection
* _ModelViewInvScale
* _NeedEyeCoords
* _EyeZDir
*
* which are calculated in light.c and are correct for the current
* lighting space (model or eye), hence dependencies on _NEW_MODELVIEW
* and _MESA_NEW_NEED_EYE_COORDS.
*/
void radeonUpdateLighting( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
/* Have to check these, or have an automatic shortcircuit mechanism
* to remove noop statechanges. (Or just do a better job on the
* front end).
*/
{
GLuint tmp = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL];
if (ctx->_NeedEyeCoords)
tmp &= ~RADEON_LIGHT_IN_MODELSPACE;
else
tmp |= RADEON_LIGHT_IN_MODELSPACE;
/* Leave this test disabled: (unexplained q3 lockup) (even with
new packets)
*/
if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL])
{
RADEON_STATECHANGE( rmesa, tcl );
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = tmp;
}
}
{
GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( eye );
fcmd[EYE_X] = ctx->_EyeZDir[0];
fcmd[EYE_Y] = ctx->_EyeZDir[1];
fcmd[EYE_Z] = - ctx->_EyeZDir[2];
fcmd[EYE_RESCALE_FACTOR] = ctx->_ModelViewInvScale;
RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.eye );
}
/* RADEON_STATECHANGE( rmesa, glt ); */
if (ctx->Light.Enabled) {
GLint p;
for (p = 0 ; p < MAX_LIGHTS; p++) {
if (ctx->Light.Light[p].Enabled) {
struct gl_light *l = &ctx->Light.Light[p];
GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( lit[p] );
if (l->EyePosition[3] == 0.0) {
COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm );
COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm );
fcmd[LIT_POSITION_W] = 0;
fcmd[LIT_DIRECTION_W] = 0;
} else {
COPY_4V( &fcmd[LIT_POSITION_X], l->_Position );
fcmd[LIT_DIRECTION_X] = -l->_NormDirection[0];
fcmd[LIT_DIRECTION_Y] = -l->_NormDirection[1];
fcmd[LIT_DIRECTION_Z] = -l->_NormDirection[2];
fcmd[LIT_DIRECTION_W] = 0;
}
RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
}
}
}
}
void radeonLightfv( GLcontext *ctx, GLenum light,
GLenum pname, const GLfloat *params )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
GLint p = light - GL_LIGHT0;
struct gl_light *l = &ctx->Light.Light[p];
GLfloat *fcmd = (GLfloat *)rmesa->hw.lit[p].cmd;
switch (pname) {
case GL_AMBIENT:
case GL_DIFFUSE:
case GL_SPECULAR:
update_light_colors( ctx, p );
break;
case GL_SPOT_DIRECTION:
/* picked up in update_light */
break;
case GL_POSITION: {
/* positions picked up in update_light, but can do flag here */
GLuint flag = (p&1)? RADEON_LIGHT_1_IS_LOCAL : RADEON_LIGHT_0_IS_LOCAL;
GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
RADEON_STATECHANGE(rmesa, tcl);
if (l->EyePosition[3] != 0.0F)
rmesa->hw.tcl.cmd[idx] |= flag;
else
rmesa->hw.tcl.cmd[idx] &= ~flag;
break;
}
case GL_SPOT_EXPONENT:
RADEON_STATECHANGE(rmesa, lit[p]);
fcmd[LIT_SPOT_EXPONENT] = params[0];
break;
case GL_SPOT_CUTOFF: {
GLuint flag = (p&1) ? RADEON_LIGHT_1_IS_SPOT : RADEON_LIGHT_0_IS_SPOT;
GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
RADEON_STATECHANGE(rmesa, lit[p]);
fcmd[LIT_SPOT_CUTOFF] = l->_CosCutoff;
RADEON_STATECHANGE(rmesa, tcl);
if (l->SpotCutoff != 180.0F)
rmesa->hw.tcl.cmd[idx] |= flag;
else
rmesa->hw.tcl.cmd[idx] &= ~flag;
break;
}
case GL_CONSTANT_ATTENUATION:
RADEON_STATECHANGE(rmesa, lit[p]);
fcmd[LIT_ATTEN_CONST] = params[0];
break;
case GL_LINEAR_ATTENUATION:
RADEON_STATECHANGE(rmesa, lit[p]);
fcmd[LIT_ATTEN_LINEAR] = params[0];
break;
case GL_QUADRATIC_ATTENUATION:
RADEON_STATECHANGE(rmesa, lit[p]);
fcmd[LIT_ATTEN_QUADRATIC] = params[0];
break;
default:
return;
}
}
void radeonLightModelfv( GLcontext *ctx, GLenum pname,
const GLfloat *param )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
switch (pname) {
case GL_LIGHT_MODEL_AMBIENT:
update_global_ambient( ctx );
break;
case GL_LIGHT_MODEL_LOCAL_VIEWER:
RADEON_STATECHANGE( rmesa, tcl );
if (ctx->Light.Model.LocalViewer)
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LOCAL_VIEWER;
else
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LOCAL_VIEWER;
break;
case GL_LIGHT_MODEL_TWO_SIDE:
RADEON_STATECHANGE( rmesa, tcl );
if (ctx->Light.Model.TwoSide)
rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_LIGHT_TWOSIDE;
else
rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_LIGHT_TWOSIDE;
check_twoside_fallback( ctx );
#if _HAVE_SWTNL
if (rmesa->TclFallback) {
radeonChooseRenderState( ctx );
radeonChooseVertexState( ctx );
}
#endif
break;
case GL_LIGHT_MODEL_COLOR_CONTROL:
radeonUpdateSpecular(ctx);
RADEON_STATECHANGE( rmesa, tcl );
if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &=
~RADEON_DIFFUSE_SPECULAR_COMBINE;
else
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |=
RADEON_DIFFUSE_SPECULAR_COMBINE;
break;
default:
break;
}
}
/* =============================================================
* Fog
*/
static void radeonFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
union { int i; float f; } c, d;
GLchan col[4];
c.i = rmesa->hw.fog.cmd[FOG_C];
d.i = rmesa->hw.fog.cmd[FOG_D];
switch (pname) {
case GL_FOG_MODE:
if (!ctx->Fog.Enabled)
return;
RADEON_STATECHANGE(rmesa, tcl);
rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_TCL_FOG_MASK;
switch (ctx->Fog.Mode) {
case GL_LINEAR:
rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_LINEAR;
if (ctx->Fog.Start == ctx->Fog.End) {
c.f = 1.0F;
d.f = 1.0F;
}
else {
c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
d.f = 1.0/(ctx->Fog.End-ctx->Fog.Start);
}
break;
case GL_EXP:
rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_EXP;
c.f = 0.0;
d.f = ctx->Fog.Density;
break;
case GL_EXP2:
rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_EXP2;
c.f = 0.0;
d.f = -(ctx->Fog.Density * ctx->Fog.Density);
break;
default:
return;
}
break;
case GL_FOG_DENSITY:
switch (ctx->Fog.Mode) {
case GL_EXP:
c.f = 0.0;
d.f = ctx->Fog.Density;
break;
case GL_EXP2:
c.f = 0.0;
d.f = -(ctx->Fog.Density * ctx->Fog.Density);
break;
default:
break;
}
break;
case GL_FOG_START:
case GL_FOG_END:
if (ctx->Fog.Mode == GL_LINEAR) {
if (ctx->Fog.Start == ctx->Fog.End) {
c.f = 1.0F;
d.f = 1.0F;
} else {
c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
d.f = 1.0/(ctx->Fog.End-ctx->Fog.Start);
}
}
break;
case GL_FOG_COLOR:
RADEON_STATECHANGE( rmesa, ctx );
UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx->Fog.Color );
rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] =
radeonPackColor( 4, col[0], col[1], col[2], 0 );
break;
case GL_FOG_COORDINATE_SOURCE_EXT:
/* What to do?
*/
break;
default:
return;
}
if (c.i != rmesa->hw.fog.cmd[FOG_C] || d.i != rmesa->hw.fog.cmd[FOG_D]) {
RADEON_STATECHANGE( rmesa, fog );
rmesa->hw.fog.cmd[FOG_C] = c.i;
rmesa->hw.fog.cmd[FOG_D] = d.i;
}
}
/* Examine lighting and texture state to determine if separate specular
* should be enabled.
*/
void radeonUpdateSpecular( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
GLuint p = rmesa->hw.ctx.cmd[CTX_PP_CNTL];
if ( ctx->_TriangleCaps & DD_SEPARATE_SPECULAR ) {
p |= RADEON_SPECULAR_ENABLE;
} else {
p &= ~RADEON_SPECULAR_ENABLE;
}
if ( rmesa->hw.ctx.cmd[CTX_PP_CNTL] != p ) {
RADEON_STATECHANGE( rmesa, ctx );
rmesa->hw.ctx.cmd[CTX_PP_CNTL] = p;
}
/* Bizzare: have to leave lighting enabled to get fog.
*/
RADEON_STATECHANGE( rmesa, tcl );
if ((ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) {
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
}
else if (ctx->Fog.Enabled) {
if (ctx->Light.Enabled) {
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
} else {
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
}
}
else if (ctx->Light.Enabled) {
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~RADEON_TCL_VTX_PK_SPEC;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
} else if (ctx->Fog.ColorSumEnabled ) {
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LIGHTING_ENABLE;
} else {
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~RADEON_TCL_VTX_PK_SPEC;
rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LIGHTING_ENABLE;
}
#if _HAVE_SWTNL
/* Update vertex/render formats
*/
if (rmesa->TclFallback) {
radeonChooseRenderState( ctx );
radeonChooseVertexState( ctx );
}
#endif
}
static void radeonLightingSpaceChange( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
GLboolean tmp;
RADEON_STATECHANGE( rmesa, tcl );
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s %d\n", __FUNCTION__, ctx->_NeedEyeCoords);
if (ctx->_NeedEyeCoords)
tmp = ctx->Transform.RescaleNormals;
else
tmp = !ctx->Transform.RescaleNormals;
if ( tmp ) {
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_RESCALE_NORMALS;
} else {
rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_RESCALE_NORMALS;
}
}
void radeonInitLightStateFuncs( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
int i;
ctx->Driver.LightModelfv = radeonLightModelfv;
ctx->Driver.Lightfv = radeonLightfv;
ctx->Driver.Fogfv = radeonFogfv;
ctx->Driver.LightingSpaceChange = radeonLightingSpaceChange;
for (i = 0 ; i < 8; i++) {
struct gl_light *l = &ctx->Light.Light[i];
GLenum p = GL_LIGHT0 + i;
*(float *)&(rmesa->hw.lit[i].cmd[LIT_RANGE_CUTOFF]) = FLT_MAX;
ctx->Driver.Lightfv( ctx, p, GL_AMBIENT, l->Ambient );
ctx->Driver.Lightfv( ctx, p, GL_DIFFUSE, l->Diffuse );
ctx->Driver.Lightfv( ctx, p, GL_SPECULAR, l->Specular );
ctx->Driver.Lightfv( ctx, p, GL_POSITION, 0 );
ctx->Driver.Lightfv( ctx, p, GL_SPOT_DIRECTION, 0 );
ctx->Driver.Lightfv( ctx, p, GL_SPOT_EXPONENT, &l->SpotExponent );
ctx->Driver.Lightfv( ctx, p, GL_SPOT_CUTOFF, &l->SpotCutoff );
ctx->Driver.Lightfv( ctx, p, GL_CONSTANT_ATTENUATION,
&l->ConstantAttenuation );
ctx->Driver.Lightfv( ctx, p, GL_LINEAR_ATTENUATION,
&l->LinearAttenuation );
ctx->Driver.Lightfv( ctx, p, GL_QUADRATIC_ATTENUATION,
&l->QuadraticAttenuation );
}
ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_AMBIENT,
ctx->Light.Model.Ambient );
ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
ctx->Driver.Fogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, 0 );
}

View File

@@ -0,0 +1,178 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c,v 1.4 2002/02/22 21:45:00 dawes Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
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
ATI, VA LINUX SYSTEMS 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.
**************************************************************************/
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*
*/
#include "glheader.h"
#include "radeon_context.h"
#include "radeon_lock.h"
#include "radeon_state.h"
#include "radeon_ioctl.h"
#if _HAVE_FULL_GL
#include "radeon_tex.h"
#else
#include "radeon_subset.h"
#endif
#if DEBUG_LOCKING
char *prevLockFile = NULL;
int prevLockLine = 0;
#endif
void radeonUpdateViewportOffset( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
GLfloat xoffset = (GLfloat)dPriv->x;
GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
const GLfloat *v = ctx->Viewport._WindowMap.m;
GLfloat tx = v[MAT_TX] + xoffset;
GLfloat ty = (- v[MAT_TY]) + yoffset;
if ( rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] != *(GLuint *)&tx ||
rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] != *(GLuint *)&ty )
{
/* Note: this should also modify whatever data the context reset
* code uses...
*/
rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = *(GLuint *)&tx;
rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = *(GLuint *)&ty;
/* update polygon stipple x/y screen offset */
{
GLuint stx, sty;
GLuint m = rmesa->hw.msc.cmd[MSC_RE_MISC];
m &= ~(RADEON_STIPPLE_X_OFFSET_MASK |
RADEON_STIPPLE_Y_OFFSET_MASK);
/* add magic offsets, then invert */
stx = 31 - ((rmesa->dri.drawable->x - 1) & RADEON_STIPPLE_COORD_MASK);
sty = 31 - ((rmesa->dri.drawable->y + rmesa->dri.drawable->h - 1)
& RADEON_STIPPLE_COORD_MASK);
m |= ((stx << RADEON_STIPPLE_X_OFFSET_SHIFT) |
(sty << RADEON_STIPPLE_Y_OFFSET_SHIFT));
if ( rmesa->hw.msc.cmd[MSC_RE_MISC] != m ) {
RADEON_STATECHANGE( rmesa, msc );
rmesa->hw.msc.cmd[MSC_RE_MISC] = m;
}
}
}
radeonUpdateScissor( ctx );
}
/* Turn on/off page flipping according to the flags in the sarea:
*/
static void
radeonUpdatePageFlipping( radeonContextPtr rmesa )
{
int use_back;
if (rmesa->dri.drmMinor < 3)
return;
rmesa->doPageFlip = rmesa->sarea->pfAllowPageFlip;
use_back = (rmesa->glCtx->Color._DrawDestMask == BACK_LEFT_BIT);
use_back ^= (rmesa->sarea->pfCurrentPage == 1);
if ( use_back ) {
rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
} else {
rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
}
RADEON_STATECHANGE( rmesa, ctx );
rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset;
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
}
/* Update the hardware state. This is called if another context has
* grabbed the hardware lock, which includes the X server. This
* function also updates the driver's window state after the X server
* moves, resizes or restacks a window -- the change will be reflected
* in the drawable position and clip rects. Since the X server grabs
* the hardware lock when it changes the window state, this routine will
* automatically be called after such a change.
*/
void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
{
__DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
__DRIscreenPrivate *sPriv = rmesa->dri.screen;
RADEONSAREAPrivPtr sarea = rmesa->sarea;
int i;
drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );
/* The window might have moved, so we might need to get new clip
* rects.
*
* NOTE: This releases and regrabs the hw lock to allow the X server
* to respond to the DRI protocol request for new drawable info.
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
if ( rmesa->lastStamp != dPriv->lastStamp ) {
radeonUpdatePageFlipping( rmesa );
if (rmesa->glCtx->Color._DrawDestMask == BACK_LEFT_BIT)
radeonSetCliprects( rmesa, GL_BACK_LEFT );
else
radeonSetCliprects( rmesa, GL_FRONT_LEFT );
radeonUpdateViewportOffset( rmesa->glCtx );
rmesa->lastStamp = dPriv->lastStamp;
}
if ( sarea->ctxOwner != rmesa->dri.hwContext ) {
sarea->ctxOwner = rmesa->dri.hwContext;
for ( i = 0 ; i < rmesa->texture.numHeaps ; i++ ) {
if ( rmesa->texture.heap[i] && sarea->texAge[i] != rmesa->texture.age[i] ) {
radeonAgeTextures( rmesa, i );
}
}
}
}

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