Compare commits
133 Commits
embedded-1
...
embedded-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1f331ef4d | ||
|
|
ca81dd07b7 | ||
|
|
8dbdb74d8a | ||
|
|
1b3edffdd1 | ||
|
|
12ee43bd7c | ||
|
|
1303475d38 | ||
|
|
56d99c8cdb | ||
|
|
f29b41f2ed | ||
|
|
89d52a0de4 | ||
|
|
b6fb04a81d | ||
|
|
7d55e9abf6 | ||
|
|
1ac609a7df | ||
|
|
00affe74c1 | ||
|
|
f221b8df75 | ||
|
|
45bd335b1c | ||
|
|
6127672e26 | ||
|
|
bb3752a434 | ||
|
|
56c896a2b8 | ||
|
|
afc72872be | ||
|
|
e511f40795 | ||
|
|
a53f53ece3 | ||
|
|
24812b3eaa | ||
|
|
42e0f2ec95 | ||
|
|
e4fcab7a35 | ||
|
|
cd6d79a82c | ||
|
|
a428744286 | ||
|
|
ccc6ef28ca | ||
|
|
3100749dd0 | ||
|
|
980e98d324 | ||
|
|
2204d5bb46 | ||
|
|
67d3c57c46 | ||
|
|
9e24ff7a0a | ||
|
|
e014d794f2 | ||
|
|
a9bd5a6860 | ||
|
|
94643c4780 | ||
|
|
993502aebc | ||
|
|
932e26e8f4 | ||
|
|
54f4c8d1a3 | ||
|
|
277d7a2a85 | ||
|
|
0a98671051 | ||
|
|
a47745e9fd | ||
|
|
69ce6b7db0 | ||
|
|
5d3ab07110 | ||
|
|
1613d48989 | ||
|
|
5a610a1974 | ||
|
|
afb339bf75 | ||
|
|
16ca6f8e93 | ||
|
|
41b5963f8d | ||
|
|
99199c0ece | ||
|
|
368d95a7dc | ||
|
|
0218da1433 | ||
|
|
6cb2411250 | ||
|
|
0d3a504b94 | ||
|
|
bde16645ca | ||
|
|
301f7e4408 | ||
|
|
173441d1a6 | ||
|
|
64b3e2fa16 | ||
|
|
6919c50029 | ||
|
|
a8512f7dda | ||
|
|
70217c70be | ||
|
|
9d4857a816 | ||
|
|
3f00e34097 | ||
|
|
3e48e6fce4 | ||
|
|
d1fa9af224 | ||
|
|
c20d946424 | ||
|
|
ff6068b217 | ||
|
|
ed1b6e98e2 | ||
|
|
b52901eb89 | ||
|
|
cff70d16aa | ||
|
|
bafbdcb703 | ||
|
|
50d1c2c921 | ||
|
|
a1fd12ab84 | ||
|
|
360bec8a6f | ||
|
|
6440630d79 | ||
|
|
02a6f4b56a | ||
|
|
f828410458 | ||
|
|
7b7af467dd | ||
|
|
3101d43a76 | ||
|
|
d95443f030 | ||
|
|
be49c0fef2 | ||
|
|
61d31cab97 | ||
|
|
7067815785 | ||
|
|
ad79ba8208 | ||
|
|
b8cdeaae3a | ||
|
|
4b930d3080 | ||
|
|
2b3cd85107 | ||
|
|
12acb24b60 | ||
|
|
b4bc6375d1 | ||
|
|
c91deeffc4 | ||
|
|
728dade650 | ||
|
|
c3ded1b33d | ||
|
|
080ae6edb5 | ||
|
|
b8bc33a6b1 | ||
|
|
1d7c610c2b | ||
|
|
70130333c2 | ||
|
|
c608a0fb2a | ||
|
|
7f35ecd070 | ||
|
|
ef9f2d4296 | ||
|
|
27b8f1d3ae | ||
|
|
c35fb58c35 | ||
|
|
eb998b80ea | ||
|
|
b77ca3d2b7 | ||
|
|
cdc64176f9 | ||
|
|
da69c37f98 | ||
|
|
661a236d09 | ||
|
|
b9f8f7f6a4 | ||
|
|
66f40571e1 | ||
|
|
6620693116 | ||
|
|
730cacfa01 | ||
|
|
2f05ae32c5 | ||
|
|
d9ed9e1a9a | ||
|
|
6133ba36ec | ||
|
|
4b5f9479eb | ||
|
|
75019b24d1 | ||
|
|
c9118dfaba | ||
|
|
a140417be9 | ||
|
|
ccf4e3e8f2 | ||
|
|
78e1fee39b | ||
|
|
75ccd62be8 | ||
|
|
cd9df92c9d | ||
|
|
cfe59bd3f9 | ||
|
|
62bc31dcae | ||
|
|
675f151c42 | ||
|
|
151cd27866 | ||
|
|
c8facc28cc | ||
|
|
086e00e086 | ||
|
|
49116e9fd2 | ||
|
|
9d0eff73b5 | ||
|
|
81c7427ddc | ||
|
|
9e3c6f3b8e | ||
|
|
18a5321288 | ||
|
|
4c864746d6 | ||
|
|
19b1476515 |
127
docs/subset.html
127
docs/subset.html
@@ -7,35 +7,42 @@
|
||||
<span style="font-style: italic;"></span><span
|
||||
style="font-weight: bold;"></span>
|
||||
<h1>
|
||||
<center>OpenGL Subset Specification</center>
|
||||
<center>Mesa Subset Specification</center>
|
||||
</h1>
|
||||
<h2>
|
||||
<center>
|
||||
<h3>Tungsten Graphics, Inc.</h3>
|
||||
<h3>January 20, 2003<br>
|
||||
<h3>February 26, 2003<br>
|
||||
</h3>
|
||||
</center>
|
||||
</h2>
|
||||
<p> Copyright © 2002-2003 by Tungsten Graphics, Inc., Cedar Park,
|
||||
Texas. All Rights Reserved. <br>
|
||||
<p> Copyright © 2002-2003 by <a
|
||||
href="http://www.tungstengraphics.com/">Tungsten Graphics, Inc.</a>,
|
||||
Cedar Park, Texas. All Rights Reserved. <br>
|
||||
<br>
|
||||
Permission is granted to make and distribute verbatim copies of this
|
||||
document provided the copyright notice and this permission notice are
|
||||
preserved on all copies.<br>
|
||||
</p>
|
||||
<p> OpenGL is a trademark of <a href="http://www.sgi.com">Silicon
|
||||
Graphics, Inc.</a>.</p>
|
||||
<h1>1. Introduction</h1>
|
||||
This document describes a subset of the OpenGL API implemented by
|
||||
Tungsten Graphics, Inc. for embedded devices. Prior to reading
|
||||
this document the reader should be familiar with the OpenGL 1.2.1
|
||||
This document describes a subset of the Mesa implemented by Tungsten
|
||||
Graphics, Inc. for embedded devices. Prior to reading this
|
||||
document the reader should be familiar with the OpenGL 1.2.1
|
||||
specification dated April 1, 1999 (available from <a
|
||||
href="http://www.opengl.org/developers/documentation/specs.html">http://www.opengl.org/developers/documentation/specs.html</a>.)
|
||||
Experience with OpenGL programming is highly advisable.<a
|
||||
href="http://www.opengl.org/developers/documentation/specs.html"><br>
|
||||
</a><br>
|
||||
Tungsten Graphics, Inc. is working with industry standards
|
||||
organizations +in an attempt to standardize this Mesa subset and any
|
||||
other possible subsets +as a result of this work. <br>
|
||||
<br>
|
||||
Appendix A contains a list of issues of which some may not be resolved.<br>
|
||||
<br>
|
||||
To summarize, the following major features of OpenGL are omitted from
|
||||
the subset:<br>
|
||||
To summarize, the following major features of Mesa are omitted from the
|
||||
subset:<br>
|
||||
<ul>
|
||||
<li>Vertex arrays</li>
|
||||
<li>Texture coordinate generation</li>
|
||||
@@ -57,10 +64,11 @@ the subset:<br>
|
||||
</ul>
|
||||
<p>Further reductions are made at a lower level of detail.<br>
|
||||
</p>
|
||||
<p>As in the OpenGL specification, OpenGL identifiers are printed in <span
|
||||
style="font-weight: bold;">bold face</span>.<br>
|
||||
<p>Mesa function names are printed in <span style="font-weight: bold;">bold
|
||||
face</span>. Function parameters are printed in <span
|
||||
style="font-style: italic;">italics</span>.<br>
|
||||
</p>
|
||||
<p>The Tungsten Graphics, Inc. OpenGL subset library is hereafter
|
||||
<p>The Tungsten Graphics, Inc. Mesa subset library is hereafter
|
||||
referred to as <span style="font-style: italic;">the subset.</span><br>
|
||||
<br>
|
||||
</p>
|
||||
@@ -108,10 +116,10 @@ GL_POLYGON - a closed, convex polygon<br>
|
||||
<br>
|
||||
The <span style="font-weight: bold;">glVertex</span> commands take two
|
||||
or three floating point coordinates, or a pointer to an array of two or
|
||||
three floating point coordinates. OpenGL vertices are actually
|
||||
4-element homogeneous coordinates. The fourth component,
|
||||
unspecified by the subset's <span style="font-weight: bold;">glVertex</span>
|
||||
commands, is one.<br>
|
||||
three floating point coordinates. Vertices are actually 4-element
|
||||
homogeneous coordinates. The fourth component, unspecified by the
|
||||
subset's <span style="font-weight: bold;">glVertex</span> commands, is
|
||||
one.<br>
|
||||
<br>
|
||||
<span style="font-weight: bold;"></span>
|
||||
<h2>2.2 Other Per-vertex Commands<br>
|
||||
@@ -162,8 +170,8 @@ command between <span style="font-weight: bold;">glBegin</span> and <span
|
||||
GL_INVALID_OPERATION.<br>
|
||||
<br>
|
||||
<h2>2.3 Unsupported Commands</h2>
|
||||
None of the following OpenGL commands related to primitive
|
||||
specification are supported by the subset:<br>
|
||||
None of the following commands related to primitive specification are
|
||||
supported by the subset:<br>
|
||||
<br>
|
||||
<div style="margin-left: 40px;">Per-Vertex commands:<br>
|
||||
</div>
|
||||
@@ -480,7 +488,7 @@ Lines are rendered with the command sequence <span
|
||||
style="font-weight: bold;">glEnd</span> where <span
|
||||
style="font-style: italic;">mode</span> is one of GL_LINES,
|
||||
GL_LINE_STRIP or GL_LINE_LOOP. Lines are rasterized as described
|
||||
in the OpenGL specification. Note that OpenGL uses the <span
|
||||
in the OpenGL specification. Note that OpenGL specifies the <span
|
||||
style="font-style: italic;">half-open</span> convention for drawing
|
||||
lines: the last fragment in a line segment is omitted so that endpoint
|
||||
pixels shared by two line segments will only be drawn once instead of
|
||||
@@ -507,9 +515,8 @@ Lines may be stippled (i.e. dashed) with the command<br>
|
||||
style="font-style: italic;">pattern</span>)<br>
|
||||
</div>
|
||||
<br>
|
||||
As described in the OpenGL specification, <span
|
||||
style="font-style: italic;">pattern</span> describes an on/off pattern
|
||||
for the fragments produced by rasterization and <span
|
||||
<span style="font-style: italic;">pattern</span> describes an on/off
|
||||
pattern for the fragments produced by rasterization and <span
|
||||
style="font-style: italic;">factor</span> specifies how many subsequent
|
||||
fragments are kept or culled for each pattern bit. Line stippling
|
||||
can be enabled or disabled by the commands <span
|
||||
@@ -582,7 +589,7 @@ front-facing triangles and quadrilaterals, respectively.<br>
|
||||
The command<br>
|
||||
<br>
|
||||
<div style="margin-left: 40px;">void <span style="font-weight: bold;">glFrontFace</span>(GLenum<span
|
||||
style="font-style: italic;">mode</span>)<br>
|
||||
style="font-style: italic;"> mode</span>)<br>
|
||||
</div>
|
||||
<br>
|
||||
specifies whether clockwise or counter-clockwise winding indicates a
|
||||
@@ -616,31 +623,7 @@ Polygon culling is enabled and disabled with the commands <span
|
||||
style="font-weight: bold;">glDisable</span>(GL_CULL_FACE),
|
||||
respectively.<br>
|
||||
<br>
|
||||
<h3>4.3.3 Polygon Fill Mode</h3>
|
||||
The command<br>
|
||||
<br>
|
||||
<div style="margin-left: 40px;">void<span style="font-weight: bold;"><span
|
||||
style="font-weight: bold;"> </span><span style="font-weight: bold;"></span>glPolygonMode</span>(GLenum<span
|
||||
style="font-style: italic;">face</span>, GLenum <span
|
||||
style="font-style: italic;">mode</span>)<br>
|
||||
</div>
|
||||
<br>
|
||||
controls whether polygons are filled, outlined or drawn with a point at
|
||||
each vertex. The <span style="font-style: italic;">face</span>
|
||||
parameter must be GL_FRONT_AND_BACK. The values GL_FRONT and
|
||||
GL_BACK are not permitted by the subset. If <span
|
||||
style="font-style: italic;">mode</span> is GL_FILL then the polygon
|
||||
will be filled (the default). If <span style="font-style: italic;">mode</span>
|
||||
is GL_LINE then the polygon will be rendered as if it were specified by <span
|
||||
style="font-weight: bold;">glBegin</span>(GL_LINE_LOOP). If <span
|
||||
style="font-style: italic;">mode</span> is GL_POINT then the polygon
|
||||
will be rendered as if it were specified with <span
|
||||
style="font-weight: bold;">glBegin</span>(GL_POINTS). Any other
|
||||
values for <span style="font-style: italic;">face</span> or <span
|
||||
style="font-style: italic;">mode</span> will raise the error
|
||||
GL_INVALID_ENUM.<br>
|
||||
<br>
|
||||
<h3>4.3.4 Polygon Antialiasing</h3>
|
||||
<h3>4.3.3 Polygon Antialiasing</h3>
|
||||
Polygons may be antialiased in order to smooth their edges.
|
||||
Polygon antialiasing is enabled and disabled with the commands <span
|
||||
style="font-weight: bold;">glEnable</span>(GL_POLYGON_SMOOTH) and <span
|
||||
@@ -676,10 +659,10 @@ the first vertex specifies the color for the entire polygon. If <span
|
||||
are linearly interpolated to produce the fragment colors.<br>
|
||||
<br>
|
||||
<h2>4.5 Bitmap Rasterization</h2>
|
||||
In OpenGL, a bitmap is a monochromatic, binary image in which each
|
||||
image element (or pixel) is represented by one bit. Fragments are
|
||||
only generated for the bits (pixels) which are set. Bitmaps are
|
||||
commonly used to draw text (glyphs) and markers.<br>
|
||||
A bitmap is a monochromatic, binary image in which each image element
|
||||
(or pixel) is represented by one bit. Fragments are only generated
|
||||
for the bits (pixels) which are set. Bitmaps are commonly used to
|
||||
draw text (glyphs) and markers.<br>
|
||||
<br>
|
||||
A bitmap is drawn with the command<br>
|
||||
<br>
|
||||
@@ -834,6 +817,7 @@ the subset.<br>
|
||||
Polygon commands:<br>
|
||||
<div style="margin-left: 40px; font-weight: bold;">glPolygonStipple<br>
|
||||
glPolygonOffset<br>
|
||||
glPolygonMode<br>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2752,15 +2736,6 @@ name stack.<br>
|
||||
<td style="vertical-align: top;">Pixel packing row length.<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top;">GL_POLYGON_MODE<br>
|
||||
</td>
|
||||
<td style="vertical-align: top;">2<br>
|
||||
</td>
|
||||
<td style="vertical-align: top;">Current front and back polygon
|
||||
modes: GL_POINT, GL_LINE or GL_FILL.<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top;">GL_POLYGON_SMOOTH<br>
|
||||
</td>
|
||||
@@ -3037,13 +3012,11 @@ implementation, such as "Tungsten Graphics, Inc."<br>
|
||||
<td style="vertical-align: top;">GL_EXTENSIONS<br>
|
||||
</td>
|
||||
<td style="vertical-align: top;">A white-space separated list of
|
||||
the supported OpenGL extensions.<br>
|
||||
</td>
|
||||
the supported extensions. </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<br>
|
||||
<h2>9.3 Error Queries</h2>
|
||||
The command<br>
|
||||
<br>
|
||||
@@ -3448,7 +3421,7 @@ number of approaches to antialiasing have been summarized in email.<br>
|
||||
RECOMMENDATION: don't support edge flags. They don't effect
|
||||
polygon antialiasing.<br>
|
||||
<br>
|
||||
RESOLUTION: open<br>
|
||||
RESOLUTION: closed, as of 26 Feb 2003.<br>
|
||||
<br>
|
||||
<h2>A.3 glRasterPos vs. glWindowPos</h2>
|
||||
Should glRasterPos and/or glWindowPos commands be supported?<br>
|
||||
@@ -3466,8 +3439,9 @@ Which image formats and types should be supported for <span
|
||||
style="font-weight: bold;">glTexImage2D</span> and <span
|
||||
style="font-weight: bold;">glReadPixels</span>?<br>
|
||||
<br>
|
||||
OpenGL supports a <span style="font-weight: bold;">large</span> variety
|
||||
of image formats and data types. Only a few are commonly used.<br>
|
||||
OpenGL specifies a <span style="font-weight: bold;">large</span>
|
||||
variety of image formats and data types. Only a few are commonly
|
||||
used.<br>
|
||||
<br>
|
||||
RECOMMENDATION: we propose a subset:<br>
|
||||
<br>
|
||||
@@ -3567,6 +3541,7 @@ be expressed as floating point values and queried with <span
|
||||
implementation of the other three commands involves many lines of code.<br>
|
||||
<br>
|
||||
RESOLUTION: open<br>
|
||||
<br>
|
||||
<h2>A.13 glBitmap and Per-Fragment Operations</h2>
|
||||
Should bitmaps rendered with <span style="font-weight: bold;">glBitmap</span>
|
||||
be subjected to the per-fragment operations?<br>
|
||||
@@ -3581,6 +3556,24 @@ easy.<br>
|
||||
<br>
|
||||
RESOLUTION: open<br>
|
||||
<br>
|
||||
<h2>A.14 Reduced gl.h Header File</h2>
|
||||
Should we produce a reduced gl.h header file which only defines the
|
||||
tokens and functions which are implemented by the subset?<br>
|
||||
<br>
|
||||
RECOMMENDATION: yes. It would be a useful reference to
|
||||
programmers to quickly determine which functions and tokens are
|
||||
supported.<br>
|
||||
<br>
|
||||
RESOLUTION: open<br>
|
||||
<br>
|
||||
<h2>A.15 glPolygonMode</h2>
|
||||
Is <span style="font-weight: bold;">glPolygonMode</span> needed?<br>
|
||||
<br>
|
||||
RECOMMENDATION: No. Omit it.<br>
|
||||
<br>
|
||||
RESOLUTION: closed, as of 26 Feb 2003<br>
|
||||
<br>
|
||||
<br>
|
||||
<p> </p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
*.tag
|
||||
array_cache
|
||||
core
|
||||
core_subset
|
||||
math
|
||||
math_subset
|
||||
miniglx
|
||||
radeon_subset
|
||||
swrast
|
||||
swrast_setup
|
||||
tnl
|
||||
|
||||
@@ -6,4 +6,5 @@ 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 either doxy/core/index.html or doxy/core_subset/index.html into
|
||||
your web browser.
|
||||
|
||||
@@ -55,7 +55,7 @@ INPUT = ../src/
|
||||
FILE_PATTERNS = *.c *.h
|
||||
RECURSIVE = NO
|
||||
EXCLUDE = ../src/glapitemp.h ../src/glapioffsets.h
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_PATTERNS = subset_*
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
@@ -132,13 +132,13 @@ GENERATE_AUTOGEN_DEF = NO
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH = ../include/
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
PREDEFINED = _HAVE_FULL_GL=1
|
||||
EXPAND_AS_DEFINED = _glthread_DECLARE_STATIC_MUTEX
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to external references
|
||||
@@ -148,8 +148,7 @@ TAGFILES = tnl_dd.tag=../tnl_dd \
|
||||
math.tag=../math \
|
||||
swrast.tag=../swrast \
|
||||
swrast_setup.tag=../swrast_setup \
|
||||
tnl.tag=../tnl \
|
||||
miniglx.tag=../miniglx
|
||||
tnl.tag=../tnl
|
||||
GENERATE_TAGFILE = core.tag
|
||||
ALLEXTERNALS = NO
|
||||
PERL_PATH =
|
||||
|
||||
226
doxygen/core_subset.doxy
Normal file
226
doxygen/core_subset.doxy
Normal file
@@ -0,0 +1,226 @@
|
||||
# Doxyfile 0.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# General configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = "Mesa Core"
|
||||
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 = YES
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
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 = subset
|
||||
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/
|
||||
FILE_PATTERNS = \
|
||||
accum.h \
|
||||
attrib.h \
|
||||
blend.[ch] \
|
||||
buffers.[ch] \
|
||||
dd.h \
|
||||
debug.h \
|
||||
depth.h \
|
||||
dlist.h \
|
||||
context.[ch] \
|
||||
config.h \
|
||||
colormac.h \
|
||||
colortab.h \
|
||||
enable.h \
|
||||
enums.h \
|
||||
eval.h \
|
||||
extensions.h \
|
||||
feedback.[ch] \
|
||||
fog.h \
|
||||
get.h \
|
||||
glheader.h \
|
||||
glthread.h \
|
||||
hash.[ch] \
|
||||
hint.h \
|
||||
histogram.h \
|
||||
image.[ch] \
|
||||
imports.[ch] \
|
||||
lines.[ch] \
|
||||
light.h \
|
||||
matrix.[ch] \
|
||||
macros.h \
|
||||
mmath.h \
|
||||
mtypes.h \
|
||||
pixel.h \
|
||||
points.[ch] \
|
||||
polygon.[ch] \
|
||||
rastpos.[ch] \
|
||||
simple_list.h \
|
||||
state.[ch] \
|
||||
stencil.[ch] \
|
||||
subset_*.c \
|
||||
texformat.h \
|
||||
teximage.h \
|
||||
texstate.h \
|
||||
texstore.h \
|
||||
texobj.[ch] \
|
||||
texutil_tmp.h \
|
||||
varray.h
|
||||
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 = YES
|
||||
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 = core_subset
|
||||
HTML_HEADER = header_subset.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 = \
|
||||
math_subset.tag=../math_subset \
|
||||
miniglx.tag=../miniglx
|
||||
GENERATE_TAGFILE = core_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 =
|
||||
@@ -3,7 +3,6 @@
|
||||
</head>
|
||||
<body><center>
|
||||
<a href="../core/index.html">Mesa Core</a>
|
||||
<a href="../miniglx/index.html">MiniGLX</a>
|
||||
<a href="../array_cache/index.html">array_cache</a>
|
||||
<a href="../math/index.html">math</a>
|
||||
<a href="../swrast/index.html">swrast</a>
|
||||
|
||||
9
doxygen/header_subset.html
Normal file
9
doxygen/header_subset.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html><head><title>Mesa Source Code Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body><center>
|
||||
<a href="../core_subset/index.html">Mesa Core</a>
|
||||
<a href="../math_subset/index.html">math</a>
|
||||
<a href="../miniglx/index.html">MiniGLX</a>
|
||||
<a href="../radeon_subset/index.html">radeon_subset</a>
|
||||
</center>
|
||||
@@ -1,11 +1,12 @@
|
||||
default:
|
||||
default: subset
|
||||
|
||||
full:
|
||||
doxygen tnl_dd.doxy
|
||||
doxygen array_cache.doxy
|
||||
doxygen math.doxy
|
||||
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
|
||||
@@ -14,10 +15,30 @@ default:
|
||||
doxygen swrast.doxy
|
||||
doxygen swrast_setup.doxy
|
||||
doxygen tnl.doxy
|
||||
doxygen miniglx.doxy
|
||||
doxygen core.doxy
|
||||
|
||||
subset:
|
||||
doxygen core_subset.doxy
|
||||
doxygen math_subset.doxy
|
||||
doxygen miniglx.doxy
|
||||
echo "Building again, to resolve tags"
|
||||
doxygen core_subset.doxy
|
||||
doxygen math_subset.doxy
|
||||
doxygen miniglx.doxy
|
||||
doxygen radeon_subset.doxy
|
||||
|
||||
clean:
|
||||
rm -rf array_cache core math swrast swrast_setup tnl_dd tnl miniglx
|
||||
rm -rf \
|
||||
array_cache \
|
||||
core \
|
||||
core_subset \
|
||||
math \
|
||||
math_subset \
|
||||
swrast \
|
||||
swrast_setup \
|
||||
tnl_dd \
|
||||
tnl \
|
||||
miniglx \
|
||||
radeon_subset
|
||||
rm -rf *.tag
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ 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
|
||||
|
||||
177
doxygen/math_subset.doxy
Normal file
177
doxygen/math_subset.doxy
Normal file
@@ -0,0 +1,177 @@
|
||||
# Doxyfile 0.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# General configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = "Mesa math module"
|
||||
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 = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
CASE_SENSE_NAMES = YES
|
||||
SHORT_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
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 = YES
|
||||
SHOW_USED_FILES = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = YES
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_FORMAT =
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../src/math/
|
||||
FILE_PATTERNS = m_matrix.[ch]
|
||||
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 = math_subset
|
||||
HTML_HEADER = header_subset.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_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES = core_subset.tag=../core_subset
|
||||
GENERATE_TAGFILE = math_subset.tag
|
||||
ALLEXTERNALS = NO
|
||||
PERL_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
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 =
|
||||
@@ -54,7 +54,7 @@ WARN_LOGFILE =
|
||||
INPUT = ../src/miniglx/ ../include/GL/miniglx.h
|
||||
FILE_PATTERNS = *.h *.c
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE = ../src/miniglx/glapi.c
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
@@ -80,7 +80,7 @@ IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = miniglx
|
||||
HTML_HEADER = header.html
|
||||
HTML_HEADER = header_subset.html
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
@@ -143,14 +143,9 @@ 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
|
||||
TAGFILES = \
|
||||
core_subset.tag=../core_subset \
|
||||
math_subset.tag=../math_subset
|
||||
GENERATE_TAGFILE = miniglx.tag
|
||||
ALLEXTERNALS = NO
|
||||
PERL_PATH =
|
||||
|
||||
203
doxygen/radeon_subset.doxy
Normal file
203
doxygen/radeon_subset.doxy
Normal file
@@ -0,0 +1,203 @@
|
||||
# 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_subset.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_subset.tag=../core_subset \
|
||||
math_subset.tag=../math_subset \
|
||||
miniglx.tag=../miniglx
|
||||
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 =
|
||||
@@ -1,10 +1,9 @@
|
||||
/* $Id: gl.h,v 1.72 2002/10/17 19:39:31 kschultz Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.1
|
||||
* Version: 5.0.1
|
||||
*
|
||||
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2003 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"),
|
||||
@@ -2646,6 +2645,13 @@ GLAPI void GLAPIENTRY glTracePointerRangeMESA( const GLvoid* first, const GLvoid
|
||||
#endif /* GL_APPLE_ycbcr_422 */
|
||||
|
||||
|
||||
#ifndef GL_ATI_texture_env_combine3
|
||||
#define GL_ATI_texture_env_combine3 1
|
||||
#define GL_MODULATE_ADD_ATI 0x8744
|
||||
#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
|
||||
#define GL_MODULATE_SUBTRACT_ATI 0x8746
|
||||
#endif
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Begin system-specific stuff
|
||||
|
||||
@@ -2423,6 +2423,11 @@ extern "C" {
|
||||
#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911
|
||||
#endif
|
||||
|
||||
#ifndef GL_ATI_texture_env_combine3
|
||||
#define GL_MODULATE_ADD_ATI 0x8744
|
||||
#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
|
||||
#define GL_MODULATE_SUBTRACT_ATI 0x8746
|
||||
#endif
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
@@ -5016,6 +5021,9 @@ GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum);
|
||||
typedef void (APIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ATI_texture_env_combine3
|
||||
#define GL_ATI_texture_env_combine3 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
PROGS = gears \
|
||||
glinfo \
|
||||
morph3d \
|
||||
texobj
|
||||
texobj \
|
||||
isosurf \
|
||||
bounce \
|
||||
terrain
|
||||
|
||||
|
||||
##### RULES #####
|
||||
@@ -13,12 +15,12 @@ PROGS = gears \
|
||||
|
||||
# make executable from .c file:
|
||||
.c: $(LIB_DEP)
|
||||
gcc -I../include -g $< -L../lib -lglut -lGL -lm -o $@
|
||||
gcc -I../include -I../util -g $< -L../lib -lglut -lGL -lGLU -lm -o $@
|
||||
|
||||
|
||||
default: $(PROGS)
|
||||
|
||||
|
||||
clean:
|
||||
-rm *.o *~
|
||||
-rm -f *.o *~ $(PROGS)
|
||||
|
||||
|
||||
@@ -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.2 2003/03/22 08:40:35 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,19 +111,19 @@ draw(void)
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glIndexi(CYAN);
|
||||
/* glIndexi(CYAN); */
|
||||
glColor3f(0, 1, 1);
|
||||
glBegin(GL_LINES);
|
||||
for (i = -5; i <= 5; i++) {
|
||||
glVertex2i(i, -5);
|
||||
glVertex2i(i, 5);
|
||||
glVertex2f(i, -5);
|
||||
glVertex2f(i, 5);
|
||||
}
|
||||
for (i = -5; i <= 5; i++) {
|
||||
glVertex2i(-5, i);
|
||||
glVertex2i(5, i);
|
||||
glVertex2f(-5, i);
|
||||
glVertex2f(5, i);
|
||||
}
|
||||
for (i = -5; i <= 5; i++) {
|
||||
glVertex2i(i, -5);
|
||||
glVertex2f(i, -5);
|
||||
glVertex2f(i * 1.15, -5.9);
|
||||
}
|
||||
glVertex2f(-5.3, -5.35);
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
/* glLightfv(GL_LIGHT0, GL_POSITION, pos); */
|
||||
glEnable(GL_CULL_FACE);
|
||||
/* 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);
|
||||
|
||||
|
||||
@@ -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.3 2003/04/07 22:27:23 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Display an isosurface of 3-D wind speed volume.
|
||||
@@ -37,52 +37,21 @@
|
||||
#define GL_GLEXT_LEGACY
|
||||
#include "GL/glut.h"
|
||||
|
||||
#include "readtex.c" /* I know, this is a hack. KW: me too. */
|
||||
#include "readtex.c"
|
||||
#define TEXTURE_FILE "../images/reflect.rgb"
|
||||
|
||||
#define LIT 0x00000001
|
||||
#define UNLIT 0x00000002
|
||||
#define REFLECT 0x00000004
|
||||
#define POINT_FILTER 0x00000008
|
||||
#define LINEAR_FILTER 0x00000010
|
||||
#define GLVERTEX 0x00000020
|
||||
#define DRAW_ELTS 0x00000040
|
||||
#define DRAW_ARRAYS 0x00000080
|
||||
#define ARRAY_ELT 0x00000100
|
||||
#define LOCKED 0x00000200
|
||||
#define UNLOCKED 0x00000400
|
||||
#define IMMEDIATE 0x00000800
|
||||
#define DISPLAYLIST 0x00001000
|
||||
#define SHADE_SMOOTH 0x00002000
|
||||
#define SHADE_FLAT 0x00004000
|
||||
#define TRIANGLES 0x00008000
|
||||
#define STRIPS 0x00010000
|
||||
#define POINTS 0x00020000
|
||||
#define USER_CLIP 0x00040000
|
||||
#define NO_USER_CLIP 0x00080000
|
||||
#define MATERIALS 0x00100000
|
||||
#define NO_MATERIALS 0x00200000
|
||||
#define FOG 0x00400000
|
||||
#define NO_FOG 0x00800000
|
||||
#define QUIT 0x01000000
|
||||
#define GLINFO 0x02000000
|
||||
#define STIPPLE 0x04000000
|
||||
#define NO_STIPPLE 0x08000000
|
||||
#define POLYGON_FILL 0x10000000
|
||||
#define POLYGON_LINE 0x20000000
|
||||
|
||||
#define LIGHT_MASK (LIT|UNLIT|REFLECT)
|
||||
#define FILTER_MASK (POINT_FILTER|LINEAR_FILTER)
|
||||
#define RENDER_STYLE_MASK (GLVERTEX|DRAW_ARRAYS|DRAW_ELTS|ARRAY_ELT)
|
||||
#define DLIST_MASK (IMMEDIATE|DISPLAYLIST)
|
||||
#define LOCK_MASK (LOCKED|UNLOCKED)
|
||||
#define MATERIAL_MASK (MATERIALS|NO_MATERIALS)
|
||||
#define PRIMITIVE_MASK (TRIANGLES|STRIPS|POINTS)
|
||||
#define CLIP_MASK (USER_CLIP|NO_USER_CLIP)
|
||||
#define SHADE_MASK (SHADE_SMOOTH|SHADE_FLAT)
|
||||
#define FOG_MASK (FOG|NO_FOG)
|
||||
#define STIPPLE_MASK (STIPPLE|NO_STIPPLE)
|
||||
#define POLYGON_MASK (POLYGON_FILL|POLYGON_LINE)
|
||||
|
||||
#define MAXVERTS 10000
|
||||
static GLint maxverts = MAXVERTS;
|
||||
@@ -147,27 +116,6 @@ static void read_surface( char *filename )
|
||||
|
||||
static void print_flags( const char *msg, GLuint flags )
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s (0x%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
|
||||
msg, flags,
|
||||
(flags & GLVERTEX) ? "glVertex, " : "",
|
||||
(flags & DRAW_ARRAYS) ? "glDrawArrays, " : "",
|
||||
(flags & DRAW_ELTS) ? "glDrawElements, " : "",
|
||||
(flags & ARRAY_ELT) ? "glArrayElement, " : "",
|
||||
(flags & LOCKED) ? "locked arrays, " : "",
|
||||
(flags & TRIANGLES) ? "GL_TRIANGLES, " : "",
|
||||
(flags & STRIPS) ? "GL_TRIANGLE_STRIP, " : "",
|
||||
(flags & POINTS) ? "GL_POINTS, " : "",
|
||||
(flags & DISPLAYLIST) ? "as a displaylist, " : "",
|
||||
(flags & LIT) ? "lit, " : "",
|
||||
(flags & UNLIT) ? "unlit, " : "",
|
||||
(flags & REFLECT) ? "reflect, " : "",
|
||||
(flags & SHADE_FLAT) ? "flat-shaded, " : "",
|
||||
(flags & USER_CLIP) ? "user_clip, " : "",
|
||||
(flags & MATERIALS) ? "materials, " : "",
|
||||
(flags & FOG) ? "fog, " : "",
|
||||
(flags & STIPPLE) ? "stipple, " : "",
|
||||
(flags & POLYGON_LINE) ? "polygon mode line, " : "");
|
||||
}
|
||||
|
||||
|
||||
@@ -372,150 +320,35 @@ static void draw_surface( unsigned int with_state )
|
||||
{
|
||||
GLint i, j;
|
||||
|
||||
if (with_state & DISPLAYLIST) {
|
||||
if ((with_state & (RENDER_STYLE_MASK|PRIMITIVE_MASK|MATERIAL_MASK)) !=
|
||||
dlist_state) {
|
||||
/*
|
||||
*/
|
||||
fprintf(stderr, "rebuilding displaylist\n");
|
||||
|
||||
if (dlist_state)
|
||||
glDeleteLists( surf1, 1 );
|
||||
switch (with_state & (PRIMITIVE_MASK)) {
|
||||
|
||||
dlist_state = with_state & (RENDER_STYLE_MASK|PRIMITIVE_MASK|
|
||||
MATERIAL_MASK);
|
||||
surf1 = glGenLists(1);
|
||||
glNewList(surf1, GL_COMPILE);
|
||||
draw_surface( dlist_state );
|
||||
glEndList();
|
||||
}
|
||||
|
||||
glCallList( surf1 );
|
||||
return;
|
||||
}
|
||||
|
||||
switch (with_state & (RENDER_STYLE_MASK|PRIMITIVE_MASK)) {
|
||||
#ifdef GL_EXT_vertex_array
|
||||
|
||||
case (DRAW_ELTS|TRIANGLES):
|
||||
if (with_state & MATERIALS) {
|
||||
for (j = i = 0 ; i < num_tri_verts ; i += 600, j++) {
|
||||
GLuint nr = MIN(num_tri_verts-i, 600);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
|
||||
glDrawElements( GL_TRIANGLES, nr, GL_UNSIGNED_INT, tri_indices+i );
|
||||
}
|
||||
} else {
|
||||
glDrawElements( GL_TRIANGLES, num_tri_verts, GL_UNSIGNED_INT,
|
||||
tri_indices );
|
||||
}
|
||||
break;
|
||||
|
||||
case (DRAW_ARRAYS|TRIANGLES):
|
||||
glDrawArraysEXT( GL_TRIANGLES, 0, (numverts-2)*3 );
|
||||
break;
|
||||
|
||||
case (ARRAY_ELT|TRIANGLES):
|
||||
if (with_state & MATERIALS) {
|
||||
for (j = i = 0 ; i < num_tri_verts ; i += 600, j++) {
|
||||
GLuint nr = MIN(num_tri_verts-i, 600);
|
||||
GLuint k;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
|
||||
glBegin( GL_TRIANGLES );
|
||||
for (k = 0 ; k < nr ; k++)
|
||||
glArrayElement( tri_indices[i+k] );
|
||||
glEnd();
|
||||
}
|
||||
} else {
|
||||
glBegin( GL_TRIANGLES );
|
||||
for (i = 0 ; i < num_tri_verts ; i++)
|
||||
glArrayElement( tri_indices[i] );
|
||||
|
||||
glEnd();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
/* Uses the original arrays (including duplicate elements):
|
||||
*/
|
||||
case (DRAW_ARRAYS|STRIPS):
|
||||
glDrawArraysEXT( GL_TRIANGLE_STRIP, 0, numverts );
|
||||
break;
|
||||
case (DRAW_ELTS|STRIPS):
|
||||
glDrawElements( GL_TRIANGLE_STRIP, numverts,
|
||||
GL_UNSIGNED_INT, strip_indices );
|
||||
break;
|
||||
|
||||
/* Uses the original arrays (including duplicate elements):
|
||||
*/
|
||||
case (ARRAY_ELT|STRIPS):
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i = 0 ; i < numverts ; i++)
|
||||
glArrayElement( i );
|
||||
glEnd();
|
||||
break;
|
||||
|
||||
case (DRAW_ARRAYS|POINTS):
|
||||
glDrawArraysEXT( GL_POINTS, 0, numuniq );
|
||||
break;
|
||||
case (DRAW_ELTS|POINTS):
|
||||
/* can use numuniq with strip_indices as strip_indices[i] == i.
|
||||
*/
|
||||
glDrawElements( GL_POINTS, numuniq,
|
||||
GL_UNSIGNED_INT, strip_indices );
|
||||
break;
|
||||
case (ARRAY_ELT|POINTS):
|
||||
/* just emit each unique element once:
|
||||
*/
|
||||
glBegin( GL_POINTS );
|
||||
for (i = 0 ; i < numuniq ; i++)
|
||||
glArrayElement( i );
|
||||
glEnd();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case (GLVERTEX|TRIANGLES):
|
||||
if (with_state & MATERIALS) {
|
||||
for (j = i = 0 ; i < num_tri_verts ; i += 600, j++) {
|
||||
GLuint nr = MIN(num_tri_verts-i, 600);
|
||||
GLuint k;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
|
||||
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] );
|
||||
glVertex3fv( &compressed_data[tri_indices[i+k]][0] );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
} else {
|
||||
case (0|TRIANGLES):
|
||||
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();
|
||||
}
|
||||
break;
|
||||
|
||||
case (GLVERTEX|POINTS):
|
||||
case (0|POINTS):
|
||||
/* Renders all points, but not in strip order... Shouldn't be a
|
||||
* problem, but people may be confused as to why points are so
|
||||
* much faster in this demo... And why cva doesn't help them...
|
||||
*/
|
||||
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();
|
||||
break;
|
||||
|
||||
case (GLVERTEX|STRIPS):
|
||||
case (0|STRIPS):
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i=0;i<numverts;i++) {
|
||||
glNormal3fv( &data[i][3] );
|
||||
glColor3fv( &data[i][0] );
|
||||
glVertex3fv( &data[i][0] );
|
||||
}
|
||||
glEnd();
|
||||
@@ -523,7 +356,7 @@ static void draw_surface( unsigned int with_state )
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unimplemented mode %x...\n",
|
||||
(with_state & (RENDER_STYLE_MASK|PRIMITIVE_MASK)));
|
||||
(with_state & (PRIMITIVE_MASK)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -595,24 +428,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); */
|
||||
}
|
||||
|
||||
|
||||
@@ -636,39 +469,6 @@ static void ModeMenu(int m)
|
||||
return;
|
||||
}
|
||||
|
||||
if (CHANGED(state, m, FILTER_MASK)) {
|
||||
UPDATE(state, m, FILTER_MASK);
|
||||
if (m & LINEAR_FILTER) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
} else {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGED(state, m, LIGHT_MASK)) {
|
||||
UPDATE(state, m, LIGHT_MASK);
|
||||
if (m & LIT) {
|
||||
glEnable(GL_LIGHTING);
|
||||
glDisable(GL_TEXTURE_GEN_S);
|
||||
glDisable(GL_TEXTURE_GEN_T);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
else if (m & UNLIT) {
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_TEXTURE_GEN_S);
|
||||
glDisable(GL_TEXTURE_GEN_T);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
else if (m & REFLECT) {
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_TEXTURE_GEN_S);
|
||||
glEnable(GL_TEXTURE_GEN_T);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGED(state, m, SHADE_MASK)) {
|
||||
UPDATE(state, m, SHADE_MASK);
|
||||
if (m & SHADE_SMOOTH)
|
||||
@@ -678,136 +478,12 @@ static void ModeMenu(int m)
|
||||
}
|
||||
|
||||
|
||||
if (CHANGED(state, m, CLIP_MASK)) {
|
||||
UPDATE(state, m, CLIP_MASK);
|
||||
if (m & USER_CLIP) {
|
||||
glEnable(GL_CLIP_PLANE0);
|
||||
} else {
|
||||
glDisable(GL_CLIP_PLANE0);
|
||||
}
|
||||
|
||||
if (m & (PRIMITIVE_MASK)) {
|
||||
UPDATE(state, m, (PRIMITIVE_MASK));
|
||||
}
|
||||
|
||||
if (CHANGED(state, m, FOG_MASK)) {
|
||||
UPDATE(state, m, FOG_MASK);
|
||||
if (m & FOG) {
|
||||
glEnable(GL_FOG);
|
||||
}
|
||||
else {
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGED(state, m, STIPPLE_MASK)) {
|
||||
UPDATE(state, m, STIPPLE_MASK);
|
||||
if (m & STIPPLE) {
|
||||
glEnable(GL_POLYGON_STIPPLE);
|
||||
}
|
||||
else {
|
||||
glDisable(GL_POLYGON_STIPPLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGED(state, m, POLYGON_MASK)) {
|
||||
UPDATE(state, m, POLYGON_MASK);
|
||||
if (m & POLYGON_FILL) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
else {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GL_EXT_vertex_array
|
||||
if (CHANGED(state, m, (LOCK_MASK|RENDER_STYLE_MASK|PRIMITIVE_MASK)))
|
||||
{
|
||||
if (m & (PRIMITIVE_MASK)) {
|
||||
UPDATE(state, m, (PRIMITIVE_MASK));
|
||||
}
|
||||
|
||||
if (m & (RENDER_STYLE_MASK)) {
|
||||
UPDATE(state, m, (RENDER_STYLE_MASK));
|
||||
}
|
||||
|
||||
if (m & LOCK_MASK) {
|
||||
UPDATE(state, m, (LOCK_MASK));
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
if (m & DLIST_MASK) {
|
||||
UPDATE(state, m, DLIST_MASK);
|
||||
}
|
||||
|
||||
if (m & MATERIAL_MASK) {
|
||||
UPDATE(state, m, MATERIAL_MASK);
|
||||
}
|
||||
|
||||
print_flags("new flags", state);
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
@@ -827,9 +503,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 +513,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;
|
||||
@@ -864,24 +540,17 @@ static void Init(int argc, char *argv[])
|
||||
expand_arrays();
|
||||
make_tri_indices();
|
||||
|
||||
if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
|
||||
printf("Error: couldn't load texture image\n");
|
||||
exit(1);
|
||||
}
|
||||
/* if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { */
|
||||
/* printf("Error: couldn't load texture image\n"); */
|
||||
/* exit(1); */
|
||||
/* } */
|
||||
}
|
||||
}
|
||||
|
||||
ModeMenu(SHADE_SMOOTH|
|
||||
LIT|
|
||||
POINT_FILTER|
|
||||
NO_USER_CLIP|
|
||||
NO_MATERIALS|
|
||||
NO_FOG|
|
||||
NO_STIPPLE|
|
||||
IMMEDIATE|
|
||||
STRIPS|
|
||||
UNLOCKED|
|
||||
GLVERTEX);
|
||||
TRIANGLES|
|
||||
0);
|
||||
|
||||
if (PrintInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
@@ -907,30 +576,9 @@ static void Key( unsigned char key, int x, int y )
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(0);
|
||||
case 'f':
|
||||
ModeMenu((state ^ FOG_MASK) & FOG_MASK);
|
||||
break;
|
||||
case 's':
|
||||
ModeMenu((state ^ SHADE_MASK) & SHADE_MASK);
|
||||
break;
|
||||
case 't':
|
||||
ModeMenu((state ^ STIPPLE_MASK) & STIPPLE_MASK);
|
||||
break;
|
||||
case 'l':
|
||||
ModeMenu((state ^ LIGHT_MASK) & (LIT|UNLIT));
|
||||
break;
|
||||
case 'm':
|
||||
ModeMenu((state ^ MATERIAL_MASK) & MATERIAL_MASK);
|
||||
break;
|
||||
case 'c':
|
||||
ModeMenu((state ^ CLIP_MASK) & CLIP_MASK);
|
||||
break;
|
||||
case 'v':
|
||||
ModeMenu((LOCKED|IMMEDIATE|DRAW_ELTS|TRIANGLES) & allowed);
|
||||
break;
|
||||
case 'V':
|
||||
ModeMenu(UNLOCKED|IMMEDIATE|GLVERTEX|STRIPS);
|
||||
break;
|
||||
case 'b':
|
||||
Benchmark(5.0, 0);
|
||||
break;
|
||||
@@ -947,24 +595,6 @@ static void Key( unsigned char key, int x, int y )
|
||||
set_matrix();
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case '-':
|
||||
case '_':
|
||||
plane[3] += 2.0;
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glClipPlane(GL_CLIP_PLANE0, plane);
|
||||
set_matrix();
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case '+':
|
||||
case '=':
|
||||
plane[3] -= 2.0;
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glClipPlane(GL_CLIP_PLANE0, plane);
|
||||
set_matrix();
|
||||
glutPostRedisplay();
|
||||
break;
|
||||
case ' ':
|
||||
Init(0,0);
|
||||
break;
|
||||
@@ -1058,16 +688,6 @@ int main(int argc, char **argv)
|
||||
/* Make sure server supports the vertex array extension */
|
||||
extensions = (char *) glGetString( GL_EXTENSIONS );
|
||||
|
||||
if (!strstr( extensions, "GL_EXT_vertex_array" ))
|
||||
{
|
||||
printf("Vertex arrays not supported by this renderer\n");
|
||||
allowed &= ~(LOCKED|DRAW_ARRAYS|DRAW_ELTS|ARRAY_ELT);
|
||||
}
|
||||
else if (!strstr( extensions, "GL_EXT_compiled_vertex_array" ))
|
||||
{
|
||||
printf("Compiled vertex arrays not supported by this renderer\n");
|
||||
allowed &= ~LOCKED;
|
||||
}
|
||||
|
||||
Init(argc, argv);
|
||||
ModeMenu(arg_mode);
|
||||
@@ -1075,43 +695,15 @@ int main(int argc, char **argv)
|
||||
glutCreateMenu(ModeMenu);
|
||||
glutAddMenuEntry("GL info", GLINFO);
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("Lit", LIT);
|
||||
glutAddMenuEntry("Unlit", UNLIT);
|
||||
glutAddMenuEntry("Reflect", REFLECT);
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("Smooth", SHADE_SMOOTH);
|
||||
glutAddMenuEntry("Flat", SHADE_FLAT);
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("Fog", FOG);
|
||||
glutAddMenuEntry("No Fog", NO_FOG);
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("Stipple", STIPPLE);
|
||||
glutAddMenuEntry("No Stipple", NO_STIPPLE);
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("Polygon Mode Fill", POLYGON_FILL);
|
||||
glutAddMenuEntry("Polygon Mode Line", POLYGON_LINE);
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("Point Filtered", POINT_FILTER);
|
||||
glutAddMenuEntry("Linear Filtered", LINEAR_FILTER);
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("GL_TRIANGLES", TRIANGLES);
|
||||
glutAddMenuEntry("GL_TRIANGLE_STRIPS", STRIPS);
|
||||
glutAddMenuEntry("GL_POINTS", POINTS);
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("Displaylist", DISPLAYLIST);
|
||||
glutAddMenuEntry("Immediate", IMMEDIATE);
|
||||
glutAddMenuEntry("", 0);
|
||||
if (allowed & LOCKED) {
|
||||
glutAddMenuEntry("Locked Arrays (CVA)", LOCKED);
|
||||
glutAddMenuEntry("Unlocked Arrays", UNLOCKED);
|
||||
glutAddMenuEntry("", 0);
|
||||
}
|
||||
glutAddMenuEntry("glVertex", GLVERTEX);
|
||||
if (allowed & DRAW_ARRAYS) {
|
||||
glutAddMenuEntry("glDrawElements", DRAW_ELTS);
|
||||
glutAddMenuEntry("glDrawArrays", DRAW_ARRAYS);
|
||||
glutAddMenuEntry("glArrayElement", ARRAY_ELT);
|
||||
}
|
||||
glutAddMenuEntry("", 0);
|
||||
glutAddMenuEntry("Quit", QUIT);
|
||||
glutAttachMenu(GLUT_RIGHT_BUTTON);
|
||||
@@ -1121,6 +713,9 @@ int main(int argc, char **argv)
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Display);
|
||||
|
||||
Benchmark(5,0);
|
||||
Benchmark(5,0);
|
||||
Benchmark(5,0);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -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,23 @@ 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,
|
||||
GL_UNSIGNED_BYTE,
|
||||
(GLvoid *) (&terrainpic[0])))) {
|
||||
fprintf(stderr, "GLULib%s\n", (char *) gluErrorString(gluerr));
|
||||
exit(-1);
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GL_RGBA, 256, 256, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, (GLvoid *) terrainpic);
|
||||
|
||||
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,
|
||||
GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_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 +699,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);
|
||||
|
||||
@@ -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.2 2003/03/22 08:40:35 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 );
|
||||
|
||||
@@ -50,7 +50,7 @@ static void draw( void )
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
glCallList( TexObj[0] );
|
||||
/* glCallList( TexObj[0] ); */
|
||||
}
|
||||
glBegin( GL_POLYGON );
|
||||
glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 );
|
||||
@@ -70,7 +70,7 @@ static void draw( void )
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
glCallList( TexObj[1] );
|
||||
/* glCallList( TexObj[1] ); */
|
||||
}
|
||||
glBegin( GL_POLYGON );
|
||||
glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 );
|
||||
@@ -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 */
|
||||
@@ -166,19 +166,19 @@ static void init( void )
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
TexObj[0] = glGenLists(2);
|
||||
TexObj[1] = TexObj[0]+1;
|
||||
/* TexObj[0] = glGenLists(2); */
|
||||
/* TexObj[1] = TexObj[0]+1; */
|
||||
}
|
||||
|
||||
/* setup first texture object */
|
||||
if (UseObj) {
|
||||
#ifdef TEXTURE_OBJECT
|
||||
glBindTexture( GL_TEXTURE_2D, TexObj[0] );
|
||||
assert(glIsTexture(TexObj[0]));
|
||||
/* assert(glIsTexture(TexObj[0])); */
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
glNewList( TexObj[0], GL_COMPILE );
|
||||
/* glNewList( TexObj[0], GL_COMPILE ); */
|
||||
}
|
||||
/* red on white */
|
||||
for (i=0;i<height;i++) {
|
||||
@@ -190,17 +190,18 @@ 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 );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
||||
if (!UseObj) {
|
||||
glEndList();
|
||||
/* glEndList(); */
|
||||
}
|
||||
/* end of texture object */
|
||||
|
||||
@@ -208,12 +209,12 @@ 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 );
|
||||
/* glNewList( TexObj[1], GL_COMPILE ); */
|
||||
}
|
||||
/* green on blue */
|
||||
for (i=0;i<height;i++) {
|
||||
@@ -227,14 +228,14 @@ 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 );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
|
||||
if (!UseObj) {
|
||||
glEndList();
|
||||
/* glEndList(); */
|
||||
}
|
||||
/* end texture object */
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
30
progs/samples/Makefile
Normal file
30
progs/samples/Makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
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 -lGLU -lm -o $@
|
||||
|
||||
|
||||
default: $(PROGS)
|
||||
|
||||
|
||||
clean: clean_here
|
||||
|
||||
clean_here:
|
||||
rm -f *.o *~ $(PROGS)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ static void Init(void)
|
||||
GLint i;
|
||||
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClearIndex(0.0);
|
||||
/* glClearIndex(0.0); */
|
||||
|
||||
if (!rgb) {
|
||||
for (i = 0; i < 16; i++) {
|
||||
@@ -71,7 +71,7 @@ static void Init(void)
|
||||
}
|
||||
}
|
||||
|
||||
glPolygonStipple(stippleBits);
|
||||
/* glPolygonStipple(stippleBits); */
|
||||
|
||||
antiAlias = GL_FALSE;
|
||||
stipple = GL_FALSE;
|
||||
@@ -135,11 +135,11 @@ static void Draw(void)
|
||||
}
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
(rgb) ? glColor3fv(RGBMap[COLOR_BLUE]) : glIndexi(ci1);
|
||||
glColor3fv(RGBMap[COLOR_BLUE]);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
(rgb) ? glColor3fv(RGBMap[COLOR_GREEN]) : glIndexi(ci2);
|
||||
glColor3fv(RGBMap[COLOR_GREEN]);
|
||||
glVertex3f(-0.9, -0.9, -40.0);
|
||||
glVertex3f(-0.9, 0.9, -40.0);
|
||||
glVertex3f( 0.9, 0.0, -25.0);
|
||||
|
||||
@@ -141,13 +141,13 @@ static void Draw(void)
|
||||
for (i = 0; i < 360; i += 5) {
|
||||
glRotatef(5.0, 0,0,1);
|
||||
|
||||
(rgb) ? glColor3f(1.0, 1.0, 0.0) : glIndexi(ci);
|
||||
glColor3f(1.0, 1.0, 0.0);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(pntA);
|
||||
glVertex3fv(pntB);
|
||||
glEnd();
|
||||
|
||||
glPointSize(1);
|
||||
/* glPointSize(1); */
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
glBegin(GL_POINTS);
|
||||
@@ -199,7 +199,7 @@ int main(int argc, char **argv)
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300);
|
||||
|
||||
windType = (rgb) ? GLUT_RGB : GLUT_INDEX;
|
||||
windType = GLUT_RGB;
|
||||
windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(windType);
|
||||
|
||||
|
||||
@@ -151,11 +151,11 @@ 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);
|
||||
glColor3f(1.0, 0.0, 0.0);
|
||||
} else {
|
||||
(rgb) ? glColor3f(1.0, 0.0, 0.0) : glIndexf(CI_RED);
|
||||
glColor3f(1.0, 0.0, 0.0);
|
||||
}
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3fv(point);
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
@@ -126,18 +126,18 @@ static void Point(void)
|
||||
|
||||
glBegin(GL_POINTS);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2f(0, 0);
|
||||
for (i = 1; i < 8; i++) {
|
||||
GLint j = i * 2;
|
||||
SetColor(COLOR_BLACK+i);
|
||||
glVertex2i(-j, -j);
|
||||
glVertex2i(-j, 0);
|
||||
glVertex2i(-j, j);
|
||||
glVertex2i(0, j);
|
||||
glVertex2i(j, j);
|
||||
glVertex2i(j, 0);
|
||||
glVertex2i(j, -j);
|
||||
glVertex2i(0, -j);
|
||||
glVertex2f(-j, -j);
|
||||
glVertex2f(-j, 0);
|
||||
glVertex2f(-j, j);
|
||||
glVertex2f(0, j);
|
||||
glVertex2f(j, j);
|
||||
glVertex2f(j, 0);
|
||||
glVertex2f(j, -j);
|
||||
glVertex2f(0, -j);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
@@ -152,8 +152,8 @@ static void Lines(void)
|
||||
for (i = 1; i < 8; i++) {
|
||||
SetColor(COLOR_BLACK+i);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
glVertex2i(boxW/4, boxH/4);
|
||||
glVertex2f(-boxW/4, -boxH/4);
|
||||
glVertex2f(boxW/4, boxH/4);
|
||||
glEnd();
|
||||
glTranslatef(4, 0, 0);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ static void Lines(void)
|
||||
glPopMatrix();
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2f(0, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ static void LineStrip(void)
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2f(0, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -218,11 +218,11 @@ static void LineLoop(void)
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2f(0, 0);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2f(0, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -231,16 +231,16 @@ static void Bitmap(void)
|
||||
|
||||
glBegin(GL_LINES);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/2, 0);
|
||||
glVertex2i(boxW/2, 0);
|
||||
glVertex2i(0, -boxH/2);
|
||||
glVertex2i(0, boxH/2);
|
||||
glVertex2f(-boxW/2, 0);
|
||||
glVertex2f(boxW/2, 0);
|
||||
glVertex2f(0, -boxH/2);
|
||||
glVertex2f(0, boxH/2);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(0, -3);
|
||||
glVertex2i(0, -3+OPENGL_HEIGHT);
|
||||
glVertex2f(0, -3);
|
||||
glVertex2f(0, -3+OPENGL_HEIGHT);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(0, -3);
|
||||
glVertex2i(OPENGL_WIDTH, -3);
|
||||
glVertex2f(0, -3);
|
||||
glVertex2f(OPENGL_WIDTH, -3);
|
||||
glEnd();
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
@@ -257,23 +257,23 @@ static void Triangles(void)
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
glVertex2f(-boxW/4, -boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/8, -boxH/16);
|
||||
glVertex2f(-boxW/8, -boxH/16);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(boxW/8, -boxH/16);
|
||||
glVertex2f(boxW/8, -boxH/16);
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, boxH/4);
|
||||
glVertex2f(-boxW/4, boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/8, boxH/16);
|
||||
glVertex2f(-boxW/8, boxH/16);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(boxW/8, boxH/16);
|
||||
glVertex2f(boxW/8, boxH/16);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(-100, 100);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -282,28 +282,28 @@ static void TriangleStrip(void)
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
glVertex2f(-boxW/4, -boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/4, boxH/4);
|
||||
glVertex2f(-boxW/4, boxH/4);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(0, -boxH/4);
|
||||
glVertex2f(0, -boxH/4);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(0, boxH/4);
|
||||
glVertex2f(0, boxH/4);
|
||||
SetColor(COLOR_CYAN);
|
||||
glVertex2i(boxW/4, -boxH/4);
|
||||
glVertex2f(boxW/4, -boxH/4);
|
||||
SetColor(COLOR_YELLOW);
|
||||
glVertex2i(boxW/4, boxH/4);
|
||||
glVertex2f(boxW/4, boxH/4);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(-100, 100);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void TriangleFan(void)
|
||||
{
|
||||
GLint vx[8][2];
|
||||
GLfloat vx[8][2];
|
||||
GLint x0, y0, x1, y1, x2, y2, x3, y3;
|
||||
GLint i;
|
||||
|
||||
@@ -327,16 +327,16 @@ static void TriangleFan(void)
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2f(0, 0);
|
||||
for (i = 0; i < 8; i++) {
|
||||
SetColor(COLOR_WHITE-i);
|
||||
glVertex2iv(vx[i]);
|
||||
glVertex2fv(vx[i]);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(-100, 100);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -344,12 +344,12 @@ 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)
|
||||
{
|
||||
GLint vx[8][2];
|
||||
GLfloat vx[8][2];
|
||||
GLint x0, y0, x1, y1, x2, y2, x3, y3;
|
||||
GLint i;
|
||||
|
||||
@@ -374,13 +374,13 @@ static void PolygonFunc(void)
|
||||
glBegin(GL_POLYGON);
|
||||
for (i = 0; i < 8; i++) {
|
||||
SetColor(COLOR_WHITE-i);
|
||||
glVertex2iv(vx[i]);
|
||||
glVertex2fv(vx[i]);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(100, 100);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -389,28 +389,28 @@ static void Quads(void)
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
glVertex2f(-boxW/4, -boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/8, -boxH/16);
|
||||
glVertex2f(-boxW/8, -boxH/16);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(boxW/8, -boxH/16);
|
||||
glVertex2f(boxW/8, -boxH/16);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(boxW/4, -boxH/4);
|
||||
glVertex2f(boxW/4, -boxH/4);
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, boxH/4);
|
||||
glVertex2f(-boxW/4, boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/8, boxH/16);
|
||||
glVertex2f(-boxW/8, boxH/16);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(boxW/8, boxH/16);
|
||||
glVertex2f(boxW/8, boxH/16);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(boxW/4, boxH/4);
|
||||
glVertex2f(boxW/4, boxH/4);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(100, 100);
|
||||
glVertex2i(-100, 100);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(100, 100);
|
||||
glVertex2f(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -419,41 +419,43 @@ static void QuadStrip(void)
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
glVertex2f(-boxW/4, -boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/4, boxH/4);
|
||||
glVertex2f(-boxW/4, boxH/4);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(0, -boxH/4);
|
||||
glVertex2f(0, -boxH/4);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(0, boxH/4);
|
||||
glVertex2f(0, boxH/4);
|
||||
SetColor(COLOR_CYAN);
|
||||
glVertex2i(boxW/4, -boxH/4);
|
||||
glVertex2f(boxW/4, -boxH/4);
|
||||
SetColor(COLOR_YELLOW);
|
||||
glVertex2i(boxW/4, boxH/4);
|
||||
glVertex2f(boxW/4, boxH/4);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(100, 100);
|
||||
glVertex2i(-100, 100);
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(100, 100);
|
||||
glVertex2f(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
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 +463,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 +480,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();
|
||||
|
||||
|
||||
@@ -255,7 +255,6 @@ static void Key(unsigned char key, int x, int y)
|
||||
|
||||
void Draw(void)
|
||||
{
|
||||
|
||||
MoveStars();
|
||||
ShowStars();
|
||||
if (nitro > 0) {
|
||||
|
||||
@@ -26,8 +26,8 @@ static void SetColor(int c)
|
||||
{
|
||||
if (glutGet(GLUT_WINDOW_RGBA))
|
||||
glColor3fv(RGBMap[c]);
|
||||
else
|
||||
glIndexf(c);
|
||||
/* else */
|
||||
/* glIndexf(c); */
|
||||
}
|
||||
|
||||
static void InitMap(void)
|
||||
|
||||
@@ -278,12 +278,12 @@ static void Draw(void)
|
||||
EndPrim();
|
||||
|
||||
if (showVerticies) {
|
||||
(rgb) ? glColor3fv(RGBMap[COLOR_RED]) : glIndexf(color1);
|
||||
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);
|
||||
(rgb) ? glColor3fv(RGBMap[COLOR_BLUE]) : glIndexf(color3);
|
||||
glRectf(p2[0]-2, p2[1]-2, p2[0]+2, p2[1]+2);
|
||||
glColor3fv(RGBMap[COLOR_RED]);
|
||||
/* glRectf(p0[0]-2, p0[1]-2, p0[0]+2, p0[1]+2); */
|
||||
glColor3fv(RGBMap[COLOR_GREEN]);
|
||||
/* glRectf(p1[0]-2, p1[1]-2, p1[0]+2, p1[1]+2); */
|
||||
glColor3fv(RGBMap[COLOR_BLUE]);
|
||||
/* 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);
|
||||
@@ -314,15 +314,15 @@ static void Draw(void)
|
||||
|
||||
SetColor(COLOR_RED);
|
||||
BeginPrim();
|
||||
(rgb) ? glColor3fv(RGBMap[COLOR_RED]) : glIndexf(color1);
|
||||
glColor3fv(RGBMap[COLOR_RED]);
|
||||
glVertex3fv(p0);
|
||||
(rgb) ? glColor3fv(RGBMap[COLOR_GREEN]) : glIndexf(color2);
|
||||
glColor3fv(RGBMap[COLOR_GREEN]);
|
||||
glVertex3fv(p1);
|
||||
(rgb) ? glColor3fv(RGBMap[COLOR_BLUE]) : glIndexf(color3);
|
||||
glColor3fv(RGBMap[COLOR_BLUE]);
|
||||
glVertex3fv(p2);
|
||||
EndPrim();
|
||||
|
||||
glPointSize(1);
|
||||
/* glPointSize(1); */
|
||||
glLineWidth(1);
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -g -I../include
|
||||
LIBS = -L../lib -lGL -lm
|
||||
LIBS = -L../lib -lGL -lGLU -lglut -lm
|
||||
|
||||
PROGS = miniglxtest miniglxsample
|
||||
PROGS = miniglxtest miniglxsample manytex texline
|
||||
|
||||
|
||||
##### RULES #####
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: manytex.c,v 1.4 2002/10/18 17:47:36 kschultz Exp $ */
|
||||
/* $Id: manytex.c,v 1.4.4.1 2003/03/22 08:46:22 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* test handling of many texture maps
|
||||
@@ -191,8 +191,8 @@ static void Init( void )
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, TextureID[i]);
|
||||
|
||||
if (i < LowPriorityCount)
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0.5F);
|
||||
/* if (i < LowPriorityCount) */
|
||||
/* glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 0.5F); */
|
||||
|
||||
if (RandomSize) {
|
||||
#if 0
|
||||
|
||||
127
progs/tests/miniglxsample.c
Normal file
127
progs/tests/miniglxsample.c
Normal file
@@ -0,0 +1,127 @@
|
||||
|
||||
#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);
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: miniglxtest.c,v 1.1.4.6 2003/01/20 11:25:50 keithw Exp $ */
|
||||
/* $Id: miniglxtest.c,v 1.1.4.9 2003/03/24 18:46:57 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Test the mini GLX interface.
|
||||
@@ -22,6 +22,19 @@
|
||||
|
||||
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");
|
||||
@@ -46,7 +59,7 @@ static void redraw( Display *dpy, Window w, int rot )
|
||||
glPushMatrix();
|
||||
glRotatef(rot, 0, 0, 1);
|
||||
glScalef(.5, .5, .5);
|
||||
glRectf( -1, -1, 1, 1 );
|
||||
_subset_Rectf( -1, -1, 1, 1 );
|
||||
glPopMatrix();
|
||||
#endif
|
||||
|
||||
@@ -109,6 +122,8 @@ static Window make_rgb_db_window( Display *dpy,
|
||||
|
||||
glXMakeCurrent( dpy, win, ctx );
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
@@ -148,7 +163,6 @@ int foo( )
|
||||
|
||||
XMapWindow( dpy, win );
|
||||
|
||||
#if !USE_MINI_GLX
|
||||
{
|
||||
XEvent e;
|
||||
while (1) {
|
||||
@@ -158,8 +172,6 @@ int foo( )
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
event_loop( dpy, win );
|
||||
|
||||
|
||||
115
progs/tests/sample_server.c
Normal file
115
progs/tests/sample_server.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/* $Id: sample_server.c,v 1.1.2.1 2003/04/16 09:34:56 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Sample server that just keeps first available window mapped.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/miniglx.h>
|
||||
|
||||
struct client {
|
||||
struct client *next;
|
||||
Window windowid;
|
||||
int mappable;
|
||||
};
|
||||
|
||||
struct client *clients = 0, *mapped_client = 0;
|
||||
|
||||
|
||||
static struct client *find_client( Window id )
|
||||
{
|
||||
struct client *c;
|
||||
|
||||
for (c = clients ; c ; c = c->next)
|
||||
if (c->windowid == id)
|
||||
return c;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
Display *dpy;
|
||||
XEvent ev;
|
||||
|
||||
dpy = __miniglx_StartServer(NULL);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "Error: __miniglx_StartServer failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* How is vt switching communicated through the XNextEvent interface?
|
||||
*/
|
||||
|
||||
while (XNextEvent( dpy, &ev )) {
|
||||
struct client *c;
|
||||
|
||||
switch (ev.type) {
|
||||
case MapRequest:
|
||||
fprintf(stderr, "MapRequest\n");
|
||||
c = find_client(ev.xmaprequest.window);
|
||||
if (!c) break;
|
||||
c->mappable = True;
|
||||
break;
|
||||
|
||||
case UnmapNotify:
|
||||
fprintf(stderr, "UnmapNotify\n");
|
||||
c = find_client(ev.xunmap.window);
|
||||
if (!c) break;
|
||||
c->mappable = False;
|
||||
if (c == mapped_client)
|
||||
mapped_client = 0;
|
||||
break;
|
||||
|
||||
case CreateNotify:
|
||||
fprintf(stderr, "CreateNotify\n");
|
||||
c = malloc(sizeof(*c));
|
||||
c->next = clients;
|
||||
c->windowid = ev.xcreatewindow.window;
|
||||
c->mappable = False;
|
||||
clients = c;
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
fprintf(stderr, "DestroyNotify\n");
|
||||
c = find_client(ev.xdestroywindow.window);
|
||||
if (!c) break;
|
||||
if (c == clients)
|
||||
clients = c->next;
|
||||
else {
|
||||
struct client *t;
|
||||
for (t = clients ; t->next != c ; t = t->next)
|
||||
;
|
||||
t->next = c->next;
|
||||
}
|
||||
|
||||
if (c == mapped_client)
|
||||
mapped_client = 0;
|
||||
|
||||
free(c);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Search for first mappable client if none already mapped.
|
||||
*/
|
||||
if (!mapped_client) {
|
||||
for (c = clients ; c ; c = c->next) {
|
||||
if (c->mappable) {
|
||||
XMapWindow( dpy, c->windowid );
|
||||
mapped_client = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCloseDisplay( dpy );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: texline.c,v 1.4 2002/08/17 00:30:36 brianp Exp $ */
|
||||
/* $Id: texline.c,v 1.4.6.1 2003/03/22 08:46:22 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Test textured lines.
|
||||
@@ -59,7 +59,7 @@ static void Display( void )
|
||||
y = t * 2.0 - 1.0;
|
||||
if (!Texture)
|
||||
glColor3f(1, 0, 1);
|
||||
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t, s);
|
||||
/* glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t, s); */
|
||||
glTexCoord2f(s, t);
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
@@ -73,12 +73,12 @@ static void Display( void )
|
||||
if (!Texture)
|
||||
glColor3f(1, 0, 1);
|
||||
glTexCoord2f(t, 0.0);
|
||||
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, t);
|
||||
/* glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, t); */
|
||||
glVertex2f(x, -1.0);
|
||||
if (!Texture)
|
||||
glColor3f(0, 1, 0);
|
||||
glTexCoord2f(t, 1.0);
|
||||
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, t);
|
||||
/* glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, t); */
|
||||
glVertex2f(x, 1.0);
|
||||
}
|
||||
glEnd();
|
||||
@@ -127,22 +127,22 @@ static void Key( unsigned char key, int x, int y )
|
||||
if (Texture > 2)
|
||||
Texture = 0;
|
||||
if (Texture == 0) {
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
/* glActiveTextureARB(GL_TEXTURE0_ARB); */
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
/* glActiveTextureARB(GL_TEXTURE1_ARB); */
|
||||
/* glDisable(GL_TEXTURE_2D); */
|
||||
}
|
||||
else if (Texture == 1) {
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
/* glActiveTextureARB(GL_TEXTURE0_ARB); */
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
/* glActiveTextureARB(GL_TEXTURE1_ARB); */
|
||||
/* glDisable(GL_TEXTURE_2D); */
|
||||
}
|
||||
else {
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTextureARB(GL_TEXTURE1_ARB);
|
||||
/* glActiveTextureARB(GL_TEXTURE0_ARB); */
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
/* glActiveTextureARB(GL_TEXTURE1_ARB); */
|
||||
/* glEnable(GL_TEXTURE_2D); */
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
@@ -212,8 +212,8 @@ static void SpecialKey( int key, int x, int y )
|
||||
static void Init( int argc, char *argv[] )
|
||||
{
|
||||
GLuint u;
|
||||
for (u = 0; u < 2; u++) {
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + u);
|
||||
for (u = 0; u < 1; u++) {
|
||||
/* glActiveTextureARB(GL_TEXTURE0_ARB + u); */
|
||||
glBindTexture(GL_TEXTURE_2D, 10+u);
|
||||
if (u == 0)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
37
src/dri-es/Makefile
Normal file
37
src/dri-es/Makefile
Normal 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
472
src/dri-es/dri_glx.c
Normal 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
59
src/dri-es/dri_glx.h
Normal 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
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
375
src/dri-es/dri_util.h
Normal 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
474
src/dri-es/drm.h
Normal 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
224
src/dri-es/extutil.h
Normal 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
678
src/dri-es/glxclient.h
Normal 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
80
src/dri-es/sarea.h
Normal 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
227
src/dri-es/xf86dri.h
Normal 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
343
src/dri-es/xf86dristr.h
Normal 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
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
607
src/dri-es/xf86drm.h
Normal 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
435
src/dri-es/xf86drmHash.c
Normal 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
219
src/dri-es/xf86drmRandom.c
Normal 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
490
src/dri-es/xf86drmSL.c
Normal 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
|
||||
7
src/glu/mini/.cvsignore
Normal file
7
src/glu/mini/.cvsignore
Normal file
@@ -0,0 +1,7 @@
|
||||
.deps
|
||||
.libs
|
||||
Makefile.in
|
||||
*.lo
|
||||
*.o
|
||||
*.la
|
||||
depend
|
||||
46
src/glu/mini/Makefile
Normal file
46
src/glu/mini/Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
|
||||
MESA = ../..
|
||||
default: libGLU.so.1.1 install
|
||||
include $(MESA)/Makefile.include
|
||||
|
||||
LIBDIR = $(MESA)/lib
|
||||
|
||||
INCLUDES = -I$(MESA)/include
|
||||
CFLAGS = -c -g $(INCLUDES) -MD
|
||||
|
||||
SOURCES = glu.c \
|
||||
mipmap.c \
|
||||
nurbs.c \
|
||||
polytest.c \
|
||||
project.c \
|
||||
quadric.c \
|
||||
tess.c \
|
||||
tesselat.c
|
||||
|
||||
|
||||
OBJS = $(addsuffix .o,$(basename $(SOURCES)))
|
||||
|
||||
LIBS=-L$(MESA)/lib -lGL -lm
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
libGLU.so.1.1: $(OBJS) Makefile
|
||||
gcc -shared -Wl,-soname,libGLU.so -Wl,-Bsymbolic $(OBJS) $(LIBS) -o $@
|
||||
|
||||
install:
|
||||
rm -f $(MESA)/lib/libGLU.so*
|
||||
install -D libGLU.so.1.1 $(MESA)/lib/libGLU.so.1.1
|
||||
ln -s libGLU.so.1.1 $(MESA)/lib/libGLU.so.1
|
||||
ln -s libGLU.so.1 $(MESA)/lib/libGLU.so
|
||||
|
||||
|
||||
clean: clean_here
|
||||
|
||||
clean_here:
|
||||
rm -f ../lib/libGLU.so*
|
||||
|
||||
|
||||
-include $(SOURCES:.c=.d)
|
||||
55
src/glu/mini/all.h
Normal file
55
src/glu/mini/all.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* $Id: all.h,v 1.1.2.1 2003/03/21 13:02:08 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file includes all .h files needed for the GLU source code for
|
||||
* the purpose of precompiled headers.
|
||||
*
|
||||
* If the preprocessor symbol PCH is defined at compile time then each
|
||||
* of the .c files will #include "all.h" only, instead of a bunch of
|
||||
* individual .h files.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GLU_ALL_H
|
||||
#define GLU_ALL_H
|
||||
|
||||
|
||||
#ifndef PC_HEADER
|
||||
This is an error. all.h should be included only if PCH is defined.
|
||||
#endif
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "GL/gl.h"
|
||||
#include "GL/glu.h"
|
||||
#include "gluP.h"
|
||||
#include "nurbs.h"
|
||||
#include "tess.h"
|
||||
|
||||
|
||||
#endif /*GLU_ALL_H */
|
||||
417
src/glu/mini/glu.c
Normal file
417
src/glu/mini/glu.c
Normal file
@@ -0,0 +1,417 @@
|
||||
/* $Id: glu.c,v 1.1.2.1 2003/03/21 13:02:08 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.5
|
||||
* Copyright (C) 1995-2001 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "gluP.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Miscellaneous utility functions
|
||||
*/
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926536
|
||||
#endif
|
||||
#define EPS 0.00001
|
||||
|
||||
#ifndef GLU_INCOMPATIBLE_GL_VERSION
|
||||
#define GLU_INCOMPATIBLE_GL_VERSION 100903
|
||||
#endif
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez,
|
||||
GLdouble centerx, GLdouble centery, GLdouble centerz,
|
||||
GLdouble upx, GLdouble upy, GLdouble 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top)
|
||||
{
|
||||
glOrtho(left, right, bottom, top, -1.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
frustum(GLfloat left, GLfloat right,
|
||||
GLfloat bottom, GLfloat top,
|
||||
GLfloat nearval, GLfloat farval)
|
||||
{
|
||||
GLfloat x, y, a, b, c, d;
|
||||
GLfloat m[16];
|
||||
|
||||
x = (2.0 * nearval) / (right - left);
|
||||
y = (2.0 * nearval) / (top - bottom);
|
||||
a = (right + left) / (right - left);
|
||||
b = (top + bottom) / (top - bottom);
|
||||
c = -(farval + nearval) / ( farval - nearval);
|
||||
d = -(2.0 * farval * nearval) / (farval - nearval);
|
||||
|
||||
#define M(row,col) m[col*4+row]
|
||||
M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F;
|
||||
M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F;
|
||||
M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d;
|
||||
M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F;
|
||||
#undef M
|
||||
|
||||
glMultMatrixf(m);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
|
||||
{
|
||||
GLfloat 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) */
|
||||
frustum(xmin, xmax, ymin, ymax, zNear, zFar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluPickMatrix(GLdouble x, GLdouble y,
|
||||
GLdouble width, GLdouble height, GLint viewport[4])
|
||||
{
|
||||
GLfloat m[16];
|
||||
GLfloat sx, sy;
|
||||
GLfloat tx, ty;
|
||||
|
||||
sx = viewport[2] / width;
|
||||
sy = viewport[3] / height;
|
||||
tx = (viewport[2] + 2.0 * (viewport[0] - x)) / width;
|
||||
ty = (viewport[3] + 2.0 * (viewport[1] - y)) / height;
|
||||
|
||||
#define M(row,col) m[col*4+row]
|
||||
M(0, 0) = sx;
|
||||
M(0, 1) = 0.0;
|
||||
M(0, 2) = 0.0;
|
||||
M(0, 3) = tx;
|
||||
M(1, 0) = 0.0;
|
||||
M(1, 1) = sy;
|
||||
M(1, 2) = 0.0;
|
||||
M(1, 3) = ty;
|
||||
M(2, 0) = 0.0;
|
||||
M(2, 1) = 0.0;
|
||||
M(2, 2) = 1.0;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const GLubyte *GLAPIENTRY
|
||||
gluErrorString(GLenum errorCode)
|
||||
{
|
||||
static char *tess_error[] = {
|
||||
"missing gluBeginPolygon",
|
||||
"missing gluBeginContour",
|
||||
"missing gluEndPolygon",
|
||||
"missing gluEndContour",
|
||||
"misoriented or self-intersecting loops",
|
||||
"coincident vertices",
|
||||
"colinear vertices",
|
||||
"FIST recovery process fatal error"
|
||||
};
|
||||
static char *nurbs_error[] = {
|
||||
"spline order un-supported",
|
||||
"too few knots",
|
||||
"valid knot range is empty",
|
||||
"decreasing knot sequence knot",
|
||||
"knot multiplicity greater than order of spline",
|
||||
"endcurve() must follow bgncurve()",
|
||||
"bgncurve() must precede endcurve()",
|
||||
"missing or extra geometric data",
|
||||
"can't draw pwlcurves",
|
||||
"missing bgncurve()",
|
||||
"missing bgnsurface()",
|
||||
"endtrim() must precede endsurface()",
|
||||
"bgnsurface() must precede endsurface()",
|
||||
"curve of improper type passed as trim curve",
|
||||
"bgnsurface() must precede bgntrim()",
|
||||
"endtrim() must follow bgntrim()",
|
||||
"bgntrim() must precede endtrim()",
|
||||
"invalid or missing trim curve",
|
||||
"bgntrim() must precede pwlcurve()",
|
||||
"pwlcurve referenced twice",
|
||||
"pwlcurve and nurbscurve mixed",
|
||||
"improper usage of trim data type",
|
||||
"nurbscurve referenced twice",
|
||||
"nurbscurve and pwlcurve mixed",
|
||||
"nurbssurface referenced twice",
|
||||
"invalid property",
|
||||
"endsurface() must follow bgnsurface()",
|
||||
"misoriented trim curves",
|
||||
"intersecting trim curves",
|
||||
"UNUSED",
|
||||
"unconnected trim curves",
|
||||
"unknown knot error",
|
||||
"negative vertex count encountered",
|
||||
"negative byte-stride encountered",
|
||||
"unknown type descriptor",
|
||||
"null control array or knot vector",
|
||||
"duplicate point on pwlcurve"
|
||||
};
|
||||
|
||||
/* GL Errors */
|
||||
if (errorCode == GL_NO_ERROR) {
|
||||
return (GLubyte *) "no error";
|
||||
}
|
||||
else if (errorCode == GL_INVALID_VALUE) {
|
||||
return (GLubyte *) "invalid value";
|
||||
}
|
||||
else if (errorCode == GL_INVALID_ENUM) {
|
||||
return (GLubyte *) "invalid enum";
|
||||
}
|
||||
else if (errorCode == GL_INVALID_OPERATION) {
|
||||
return (GLubyte *) "invalid operation";
|
||||
}
|
||||
else if (errorCode == GL_STACK_OVERFLOW) {
|
||||
return (GLubyte *) "stack overflow";
|
||||
}
|
||||
else if (errorCode == GL_STACK_UNDERFLOW) {
|
||||
return (GLubyte *) "stack underflow";
|
||||
}
|
||||
else if (errorCode == GL_OUT_OF_MEMORY) {
|
||||
return (GLubyte *) "out of memory";
|
||||
}
|
||||
/* GLU Errors */
|
||||
else if (errorCode == GLU_NO_ERROR) {
|
||||
return (GLubyte *) "no error";
|
||||
}
|
||||
else if (errorCode == GLU_INVALID_ENUM) {
|
||||
return (GLubyte *) "invalid enum";
|
||||
}
|
||||
else if (errorCode == GLU_INVALID_VALUE) {
|
||||
return (GLubyte *) "invalid value";
|
||||
}
|
||||
else if (errorCode == GLU_OUT_OF_MEMORY) {
|
||||
return (GLubyte *) "out of memory";
|
||||
}
|
||||
else if (errorCode == GLU_INCOMPATIBLE_GL_VERSION) {
|
||||
return (GLubyte *) "incompatible GL version";
|
||||
}
|
||||
else if (errorCode >= GLU_TESS_ERROR1 && errorCode <= GLU_TESS_ERROR8) {
|
||||
return (GLubyte *) tess_error[errorCode - GLU_TESS_ERROR1];
|
||||
}
|
||||
else if (errorCode >= GLU_NURBS_ERROR1 && errorCode <= GLU_NURBS_ERROR37) {
|
||||
return (GLubyte *) nurbs_error[errorCode - GLU_NURBS_ERROR1];
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* New in GLU 1.1
|
||||
*/
|
||||
|
||||
const GLubyte *GLAPIENTRY
|
||||
gluGetString(GLenum name)
|
||||
{
|
||||
static char *extensions = "GL_EXT_abgr";
|
||||
static char *version = "1.1 Mesa 3.5";
|
||||
|
||||
switch (name) {
|
||||
case GLU_EXTENSIONS:
|
||||
return (GLubyte *) extensions;
|
||||
case GLU_VERSION:
|
||||
return (GLubyte *) version;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0 /* gluGetProcAddressEXT not finalized yet! */
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* for BeOS R4.5 */
|
||||
void GLAPIENTRY(*gluGetProcAddressEXT(const GLubyte * procName)) (...)
|
||||
#else
|
||||
void (GLAPIENTRY * gluGetProcAddressEXT(const GLubyte * procName)) ()
|
||||
#endif
|
||||
{
|
||||
struct proc
|
||||
{
|
||||
const char *name;
|
||||
void *address;
|
||||
};
|
||||
static struct proc procTable[] = {
|
||||
{"gluGetProcAddressEXT", (void *) gluGetProcAddressEXT}, /* me! */
|
||||
|
||||
/* new 1.1 functions */
|
||||
{"gluGetString", (void *) gluGetString},
|
||||
|
||||
/* new 1.2 functions */
|
||||
{"gluTessBeginPolygon", (void *) gluTessBeginPolygon},
|
||||
{"gluTessBeginContour", (void *) gluTessBeginContour},
|
||||
{"gluTessEndContour", (void *) gluTessEndContour},
|
||||
{"gluTessEndPolygon", (void *) gluTessEndPolygon},
|
||||
{"gluGetTessProperty", (void *) gluGetTessProperty},
|
||||
|
||||
/* new 1.3 functions */
|
||||
|
||||
{NULL, NULL}
|
||||
};
|
||||
GLuint i;
|
||||
|
||||
for (i = 0; procTable[i].address; i++) {
|
||||
if (strcmp((const char *) procName, procTable[i].name) == 0)
|
||||
return (void (GLAPIENTRY *) ()) procTable[i].address;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* New in GLU 1.3
|
||||
*/
|
||||
#ifdef GLU_VERSION_1_3
|
||||
GLboolean GLAPIENTRY
|
||||
gluCheckExtension(const GLubyte *extName, const GLubyte * extString)
|
||||
{
|
||||
assert(extName);
|
||||
assert(extString);
|
||||
{
|
||||
const int len = strlen((const char *) extName);
|
||||
const char *start = (const char *) extString;
|
||||
|
||||
while (1) {
|
||||
const char *c = strstr(start, (const char *) extName);
|
||||
if (!c)
|
||||
return GL_FALSE;
|
||||
|
||||
if ((c == start || c[-1] == ' ') && (c[len] == ' ' || c[len] == 0))
|
||||
return GL_TRUE;
|
||||
|
||||
start = c + len;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
142
src/glu/mini/gluP.h
Normal file
142
src/glu/mini/gluP.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/* $Id: gluP.h,v 1.1.2.1 2003/03/21 13:02:10 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file allows the GLU code to be compiled either with the Mesa
|
||||
* headers or with the real OpenGL headers.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GLUP_H
|
||||
#define GLUP_H
|
||||
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#if defined(_WIN32) && !defined(__WIN32__)
|
||||
# define __WIN32__
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN__))
|
||||
# pragma warning( disable : 4068 ) /* unknown pragma */
|
||||
# pragma warning( disable : 4710 ) /* function 'foo' not inlined */
|
||||
# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
|
||||
# pragma warning( disable : 4127 ) /* conditional expression is constant */
|
||||
# if defined(MESA_MINWARN)
|
||||
# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
|
||||
# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
|
||||
# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
|
||||
# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
|
||||
# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
|
||||
# endif
|
||||
# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
|
||||
# define GLAPI __declspec(dllexport)
|
||||
# define WGLAPI __declspec(dllexport)
|
||||
# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
|
||||
# define GLAPI __declspec(dllimport)
|
||||
# define WGLAPI __declspec(dllimport)
|
||||
# else /* for use with static link lib build of Win32 edition only */
|
||||
# define GLAPI extern
|
||||
# define WGLAPI __declspec(dllimport)
|
||||
# endif /* _STATIC_MESA support */
|
||||
# define GLAPIENTRY __stdcall
|
||||
# define GLAPIENTRYP __stdcall *
|
||||
# define GLCALLBACK __stdcall
|
||||
# define GLCALLBACKP __stdcall *
|
||||
# if defined(__CYGWIN__)
|
||||
# define GLCALLBACKPCAST *
|
||||
# else
|
||||
# define GLCALLBACKPCAST __stdcall *
|
||||
# endif
|
||||
# define GLWINAPI __stdcall
|
||||
# define GLWINAPIV __cdecl
|
||||
#else
|
||||
/* non-Windows compilation */
|
||||
# define GLAPI extern
|
||||
# define GLAPIENTRY
|
||||
# define GLAPIENTRYP *
|
||||
# define GLCALLBACK
|
||||
# define GLCALLBACKP *
|
||||
# define GLCALLBACKPCAST *
|
||||
# define GLWINAPI
|
||||
# define GLWINAPIV
|
||||
#endif /* WIN32 / CYGWIN bracket */
|
||||
|
||||
/* compatability guard so we don't need to change client code */
|
||||
|
||||
#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP)
|
||||
# define CALLBACK GLCALLBACK
|
||||
typedef int (GLAPIENTRY *PROC)();
|
||||
typedef void *HGLRC;
|
||||
typedef void *HDC;
|
||||
typedef unsigned long COLORREF;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
|
||||
# define WGL_FONT_LINES 0
|
||||
# define WGL_FONT_POLYGONS 1
|
||||
#ifndef _GNU_H_WINDOWS32_FUNCTIONS
|
||||
# ifdef UNICODE
|
||||
# define wglUseFontBitmaps wglUseFontBitmapsW
|
||||
# define wglUseFontOutlines wglUseFontOutlinesW
|
||||
# else
|
||||
# define wglUseFontBitmaps wglUseFontBitmapsA
|
||||
# define wglUseFontOutlines wglUseFontOutlinesA
|
||||
# endif /* !UNICODE */
|
||||
#endif /* _GNU_H_WINDOWS32_FUNCTIONS */
|
||||
typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
|
||||
typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
|
||||
typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
|
||||
#include <gl/mesa_wgl.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef GLU_TESS_ERROR9
|
||||
/* If we're using the real OpenGL header files... */
|
||||
# define GLU_TESS_ERROR9 100159
|
||||
#endif
|
||||
|
||||
|
||||
#define GLU_NO_ERROR GL_NO_ERROR
|
||||
|
||||
|
||||
/* for Sun: */
|
||||
#ifdef SUNOS4
|
||||
#define MEMCPY( DST, SRC, BYTES) \
|
||||
memcpy( (char *) (DST), (char *) (SRC), (int) (BYTES) )
|
||||
#else
|
||||
#define MEMCPY( DST, SRC, BYTES) \
|
||||
memcpy( (void *) (DST), (void *) (SRC), (size_t) (BYTES) )
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
764
src/glu/mini/mipmap.c
Normal file
764
src/glu/mini/mipmap.c
Normal file
@@ -0,0 +1,764 @@
|
||||
/* $Id: mipmap.c,v 1.1.2.1 2003/03/21 13:02:12 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.4
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gluP.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Compute ceiling of integer quotient of A divided by B:
|
||||
*/
|
||||
#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
|
||||
|
||||
|
||||
|
||||
#ifdef EPSILON
|
||||
#undef EPSILON
|
||||
#endif
|
||||
#define EPSILON 0.001
|
||||
|
||||
|
||||
/* To work around optimizer bug in MSVC4.1 */
|
||||
#if defined(__WIN32__) && !defined(OPENSTEP)
|
||||
void
|
||||
dummy(GLuint j, GLuint k)
|
||||
{
|
||||
}
|
||||
#else
|
||||
#define dummy(J, K)
|
||||
#endif
|
||||
|
||||
|
||||
GLint GLAPIENTRY
|
||||
gluScaleImage(GLenum format,
|
||||
GLsizei widthin, GLsizei heightin,
|
||||
GLenum typein, const void *datain,
|
||||
GLsizei widthout, GLsizei heightout,
|
||||
GLenum typeout, void *dataout)
|
||||
{
|
||||
GLint components, i, j, k;
|
||||
GLfloat *tempin, *tempout, f;
|
||||
GLfloat sx, sy;
|
||||
GLint unpackrowlength, unpackalignment, unpackskiprows, unpackskippixels;
|
||||
GLint packrowlength, packalignment, packskiprows, packskippixels;
|
||||
GLint sizein, sizeout;
|
||||
GLint rowstride, rowlen;
|
||||
|
||||
|
||||
/* Determine number of components per pixel */
|
||||
switch (format) {
|
||||
case GL_COLOR_INDEX:
|
||||
case GL_STENCIL_INDEX:
|
||||
case GL_DEPTH_COMPONENT:
|
||||
case GL_RED:
|
||||
case GL_GREEN:
|
||||
case GL_BLUE:
|
||||
case GL_ALPHA:
|
||||
case GL_LUMINANCE:
|
||||
components = 1;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
components = 2;
|
||||
break;
|
||||
case GL_RGB:
|
||||
case GL_BGR:
|
||||
components = 3;
|
||||
break;
|
||||
case GL_RGBA:
|
||||
case GL_BGRA:
|
||||
#ifdef GL_EXT_abgr
|
||||
case GL_ABGR_EXT:
|
||||
#endif
|
||||
components = 4;
|
||||
break;
|
||||
default:
|
||||
return GLU_INVALID_ENUM;
|
||||
}
|
||||
|
||||
/* Determine bytes per input datum */
|
||||
switch (typein) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
sizein = sizeof(GLubyte);
|
||||
break;
|
||||
case GL_BYTE:
|
||||
sizein = sizeof(GLbyte);
|
||||
break;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
sizein = sizeof(GLushort);
|
||||
break;
|
||||
case GL_SHORT:
|
||||
sizein = sizeof(GLshort);
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
sizein = sizeof(GLuint);
|
||||
break;
|
||||
case GL_INT:
|
||||
sizein = sizeof(GLint);
|
||||
break;
|
||||
case GL_FLOAT:
|
||||
sizein = sizeof(GLfloat);
|
||||
break;
|
||||
case GL_BITMAP:
|
||||
/* not implemented yet */
|
||||
default:
|
||||
return GL_INVALID_ENUM;
|
||||
}
|
||||
|
||||
/* Determine bytes per output datum */
|
||||
switch (typeout) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
sizeout = sizeof(GLubyte);
|
||||
break;
|
||||
case GL_BYTE:
|
||||
sizeout = sizeof(GLbyte);
|
||||
break;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
sizeout = sizeof(GLushort);
|
||||
break;
|
||||
case GL_SHORT:
|
||||
sizeout = sizeof(GLshort);
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
sizeout = sizeof(GLuint);
|
||||
break;
|
||||
case GL_INT:
|
||||
sizeout = sizeof(GLint);
|
||||
break;
|
||||
case GL_FLOAT:
|
||||
sizeout = sizeof(GLfloat);
|
||||
break;
|
||||
case GL_BITMAP:
|
||||
/* not implemented yet */
|
||||
default:
|
||||
return GL_INVALID_ENUM;
|
||||
}
|
||||
|
||||
/* Get glPixelStore state */
|
||||
glGetFloatv(GL_UNPACK_ROW_LENGTH, &f); unpackrowlength = (int)f;
|
||||
glGetFloatv(GL_UNPACK_ALIGNMENT, &f); unpackalignment = (int)f;
|
||||
glGetFloatv(GL_UNPACK_SKIP_ROWS, &f); unpackskiprows = (int)f;
|
||||
glGetFloatv(GL_UNPACK_SKIP_PIXELS, &f); unpackskippixels = (int)f;
|
||||
glGetFloatv(GL_PACK_ROW_LENGTH, &f); packrowlength = (int)f;
|
||||
glGetFloatv(GL_PACK_ALIGNMENT, &f); packalignment = (int)f;
|
||||
glGetFloatv(GL_PACK_SKIP_ROWS, &f); packskiprows = (int)f;
|
||||
glGetFloatv(GL_PACK_SKIP_PIXELS, &f); packskippixels = (int)f;
|
||||
|
||||
/* Allocate storage for intermediate images */
|
||||
tempin = (GLfloat *) malloc(widthin * heightin
|
||||
* components * sizeof(GLfloat));
|
||||
if (!tempin) {
|
||||
return GLU_OUT_OF_MEMORY;
|
||||
}
|
||||
tempout = (GLfloat *) malloc(widthout * heightout
|
||||
* components * sizeof(GLfloat));
|
||||
if (!tempout) {
|
||||
free(tempin);
|
||||
return GLU_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Unpack the pixel data and convert to floating point
|
||||
*/
|
||||
|
||||
if (unpackrowlength > 0) {
|
||||
rowlen = unpackrowlength;
|
||||
}
|
||||
else {
|
||||
rowlen = widthin;
|
||||
}
|
||||
if (sizein >= unpackalignment) {
|
||||
rowstride = components * rowlen;
|
||||
}
|
||||
else {
|
||||
rowstride = unpackalignment / sizein
|
||||
* CEILING(components * rowlen * sizein, unpackalignment);
|
||||
}
|
||||
|
||||
switch (typein) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
k = 0;
|
||||
for (i = 0; i < heightin; i++) {
|
||||
GLubyte *ubptr = (GLubyte *) datain
|
||||
+ i * rowstride
|
||||
+ unpackskiprows * rowstride + unpackskippixels * components;
|
||||
for (j = 0; j < widthin * components; j++) {
|
||||
dummy(j, k);
|
||||
tempin[k++] = (GLfloat) * ubptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_BYTE:
|
||||
k = 0;
|
||||
for (i = 0; i < heightin; i++) {
|
||||
GLbyte *bptr = (GLbyte *) datain
|
||||
+ i * rowstride
|
||||
+ unpackskiprows * rowstride + unpackskippixels * components;
|
||||
for (j = 0; j < widthin * components; j++) {
|
||||
dummy(j, k);
|
||||
tempin[k++] = (GLfloat) * bptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightin; i++) {
|
||||
GLushort *usptr = (GLushort *) datain
|
||||
+ i * rowstride
|
||||
+ unpackskiprows * rowstride + unpackskippixels * components;
|
||||
for (j = 0; j < widthin * components; j++) {
|
||||
dummy(j, k);
|
||||
tempin[k++] = (GLfloat) * usptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_SHORT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightin; i++) {
|
||||
GLshort *sptr = (GLshort *) datain
|
||||
+ i * rowstride
|
||||
+ unpackskiprows * rowstride + unpackskippixels * components;
|
||||
for (j = 0; j < widthin * components; j++) {
|
||||
dummy(j, k);
|
||||
tempin[k++] = (GLfloat) * sptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightin; i++) {
|
||||
GLuint *uiptr = (GLuint *) datain
|
||||
+ i * rowstride
|
||||
+ unpackskiprows * rowstride + unpackskippixels * components;
|
||||
for (j = 0; j < widthin * components; j++) {
|
||||
dummy(j, k);
|
||||
tempin[k++] = (GLfloat) * uiptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_INT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightin; i++) {
|
||||
GLint *iptr = (GLint *) datain
|
||||
+ i * rowstride
|
||||
+ unpackskiprows * rowstride + unpackskippixels * components;
|
||||
for (j = 0; j < widthin * components; j++) {
|
||||
dummy(j, k);
|
||||
tempin[k++] = (GLfloat) * iptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_FLOAT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightin; i++) {
|
||||
GLfloat *fptr = (GLfloat *) datain
|
||||
+ i * rowstride
|
||||
+ unpackskiprows * rowstride + unpackskippixels * components;
|
||||
for (j = 0; j < widthin * components; j++) {
|
||||
dummy(j, k);
|
||||
tempin[k++] = *fptr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return GLU_INVALID_ENUM;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Scale the image!
|
||||
*/
|
||||
|
||||
if (widthout > 1)
|
||||
sx = (GLfloat) (widthin - 1) / (GLfloat) (widthout - 1);
|
||||
else
|
||||
sx = (GLfloat) (widthin - 1);
|
||||
if (heightout > 1)
|
||||
sy = (GLfloat) (heightin - 1) / (GLfloat) (heightout - 1);
|
||||
else
|
||||
sy = (GLfloat) (heightin - 1);
|
||||
|
||||
/*#define POINT_SAMPLE*/
|
||||
#ifdef POINT_SAMPLE
|
||||
for (i = 0; i < heightout; i++) {
|
||||
GLint ii = i * sy;
|
||||
for (j = 0; j < widthout; j++) {
|
||||
GLint jj = j * sx;
|
||||
|
||||
GLfloat *src = tempin + (ii * widthin + jj) * components;
|
||||
GLfloat *dst = tempout + (i * widthout + j) * components;
|
||||
|
||||
for (k = 0; k < components; k++) {
|
||||
*dst++ = *src++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (sx < 1.0 && sy < 1.0) {
|
||||
/* magnify both width and height: use weighted sample of 4 pixels */
|
||||
GLint i0, i1, j0, j1;
|
||||
GLfloat alpha, beta;
|
||||
GLfloat *src00, *src01, *src10, *src11;
|
||||
GLfloat s1, s2;
|
||||
GLfloat *dst;
|
||||
|
||||
for (i = 0; i < heightout; i++) {
|
||||
i0 = i * sy;
|
||||
i1 = i0 + 1;
|
||||
if (i1 >= heightin)
|
||||
i1 = heightin - 1;
|
||||
/* i1 = (i+1) * sy - EPSILON;*/
|
||||
alpha = i * sy - i0;
|
||||
for (j = 0; j < widthout; j++) {
|
||||
j0 = j * sx;
|
||||
j1 = j0 + 1;
|
||||
if (j1 >= widthin)
|
||||
j1 = widthin - 1;
|
||||
/* j1 = (j+1) * sx - EPSILON; */
|
||||
beta = j * sx - j0;
|
||||
|
||||
/* compute weighted average of pixels in rect (i0,j0)-(i1,j1) */
|
||||
src00 = tempin + (i0 * widthin + j0) * components;
|
||||
src01 = tempin + (i0 * widthin + j1) * components;
|
||||
src10 = tempin + (i1 * widthin + j0) * components;
|
||||
src11 = tempin + (i1 * widthin + j1) * components;
|
||||
|
||||
dst = tempout + (i * widthout + j) * components;
|
||||
|
||||
for (k = 0; k < components; k++) {
|
||||
s1 = *src00++ * (1.0 - beta) + *src01++ * beta;
|
||||
s2 = *src10++ * (1.0 - beta) + *src11++ * beta;
|
||||
*dst++ = s1 * (1.0 - alpha) + s2 * alpha;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* shrink width and/or height: use an unweighted box filter */
|
||||
GLint i0, i1;
|
||||
GLint j0, j1;
|
||||
GLint ii, jj;
|
||||
GLfloat sum, *dst;
|
||||
|
||||
for (i = 0; i < heightout; i++) {
|
||||
i0 = i * sy;
|
||||
i1 = i0 + 1;
|
||||
if (i1 >= heightin)
|
||||
i1 = heightin - 1;
|
||||
/* i1 = (i+1) * sy - EPSILON; */
|
||||
for (j = 0; j < widthout; j++) {
|
||||
j0 = j * sx;
|
||||
j1 = j0 + 1;
|
||||
if (j1 >= widthin)
|
||||
j1 = widthin - 1;
|
||||
/* j1 = (j+1) * sx - EPSILON; */
|
||||
|
||||
dst = tempout + (i * widthout + j) * components;
|
||||
|
||||
/* compute average of pixels in the rectangle (i0,j0)-(i1,j1) */
|
||||
for (k = 0; k < components; k++) {
|
||||
sum = 0.0;
|
||||
for (ii = i0; ii <= i1; ii++) {
|
||||
for (jj = j0; jj <= j1; jj++) {
|
||||
sum += *(tempin + (ii * widthin + jj) * components + k);
|
||||
}
|
||||
}
|
||||
sum /= (j1 - j0 + 1) * (i1 - i0 + 1);
|
||||
*dst++ = sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Return output image
|
||||
*/
|
||||
|
||||
if (packrowlength > 0) {
|
||||
rowlen = packrowlength;
|
||||
}
|
||||
else {
|
||||
rowlen = widthout;
|
||||
}
|
||||
if (sizeout >= packalignment) {
|
||||
rowstride = components * rowlen;
|
||||
}
|
||||
else {
|
||||
rowstride = packalignment / sizeout
|
||||
* CEILING(components * rowlen * sizeout, packalignment);
|
||||
}
|
||||
|
||||
switch (typeout) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
k = 0;
|
||||
for (i = 0; i < heightout; i++) {
|
||||
GLubyte *ubptr = (GLubyte *) dataout
|
||||
+ i * rowstride
|
||||
+ packskiprows * rowstride + packskippixels * components;
|
||||
for (j = 0; j < widthout * components; j++) {
|
||||
dummy(j, k + i);
|
||||
*ubptr++ = (GLubyte) tempout[k++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_BYTE:
|
||||
k = 0;
|
||||
for (i = 0; i < heightout; i++) {
|
||||
GLbyte *bptr = (GLbyte *) dataout
|
||||
+ i * rowstride
|
||||
+ packskiprows * rowstride + packskippixels * components;
|
||||
for (j = 0; j < widthout * components; j++) {
|
||||
dummy(j, k + i);
|
||||
*bptr++ = (GLbyte) tempout[k++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightout; i++) {
|
||||
GLushort *usptr = (GLushort *) dataout
|
||||
+ i * rowstride
|
||||
+ packskiprows * rowstride + packskippixels * components;
|
||||
for (j = 0; j < widthout * components; j++) {
|
||||
dummy(j, k + i);
|
||||
*usptr++ = (GLushort) tempout[k++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_SHORT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightout; i++) {
|
||||
GLshort *sptr = (GLshort *) dataout
|
||||
+ i * rowstride
|
||||
+ packskiprows * rowstride + packskippixels * components;
|
||||
for (j = 0; j < widthout * components; j++) {
|
||||
dummy(j, k + i);
|
||||
*sptr++ = (GLshort) tempout[k++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightout; i++) {
|
||||
GLuint *uiptr = (GLuint *) dataout
|
||||
+ i * rowstride
|
||||
+ packskiprows * rowstride + packskippixels * components;
|
||||
for (j = 0; j < widthout * components; j++) {
|
||||
dummy(j, k + i);
|
||||
*uiptr++ = (GLuint) tempout[k++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_INT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightout; i++) {
|
||||
GLint *iptr = (GLint *) dataout
|
||||
+ i * rowstride
|
||||
+ packskiprows * rowstride + packskippixels * components;
|
||||
for (j = 0; j < widthout * components; j++) {
|
||||
dummy(j, k + i);
|
||||
*iptr++ = (GLint) tempout[k++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GL_FLOAT:
|
||||
k = 0;
|
||||
for (i = 0; i < heightout; i++) {
|
||||
GLfloat *fptr = (GLfloat *) dataout
|
||||
+ i * rowstride
|
||||
+ packskiprows * rowstride + packskippixels * components;
|
||||
for (j = 0; j < widthout * components; j++) {
|
||||
dummy(j, k + i);
|
||||
*fptr++ = tempout[k++];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return GLU_INVALID_ENUM;
|
||||
}
|
||||
|
||||
|
||||
/* free temporary image storage */
|
||||
free(tempin);
|
||||
free(tempout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Return the largest k such that 2^k <= n.
|
||||
*/
|
||||
static GLint
|
||||
ilog2(GLint n)
|
||||
{
|
||||
GLint k;
|
||||
|
||||
if (n <= 0)
|
||||
return 0;
|
||||
for (k = 0; n >>= 1; k++);
|
||||
return k;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Find the value nearest to n which is also a power of two.
|
||||
*/
|
||||
static GLint
|
||||
round2(GLint n)
|
||||
{
|
||||
GLint m;
|
||||
|
||||
for (m = 1; m < n; m *= 2);
|
||||
|
||||
/* m>=n */
|
||||
if (m - n <= n - m / 2) {
|
||||
return m;
|
||||
}
|
||||
else {
|
||||
return m / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Given an pixel format and datatype, return the number of bytes to
|
||||
* store one pixel.
|
||||
*/
|
||||
static GLint
|
||||
bytes_per_pixel(GLenum format, GLenum type)
|
||||
{
|
||||
GLint n, m;
|
||||
|
||||
switch (format) {
|
||||
case GL_COLOR_INDEX:
|
||||
case GL_STENCIL_INDEX:
|
||||
case GL_DEPTH_COMPONENT:
|
||||
case GL_RED:
|
||||
case GL_GREEN:
|
||||
case GL_BLUE:
|
||||
case GL_ALPHA:
|
||||
case GL_LUMINANCE:
|
||||
n = 1;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
n = 2;
|
||||
break;
|
||||
case GL_RGB:
|
||||
case GL_BGR:
|
||||
n = 3;
|
||||
break;
|
||||
case GL_RGBA:
|
||||
case GL_BGRA:
|
||||
#ifdef GL_EXT_abgr
|
||||
case GL_ABGR_EXT:
|
||||
#endif
|
||||
n = 4;
|
||||
break;
|
||||
default:
|
||||
n = 0;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
m = sizeof(GLubyte);
|
||||
break;
|
||||
case GL_BYTE:
|
||||
m = sizeof(GLbyte);
|
||||
break;
|
||||
case GL_BITMAP:
|
||||
m = 1;
|
||||
break;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
m = sizeof(GLushort);
|
||||
break;
|
||||
case GL_SHORT:
|
||||
m = sizeof(GLshort);
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
m = sizeof(GLuint);
|
||||
break;
|
||||
case GL_INT:
|
||||
m = sizeof(GLint);
|
||||
break;
|
||||
case GL_FLOAT:
|
||||
m = sizeof(GLfloat);
|
||||
break;
|
||||
default:
|
||||
m = 0;
|
||||
}
|
||||
|
||||
return n * m;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* WARNING: This function isn't finished and has never been tested!!!!
|
||||
*/
|
||||
GLint GLAPIENTRY
|
||||
gluBuild1DMipmaps(GLenum target, GLint components,
|
||||
GLsizei width, GLenum format, GLenum type, const void *data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLint GLAPIENTRY
|
||||
gluBuild2DMipmaps(GLenum target, GLint components,
|
||||
GLsizei width, GLsizei height, GLenum format,
|
||||
GLenum type, const void *data)
|
||||
{
|
||||
GLint w, h;
|
||||
GLint maxsize;
|
||||
void *image, *newimage;
|
||||
GLint neww, newh, level, bpp;
|
||||
int error;
|
||||
GLboolean done;
|
||||
GLint retval = 0;
|
||||
GLint unpackrowlength, unpackalignment, unpackskiprows, unpackskippixels;
|
||||
GLint packrowlength, packalignment, packskiprows, packskippixels;
|
||||
GLfloat f;
|
||||
|
||||
if (width < 1 || height < 1)
|
||||
return GLU_INVALID_VALUE;
|
||||
|
||||
glGetFloatv(GL_MAX_TEXTURE_SIZE, &f); maxsize = (int)f;
|
||||
|
||||
w = round2(width);
|
||||
if (w > maxsize) {
|
||||
w = maxsize;
|
||||
}
|
||||
h = round2(height);
|
||||
if (h > maxsize) {
|
||||
h = maxsize;
|
||||
}
|
||||
|
||||
bpp = bytes_per_pixel(format, type);
|
||||
if (bpp == 0) {
|
||||
/* probably a bad format or type enum */
|
||||
return GLU_INVALID_ENUM;
|
||||
}
|
||||
|
||||
/* Get current glPixelStore values */
|
||||
glGetFloatv(GL_UNPACK_ROW_LENGTH, &f); unpackrowlength = (int)f;
|
||||
glGetFloatv(GL_UNPACK_ALIGNMENT, &f); unpackalignment = (int)f;
|
||||
glGetFloatv(GL_UNPACK_SKIP_ROWS, &f); unpackskiprows = (int)f;
|
||||
glGetFloatv(GL_UNPACK_SKIP_PIXELS, &f); unpackskippixels = (int)f;
|
||||
glGetFloatv(GL_PACK_ROW_LENGTH, &f); packrowlength = (int)f;
|
||||
glGetFloatv(GL_PACK_ALIGNMENT, &f); packalignment = (int)f;
|
||||
glGetFloatv(GL_PACK_SKIP_ROWS, &f); packskiprows = (int)f;
|
||||
glGetFloatv(GL_PACK_SKIP_PIXELS, &f); packskippixels = (int)f;
|
||||
|
||||
/* set pixel packing */
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
|
||||
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
|
||||
|
||||
done = GL_FALSE;
|
||||
|
||||
if (w != width || h != height) {
|
||||
/* must rescale image to get "top" mipmap texture image */
|
||||
image = malloc((w + 4) * h * bpp);
|
||||
if (!image) {
|
||||
return GLU_OUT_OF_MEMORY;
|
||||
}
|
||||
error = gluScaleImage(format, width, height, type, data,
|
||||
w, h, type, image);
|
||||
if (error) {
|
||||
retval = error;
|
||||
done = GL_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
image = (void *) data;
|
||||
}
|
||||
|
||||
level = 0;
|
||||
while (!done) {
|
||||
if (image != data) {
|
||||
/* set pixel unpacking */
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
}
|
||||
|
||||
glTexImage2D(target, level, components, w, h, 0, format, type, image);
|
||||
|
||||
if (w == 1 && h == 1)
|
||||
break;
|
||||
|
||||
neww = (w < 2) ? 1 : w / 2;
|
||||
newh = (h < 2) ? 1 : h / 2;
|
||||
newimage = malloc((neww + 4) * newh * bpp);
|
||||
if (!newimage) {
|
||||
return GLU_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
error = gluScaleImage(format, w, h, type, image,
|
||||
neww, newh, type, newimage);
|
||||
if (error) {
|
||||
retval = error;
|
||||
done = GL_TRUE;
|
||||
}
|
||||
|
||||
if (image != data) {
|
||||
free(image);
|
||||
}
|
||||
image = newimage;
|
||||
|
||||
w = neww;
|
||||
h = newh;
|
||||
level++;
|
||||
}
|
||||
|
||||
if (image != data) {
|
||||
free(image);
|
||||
}
|
||||
|
||||
/* Restore original glPixelStore state */
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, unpackrowlength);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, unpackalignment);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, unpackskiprows);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, unpackskippixels);
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, packrowlength);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, packalignment);
|
||||
glPixelStorei(GL_PACK_SKIP_ROWS, packskiprows);
|
||||
glPixelStorei(GL_PACK_SKIP_PIXELS, packskippixels);
|
||||
|
||||
return retval;
|
||||
}
|
||||
158
src/glu/mini/nurbs.c
Normal file
158
src/glu/mini/nurbs.c
Normal file
@@ -0,0 +1,158 @@
|
||||
/* $Id: nurbs.c,v 1.1.2.1 2003/03/21 13:02:13 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* NURBS implementation written by Bogdan Sikorski (bogdan@cira.it)
|
||||
* See README2 for more info.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gluP.h"
|
||||
#include "nurbs.h"
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
call_user_error(GLUnurbsObj * nobj, GLenum error)
|
||||
{
|
||||
nobj->error = error;
|
||||
if (nobj->error_callback != NULL) {
|
||||
(*(nobj->error_callback)) (error);
|
||||
}
|
||||
else {
|
||||
printf("NURBS error %d %s\n", error, (char *) gluErrorString(error));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLUnurbsObj *GLAPIENTRY
|
||||
gluNewNurbsRenderer(void)
|
||||
{
|
||||
GLUnurbsObj *n;
|
||||
GLfloat tmp_viewport[4];
|
||||
GLint i, j;
|
||||
|
||||
n = (GLUnurbsObj *) malloc(sizeof(GLUnurbsObj));
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluDeleteNurbsRenderer(GLUnurbsObj * nobj)
|
||||
{
|
||||
if (nobj) {
|
||||
free(nobj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluLoadSamplingMatrices(GLUnurbsObj * nobj,
|
||||
const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16], const GLint viewport[4])
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsProperty(GLUnurbsObj * nobj, GLenum property, GLfloat value)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluGetNurbsProperty(GLUnurbsObj * nobj, GLenum property, GLfloat * value)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginCurve(GLUnurbsObj * nobj)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndCurve(GLUnurbsObj * nobj)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsCurve(GLUnurbsObj * nobj, GLint nknots, GLfloat * knot,
|
||||
GLint stride, GLfloat * ctlarray, GLint order, GLenum type)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginSurface(GLUnurbsObj * nobj)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndSurface(GLUnurbsObj * nobj)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsSurface(GLUnurbsObj * nobj,
|
||||
GLint sknot_count, GLfloat * sknot,
|
||||
GLint tknot_count, GLfloat * tknot,
|
||||
GLint s_stride, GLint t_stride,
|
||||
GLfloat * ctrlarray, GLint sorder, GLint torder, GLenum type)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNurbsCallback(GLUnurbsObj * nobj, GLenum which, void (GLCALLBACK * fn) ())
|
||||
{
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginTrim(GLUnurbsObj * nobj)
|
||||
{
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluPwlCurve(GLUnurbsObj * nobj, GLint count, GLfloat * array, GLint stride,
|
||||
GLenum type)
|
||||
{
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndTrim(GLUnurbsObj * nobj)
|
||||
{
|
||||
}
|
||||
253
src/glu/mini/nurbs.h
Normal file
253
src/glu/mini/nurbs.h
Normal file
@@ -0,0 +1,253 @@
|
||||
/* $Id: nurbs.h,v 1.1.2.1 2003/03/21 13:02:14 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* NURBS implementation written by Bogdan Sikorski (bogdan@cira.it)
|
||||
* See README2 for more info.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NURBS_H
|
||||
#define NURBS_H
|
||||
|
||||
|
||||
#define EPSILON 1e-06 /* epsilon for double precision compares */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GLU_NURBS_CURVE, GLU_NURBS_SURFACE, GLU_NURBS_TRIM, GLU_NURBS_NO_TRIM,
|
||||
GLU_NURBS_TRIM_DONE, GLU_NURBS_NONE
|
||||
}
|
||||
GLU_nurbs_enum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GLU_TRIM_NURBS, GLU_TRIM_PWL
|
||||
}
|
||||
GLU_trim_enum;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLint sknot_count;
|
||||
GLfloat *sknot;
|
||||
GLint tknot_count;
|
||||
GLfloat *tknot;
|
||||
GLint s_stride;
|
||||
GLint t_stride;
|
||||
GLfloat *ctrlarray;
|
||||
GLint sorder;
|
||||
GLint torder;
|
||||
GLint dim;
|
||||
GLenum type;
|
||||
}
|
||||
surface_attribs;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
surface_attribs geom;
|
||||
surface_attribs color;
|
||||
surface_attribs texture;
|
||||
surface_attribs normal;
|
||||
}
|
||||
nurbs_surface;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLint knot_count;
|
||||
GLfloat *knot;
|
||||
GLint stride;
|
||||
GLfloat *ctrlarray;
|
||||
GLint order;
|
||||
GLint dim;
|
||||
GLenum type;
|
||||
}
|
||||
curve_attribs;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLint pt_count;
|
||||
GLfloat *ctrlarray;
|
||||
GLint stride;
|
||||
GLint dim;
|
||||
GLenum type;
|
||||
}
|
||||
pwl_curve_attribs;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
curve_attribs geom;
|
||||
curve_attribs color;
|
||||
curve_attribs texture;
|
||||
curve_attribs normal;
|
||||
}
|
||||
nurbs_curve;
|
||||
|
||||
typedef struct trim_list_str
|
||||
{
|
||||
GLU_trim_enum trim_type;
|
||||
union
|
||||
{
|
||||
pwl_curve_attribs pwl_curve;
|
||||
curve_attribs nurbs_curve;
|
||||
}
|
||||
curve;
|
||||
struct trim_list_str *next;
|
||||
}
|
||||
trim_list;
|
||||
|
||||
typedef struct seg_trim_str
|
||||
{
|
||||
GLfloat *points;
|
||||
GLint pt_cnt, seg_array_len;
|
||||
struct seg_trim_str *next;
|
||||
}
|
||||
trim_segments;
|
||||
|
||||
typedef struct nurbs_trim_str
|
||||
{
|
||||
trim_list *trim_loop;
|
||||
trim_segments *segments;
|
||||
struct nurbs_trim_str *next;
|
||||
}
|
||||
nurbs_trim;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLfloat model[16], proj[16], viewport[4];
|
||||
}
|
||||
culling_and_sampling_str;
|
||||
|
||||
struct GLUnurbs
|
||||
{
|
||||
GLboolean culling;
|
||||
GLenum error;
|
||||
void (GLCALLBACK * error_callback) (GLenum err);
|
||||
GLenum display_mode;
|
||||
GLU_nurbs_enum nurbs_type;
|
||||
GLboolean auto_load_matrix;
|
||||
culling_and_sampling_str sampling_matrices;
|
||||
GLenum sampling_method;
|
||||
GLfloat sampling_tolerance;
|
||||
GLfloat parametric_tolerance;
|
||||
GLint u_step, v_step;
|
||||
nurbs_surface surface;
|
||||
nurbs_curve curve;
|
||||
nurbs_trim *trim;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLfloat *knot;
|
||||
GLint nknots;
|
||||
GLfloat *unified_knot;
|
||||
GLint unified_nknots;
|
||||
GLint order;
|
||||
GLint t_min, t_max;
|
||||
GLint delta_nknots;
|
||||
GLboolean open_at_begin, open_at_end;
|
||||
GLfloat *new_knot;
|
||||
GLfloat *alpha;
|
||||
}
|
||||
knot_str_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLfloat *geom_ctrl;
|
||||
GLint geom_s_stride, geom_t_stride;
|
||||
GLfloat **geom_offsets;
|
||||
GLint geom_s_pt_cnt, geom_t_pt_cnt;
|
||||
GLfloat *color_ctrl;
|
||||
GLint color_s_stride, color_t_stride;
|
||||
GLfloat **color_offsets;
|
||||
GLint color_s_pt_cnt, color_t_pt_cnt;
|
||||
GLfloat *normal_ctrl;
|
||||
GLint normal_s_stride, normal_t_stride;
|
||||
GLfloat **normal_offsets;
|
||||
GLint normal_s_pt_cnt, normal_t_pt_cnt;
|
||||
GLfloat *texture_ctrl;
|
||||
GLint texture_s_stride, texture_t_stride;
|
||||
GLfloat **texture_offsets;
|
||||
GLint texture_s_pt_cnt, texture_t_pt_cnt;
|
||||
GLint s_bezier_cnt, t_bezier_cnt;
|
||||
}
|
||||
new_ctrl_type;
|
||||
|
||||
extern void call_user_error(GLUnurbsObj * nobj, GLenum error);
|
||||
|
||||
extern GLenum test_knot(GLint nknots, GLfloat * knot, GLint order);
|
||||
|
||||
extern GLenum explode_knot(knot_str_type * the_knot);
|
||||
|
||||
extern GLenum calc_alphas(knot_str_type * the_knot);
|
||||
|
||||
extern GLenum calc_new_ctrl_pts(GLfloat * ctrl, GLint stride,
|
||||
knot_str_type * the_knot, GLint dim,
|
||||
GLfloat ** new_ctrl, GLint * ncontrol);
|
||||
|
||||
extern GLenum glu_do_sampling_crv(GLUnurbsObj * nobj, GLfloat * new_ctrl,
|
||||
GLint n_ctrl, GLint order, GLint dim,
|
||||
GLint ** factors);
|
||||
|
||||
extern GLenum glu_do_sampling_3D(GLUnurbsObj * nobj, new_ctrl_type * new_ctrl,
|
||||
int **sfactors, GLint ** tfactors);
|
||||
|
||||
extern GLenum glu_do_sampling_uv(GLUnurbsObj * nobj, new_ctrl_type * new_ctrl,
|
||||
int **sfactors, GLint ** tfactors);
|
||||
|
||||
extern GLenum glu_do_sampling_param_3D(GLUnurbsObj * nobj,
|
||||
new_ctrl_type * new_ctrl,
|
||||
int **sfactors, GLint ** tfactors);
|
||||
|
||||
extern GLboolean fine_culling_test_2D(GLUnurbsObj * nobj, GLfloat * ctrl,
|
||||
GLint n_ctrl, GLint stride, GLint dim);
|
||||
|
||||
extern GLboolean fine_culling_test_3D(GLUnurbsObj * nobj, GLfloat * ctrl,
|
||||
GLint s_n_ctrl, GLint t_n_ctrl,
|
||||
GLint s_stride, GLint t_stride,
|
||||
GLint dim);
|
||||
|
||||
extern void do_nurbs_curve(GLUnurbsObj * nobj);
|
||||
|
||||
extern void do_nurbs_surface(GLUnurbsObj * nobj);
|
||||
|
||||
extern GLenum patch_trimming(GLUnurbsObj * nobj, new_ctrl_type * new_ctrl,
|
||||
GLint * sfactors, GLint * tfactors);
|
||||
|
||||
extern void collect_unified_knot(knot_str_type * dest, knot_str_type * src,
|
||||
GLfloat maximal_min_knot,
|
||||
GLfloat minimal_max_knot);
|
||||
|
||||
extern GLenum select_knot_working_range(GLUnurbsObj * nobj,
|
||||
knot_str_type * geom_knot,
|
||||
knot_str_type * color_knot,
|
||||
knot_str_type * normal_knot,
|
||||
knot_str_type * texture_knot);
|
||||
|
||||
extern void free_unified_knots(knot_str_type * geom_knot,
|
||||
knot_str_type * color_knot,
|
||||
knot_str_type * normal_knot,
|
||||
knot_str_type * texture_knot);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
133
src/glu/mini/nurbscrv.c
Normal file
133
src/glu/mini/nurbscrv.c
Normal file
@@ -0,0 +1,133 @@
|
||||
/* $Id: nurbscrv.c,v 1.1.2.1 2003/03/21 13:02:16 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* NURBS implementation written by Bogdan Sikorski (bogdan@cira.it)
|
||||
* See README2 for more info.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "gluP.h"
|
||||
#include "nurbs.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* main NURBS curve procedure */
|
||||
void
|
||||
do_nurbs_curve(GLUnurbsObj * nobj)
|
||||
{
|
||||
GLint geom_order, color_order = 0, normal_order = 0, texture_order = 0;
|
||||
GLenum geom_type;
|
||||
GLint n_ctrl;
|
||||
GLfloat *new_geom_ctrl, *new_color_ctrl, *new_normal_ctrl,
|
||||
*new_texture_ctrl;
|
||||
GLfloat *geom_ctrl = 0, *color_ctrl = 0, *normal_ctrl = 0, *texture_ctrl = 0;
|
||||
GLint *factors;
|
||||
GLint i, j;
|
||||
GLint geom_dim, color_dim = 0, normal_dim = 0, texture_dim = 0;
|
||||
|
||||
/* test the user supplied data */
|
||||
if (test_nurbs_curves(nobj) != GLU_NO_ERROR)
|
||||
return;
|
||||
|
||||
if (convert_curves(nobj, &new_geom_ctrl, &n_ctrl, &new_color_ctrl,
|
||||
&new_normal_ctrl, &new_texture_ctrl) != GLU_NO_ERROR)
|
||||
return;
|
||||
|
||||
geom_order = nobj->curve.geom.order;
|
||||
geom_type = nobj->curve.geom.type;
|
||||
geom_dim = nobj->curve.geom.dim;
|
||||
|
||||
if (glu_do_sampling_crv(nobj, new_geom_ctrl, n_ctrl, geom_order, geom_dim,
|
||||
&factors) != GLU_NO_ERROR) {
|
||||
free(new_geom_ctrl);
|
||||
if (new_color_ctrl)
|
||||
free(new_color_ctrl);
|
||||
if (new_normal_ctrl)
|
||||
free(new_normal_ctrl);
|
||||
if (new_texture_ctrl)
|
||||
free(new_texture_ctrl);
|
||||
return;
|
||||
}
|
||||
glEnable(geom_type);
|
||||
if (new_color_ctrl) {
|
||||
glEnable(nobj->curve.color.type);
|
||||
color_dim = nobj->curve.color.dim;
|
||||
color_ctrl = new_color_ctrl;
|
||||
color_order = nobj->curve.color.order;
|
||||
}
|
||||
if (new_normal_ctrl) {
|
||||
glEnable(nobj->curve.normal.type);
|
||||
normal_dim = nobj->curve.normal.dim;
|
||||
normal_ctrl = new_normal_ctrl;
|
||||
normal_order = nobj->curve.normal.order;
|
||||
}
|
||||
if (new_texture_ctrl) {
|
||||
glEnable(nobj->curve.texture.type);
|
||||
texture_dim = nobj->curve.texture.dim;
|
||||
texture_ctrl = new_texture_ctrl;
|
||||
texture_order = nobj->curve.texture.order;
|
||||
}
|
||||
for (i = 0, j = 0, geom_ctrl = new_geom_ctrl;
|
||||
i < n_ctrl; i += geom_order, j++, geom_ctrl += geom_order * geom_dim) {
|
||||
if (fine_culling_test_2D
|
||||
(nobj, geom_ctrl, geom_order, geom_dim, geom_dim)) {
|
||||
color_ctrl += color_order * color_dim;
|
||||
normal_ctrl += normal_order * normal_dim;
|
||||
texture_ctrl += texture_order * texture_dim;
|
||||
continue;
|
||||
}
|
||||
glMap1f(geom_type, 0.0, 1.0, geom_dim, geom_order, geom_ctrl);
|
||||
if (new_color_ctrl) {
|
||||
glMap1f(nobj->curve.color.type, 0.0, 1.0, color_dim,
|
||||
color_order, color_ctrl);
|
||||
color_ctrl += color_order * color_dim;
|
||||
}
|
||||
if (new_normal_ctrl) {
|
||||
glMap1f(nobj->curve.normal.type, 0.0, 1.0, normal_dim,
|
||||
normal_order, normal_ctrl);
|
||||
normal_ctrl += normal_order * normal_dim;
|
||||
}
|
||||
if (new_texture_ctrl) {
|
||||
glMap1f(nobj->curve.texture.type, 0.0, 1.0, texture_dim,
|
||||
texture_order, texture_ctrl);
|
||||
texture_ctrl += texture_order * texture_dim;
|
||||
}
|
||||
glMapGrid1f(factors[j], 0.0, 1.0);
|
||||
glEvalMesh1(GL_LINE, 0, factors[j]);
|
||||
}
|
||||
free(new_geom_ctrl);
|
||||
free(factors);
|
||||
if (new_color_ctrl)
|
||||
free(new_color_ctrl);
|
||||
if (new_normal_ctrl)
|
||||
free(new_normal_ctrl);
|
||||
if (new_texture_ctrl)
|
||||
free(new_texture_ctrl);
|
||||
}
|
||||
938
src/glu/mini/polytest.c
Normal file
938
src/glu/mini/polytest.c
Normal file
@@ -0,0 +1,938 @@
|
||||
/* $Id: polytest.c,v 1.1.2.1 2003/03/21 13:02:17 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file is part of the polygon tesselation code contributed by
|
||||
* Bogdan Sikorski
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "gluP.h"
|
||||
#include "tess.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static GLenum store_polygon_as_contour(GLUtriangulatorObj *);
|
||||
static void free_current_polygon(tess_polygon *);
|
||||
static void prepare_projection_info(GLUtriangulatorObj *);
|
||||
static GLdouble twice_the_polygon_area(tess_vertex *, tess_vertex *);
|
||||
static GLenum verify_edge_vertex_intersections(GLUtriangulatorObj *);
|
||||
void tess_find_contour_hierarchies(GLUtriangulatorObj *);
|
||||
static GLenum test_for_overlapping_contours(GLUtriangulatorObj *);
|
||||
static GLenum contours_overlap(tess_contour *, tess_polygon *);
|
||||
static GLenum is_contour_contained_in(tess_contour *, tess_contour *);
|
||||
static void add_new_exterior(GLUtriangulatorObj *, tess_contour *);
|
||||
static void add_new_interior(GLUtriangulatorObj *, tess_contour *,
|
||||
tess_contour *);
|
||||
static void add_interior_with_hierarchy_check(GLUtriangulatorObj *,
|
||||
tess_contour *, tess_contour *);
|
||||
static void reverse_hierarchy_and_add_exterior(GLUtriangulatorObj *,
|
||||
tess_contour *,
|
||||
tess_contour *);
|
||||
static GLboolean point_in_polygon(tess_contour *, GLdouble, GLdouble);
|
||||
static void shift_interior_to_exterior(GLUtriangulatorObj *, tess_contour *);
|
||||
static void add_exterior_with_check(GLUtriangulatorObj *, tess_contour *,
|
||||
tess_contour *);
|
||||
static GLenum cut_out_hole(GLUtriangulatorObj *, tess_contour *,
|
||||
tess_contour *);
|
||||
static GLenum merge_hole_with_contour(GLUtriangulatorObj *,
|
||||
tess_contour *, tess_contour *,
|
||||
tess_vertex *, tess_vertex *);
|
||||
|
||||
static GLenum
|
||||
find_normal(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_polygon *polygon = tobj->current_polygon;
|
||||
tess_vertex *va, *vb, *vc;
|
||||
GLdouble A, B, C;
|
||||
GLdouble A0, A1, A2, B0, B1, B2;
|
||||
|
||||
va = polygon->vertices;
|
||||
vb = va->next;
|
||||
A0 = vb->location[0] - va->location[0];
|
||||
A1 = vb->location[1] - va->location[1];
|
||||
A2 = vb->location[2] - va->location[2];
|
||||
for (vc = vb->next; vc != va; vc = vc->next) {
|
||||
B0 = vc->location[0] - va->location[0];
|
||||
B1 = vc->location[1] - va->location[1];
|
||||
B2 = vc->location[2] - va->location[2];
|
||||
A = A1 * B2 - A2 * B1;
|
||||
B = A2 * B0 - A0 * B2;
|
||||
C = A0 * B1 - A1 * B0;
|
||||
if (fabs(A) > EPSILON || fabs(B) > EPSILON || fabs(C) > EPSILON) {
|
||||
polygon->A = A;
|
||||
polygon->B = B;
|
||||
polygon->C = C;
|
||||
polygon->D =
|
||||
-A * va->location[0] - B * va->location[1] - C * va->location[2];
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
}
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR7);
|
||||
return GLU_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
tess_test_polygon(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_polygon *polygon = tobj->current_polygon;
|
||||
|
||||
/* any vertices defined? */
|
||||
if (polygon->vertex_cnt < 3) {
|
||||
free_current_polygon(polygon);
|
||||
return;
|
||||
}
|
||||
/* wrap pointers */
|
||||
polygon->last_vertex->next = polygon->vertices;
|
||||
polygon->vertices->previous = polygon->last_vertex;
|
||||
/* determine the normal */
|
||||
if (find_normal(tobj) == GLU_ERROR)
|
||||
return;
|
||||
/* compare the normals of previously defined contours and this one */
|
||||
/* first contour define ? */
|
||||
if (tobj->contours == NULL) {
|
||||
tobj->A = polygon->A;
|
||||
tobj->B = polygon->B;
|
||||
tobj->C = polygon->C;
|
||||
tobj->D = polygon->D;
|
||||
/* determine the best projection to use */
|
||||
if (fabs(polygon->A) > fabs(polygon->B))
|
||||
if (fabs(polygon->A) > fabs(polygon->C))
|
||||
tobj->projection = OYZ;
|
||||
else
|
||||
tobj->projection = OXY;
|
||||
else if (fabs(polygon->B) > fabs(polygon->C))
|
||||
tobj->projection = OXZ;
|
||||
else
|
||||
tobj->projection = OXY;
|
||||
}
|
||||
else {
|
||||
GLdouble a[3], b[3];
|
||||
tess_vertex *vertex = polygon->vertices;
|
||||
|
||||
a[0] = tobj->A;
|
||||
a[1] = tobj->B;
|
||||
a[2] = tobj->C;
|
||||
b[0] = polygon->A;
|
||||
b[1] = polygon->B;
|
||||
b[2] = polygon->C;
|
||||
|
||||
/* compare the normals */
|
||||
if (fabs(a[1] * b[2] - a[2] * b[1]) > EPSILON ||
|
||||
fabs(a[2] * b[0] - a[0] * b[2]) > EPSILON ||
|
||||
fabs(a[0] * b[1] - a[1] * b[0]) > EPSILON) {
|
||||
/* not coplanar */
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR9);
|
||||
return;
|
||||
}
|
||||
/* the normals are parallel - test for plane equation */
|
||||
if (fabs(a[0] * vertex->location[0] + a[1] * vertex->location[1] +
|
||||
a[2] * vertex->location[2] + tobj->D) > EPSILON) {
|
||||
/* not the same plane */
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR9);
|
||||
return;
|
||||
}
|
||||
}
|
||||
prepare_projection_info(tobj);
|
||||
if (verify_edge_vertex_intersections(tobj) == GLU_ERROR)
|
||||
return;
|
||||
if (test_for_overlapping_contours(tobj) == GLU_ERROR)
|
||||
return;
|
||||
if (store_polygon_as_contour(tobj) == GLU_ERROR)
|
||||
return;
|
||||
}
|
||||
|
||||
static GLenum
|
||||
test_for_overlapping_contours(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_contour *contour;
|
||||
tess_polygon *polygon;
|
||||
|
||||
polygon = tobj->current_polygon;
|
||||
for (contour = tobj->contours; contour != NULL; contour = contour->next)
|
||||
if (contours_overlap(contour, polygon) != GLU_NO_ERROR) {
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR5);
|
||||
return GLU_ERROR;
|
||||
}
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
|
||||
static GLenum
|
||||
store_polygon_as_contour(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_polygon *polygon = tobj->current_polygon;
|
||||
tess_contour *contour = tobj->contours;
|
||||
|
||||
/* the first contour defined */
|
||||
if (contour == NULL) {
|
||||
if ((contour = (tess_contour *) malloc(sizeof(tess_contour))) == NULL) {
|
||||
tess_call_user_error(tobj, GLU_OUT_OF_MEMORY);
|
||||
free_current_polygon(polygon);
|
||||
return GLU_ERROR;
|
||||
}
|
||||
tobj->contours = tobj->last_contour = contour;
|
||||
contour->next = contour->previous = NULL;
|
||||
}
|
||||
else {
|
||||
if ((contour = (tess_contour *) malloc(sizeof(tess_contour))) == NULL) {
|
||||
tess_call_user_error(tobj, GLU_OUT_OF_MEMORY);
|
||||
free_current_polygon(polygon);
|
||||
return GLU_ERROR;
|
||||
}
|
||||
contour->previous = tobj->last_contour;
|
||||
tobj->last_contour->next = contour;
|
||||
tobj->last_contour = contour;
|
||||
contour->next = NULL;
|
||||
}
|
||||
/* mark all vertices in new contour as not special */
|
||||
/* and all are boundary edges */
|
||||
{
|
||||
tess_vertex *vertex;
|
||||
GLuint vertex_cnt, i;
|
||||
|
||||
for (vertex = polygon->vertices, i = 0, vertex_cnt =
|
||||
polygon->vertex_cnt; i < vertex_cnt; vertex = vertex->next, i++) {
|
||||
vertex->shadow_vertex = NULL;
|
||||
vertex->edge_flag = GL_TRUE;
|
||||
}
|
||||
}
|
||||
contour->vertex_cnt = polygon->vertex_cnt;
|
||||
contour->area = polygon->area;
|
||||
contour->orientation = polygon->orientation;
|
||||
contour->type = GLU_UNKNOWN;
|
||||
contour->vertices = polygon->vertices;
|
||||
contour->last_vertex = polygon->last_vertex;
|
||||
polygon->vertices = polygon->last_vertex = NULL;
|
||||
polygon->vertex_cnt = 0;
|
||||
++(tobj->contour_cnt);
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
free_current_polygon(tess_polygon * polygon)
|
||||
{
|
||||
tess_vertex *vertex, *vertex_tmp;
|
||||
GLuint i;
|
||||
|
||||
/* free current_polygon structures */
|
||||
for (vertex = polygon->vertices, i = 0; i < polygon->vertex_cnt; i++) {
|
||||
vertex_tmp = vertex->next;
|
||||
free(vertex);
|
||||
vertex = vertex_tmp;
|
||||
}
|
||||
polygon->vertices = polygon->last_vertex = NULL;
|
||||
polygon->vertex_cnt = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_projection_info(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_polygon *polygon = tobj->current_polygon;
|
||||
tess_vertex *vertex, *last_vertex_ptr;
|
||||
GLdouble area;
|
||||
|
||||
last_vertex_ptr = polygon->last_vertex;
|
||||
switch (tobj->projection) {
|
||||
case OXY:
|
||||
for (vertex = polygon->vertices; vertex != last_vertex_ptr;
|
||||
vertex = vertex->next) {
|
||||
vertex->x = vertex->location[0];
|
||||
vertex->y = vertex->location[1];
|
||||
}
|
||||
last_vertex_ptr->x = last_vertex_ptr->location[0];
|
||||
last_vertex_ptr->y = last_vertex_ptr->location[1];
|
||||
break;
|
||||
case OXZ:
|
||||
for (vertex = polygon->vertices; vertex != last_vertex_ptr;
|
||||
vertex = vertex->next) {
|
||||
vertex->x = vertex->location[0];
|
||||
vertex->y = vertex->location[2];
|
||||
}
|
||||
last_vertex_ptr->x = last_vertex_ptr->location[0];
|
||||
last_vertex_ptr->y = last_vertex_ptr->location[2];
|
||||
break;
|
||||
case OYZ:
|
||||
for (vertex = polygon->vertices; vertex != last_vertex_ptr;
|
||||
vertex = vertex->next) {
|
||||
vertex->x = vertex->location[1];
|
||||
vertex->y = vertex->location[2];
|
||||
}
|
||||
last_vertex_ptr->x = last_vertex_ptr->location[1];
|
||||
last_vertex_ptr->y = last_vertex_ptr->location[2];
|
||||
break;
|
||||
}
|
||||
area = twice_the_polygon_area(polygon->vertices, polygon->last_vertex);
|
||||
if (area >= 0.0) {
|
||||
polygon->orientation = GLU_CCW;
|
||||
polygon->area = area;
|
||||
}
|
||||
else {
|
||||
polygon->orientation = GLU_CW;
|
||||
polygon->area = -area;
|
||||
}
|
||||
}
|
||||
|
||||
static GLdouble
|
||||
twice_the_polygon_area(tess_vertex * vertex, tess_vertex * last_vertex)
|
||||
{
|
||||
tess_vertex *next;
|
||||
GLdouble area, x, y;
|
||||
|
||||
area = 0.0;
|
||||
x = vertex->x;
|
||||
y = vertex->y;
|
||||
vertex = vertex->next;
|
||||
for (; vertex != last_vertex; vertex = vertex->next) {
|
||||
next = vertex->next;
|
||||
area +=
|
||||
(vertex->x - x) * (next->y - y) - (vertex->y - y) * (next->x - x);
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
/* test if edges ab and cd intersect */
|
||||
/* if not return GLU_NO_ERROR, else if cross return GLU_TESS_ERROR8, */
|
||||
/* else if adjacent return GLU_TESS_ERROR4 */
|
||||
static GLenum
|
||||
edge_edge_intersect(tess_vertex * a,
|
||||
tess_vertex * b, tess_vertex * c, tess_vertex * d)
|
||||
{
|
||||
GLdouble denom, r, s;
|
||||
GLdouble xba, ydc, yba, xdc, yac, xac;
|
||||
|
||||
xba = b->x - a->x;
|
||||
yba = b->y - a->y;
|
||||
xdc = d->x - c->x;
|
||||
ydc = d->y - c->y;
|
||||
xac = a->x - c->x;
|
||||
yac = a->y - c->y;
|
||||
denom = xba * ydc - yba * xdc;
|
||||
r = yac * xdc - xac * ydc;
|
||||
/* parallel? */
|
||||
if (fabs(denom) < EPSILON) {
|
||||
if (fabs(r) < EPSILON) {
|
||||
/* colinear */
|
||||
if (fabs(xba) < EPSILON) {
|
||||
/* compare the Y coordinate */
|
||||
if (yba > 0.0) {
|
||||
if (
|
||||
(fabs(a->y - c->y) < EPSILON
|
||||
&& fabs(c->y - b->y) < EPSILON)
|
||||
|| (fabs(a->y - d->y) < EPSILON
|
||||
&& fabs(d->y - b->y) <
|
||||
EPSILON)) return GLU_TESS_ERROR4;
|
||||
|
||||
}
|
||||
else {
|
||||
if (
|
||||
(fabs(b->y - c->y) < EPSILON
|
||||
&& fabs(c->y - a->y) < EPSILON)
|
||||
|| (fabs(b->y - d->y) < EPSILON
|
||||
&& fabs(d->y - a->y) <
|
||||
EPSILON)) return GLU_TESS_ERROR4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* compare the X coordinate */
|
||||
if (xba > 0.0) {
|
||||
if (
|
||||
(fabs(a->x - c->x) < EPSILON
|
||||
&& fabs(c->x - b->x) < EPSILON)
|
||||
|| (fabs(a->x - d->x) < EPSILON
|
||||
&& fabs(d->x - b->x) <
|
||||
EPSILON)) return GLU_TESS_ERROR4;
|
||||
}
|
||||
else {
|
||||
if (
|
||||
(fabs(b->x - c->x) < EPSILON
|
||||
&& fabs(c->x - a->x) < EPSILON)
|
||||
|| (fabs(b->x - d->x) < EPSILON
|
||||
&& fabs(d->x - a->x) <
|
||||
EPSILON)) return GLU_TESS_ERROR4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
r /= denom;
|
||||
s = (yac * xba - xac * yba) / denom;
|
||||
/* test if one vertex lies on other edge */
|
||||
if (((fabs(r) < EPSILON || (r < 1.0 + EPSILON && r > 1.0 - EPSILON)) &&
|
||||
s > -EPSILON && s < 1.0 + EPSILON) ||
|
||||
((fabs(s) < EPSILON || (s < 1.0 + EPSILON && s > 1.0 - EPSILON)) &&
|
||||
r > -EPSILON && r < 1.0 + EPSILON)) {
|
||||
return GLU_TESS_ERROR4;
|
||||
}
|
||||
/* test for crossing */
|
||||
if (r > -EPSILON && r < 1.0 + EPSILON && s > -EPSILON && s < 1.0 + EPSILON) {
|
||||
return GLU_TESS_ERROR8;
|
||||
}
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
|
||||
static GLenum
|
||||
verify_edge_vertex_intersections(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_polygon *polygon = tobj->current_polygon;
|
||||
tess_vertex *vertex1, *last_vertex, *vertex2;
|
||||
GLenum test;
|
||||
|
||||
last_vertex = polygon->last_vertex;
|
||||
vertex1 = last_vertex;
|
||||
for (vertex2 = vertex1->next->next;
|
||||
vertex2->next != last_vertex; vertex2 = vertex2->next) {
|
||||
test = edge_edge_intersect(vertex1, vertex1->next, vertex2,
|
||||
vertex2->next);
|
||||
if (test != GLU_NO_ERROR) {
|
||||
tess_call_user_error(tobj, test);
|
||||
return GLU_ERROR;
|
||||
}
|
||||
}
|
||||
for (vertex1 = polygon->vertices;
|
||||
vertex1->next->next != last_vertex; vertex1 = vertex1->next) {
|
||||
for (vertex2 = vertex1->next->next;
|
||||
vertex2 != last_vertex; vertex2 = vertex2->next) {
|
||||
test = edge_edge_intersect(vertex1, vertex1->next, vertex2,
|
||||
vertex2->next);
|
||||
if (test != GLU_NO_ERROR) {
|
||||
tess_call_user_error(tobj, test);
|
||||
return GLU_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
|
||||
static int
|
||||
#ifdef WIN32
|
||||
__cdecl
|
||||
#endif
|
||||
area_compare(const void *a, const void *b)
|
||||
{
|
||||
GLdouble area1, area2;
|
||||
|
||||
area1 = (*((tess_contour **) a))->area;
|
||||
area2 = (*((tess_contour **) b))->area;
|
||||
if (area1 < area2)
|
||||
return 1;
|
||||
if (area1 > area2)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
tess_find_contour_hierarchies(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_contour **contours; /* dinamic array of pointers */
|
||||
tess_contour *tmp_contour_ptr = tobj->contours;
|
||||
GLuint cnt, i;
|
||||
GLenum result;
|
||||
GLboolean hierarchy_changed;
|
||||
|
||||
/* any contours? */
|
||||
if (tobj->contour_cnt < 2) {
|
||||
tobj->contours->type = GLU_EXTERIOR;
|
||||
return;
|
||||
}
|
||||
if ((contours = (tess_contour **)
|
||||
malloc(sizeof(tess_contour *) * (tobj->contour_cnt))) == NULL) {
|
||||
tess_call_user_error(tobj, GLU_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
for (tmp_contour_ptr = tobj->contours, cnt = 0;
|
||||
tmp_contour_ptr != NULL; tmp_contour_ptr = tmp_contour_ptr->next)
|
||||
contours[cnt++] = tmp_contour_ptr;
|
||||
/* now sort the contours in decreasing area size order */
|
||||
qsort((void *) contours, (size_t) cnt, (size_t) sizeof(tess_contour *),
|
||||
area_compare);
|
||||
/* we leave just the first contour - remove others from list */
|
||||
tobj->contours = contours[0];
|
||||
tobj->contours->next = tobj->contours->previous = NULL;
|
||||
tobj->last_contour = tobj->contours;
|
||||
tobj->contour_cnt = 1;
|
||||
/* first contour is the one with greatest area */
|
||||
/* must be EXTERIOR */
|
||||
tobj->contours->type = GLU_EXTERIOR;
|
||||
tmp_contour_ptr = tobj->contours;
|
||||
/* now we play! */
|
||||
for (i = 1; i < cnt; i++) {
|
||||
hierarchy_changed = GL_FALSE;
|
||||
for (tmp_contour_ptr = tobj->contours;
|
||||
tmp_contour_ptr != NULL; tmp_contour_ptr = tmp_contour_ptr->next) {
|
||||
if (tmp_contour_ptr->type == GLU_EXTERIOR) {
|
||||
/* check if contour completely contained in EXTERIOR */
|
||||
result = is_contour_contained_in(tmp_contour_ptr, contours[i]);
|
||||
switch (result) {
|
||||
case GLU_INTERIOR:
|
||||
/* now we have to check if contour is inside interiors */
|
||||
/* or not */
|
||||
/* any interiors? */
|
||||
if (tmp_contour_ptr->next != NULL &&
|
||||
tmp_contour_ptr->next->type == GLU_INTERIOR) {
|
||||
/* for all interior, check if inside any of them */
|
||||
/* if not inside any of interiors, its another */
|
||||
/* interior */
|
||||
/* or it may contain some interiors, then change */
|
||||
/* the contained interiors to exterior ones */
|
||||
add_interior_with_hierarchy_check(tobj,
|
||||
tmp_contour_ptr,
|
||||
contours[i]);
|
||||
}
|
||||
else {
|
||||
/* not in interior, add as new interior contour */
|
||||
add_new_interior(tobj, tmp_contour_ptr, contours[i]);
|
||||
}
|
||||
hierarchy_changed = GL_TRUE;
|
||||
break;
|
||||
case GLU_EXTERIOR:
|
||||
/* ooops, the marked as EXTERIOR (contours[i]) is */
|
||||
/* actually an interior of tmp_contour_ptr */
|
||||
/* reverse the local hierarchy */
|
||||
reverse_hierarchy_and_add_exterior(tobj, tmp_contour_ptr,
|
||||
contours[i]);
|
||||
hierarchy_changed = GL_TRUE;
|
||||
break;
|
||||
case GLU_NO_ERROR:
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
if (hierarchy_changed)
|
||||
break; /* break from for loop */
|
||||
}
|
||||
if (hierarchy_changed == GL_FALSE) {
|
||||
/* disjoint with all contours, add to contour list */
|
||||
add_new_exterior(tobj, contours[i]);
|
||||
}
|
||||
}
|
||||
free(contours);
|
||||
}
|
||||
|
||||
/* returns GLU_INTERIOR if inner is completey enclosed within outer */
|
||||
/* returns GLU_EXTERIOR if outer is completely enclosed within inner */
|
||||
/* returns GLU_NO_ERROR if contours are disjoint */
|
||||
static GLenum
|
||||
is_contour_contained_in(tess_contour * outer, tess_contour * inner)
|
||||
{
|
||||
GLenum relation_flag;
|
||||
|
||||
/* set relation_flag to relation of containment of first inner vertex */
|
||||
/* regarding outer contour */
|
||||
if (point_in_polygon(outer, inner->vertices->x, inner->vertices->y))
|
||||
relation_flag = GLU_INTERIOR;
|
||||
else
|
||||
relation_flag = GLU_EXTERIOR;
|
||||
if (relation_flag == GLU_INTERIOR)
|
||||
return GLU_INTERIOR;
|
||||
if (point_in_polygon(inner, outer->vertices->x, outer->vertices->y))
|
||||
return GLU_EXTERIOR;
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
point_in_polygon(tess_contour * contour, GLdouble x, GLdouble y)
|
||||
{
|
||||
tess_vertex *v1, *v2;
|
||||
GLuint i, vertex_cnt;
|
||||
GLdouble xp1, yp1, xp2, yp2;
|
||||
GLboolean tst;
|
||||
|
||||
tst = GL_FALSE;
|
||||
v1 = contour->vertices;
|
||||
v2 = contour->vertices->previous;
|
||||
for (i = 0, vertex_cnt = contour->vertex_cnt; i < vertex_cnt; i++) {
|
||||
xp1 = v1->x;
|
||||
yp1 = v1->y;
|
||||
xp2 = v2->x;
|
||||
yp2 = v2->y;
|
||||
if ((((yp1 <= y) && (y < yp2)) || ((yp2 <= y) && (y < yp1))) &&
|
||||
(x < (xp2 - xp1) * (y - yp1) / (yp2 - yp1) + xp1))
|
||||
tst = (tst == GL_FALSE ? GL_TRUE : GL_FALSE);
|
||||
v2 = v1;
|
||||
v1 = v1->next;
|
||||
}
|
||||
return tst;
|
||||
}
|
||||
|
||||
static GLenum
|
||||
contours_overlap(tess_contour * contour, tess_polygon * polygon)
|
||||
{
|
||||
tess_vertex *vertex1, *vertex2;
|
||||
GLuint vertex1_cnt, vertex2_cnt, i, j;
|
||||
GLenum test;
|
||||
|
||||
vertex1 = contour->vertices;
|
||||
vertex2 = polygon->vertices;
|
||||
vertex1_cnt = contour->vertex_cnt;
|
||||
vertex2_cnt = polygon->vertex_cnt;
|
||||
for (i = 0; i < vertex1_cnt; vertex1 = vertex1->next, i++) {
|
||||
for (j = 0; j < vertex2_cnt; vertex2 = vertex2->next, j++)
|
||||
if ((test = edge_edge_intersect(vertex1, vertex1->next, vertex2,
|
||||
vertex2->next)) != GLU_NO_ERROR)
|
||||
return test;
|
||||
}
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
add_new_exterior(GLUtriangulatorObj * tobj, tess_contour * contour)
|
||||
{
|
||||
contour->type = GLU_EXTERIOR;
|
||||
contour->next = NULL;
|
||||
contour->previous = tobj->last_contour;
|
||||
tobj->last_contour->next = contour;
|
||||
tobj->last_contour = contour;
|
||||
}
|
||||
|
||||
static void
|
||||
add_new_interior(GLUtriangulatorObj * tobj,
|
||||
tess_contour * outer, tess_contour * contour)
|
||||
{
|
||||
contour->type = GLU_INTERIOR;
|
||||
contour->next = outer->next;
|
||||
contour->previous = outer;
|
||||
if (outer->next != NULL)
|
||||
outer->next->previous = contour;
|
||||
outer->next = contour;
|
||||
if (tobj->last_contour == outer)
|
||||
tobj->last_contour = contour;
|
||||
}
|
||||
|
||||
static void
|
||||
add_interior_with_hierarchy_check(GLUtriangulatorObj * tobj,
|
||||
tess_contour * outer,
|
||||
tess_contour * contour)
|
||||
{
|
||||
tess_contour *ptr;
|
||||
|
||||
/* for all interiors of outer check if they are interior of contour */
|
||||
/* if so, change that interior to exterior and move it of of the */
|
||||
/* interior sequence */
|
||||
if (outer->next != NULL && outer->next->type == GLU_INTERIOR) {
|
||||
GLenum test;
|
||||
|
||||
for (ptr = outer->next; ptr != NULL && ptr->type == GLU_INTERIOR;
|
||||
ptr = ptr->next) {
|
||||
test = is_contour_contained_in(ptr, contour);
|
||||
switch (test) {
|
||||
case GLU_INTERIOR:
|
||||
/* contour is contained in one of the interiors */
|
||||
/* check if possibly contained in other exteriors */
|
||||
/* move ptr to first EXTERIOR */
|
||||
for (; ptr != NULL && ptr->type == GLU_INTERIOR; ptr = ptr->next);
|
||||
if (ptr == NULL)
|
||||
/* another exterior */
|
||||
add_new_exterior(tobj, contour);
|
||||
else
|
||||
add_exterior_with_check(tobj, ptr, contour);
|
||||
return;
|
||||
case GLU_EXTERIOR:
|
||||
/* one of the interiors is contained in the contour */
|
||||
/* change it to EXTERIOR, and shift it away from the */
|
||||
/* interior sequence */
|
||||
shift_interior_to_exterior(tobj, ptr);
|
||||
break;
|
||||
case GLU_NO_ERROR:
|
||||
/* disjoint */
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* add contour to the interior sequence */
|
||||
add_new_interior(tobj, outer, contour);
|
||||
}
|
||||
|
||||
static void
|
||||
reverse_hierarchy_and_add_exterior(GLUtriangulatorObj * tobj,
|
||||
tess_contour * outer,
|
||||
tess_contour * contour)
|
||||
{
|
||||
tess_contour *ptr;
|
||||
|
||||
/* reverse INTERIORS to EXTERIORS */
|
||||
/* any INTERIORS? */
|
||||
if (outer->next != NULL && outer->next->type == GLU_INTERIOR)
|
||||
for (ptr = outer->next; ptr != NULL && ptr->type == GLU_INTERIOR;
|
||||
ptr = ptr->next) ptr->type = GLU_EXTERIOR;
|
||||
/* the outer now becomes inner */
|
||||
outer->type = GLU_INTERIOR;
|
||||
/* contour is the EXTERIOR */
|
||||
contour->next = outer;
|
||||
if (tobj->contours == outer) {
|
||||
/* first contour beeing reversed */
|
||||
contour->previous = NULL;
|
||||
tobj->contours = contour;
|
||||
}
|
||||
else {
|
||||
outer->previous->next = contour;
|
||||
contour->previous = outer->previous;
|
||||
}
|
||||
outer->previous = contour;
|
||||
}
|
||||
|
||||
static void
|
||||
shift_interior_to_exterior(GLUtriangulatorObj * tobj, tess_contour * contour)
|
||||
{
|
||||
contour->previous->next = contour->next;
|
||||
if (contour->next != NULL)
|
||||
contour->next->previous = contour->previous;
|
||||
else
|
||||
tobj->last_contour = contour->previous;
|
||||
}
|
||||
|
||||
static void
|
||||
add_exterior_with_check(GLUtriangulatorObj * tobj,
|
||||
tess_contour * outer, tess_contour * contour)
|
||||
{
|
||||
GLenum test;
|
||||
|
||||
/* this contour might be interior to further exteriors - check */
|
||||
/* if not, just add as a new exterior */
|
||||
for (; outer != NULL && outer->type == GLU_EXTERIOR; outer = outer->next) {
|
||||
test = is_contour_contained_in(outer, contour);
|
||||
switch (test) {
|
||||
case GLU_INTERIOR:
|
||||
/* now we have to check if contour is inside interiors */
|
||||
/* or not */
|
||||
/* any interiors? */
|
||||
if (outer->next != NULL && outer->next->type == GLU_INTERIOR) {
|
||||
/* for all interior, check if inside any of them */
|
||||
/* if not inside any of interiors, its another */
|
||||
/* interior */
|
||||
/* or it may contain some interiors, then change */
|
||||
/* the contained interiors to exterior ones */
|
||||
add_interior_with_hierarchy_check(tobj, outer, contour);
|
||||
}
|
||||
else {
|
||||
/* not in interior, add as new interior contour */
|
||||
add_new_interior(tobj, outer, contour);
|
||||
}
|
||||
return;
|
||||
case GLU_NO_ERROR:
|
||||
/* disjoint */
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
/* add contour to the exterior sequence */
|
||||
add_new_exterior(tobj, contour);
|
||||
}
|
||||
|
||||
void
|
||||
tess_handle_holes(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_contour *contour, *hole;
|
||||
GLenum exterior_orientation;
|
||||
|
||||
/* verify hole orientation */
|
||||
for (contour = tobj->contours; contour != NULL;) {
|
||||
exterior_orientation = contour->orientation;
|
||||
for (contour = contour->next;
|
||||
contour != NULL && contour->type == GLU_INTERIOR;
|
||||
contour = contour->next) {
|
||||
if (contour->orientation == exterior_orientation) {
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR5);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* now cut-out holes */
|
||||
for (contour = tobj->contours; contour != NULL;) {
|
||||
hole = contour->next;
|
||||
while (hole != NULL && hole->type == GLU_INTERIOR) {
|
||||
if (cut_out_hole(tobj, contour, hole) == GLU_ERROR)
|
||||
return;
|
||||
hole = contour->next;
|
||||
}
|
||||
contour = contour->next;
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum
|
||||
cut_out_hole(GLUtriangulatorObj * tobj,
|
||||
tess_contour * contour, tess_contour * hole)
|
||||
{
|
||||
tess_contour *tmp_hole;
|
||||
tess_vertex *v1, *v2, *tmp_vertex;
|
||||
GLuint vertex1_cnt, vertex2_cnt, tmp_vertex_cnt;
|
||||
GLuint i, j, k;
|
||||
GLenum test = 0;
|
||||
|
||||
/* find an edge connecting contour and hole not intersecting any other */
|
||||
/* edge belonging to either the contour or any of the other holes */
|
||||
for (v1 = contour->vertices, vertex1_cnt = contour->vertex_cnt, i = 0;
|
||||
i < vertex1_cnt; i++, v1 = v1->next) {
|
||||
for (v2 = hole->vertices, vertex2_cnt = hole->vertex_cnt, j = 0;
|
||||
j < vertex2_cnt; j++, v2 = v2->next) {
|
||||
/* does edge (v1,v2) intersect any edge of contour */
|
||||
for (tmp_vertex = contour->vertices, tmp_vertex_cnt =
|
||||
contour->vertex_cnt, k = 0; k < tmp_vertex_cnt;
|
||||
tmp_vertex = tmp_vertex->next, k++) {
|
||||
/* skip edge tests for edges directly connected */
|
||||
if (v1 == tmp_vertex || v1 == tmp_vertex->next)
|
||||
continue;
|
||||
test = edge_edge_intersect(v1, v2, tmp_vertex, tmp_vertex->next);
|
||||
if (test != GLU_NO_ERROR)
|
||||
break;
|
||||
}
|
||||
if (test == GLU_NO_ERROR) {
|
||||
/* does edge (v1,v2) intersect any edge of hole */
|
||||
for (tmp_vertex = hole->vertices,
|
||||
tmp_vertex_cnt = hole->vertex_cnt, k = 0;
|
||||
k < tmp_vertex_cnt; tmp_vertex = tmp_vertex->next, k++) {
|
||||
/* skip edge tests for edges directly connected */
|
||||
if (v2 == tmp_vertex || v2 == tmp_vertex->next)
|
||||
continue;
|
||||
test =
|
||||
edge_edge_intersect(v1, v2, tmp_vertex, tmp_vertex->next);
|
||||
if (test != GLU_NO_ERROR)
|
||||
break;
|
||||
}
|
||||
if (test == GLU_NO_ERROR) {
|
||||
/* does edge (v1,v2) intersect any other hole? */
|
||||
for (tmp_hole = hole->next;
|
||||
tmp_hole != NULL && tmp_hole->type == GLU_INTERIOR;
|
||||
tmp_hole = tmp_hole->next) {
|
||||
/* does edge (v1,v2) intersect any edge of hole */
|
||||
for (tmp_vertex = tmp_hole->vertices,
|
||||
tmp_vertex_cnt = tmp_hole->vertex_cnt, k = 0;
|
||||
k < tmp_vertex_cnt; tmp_vertex = tmp_vertex->next, k++) {
|
||||
test = edge_edge_intersect(v1, v2, tmp_vertex,
|
||||
tmp_vertex->next);
|
||||
if (test != GLU_NO_ERROR)
|
||||
break;
|
||||
}
|
||||
if (test != GLU_NO_ERROR)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (test == GLU_NO_ERROR) {
|
||||
/* edge (v1,v2) is good for eliminating the hole */
|
||||
if (merge_hole_with_contour(tobj, contour, hole, v1, v2)
|
||||
== GLU_NO_ERROR)
|
||||
return GLU_NO_ERROR;
|
||||
else
|
||||
return GLU_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* other holes are blocking all possible connections of hole */
|
||||
/* with contour, we shift this hole as the last hole and retry */
|
||||
for (tmp_hole = hole;
|
||||
tmp_hole != NULL && tmp_hole->type == GLU_INTERIOR;
|
||||
tmp_hole = tmp_hole->next);
|
||||
contour->next = hole->next;
|
||||
hole->next->previous = contour;
|
||||
if (tmp_hole == NULL) {
|
||||
/* last EXTERIOR contour, shift hole as last contour */
|
||||
hole->next = NULL;
|
||||
hole->previous = tobj->last_contour;
|
||||
tobj->last_contour->next = hole;
|
||||
tobj->last_contour = hole;
|
||||
}
|
||||
else {
|
||||
tmp_hole->previous->next = hole;
|
||||
hole->previous = tmp_hole->previous;
|
||||
tmp_hole->previous = hole;
|
||||
hole->next = tmp_hole;
|
||||
}
|
||||
hole = contour->next;
|
||||
/* try once again - recurse */
|
||||
return cut_out_hole(tobj, contour, hole);
|
||||
}
|
||||
|
||||
static GLenum
|
||||
merge_hole_with_contour(GLUtriangulatorObj * tobj,
|
||||
tess_contour * contour,
|
||||
tess_contour * hole,
|
||||
tess_vertex * v1, tess_vertex * v2)
|
||||
{
|
||||
tess_vertex *v1_new, *v2_new;
|
||||
|
||||
/* make copies of v1 and v2, place them respectively after their originals */
|
||||
if ((v1_new = (tess_vertex *) malloc(sizeof(tess_vertex))) == NULL) {
|
||||
tess_call_user_error(tobj, GLU_OUT_OF_MEMORY);
|
||||
return GLU_ERROR;
|
||||
}
|
||||
if ((v2_new = (tess_vertex *) malloc(sizeof(tess_vertex))) == NULL) {
|
||||
tess_call_user_error(tobj, GLU_OUT_OF_MEMORY);
|
||||
return GLU_ERROR;
|
||||
}
|
||||
v1_new->edge_flag = GL_TRUE;
|
||||
v1_new->data = v1->data;
|
||||
v1_new->location[0] = v1->location[0];
|
||||
v1_new->location[1] = v1->location[1];
|
||||
v1_new->location[2] = v1->location[2];
|
||||
v1_new->x = v1->x;
|
||||
v1_new->y = v1->y;
|
||||
v1_new->shadow_vertex = v1;
|
||||
v1->shadow_vertex = v1_new;
|
||||
v1_new->next = v1->next;
|
||||
v1_new->previous = v1;
|
||||
v1->next->previous = v1_new;
|
||||
v1->next = v1_new;
|
||||
v2_new->edge_flag = GL_TRUE;
|
||||
v2_new->data = v2->data;
|
||||
v2_new->location[0] = v2->location[0];
|
||||
v2_new->location[1] = v2->location[1];
|
||||
v2_new->location[2] = v2->location[2];
|
||||
v2_new->x = v2->x;
|
||||
v2_new->y = v2->y;
|
||||
v2_new->shadow_vertex = v2;
|
||||
v2->shadow_vertex = v2_new;
|
||||
v2_new->next = v2->next;
|
||||
v2_new->previous = v2;
|
||||
v2->next->previous = v2_new;
|
||||
v2->next = v2_new;
|
||||
/* link together the two lists */
|
||||
v1->next = v2_new;
|
||||
v2_new->previous = v1;
|
||||
v2->next = v1_new;
|
||||
v1_new->previous = v2;
|
||||
/* update the vertex count of the contour */
|
||||
contour->vertex_cnt += hole->vertex_cnt + 2;
|
||||
/* remove the INTERIOR contour */
|
||||
contour->next = hole->next;
|
||||
if (hole->next != NULL)
|
||||
hole->next->previous = contour;
|
||||
free(hole);
|
||||
/* update tobj structure */
|
||||
--(tobj->contour_cnt);
|
||||
if (contour->last_vertex == v1)
|
||||
contour->last_vertex = v1_new;
|
||||
/* mark two vertices with edge_flag */
|
||||
v2->edge_flag = GL_FALSE;
|
||||
v1->edge_flag = GL_FALSE;
|
||||
return GLU_NO_ERROR;
|
||||
}
|
||||
402
src/glu/mini/project.c
Normal file
402
src/glu/mini/project.c
Normal file
@@ -0,0 +1,402 @@
|
||||
/* $Id: project.c,v 1.1.2.1 2003/03/21 13:02:18 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "gluP.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* This code was contributed by Marc Buffat (buffat@mecaflu.ec-lyon.fr).
|
||||
* Thanks Marc!!!
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* implementation de gluProject et gluUnproject */
|
||||
/* M. Buffat 17/2/95 */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Transform a point (column vector) by a 4x4 matrix. I.e. out = m * in
|
||||
* Input: m - the 4x4 matrix
|
||||
* in - the 4x1 vector
|
||||
* Output: out - the resulting 4x1 vector.
|
||||
*/
|
||||
static void
|
||||
transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4])
|
||||
{
|
||||
#define M(row,col) m[col*4+row]
|
||||
out[0] =
|
||||
M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3];
|
||||
out[1] =
|
||||
M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3];
|
||||
out[2] =
|
||||
M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3];
|
||||
out[3] =
|
||||
M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3];
|
||||
#undef M
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Perform a 4x4 matrix multiplication (product = a x b).
|
||||
* Input: a, b - matrices to multiply
|
||||
* Output: product - product of a and b
|
||||
*/
|
||||
static void
|
||||
matmul(GLdouble * product, const GLdouble * a, const GLdouble * b)
|
||||
{
|
||||
/* This matmul was contributed by Thomas Malik */
|
||||
GLdouble temp[16];
|
||||
GLint i;
|
||||
|
||||
#define A(row,col) a[(col<<2)+row]
|
||||
#define B(row,col) b[(col<<2)+row]
|
||||
#define T(row,col) temp[(col<<2)+row]
|
||||
|
||||
/* i-te Zeile */
|
||||
for (i = 0; i < 4; i++) {
|
||||
T(i, 0) =
|
||||
A(i, 0) * B(0, 0) + A(i, 1) * B(1, 0) + A(i, 2) * B(2, 0) + A(i,
|
||||
3) *
|
||||
B(3, 0);
|
||||
T(i, 1) =
|
||||
A(i, 0) * B(0, 1) + A(i, 1) * B(1, 1) + A(i, 2) * B(2, 1) + A(i,
|
||||
3) *
|
||||
B(3, 1);
|
||||
T(i, 2) =
|
||||
A(i, 0) * B(0, 2) + A(i, 1) * B(1, 2) + A(i, 2) * B(2, 2) + A(i,
|
||||
3) *
|
||||
B(3, 2);
|
||||
T(i, 3) =
|
||||
A(i, 0) * B(0, 3) + A(i, 1) * B(1, 3) + A(i, 2) * B(2, 3) + A(i,
|
||||
3) *
|
||||
B(3, 3);
|
||||
}
|
||||
|
||||
#undef A
|
||||
#undef B
|
||||
#undef T
|
||||
MEMCPY(product, temp, 16 * sizeof(GLdouble));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Compute inverse of 4x4 transformation matrix.
|
||||
* Code contributed by Jacques Leroy jle@star.be
|
||||
* Return GL_TRUE for success, GL_FALSE for failure (singular matrix)
|
||||
*/
|
||||
static GLboolean
|
||||
invert_matrix(const GLdouble * m, GLdouble * out)
|
||||
{
|
||||
/* NB. OpenGL Matrices are COLUMN major. */
|
||||
#define SWAP_ROWS(a, b) { GLdouble *_tmp = a; (a)=(b); (b)=_tmp; }
|
||||
#define MAT(m,r,c) (m)[(c)*4+(r)]
|
||||
|
||||
GLdouble wtmp[4][8];
|
||||
GLdouble m0, m1, m2, m3, s;
|
||||
GLdouble *r0, *r1, *r2, *r3;
|
||||
|
||||
r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
|
||||
|
||||
r0[0] = MAT(m, 0, 0), r0[1] = MAT(m, 0, 1),
|
||||
r0[2] = MAT(m, 0, 2), r0[3] = MAT(m, 0, 3),
|
||||
r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
|
||||
r1[0] = MAT(m, 1, 0), r1[1] = MAT(m, 1, 1),
|
||||
r1[2] = MAT(m, 1, 2), r1[3] = MAT(m, 1, 3),
|
||||
r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
|
||||
r2[0] = MAT(m, 2, 0), r2[1] = MAT(m, 2, 1),
|
||||
r2[2] = MAT(m, 2, 2), r2[3] = MAT(m, 2, 3),
|
||||
r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
|
||||
r3[0] = MAT(m, 3, 0), r3[1] = MAT(m, 3, 1),
|
||||
r3[2] = MAT(m, 3, 2), r3[3] = MAT(m, 3, 3),
|
||||
r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
|
||||
|
||||
/* choose pivot - or die */
|
||||
if (fabs(r3[0]) > fabs(r2[0]))
|
||||
SWAP_ROWS(r3, r2);
|
||||
if (fabs(r2[0]) > fabs(r1[0]))
|
||||
SWAP_ROWS(r2, r1);
|
||||
if (fabs(r1[0]) > fabs(r0[0]))
|
||||
SWAP_ROWS(r1, r0);
|
||||
if (0.0 == r0[0])
|
||||
return GL_FALSE;
|
||||
|
||||
/* eliminate first variable */
|
||||
m1 = r1[0] / r0[0];
|
||||
m2 = r2[0] / r0[0];
|
||||
m3 = r3[0] / r0[0];
|
||||
s = r0[1];
|
||||
r1[1] -= m1 * s;
|
||||
r2[1] -= m2 * s;
|
||||
r3[1] -= m3 * s;
|
||||
s = r0[2];
|
||||
r1[2] -= m1 * s;
|
||||
r2[2] -= m2 * s;
|
||||
r3[2] -= m3 * s;
|
||||
s = r0[3];
|
||||
r1[3] -= m1 * s;
|
||||
r2[3] -= m2 * s;
|
||||
r3[3] -= m3 * s;
|
||||
s = r0[4];
|
||||
if (s != 0.0) {
|
||||
r1[4] -= m1 * s;
|
||||
r2[4] -= m2 * s;
|
||||
r3[4] -= m3 * s;
|
||||
}
|
||||
s = r0[5];
|
||||
if (s != 0.0) {
|
||||
r1[5] -= m1 * s;
|
||||
r2[5] -= m2 * s;
|
||||
r3[5] -= m3 * s;
|
||||
}
|
||||
s = r0[6];
|
||||
if (s != 0.0) {
|
||||
r1[6] -= m1 * s;
|
||||
r2[6] -= m2 * s;
|
||||
r3[6] -= m3 * s;
|
||||
}
|
||||
s = r0[7];
|
||||
if (s != 0.0) {
|
||||
r1[7] -= m1 * s;
|
||||
r2[7] -= m2 * s;
|
||||
r3[7] -= m3 * s;
|
||||
}
|
||||
|
||||
/* choose pivot - or die */
|
||||
if (fabs(r3[1]) > fabs(r2[1]))
|
||||
SWAP_ROWS(r3, r2);
|
||||
if (fabs(r2[1]) > fabs(r1[1]))
|
||||
SWAP_ROWS(r2, r1);
|
||||
if (0.0 == r1[1])
|
||||
return GL_FALSE;
|
||||
|
||||
/* eliminate second variable */
|
||||
m2 = r2[1] / r1[1];
|
||||
m3 = r3[1] / r1[1];
|
||||
r2[2] -= m2 * r1[2];
|
||||
r3[2] -= m3 * r1[2];
|
||||
r2[3] -= m2 * r1[3];
|
||||
r3[3] -= m3 * r1[3];
|
||||
s = r1[4];
|
||||
if (0.0 != s) {
|
||||
r2[4] -= m2 * s;
|
||||
r3[4] -= m3 * s;
|
||||
}
|
||||
s = r1[5];
|
||||
if (0.0 != s) {
|
||||
r2[5] -= m2 * s;
|
||||
r3[5] -= m3 * s;
|
||||
}
|
||||
s = r1[6];
|
||||
if (0.0 != s) {
|
||||
r2[6] -= m2 * s;
|
||||
r3[6] -= m3 * s;
|
||||
}
|
||||
s = r1[7];
|
||||
if (0.0 != s) {
|
||||
r2[7] -= m2 * s;
|
||||
r3[7] -= m3 * s;
|
||||
}
|
||||
|
||||
/* choose pivot - or die */
|
||||
if (fabs(r3[2]) > fabs(r2[2]))
|
||||
SWAP_ROWS(r3, r2);
|
||||
if (0.0 == r2[2])
|
||||
return GL_FALSE;
|
||||
|
||||
/* eliminate third variable */
|
||||
m3 = r3[2] / r2[2];
|
||||
r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
|
||||
r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6], r3[7] -= m3 * r2[7];
|
||||
|
||||
/* last check */
|
||||
if (0.0 == r3[3])
|
||||
return GL_FALSE;
|
||||
|
||||
s = 1.0 / r3[3]; /* now back substitute row 3 */
|
||||
r3[4] *= s;
|
||||
r3[5] *= s;
|
||||
r3[6] *= s;
|
||||
r3[7] *= s;
|
||||
|
||||
m2 = r2[3]; /* now back substitute row 2 */
|
||||
s = 1.0 / r2[2];
|
||||
r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
|
||||
r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
|
||||
m1 = r1[3];
|
||||
r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
|
||||
r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
|
||||
m0 = r0[3];
|
||||
r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
|
||||
r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
|
||||
|
||||
m1 = r1[2]; /* now back substitute row 1 */
|
||||
s = 1.0 / r1[1];
|
||||
r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
|
||||
r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
|
||||
m0 = r0[2];
|
||||
r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
|
||||
r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
|
||||
|
||||
m0 = r0[1]; /* now back substitute row 0 */
|
||||
s = 1.0 / r0[0];
|
||||
r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
|
||||
r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
|
||||
|
||||
MAT(out, 0, 0) = r0[4];
|
||||
MAT(out, 0, 1) = r0[5], MAT(out, 0, 2) = r0[6];
|
||||
MAT(out, 0, 3) = r0[7], MAT(out, 1, 0) = r1[4];
|
||||
MAT(out, 1, 1) = r1[5], MAT(out, 1, 2) = r1[6];
|
||||
MAT(out, 1, 3) = r1[7], MAT(out, 2, 0) = r2[4];
|
||||
MAT(out, 2, 1) = r2[5], MAT(out, 2, 2) = r2[6];
|
||||
MAT(out, 2, 3) = r2[7], MAT(out, 3, 0) = r3[4];
|
||||
MAT(out, 3, 1) = r3[5], MAT(out, 3, 2) = r3[6];
|
||||
MAT(out, 3, 3) = r3[7];
|
||||
|
||||
return GL_TRUE;
|
||||
|
||||
#undef MAT
|
||||
#undef SWAP_ROWS
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* projection du point (objx,objy,obz) sur l'ecran (winx,winy,winz) */
|
||||
GLint GLAPIENTRY
|
||||
gluProject(GLdouble objx, GLdouble objy, GLdouble objz,
|
||||
const GLdouble model[16], const GLdouble proj[16],
|
||||
const GLint viewport[4],
|
||||
GLdouble * winx, GLdouble * winy, GLdouble * winz)
|
||||
{
|
||||
/* matrice de transformation */
|
||||
GLdouble in[4], out[4];
|
||||
|
||||
/* initilise la matrice et le vecteur a transformer */
|
||||
in[0] = objx;
|
||||
in[1] = objy;
|
||||
in[2] = objz;
|
||||
in[3] = 1.0;
|
||||
transform_point(out, model, in);
|
||||
transform_point(in, proj, out);
|
||||
|
||||
/* d'ou le resultat normalise entre -1 et 1 */
|
||||
if (in[3] == 0.0)
|
||||
return GL_FALSE;
|
||||
|
||||
in[0] /= in[3];
|
||||
in[1] /= in[3];
|
||||
in[2] /= in[3];
|
||||
|
||||
/* en coordonnees ecran */
|
||||
*winx = viewport[0] + (1 + in[0]) * viewport[2] / 2;
|
||||
*winy = viewport[1] + (1 + in[1]) * viewport[3] / 2;
|
||||
/* entre 0 et 1 suivant z */
|
||||
*winz = (1 + in[2]) / 2;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* transformation du point ecran (winx,winy,winz) en point objet */
|
||||
GLint GLAPIENTRY
|
||||
gluUnProject(GLdouble winx, GLdouble winy, GLdouble winz,
|
||||
const GLdouble model[16], const GLdouble proj[16],
|
||||
const GLint viewport[4],
|
||||
GLdouble * objx, GLdouble * objy, GLdouble * objz)
|
||||
{
|
||||
/* matrice de transformation */
|
||||
GLdouble m[16], A[16];
|
||||
GLdouble in[4], out[4];
|
||||
|
||||
/* transformation coordonnees normalisees entre -1 et 1 */
|
||||
in[0] = (winx - viewport[0]) * 2 / viewport[2] - 1.0;
|
||||
in[1] = (winy - viewport[1]) * 2 / viewport[3] - 1.0;
|
||||
in[2] = 2 * winz - 1.0;
|
||||
in[3] = 1.0;
|
||||
|
||||
/* calcul transformation inverse */
|
||||
matmul(A, proj, model);
|
||||
invert_matrix(A, m);
|
||||
|
||||
/* d'ou les coordonnees objets */
|
||||
transform_point(out, m, in);
|
||||
if (out[3] == 0.0)
|
||||
return GL_FALSE;
|
||||
*objx = out[0] / out[3];
|
||||
*objy = out[1] / out[3];
|
||||
*objz = out[2] / out[3];
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* New in GLU 1.3
|
||||
* This is like gluUnProject but also takes near and far DepthRange values.
|
||||
*/
|
||||
#ifdef GLU_VERSION_1_3
|
||||
GLint GLAPIENTRY
|
||||
gluUnProject4(GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw,
|
||||
const GLdouble modelMatrix[16],
|
||||
const GLdouble projMatrix[16],
|
||||
const GLint viewport[4],
|
||||
GLclampd nearZ, GLclampd farZ,
|
||||
GLdouble * objx, GLdouble * objy, GLdouble * objz,
|
||||
GLdouble * objw)
|
||||
{
|
||||
/* matrice de transformation */
|
||||
GLdouble m[16], A[16];
|
||||
GLdouble in[4], out[4];
|
||||
GLdouble z = nearZ + winz * (farZ - nearZ);
|
||||
|
||||
/* transformation coordonnees normalisees entre -1 et 1 */
|
||||
in[0] = (winx - viewport[0]) * 2 / viewport[2] - 1.0;
|
||||
in[1] = (winy - viewport[1]) * 2 / viewport[3] - 1.0;
|
||||
in[2] = 2.0 * z - 1.0;
|
||||
in[3] = clipw;
|
||||
|
||||
/* calcul transformation inverse */
|
||||
matmul(A, projMatrix, modelMatrix);
|
||||
invert_matrix(A, m);
|
||||
|
||||
/* d'ou les coordonnees objets */
|
||||
transform_point(out, m, in);
|
||||
if (out[3] == 0.0)
|
||||
return GL_FALSE;
|
||||
*objx = out[0] / out[3];
|
||||
*objy = out[1] / out[3];
|
||||
*objz = out[2] / out[3];
|
||||
*objw = out[3];
|
||||
return GL_TRUE;
|
||||
}
|
||||
#endif
|
||||
774
src/glu/mini/quadric.c
Normal file
774
src/glu/mini/quadric.c
Normal file
@@ -0,0 +1,774 @@
|
||||
/* $Id: quadric.c,v 1.1.2.1 2003/03/21 13:02:22 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1999-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/* TODO:
|
||||
* texture coordinate support
|
||||
* flip normals according to orientation
|
||||
* there's still some inside/outside orientation bugs in possibly all
|
||||
* but the sphere function
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gluP.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
# define M_PI (3.1415926)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Convert degrees to radians:
|
||||
*/
|
||||
#define DEG_TO_RAD(A) ((A)*(M_PI/180.0))
|
||||
|
||||
|
||||
/*
|
||||
* Sin and Cos for degree angles:
|
||||
*/
|
||||
#define SIND( A ) sin( (A)*(M_PI/180.0) )
|
||||
#define COSD( A) cos( (A)*(M_PI/180.0) )
|
||||
|
||||
|
||||
/*
|
||||
* Texture coordinates if texture flag is set
|
||||
*/
|
||||
#define TXTR_COORD(x,y) if (qobj->TextureFlag) glTexCoord2f(x,y);
|
||||
|
||||
|
||||
|
||||
struct GLUquadric
|
||||
{
|
||||
GLenum DrawStyle; /* GLU_FILL, LINE, SILHOUETTE, or POINT */
|
||||
GLenum Orientation; /* GLU_INSIDE or GLU_OUTSIDE */
|
||||
GLboolean TextureFlag; /* Generate texture coords? */
|
||||
GLenum Normals; /* GLU_NONE, GLU_FLAT, or GLU_SMOOTH */
|
||||
void (GLCALLBACK * ErrorFunc) (GLenum err); /* Error handler callback function */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Process a GLU error.
|
||||
*/
|
||||
static void
|
||||
quadric_error(GLUquadricObj * qobj, GLenum error, const char *msg)
|
||||
{
|
||||
/* Call the error call back function if any */
|
||||
if (qobj->ErrorFunc) {
|
||||
(*qobj->ErrorFunc) (error);
|
||||
}
|
||||
/* Print a message to stdout if MESA_DEBUG variable is defined */
|
||||
if (getenv("MESA_DEBUG")) {
|
||||
fprintf(stderr, "GLUError: %s: %s\n", (char *) gluErrorString(error),
|
||||
msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
GLUquadricObj *GLAPIENTRY
|
||||
gluNewQuadric(void)
|
||||
{
|
||||
GLUquadricObj *q;
|
||||
|
||||
q = (GLUquadricObj *) malloc(sizeof(struct GLUquadric));
|
||||
if (q) {
|
||||
q->DrawStyle = GLU_FILL;
|
||||
q->Orientation = GLU_OUTSIDE;
|
||||
q->TextureFlag = GL_FALSE;
|
||||
q->Normals = GLU_SMOOTH;
|
||||
q->ErrorFunc = NULL;
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluDeleteQuadric(GLUquadricObj * state)
|
||||
{
|
||||
if (state) {
|
||||
free((void *) state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Set the drawing style to be GLU_FILL, GLU_LINE, GLU_SILHOUETTE,
|
||||
* or GLU_POINT.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
gluQuadricDrawStyle(GLUquadricObj * quadObject, GLenum drawStyle)
|
||||
{
|
||||
if (quadObject && (drawStyle == GLU_FILL || drawStyle == GLU_LINE
|
||||
|| drawStyle == GLU_SILHOUETTE
|
||||
|| drawStyle == GLU_POINT)) {
|
||||
quadObject->DrawStyle = drawStyle;
|
||||
}
|
||||
else {
|
||||
quadric_error(quadObject, GLU_INVALID_ENUM, "qluQuadricDrawStyle");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Set the orientation to GLU_INSIDE or GLU_OUTSIDE.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
gluQuadricOrientation(GLUquadricObj * quadObject, GLenum orientation)
|
||||
{
|
||||
if (quadObject
|
||||
&& (orientation == GLU_INSIDE || orientation == GLU_OUTSIDE)) {
|
||||
quadObject->Orientation = orientation;
|
||||
}
|
||||
else {
|
||||
quadric_error(quadObject, GLU_INVALID_ENUM, "qluQuadricOrientation");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Set the error handler callback function.
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
gluQuadricCallback(GLUquadricObj * qobj,
|
||||
GLenum which, void (GLCALLBACK * fn) ())
|
||||
{
|
||||
/*
|
||||
* UGH, this is a mess! I thought ANSI was a standard.
|
||||
*/
|
||||
if (qobj && which == GLU_ERROR) {
|
||||
#ifdef __CYGWIN32__
|
||||
qobj->ErrorFunc = (void (GLCALLBACKPCAST) (GLenum)) fn;
|
||||
#elif defined(OPENSTEP)
|
||||
qobj->ErrorFunc = (void (*)(GLenum)) fn;
|
||||
#elif defined(_WIN32)
|
||||
qobj->ErrorFunc = (void (GLCALLBACK *) (int)) fn;
|
||||
#elif defined(__STORM__)
|
||||
qobj->ErrorFunc = (void (GLCALLBACK *) (GLenum)) fn;
|
||||
#elif defined(__BEOS__)
|
||||
qobj->ErrorFunc = (void (*)(GLenum)) fn;
|
||||
#else
|
||||
qobj->ErrorFunc = (void (GLCALLBACK *) ()) fn;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluQuadricNormals(GLUquadricObj * quadObject, GLenum normals)
|
||||
{
|
||||
if (quadObject
|
||||
&& (normals == GLU_NONE || normals == GLU_FLAT
|
||||
|| normals == GLU_SMOOTH)) {
|
||||
quadObject->Normals = normals;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluQuadricTexture(GLUquadricObj * quadObject, GLboolean textureCoords)
|
||||
{
|
||||
if (quadObject) {
|
||||
quadObject->TextureFlag = textureCoords;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Call glNormal3f after scaling normal to unit length.
|
||||
*/
|
||||
static void
|
||||
normal3f(GLfloat x, GLfloat y, GLfloat z)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluCylinder(GLUquadricObj * qobj,
|
||||
GLdouble baseRadius, GLdouble topRadius,
|
||||
GLdouble height, GLint slices, GLint stacks)
|
||||
{
|
||||
GLdouble da, r, dr, dz;
|
||||
GLfloat x, y, z, nz, nsign;
|
||||
GLint i, j;
|
||||
|
||||
if (qobj->Orientation == GLU_INSIDE) {
|
||||
nsign = -1.0;
|
||||
}
|
||||
else {
|
||||
nsign = 1.0;
|
||||
}
|
||||
|
||||
da = 2.0 * M_PI / slices;
|
||||
dr = (topRadius - baseRadius) / stacks;
|
||||
dz = height / stacks;
|
||||
nz = (baseRadius - topRadius) / height; /* Z component of normal vectors */
|
||||
|
||||
if (qobj->DrawStyle == GLU_POINT) {
|
||||
glBegin(GL_POINTS);
|
||||
for (i = 0; i < slices; i++) {
|
||||
x = cos(i * da);
|
||||
y = sin(i * da);
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
|
||||
z = 0.0;
|
||||
r = baseRadius;
|
||||
for (j = 0; j <= stacks; j++) {
|
||||
glVertex3f(x * r, y * r, z);
|
||||
z += dz;
|
||||
r += dr;
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else if (qobj->DrawStyle == GLU_LINE || qobj->DrawStyle == GLU_SILHOUETTE) {
|
||||
/* Draw rings */
|
||||
if (qobj->DrawStyle == GLU_LINE) {
|
||||
z = 0.0;
|
||||
r = baseRadius;
|
||||
for (j = 0; j <= stacks; j++) {
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (i = 0; i < slices; i++) {
|
||||
x = cos(i * da);
|
||||
y = sin(i * da);
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
glVertex3f(x * r, y * r, z);
|
||||
}
|
||||
glEnd();
|
||||
z += dz;
|
||||
r += dr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* draw one ring at each end */
|
||||
if (baseRadius != 0.0) {
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (i = 0; i < slices; i++) {
|
||||
x = cos(i * da);
|
||||
y = sin(i * da);
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
glVertex3f(x * baseRadius, y * baseRadius, 0.0);
|
||||
}
|
||||
glEnd();
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (i = 0; i < slices; i++) {
|
||||
x = cos(i * da);
|
||||
y = sin(i * da);
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
glVertex3f(x * topRadius, y * topRadius, height);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
/* draw length lines */
|
||||
glBegin(GL_LINES);
|
||||
for (i = 0; i < slices; i++) {
|
||||
x = cos(i * da);
|
||||
y = sin(i * da);
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
glVertex3f(x * baseRadius, y * baseRadius, 0.0);
|
||||
glVertex3f(x * topRadius, y * topRadius, height);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else if (qobj->DrawStyle == GLU_FILL) {
|
||||
GLfloat ds = 1.0 / slices;
|
||||
GLfloat dt = 1.0 / stacks;
|
||||
GLfloat t = 0.0;
|
||||
z = 0.0;
|
||||
r = baseRadius;
|
||||
for (j = 0; j < stacks; j++) {
|
||||
GLfloat s = 0.0;
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= slices; i++) {
|
||||
GLfloat x, y;
|
||||
if (i == slices) {
|
||||
x = sin(0.0);
|
||||
y = cos(0.0);
|
||||
}
|
||||
else {
|
||||
x = sin(i * da);
|
||||
y = cos(i * da);
|
||||
}
|
||||
if (nsign == 1.0) {
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
TXTR_COORD(s, t);
|
||||
glVertex3f(x * r, y * r, z);
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
TXTR_COORD(s, t + dt);
|
||||
glVertex3f(x * (r + dr), y * (r + dr), z + dz);
|
||||
}
|
||||
else {
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
TXTR_COORD(s, t);
|
||||
glVertex3f(x * r, y * r, z);
|
||||
normal3f(x * nsign, y * nsign, nz * nsign);
|
||||
TXTR_COORD(s, t + dt);
|
||||
glVertex3f(x * (r + dr), y * (r + dr), z + dz);
|
||||
}
|
||||
s += ds;
|
||||
} /* for slices */
|
||||
glEnd();
|
||||
r += dr;
|
||||
t += dt;
|
||||
z += dz;
|
||||
} /* for stacks */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluSphere(GLUquadricObj * qobj, GLdouble radius, GLint slices, GLint stacks)
|
||||
{
|
||||
GLfloat rho, drho, theta, dtheta;
|
||||
GLfloat x, y, z;
|
||||
GLfloat s, t, ds, dt;
|
||||
GLint i, j, imin, imax;
|
||||
GLboolean normals;
|
||||
GLfloat nsign;
|
||||
|
||||
if (qobj->Normals == GLU_NONE) {
|
||||
normals = GL_FALSE;
|
||||
}
|
||||
else {
|
||||
normals = GL_TRUE;
|
||||
}
|
||||
if (qobj->Orientation == GLU_INSIDE) {
|
||||
nsign = -1.0;
|
||||
}
|
||||
else {
|
||||
nsign = 1.0;
|
||||
}
|
||||
|
||||
drho = M_PI / (GLfloat) stacks;
|
||||
dtheta = 2.0 * M_PI / (GLfloat) slices;
|
||||
|
||||
/* texturing: s goes from 0.0/0.25/0.5/0.75/1.0 at +y/+x/-y/-x/+y axis */
|
||||
/* t goes from -1.0/+1.0 at z = -radius/+radius (linear along longitudes) */
|
||||
/* cannot use triangle fan on texturing (s coord. at top/bottom tip varies) */
|
||||
|
||||
if (qobj->DrawStyle == GLU_FILL) {
|
||||
if (!qobj->TextureFlag) {
|
||||
/* draw +Z end as a triangle fan */
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
/* glNormal3f(0.0, 0.0, 1.0); */
|
||||
glVertex3f(0.0, 0.0, nsign * radius);
|
||||
for (j = 0; j <= slices; j++) {
|
||||
theta = (j == slices) ? 0.0 : j * dtheta;
|
||||
x = -sin(theta) * sin(drho);
|
||||
y = cos(theta) * sin(drho);
|
||||
z = nsign * cos(drho);
|
||||
glVertex3f(x * radius, y * radius, z * radius);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
ds = 1.0 / slices;
|
||||
dt = 1.0 / stacks;
|
||||
t = 1.0; /* because loop now runs from 0 */
|
||||
if (qobj->TextureFlag) {
|
||||
imin = 0;
|
||||
imax = stacks;
|
||||
}
|
||||
else {
|
||||
imin = 1;
|
||||
imax = stacks - 1;
|
||||
}
|
||||
|
||||
/* draw intermediate stacks as quad strips */
|
||||
for (i = imin; i < imax; i++) {
|
||||
rho = i * drho;
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
s = 0.0;
|
||||
for (j = 0; j <= slices; j++) {
|
||||
theta = (j == slices) ? 0.0 : j * dtheta;
|
||||
x = -sin(theta) * sin(rho);
|
||||
y = cos(theta) * sin(rho);
|
||||
z = nsign * cos(rho);
|
||||
TXTR_COORD(s, t);
|
||||
glVertex3f(x * radius, y * radius, z * radius);
|
||||
x = -sin(theta) * sin(rho + drho);
|
||||
y = cos(theta) * sin(rho + drho);
|
||||
z = nsign * cos(rho + drho);
|
||||
TXTR_COORD(s, t - dt);
|
||||
s += ds;
|
||||
glVertex3f(x * radius, y * radius, z * radius);
|
||||
}
|
||||
glEnd();
|
||||
t -= dt;
|
||||
}
|
||||
|
||||
if (!qobj->TextureFlag) {
|
||||
/* draw -Z end as a triangle fan */
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex3f(0.0, 0.0, -radius * nsign);
|
||||
rho = M_PI - drho;
|
||||
s = 1.0;
|
||||
t = dt;
|
||||
for (j = slices; j >= 0; j--) {
|
||||
theta = (j == slices) ? 0.0 : j * dtheta;
|
||||
x = -sin(theta) * sin(rho);
|
||||
y = cos(theta) * sin(rho);
|
||||
z = nsign * cos(rho);
|
||||
s -= ds;
|
||||
glVertex3f(x * radius, y * radius, z * radius);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
else if (qobj->DrawStyle == GLU_LINE || qobj->DrawStyle == GLU_SILHOUETTE) {
|
||||
/* draw stack lines */
|
||||
for (i = 1; i < stacks; i++) { /* stack line at i==stacks-1 was missing here */
|
||||
rho = i * drho;
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (j = 0; j < slices; j++) {
|
||||
theta = j * dtheta;
|
||||
x = cos(theta) * sin(rho);
|
||||
y = sin(theta) * sin(rho);
|
||||
z = cos(rho);
|
||||
glVertex3f(x * radius, y * radius, z * radius);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
/* draw slice lines */
|
||||
for (j = 0; j < slices; j++) {
|
||||
theta = j * dtheta;
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i = 0; i <= stacks; i++) {
|
||||
rho = i * drho;
|
||||
x = cos(theta) * sin(rho);
|
||||
y = sin(theta) * sin(rho);
|
||||
z = cos(rho);
|
||||
glVertex3f(x * radius, y * radius, z * radius);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
else if (qobj->DrawStyle == GLU_POINT) {
|
||||
/* top and bottom-most points */
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3f(0.0, 0.0, radius);
|
||||
glVertex3f(0.0, 0.0, -radius);
|
||||
|
||||
/* loop over stacks */
|
||||
for (i = 1; i < stacks - 1; i++) {
|
||||
rho = i * drho;
|
||||
for (j = 0; j < slices; j++) {
|
||||
theta = j * dtheta;
|
||||
x = cos(theta) * sin(rho);
|
||||
y = sin(theta) * sin(rho);
|
||||
z = cos(rho);
|
||||
glVertex3f(x * radius, y * radius, z * radius);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluDisk(GLUquadricObj * qobj,
|
||||
GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops)
|
||||
{
|
||||
GLfloat da, dr;
|
||||
#if 0
|
||||
GLdouble a, da;
|
||||
GLfloat r, dr;
|
||||
GLfloat x, y;
|
||||
GLfloat r1, r2, dtc;
|
||||
GLint s, l;
|
||||
#endif
|
||||
|
||||
|
||||
da = 2.0 * M_PI / slices;
|
||||
dr = (outerRadius - innerRadius) / (GLfloat) loops;
|
||||
|
||||
switch (qobj->DrawStyle) {
|
||||
case GLU_FILL:
|
||||
{
|
||||
/* texture of a gluDisk is a cut out of the texture unit square
|
||||
* x, y in [-outerRadius, +outerRadius]; s, t in [0, 1]
|
||||
* (linear mapping)
|
||||
*/
|
||||
GLfloat dtc = 2.0f * outerRadius;
|
||||
GLfloat sa, ca;
|
||||
GLfloat r1 = innerRadius;
|
||||
GLint l;
|
||||
for (l = 0; l < loops; l++) {
|
||||
GLfloat r2 = r1 + dr;
|
||||
if (qobj->Orientation == GLU_OUTSIDE) {
|
||||
GLint s;
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (s = 0; s <= slices; s++) {
|
||||
GLfloat a;
|
||||
if (s == slices)
|
||||
a = 0.0;
|
||||
else
|
||||
a = s * da;
|
||||
sa = sin(a);
|
||||
ca = cos(a);
|
||||
TXTR_COORD(0.5 + sa * r2 / dtc, 0.5 + ca * r2 / dtc);
|
||||
glVertex2f(r2 * sa, r2 * ca);
|
||||
TXTR_COORD(0.5 + sa * r1 / dtc, 0.5 + ca * r1 / dtc);
|
||||
glVertex2f(r1 * sa, r1 * ca);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else {
|
||||
GLint s;
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (s = slices; s >= 0; s--) {
|
||||
GLfloat a;
|
||||
if (s == slices)
|
||||
a = 0.0;
|
||||
else
|
||||
a = s * da;
|
||||
sa = sin(a);
|
||||
ca = cos(a);
|
||||
TXTR_COORD(0.5 - sa * r2 / dtc, 0.5 + ca * r2 / dtc);
|
||||
glVertex2f(r2 * sa, r2 * ca);
|
||||
TXTR_COORD(0.5 - sa * r1 / dtc, 0.5 + ca * r1 / dtc);
|
||||
glVertex2f(r1 * sa, r1 * ca);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
r1 = r2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GLU_LINE:
|
||||
{
|
||||
GLint l, s;
|
||||
/* draw loops */
|
||||
for (l = 0; l <= loops; l++) {
|
||||
GLfloat r = innerRadius + l * dr;
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (s = 0; s < slices; s++) {
|
||||
GLfloat a = s * da;
|
||||
glVertex2f(r * sin(a), r * cos(a));
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
/* draw spokes */
|
||||
for (s = 0; s < slices; s++) {
|
||||
GLfloat a = s * da;
|
||||
GLfloat x = sin(a);
|
||||
GLfloat y = cos(a);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (l = 0; l <= loops; l++) {
|
||||
GLfloat r = innerRadius + l * dr;
|
||||
glVertex2f(r * x, r * y);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GLU_POINT:
|
||||
{
|
||||
GLint s;
|
||||
glBegin(GL_POINTS);
|
||||
for (s = 0; s < slices; s++) {
|
||||
GLfloat a = s * da;
|
||||
GLfloat x = sin(a);
|
||||
GLfloat y = cos(a);
|
||||
GLint l;
|
||||
for (l = 0; l <= loops; l++) {
|
||||
GLfloat r = innerRadius * l * dr;
|
||||
glVertex2f(r * x, r * y);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
break;
|
||||
}
|
||||
case GLU_SILHOUETTE:
|
||||
{
|
||||
if (innerRadius != 0.0) {
|
||||
GLfloat a;
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (a = 0.0; a < 2.0 * M_PI; a += da) {
|
||||
GLfloat x = innerRadius * sin(a);
|
||||
GLfloat y = innerRadius * cos(a);
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
{
|
||||
GLfloat a;
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (a = 0; a < 2.0 * M_PI; a += da) {
|
||||
GLfloat x = outerRadius * sin(a);
|
||||
GLfloat y = outerRadius * cos(a);
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluPartialDisk(GLUquadricObj * qobj, GLdouble innerRadius,
|
||||
GLdouble outerRadius, GLint slices, GLint loops,
|
||||
GLdouble startAngle, GLdouble sweepAngle)
|
||||
{
|
||||
if (qobj->DrawStyle == GLU_POINT) {
|
||||
GLint loop, slice;
|
||||
GLdouble radius, delta_radius;
|
||||
GLdouble angle, delta_angle;
|
||||
delta_radius = (outerRadius - innerRadius) / (loops - 1);
|
||||
delta_angle = DEG_TO_RAD((sweepAngle) / (slices - 1));
|
||||
glBegin(GL_POINTS);
|
||||
radius = innerRadius;
|
||||
for (loop = 0; loop < loops; loop++) {
|
||||
angle = DEG_TO_RAD(startAngle);
|
||||
for (slice = 0; slice < slices; slice++) {
|
||||
glVertex2f(radius * sin(angle), radius * cos(angle));
|
||||
angle += delta_angle;
|
||||
}
|
||||
radius += delta_radius;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else if (qobj->DrawStyle == GLU_LINE) {
|
||||
GLint loop, slice;
|
||||
GLdouble radius, delta_radius;
|
||||
GLdouble angle, delta_angle;
|
||||
delta_radius = (outerRadius - innerRadius) / loops;
|
||||
delta_angle = DEG_TO_RAD(sweepAngle / slices);
|
||||
/* draw rings */
|
||||
radius = innerRadius;
|
||||
for (loop = 0; loop < loops; loop++) {
|
||||
angle = DEG_TO_RAD(startAngle);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (slice = 0; slice <= slices; slice++) {
|
||||
glVertex2f(radius * sin(angle), radius * cos(angle));
|
||||
angle += delta_angle;
|
||||
}
|
||||
glEnd();
|
||||
radius += delta_radius;
|
||||
}
|
||||
/* draw spokes */
|
||||
angle = DEG_TO_RAD(startAngle);
|
||||
for (slice = 0; slice <= slices; slice++) {
|
||||
radius = innerRadius;
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (loop = 0; loop < loops; loop++) {
|
||||
glVertex2f(radius * sin(angle), radius * cos(angle));
|
||||
radius += delta_radius;
|
||||
}
|
||||
glEnd();
|
||||
angle += delta_angle;
|
||||
}
|
||||
}
|
||||
else if (qobj->DrawStyle == GLU_SILHOUETTE) {
|
||||
GLint slice;
|
||||
GLdouble angle, delta_angle;
|
||||
delta_angle = DEG_TO_RAD(sweepAngle / slices);
|
||||
/* draw outer ring */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
angle = DEG_TO_RAD(startAngle);
|
||||
for (slice = 0; slice <= slices; slice++) {
|
||||
glVertex2f(outerRadius * sin(angle), outerRadius * cos(angle));
|
||||
angle += delta_angle;
|
||||
}
|
||||
glEnd();
|
||||
/* draw inner ring */
|
||||
if (innerRadius > 0.0) {
|
||||
glBegin(GL_LINE_STRIP);
|
||||
angle = DEG_TO_RAD(startAngle);
|
||||
for (slice = 0; slice < slices; slice++) {
|
||||
glVertex2f(innerRadius * sin(angle), innerRadius * cos(angle));
|
||||
angle += delta_angle;
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
/* draw spokes */
|
||||
if (sweepAngle < 360.0) {
|
||||
GLdouble stopAngle = startAngle + sweepAngle;
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(innerRadius * SIND(startAngle),
|
||||
innerRadius * COSD(startAngle));
|
||||
glVertex2f(outerRadius * SIND(startAngle),
|
||||
outerRadius * COSD(startAngle));
|
||||
glVertex2f(innerRadius * SIND(stopAngle),
|
||||
innerRadius * COSD(stopAngle));
|
||||
glVertex2f(outerRadius * SIND(stopAngle),
|
||||
outerRadius * COSD(stopAngle));
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
else if (qobj->DrawStyle == GLU_FILL) {
|
||||
GLint loop, slice;
|
||||
GLdouble radius, delta_radius;
|
||||
GLdouble angle, delta_angle;
|
||||
delta_radius = (outerRadius - innerRadius) / loops;
|
||||
delta_angle = DEG_TO_RAD(sweepAngle / slices);
|
||||
radius = innerRadius;
|
||||
for (loop = 0; loop < loops; loop++) {
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
angle = DEG_TO_RAD(startAngle);
|
||||
for (slice = 0; slice <= slices; slice++) {
|
||||
if (qobj->Orientation == GLU_OUTSIDE) {
|
||||
glVertex2f((radius + delta_radius) * sin(angle),
|
||||
(radius + delta_radius) * cos(angle));
|
||||
glVertex2f(radius * sin(angle), radius * cos(angle));
|
||||
}
|
||||
else {
|
||||
glVertex2f(radius * sin(angle), radius * cos(angle));
|
||||
glVertex2f((radius + delta_radius) * sin(angle),
|
||||
(radius + delta_radius) * cos(angle));
|
||||
}
|
||||
angle += delta_angle;
|
||||
}
|
||||
glEnd();
|
||||
radius += delta_radius;
|
||||
}
|
||||
}
|
||||
}
|
||||
328
src/glu/mini/tess.c
Normal file
328
src/glu/mini/tess.c
Normal file
@@ -0,0 +1,328 @@
|
||||
/* $Id: tess.c,v 1.1.2.1 2003/03/21 13:02:23 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file is part of the polygon tesselation code contributed by
|
||||
* Bogdan Sikorski
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "tess.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* This is ugly, but seems the easiest way to do things to make the
|
||||
* code work under YellowBox for Windows
|
||||
*/
|
||||
#if defined(OPENSTEP) && defined(CALLBACK)
|
||||
#undef CALLBACK
|
||||
#define CALLBACK
|
||||
#endif
|
||||
|
||||
|
||||
static void delete_contours(GLUtriangulatorObj *);
|
||||
|
||||
#ifdef __CYGWIN32__
|
||||
#define _CALLBACK
|
||||
#else
|
||||
#define _CALLBACK GLCALLBACK
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
init_callbacks(tess_callbacks * callbacks)
|
||||
{
|
||||
callbacks->begin = (void (_CALLBACK *) (GLenum)) 0;
|
||||
callbacks->edgeFlag = (void (_CALLBACK *) (GLboolean)) 0;
|
||||
callbacks->vertex = (void (_CALLBACK *) (void *)) 0;
|
||||
callbacks->end = (void (_CALLBACK *) (void)) 0;
|
||||
callbacks->error = (void (_CALLBACK *) (GLenum)) 0;
|
||||
}
|
||||
|
||||
void
|
||||
tess_call_user_error(GLUtriangulatorObj * tobj, GLenum gluerr)
|
||||
{
|
||||
if (tobj->error == GLU_NO_ERROR)
|
||||
tobj->error = gluerr;
|
||||
if (tobj->callbacks.error != NULL)
|
||||
(tobj->callbacks.error) (gluerr);
|
||||
}
|
||||
|
||||
GLUtriangulatorObj *GLAPIENTRY
|
||||
gluNewTess(void)
|
||||
{
|
||||
GLUtriangulatorObj *tobj;
|
||||
|
||||
if ((tobj = (GLUtriangulatorObj *)
|
||||
malloc(sizeof(struct GLUtesselator))) == NULL)
|
||||
return NULL;
|
||||
tobj->contours = tobj->last_contour = NULL;
|
||||
init_callbacks(&tobj->callbacks);
|
||||
tobj->error = GLU_NO_ERROR;
|
||||
tobj->current_polygon = NULL;
|
||||
tobj->contour_cnt = 0;
|
||||
return tobj;
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluTessCallback(GLUtriangulatorObj * tobj, GLenum which,
|
||||
void (GLCALLBACK * fn) ())
|
||||
{
|
||||
switch (which) {
|
||||
case GLU_BEGIN:
|
||||
tobj->callbacks.begin = (void (_CALLBACK *) (GLenum)) fn;
|
||||
break;
|
||||
case GLU_EDGE_FLAG:
|
||||
tobj->callbacks.edgeFlag = (void (_CALLBACK *) (GLboolean)) fn;
|
||||
break;
|
||||
case GLU_VERTEX:
|
||||
tobj->callbacks.vertex = (void (_CALLBACK *) (void *)) fn;
|
||||
break;
|
||||
case GLU_END:
|
||||
tobj->callbacks.end = (void (_CALLBACK *) (void)) fn;
|
||||
break;
|
||||
case GLU_ERROR:
|
||||
tobj->callbacks.error = (void (_CALLBACK *) (GLenum)) fn;
|
||||
break;
|
||||
default:
|
||||
tobj->error = GLU_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluDeleteTess(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
if (tobj->error == GLU_NO_ERROR && tobj->contour_cnt)
|
||||
/* was gluEndPolygon called? */
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR1);
|
||||
/* delete all internal structures */
|
||||
delete_contours(tobj);
|
||||
free(tobj);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluBeginPolygon(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
/*
|
||||
if(tobj->error!=GLU_NO_ERROR)
|
||||
return;
|
||||
*/
|
||||
tobj->error = GLU_NO_ERROR;
|
||||
if (tobj->current_polygon != NULL) {
|
||||
/* gluEndPolygon was not called */
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR1);
|
||||
/* delete all internal structures */
|
||||
delete_contours(tobj);
|
||||
}
|
||||
else {
|
||||
if ((tobj->current_polygon =
|
||||
(tess_polygon *) malloc(sizeof(tess_polygon))) == NULL) {
|
||||
tess_call_user_error(tobj, GLU_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
tobj->current_polygon->vertex_cnt = 0;
|
||||
tobj->current_polygon->vertices =
|
||||
tobj->current_polygon->last_vertex = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluEndPolygon(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
/*tess_contour *contour_ptr; */
|
||||
|
||||
/* there was an error */
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
goto end;
|
||||
|
||||
/* check if gluBeginPolygon was called */
|
||||
if (tobj->current_polygon == NULL) {
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR2);
|
||||
return;
|
||||
}
|
||||
tess_test_polygon(tobj);
|
||||
/* there was an error */
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
goto end;
|
||||
|
||||
/* any real contours? */
|
||||
if (tobj->contour_cnt == 0) {
|
||||
/* delete all internal structures */
|
||||
delete_contours(tobj);
|
||||
return;
|
||||
}
|
||||
tess_find_contour_hierarchies(tobj);
|
||||
/* there was an error */
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
goto end;
|
||||
|
||||
tess_handle_holes(tobj);
|
||||
/* there was an error */
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
goto end;
|
||||
|
||||
/* if no callbacks, nothing to do */
|
||||
if (tobj->callbacks.begin != NULL && tobj->callbacks.vertex != NULL &&
|
||||
tobj->callbacks.end != NULL) {
|
||||
if (tobj->callbacks.edgeFlag == NULL)
|
||||
tess_tesselate(tobj);
|
||||
else
|
||||
tess_tesselate_with_edge_flag(tobj);
|
||||
}
|
||||
|
||||
end:
|
||||
/* delete all internal structures */
|
||||
delete_contours(tobj);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluNextContour(GLUtriangulatorObj * tobj, GLenum type)
|
||||
{
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
return;
|
||||
if (tobj->current_polygon == NULL) {
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR2);
|
||||
return;
|
||||
}
|
||||
/* first contour? */
|
||||
if (tobj->current_polygon->vertex_cnt)
|
||||
tess_test_polygon(tobj);
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluTessVertex(GLUtriangulatorObj * tobj, GLdouble v[3], void *data)
|
||||
{
|
||||
tess_polygon *polygon = tobj->current_polygon;
|
||||
tess_vertex *last_vertex_ptr;
|
||||
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
return;
|
||||
if (polygon == NULL) {
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR2);
|
||||
return;
|
||||
}
|
||||
last_vertex_ptr = polygon->last_vertex;
|
||||
if (last_vertex_ptr == NULL) {
|
||||
if ((last_vertex_ptr = (tess_vertex *)
|
||||
malloc(sizeof(tess_vertex))) == NULL) {
|
||||
tess_call_user_error(tobj, GLU_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
polygon->vertices = last_vertex_ptr;
|
||||
polygon->last_vertex = last_vertex_ptr;
|
||||
last_vertex_ptr->data = data;
|
||||
last_vertex_ptr->location[0] = v[0];
|
||||
last_vertex_ptr->location[1] = v[1];
|
||||
last_vertex_ptr->location[2] = v[2];
|
||||
last_vertex_ptr->next = NULL;
|
||||
last_vertex_ptr->previous = NULL;
|
||||
++(polygon->vertex_cnt);
|
||||
}
|
||||
else {
|
||||
tess_vertex *vertex_ptr;
|
||||
|
||||
/* same point twice? */
|
||||
if (fabs(last_vertex_ptr->location[0] - v[0]) < EPSILON &&
|
||||
fabs(last_vertex_ptr->location[1] - v[1]) < EPSILON &&
|
||||
fabs(last_vertex_ptr->location[2] - v[2]) < EPSILON) {
|
||||
tess_call_user_error(tobj, GLU_TESS_ERROR6);
|
||||
return;
|
||||
}
|
||||
if ((vertex_ptr = (tess_vertex *)
|
||||
malloc(sizeof(tess_vertex))) == NULL) {
|
||||
tess_call_user_error(tobj, GLU_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
vertex_ptr->data = data;
|
||||
vertex_ptr->location[0] = v[0];
|
||||
vertex_ptr->location[1] = v[1];
|
||||
vertex_ptr->location[2] = v[2];
|
||||
vertex_ptr->next = NULL;
|
||||
vertex_ptr->previous = last_vertex_ptr;
|
||||
++(polygon->vertex_cnt);
|
||||
last_vertex_ptr->next = vertex_ptr;
|
||||
polygon->last_vertex = vertex_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
delete_contours(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_polygon *polygon = tobj->current_polygon;
|
||||
tess_contour *contour, *contour_tmp;
|
||||
tess_vertex *vertex, *vertex_tmp;
|
||||
|
||||
/* remove current_polygon list - if exists due to detected error */
|
||||
if (polygon != NULL) {
|
||||
if (polygon->vertices) {
|
||||
for (vertex = polygon->vertices; vertex != polygon->last_vertex;) {
|
||||
vertex_tmp = vertex->next;
|
||||
free(vertex);
|
||||
vertex = vertex_tmp;
|
||||
}
|
||||
free(vertex);
|
||||
}
|
||||
free(polygon);
|
||||
tobj->current_polygon = NULL;
|
||||
}
|
||||
/* remove all contour data */
|
||||
for (contour = tobj->contours; contour != NULL;) {
|
||||
for (vertex = contour->vertices; vertex != contour->last_vertex;) {
|
||||
vertex_tmp = vertex->next;
|
||||
free(vertex);
|
||||
vertex = vertex_tmp;
|
||||
}
|
||||
free(vertex);
|
||||
contour_tmp = contour->next;
|
||||
free(contour);
|
||||
contour = contour_tmp;
|
||||
}
|
||||
tobj->contours = tobj->last_contour = NULL;
|
||||
tobj->contour_cnt = 0;
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
gluTessNormal(GLUtesselator *tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ)
|
||||
{
|
||||
/* dummy function */
|
||||
(void) tess;
|
||||
(void) valueX;
|
||||
(void) valueY;
|
||||
(void) valueZ;
|
||||
}
|
||||
108
src/glu/mini/tess.h
Normal file
108
src/glu/mini/tess.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* $Id: tess.h,v 1.1.2.1 2003/03/21 13:02:23 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file is part of the polygon tesselation code contributed by
|
||||
* Bogdan Sikorski
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TESS_H
|
||||
#define TESS_H
|
||||
|
||||
|
||||
#include "gluP.h"
|
||||
|
||||
#define EPSILON 1e-06 /* epsilon for double precision compares */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OXY,
|
||||
OYZ,
|
||||
OXZ
|
||||
}
|
||||
projection_type;
|
||||
|
||||
typedef struct callbacks_str
|
||||
{
|
||||
void (GLCALLBACK * begin) (GLenum mode);
|
||||
void (GLCALLBACK * edgeFlag) (GLboolean flag);
|
||||
void (GLCALLBACK * vertex) (GLvoid * v);
|
||||
void (GLCALLBACK * end) (void);
|
||||
void (GLCALLBACK * error) (GLenum err);
|
||||
}
|
||||
tess_callbacks;
|
||||
|
||||
typedef struct vertex_str
|
||||
{
|
||||
void *data;
|
||||
GLdouble location[3];
|
||||
GLdouble x, y;
|
||||
GLboolean edge_flag;
|
||||
struct vertex_str *shadow_vertex;
|
||||
struct vertex_str *next, *previous;
|
||||
}
|
||||
tess_vertex;
|
||||
|
||||
typedef struct contour_str
|
||||
{
|
||||
GLenum type;
|
||||
GLuint vertex_cnt;
|
||||
GLdouble area;
|
||||
GLenum orientation;
|
||||
struct vertex_str *vertices, *last_vertex;
|
||||
struct contour_str *next, *previous;
|
||||
}
|
||||
tess_contour;
|
||||
|
||||
typedef struct polygon_str
|
||||
{
|
||||
GLuint vertex_cnt;
|
||||
GLdouble A, B, C, D;
|
||||
GLdouble area;
|
||||
GLenum orientation;
|
||||
struct vertex_str *vertices, *last_vertex;
|
||||
}
|
||||
tess_polygon;
|
||||
|
||||
struct GLUtesselator
|
||||
{
|
||||
tess_contour *contours, *last_contour;
|
||||
GLuint contour_cnt;
|
||||
tess_callbacks callbacks;
|
||||
tess_polygon *current_polygon;
|
||||
GLenum error;
|
||||
GLdouble A, B, C, D;
|
||||
projection_type projection;
|
||||
};
|
||||
|
||||
|
||||
extern void tess_call_user_error(GLUtriangulatorObj *, GLenum);
|
||||
extern void tess_test_polygon(GLUtriangulatorObj *);
|
||||
extern void tess_find_contour_hierarchies(GLUtriangulatorObj *);
|
||||
extern void tess_handle_holes(GLUtriangulatorObj *);
|
||||
extern void tess_tesselate(GLUtriangulatorObj *);
|
||||
extern void tess_tesselate_with_edge_flag(GLUtriangulatorObj *);
|
||||
|
||||
|
||||
#endif
|
||||
407
src/glu/mini/tesselat.c
Normal file
407
src/glu/mini/tesselat.c
Normal file
@@ -0,0 +1,407 @@
|
||||
/* $Id: tesselat.c,v 1.1.2.1 2003/03/21 13:02:23 keithw Exp $ */
|
||||
|
||||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 3.3
|
||||
* Copyright (C) 1995-2000 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file is part of the polygon tesselation code contributed by
|
||||
* Bogdan Sikorski
|
||||
*/
|
||||
|
||||
|
||||
#ifdef PC_HEADER
|
||||
#include "all.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "tess.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static GLboolean edge_flag;
|
||||
|
||||
static void emit_triangle(GLUtriangulatorObj *, tess_vertex *,
|
||||
tess_vertex *, tess_vertex *);
|
||||
|
||||
static void emit_triangle_with_edge_flag(GLUtriangulatorObj *,
|
||||
tess_vertex *, GLboolean,
|
||||
tess_vertex *, GLboolean,
|
||||
tess_vertex *, GLboolean);
|
||||
|
||||
static GLdouble
|
||||
twice_the_triangle_area(tess_vertex * va, tess_vertex * vb, tess_vertex * vc)
|
||||
{
|
||||
return (vb->x - va->x) * (vc->y - va->y) - (vb->y - va->y) * (vc->x -
|
||||
va->x);
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
left(GLdouble A, GLdouble B, GLdouble C, GLdouble x, GLdouble y)
|
||||
{
|
||||
if (A * x + B * y + C > -EPSILON)
|
||||
return GL_TRUE;
|
||||
else
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
right(GLdouble A, GLdouble B, GLdouble C, GLdouble x, GLdouble y)
|
||||
{
|
||||
if (A * x + B * y + C < EPSILON)
|
||||
return GL_TRUE;
|
||||
else
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
static GLint
|
||||
convex_ccw(tess_vertex * va,
|
||||
tess_vertex * vb, tess_vertex * vc, GLUtriangulatorObj * tobj)
|
||||
{
|
||||
GLdouble d;
|
||||
|
||||
d = twice_the_triangle_area(va, vb, vc);
|
||||
|
||||
if (d > EPSILON) {
|
||||
return 1;
|
||||
}
|
||||
else if (d < -EPSILON) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static GLint
|
||||
convex_cw(tess_vertex * va,
|
||||
tess_vertex * vb, tess_vertex * vc, GLUtriangulatorObj * tobj)
|
||||
{
|
||||
GLdouble d;
|
||||
|
||||
d = twice_the_triangle_area(va, vb, vc);
|
||||
|
||||
if (d < -EPSILON) {
|
||||
return 1;
|
||||
}
|
||||
else if (d > EPSILON) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
diagonal_ccw(tess_vertex * va,
|
||||
tess_vertex * vb,
|
||||
GLUtriangulatorObj * tobj, tess_contour * contour)
|
||||
{
|
||||
tess_vertex *vc = va->next, *vertex, *shadow_vertex;
|
||||
struct
|
||||
{
|
||||
GLdouble A, B, C;
|
||||
}
|
||||
ac, cb, ba;
|
||||
GLdouble x, y;
|
||||
|
||||
GLint res = convex_ccw(va, vc, vb, tobj);
|
||||
if (res == 0)
|
||||
return GL_FALSE;
|
||||
if (res == -1)
|
||||
return GL_TRUE;
|
||||
|
||||
ba.A = vb->y - va->y;
|
||||
ba.B = va->x - vb->x;
|
||||
ba.C = -ba.A * va->x - ba.B * va->y;
|
||||
ac.A = va->y - vc->y;
|
||||
ac.B = vc->x - va->x;
|
||||
ac.C = -ac.A * vc->x - ac.B * vc->y;
|
||||
cb.A = vc->y - vb->y;
|
||||
cb.B = vb->x - vc->x;
|
||||
cb.C = -cb.A * vb->x - cb.B * vb->y;
|
||||
for (vertex = vb->next; vertex != va; vertex = vertex->next) {
|
||||
shadow_vertex = vertex->shadow_vertex;
|
||||
if (shadow_vertex != NULL &&
|
||||
(shadow_vertex == va || shadow_vertex == vb || shadow_vertex == vc))
|
||||
continue;
|
||||
x = vertex->x;
|
||||
y = vertex->y;
|
||||
if (left(ba.A, ba.B, ba.C, x, y) &&
|
||||
left(ac.A, ac.B, ac.C, x, y) && left(cb.A, cb.B, cb.C, x, y))
|
||||
return GL_FALSE;
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
diagonal_cw(tess_vertex * va,
|
||||
tess_vertex * vb,
|
||||
GLUtriangulatorObj * tobj, tess_contour * contour)
|
||||
{
|
||||
tess_vertex *vc = va->next, *vertex, *shadow_vertex;
|
||||
struct
|
||||
{
|
||||
GLdouble A, B, C;
|
||||
}
|
||||
ac, cb, ba;
|
||||
GLdouble x, y;
|
||||
|
||||
GLint res = convex_cw(va, vc, vb, tobj);
|
||||
if (res == 0)
|
||||
return GL_FALSE;
|
||||
if (res == -1)
|
||||
return GL_TRUE;
|
||||
|
||||
ba.A = vb->y - va->y;
|
||||
ba.B = va->x - vb->x;
|
||||
ba.C = -ba.A * va->x - ba.B * va->y;
|
||||
ac.A = va->y - vc->y;
|
||||
ac.B = vc->x - va->x;
|
||||
ac.C = -ac.A * vc->x - ac.B * vc->y;
|
||||
cb.A = vc->y - vb->y;
|
||||
cb.B = vb->x - vc->x;
|
||||
cb.C = -cb.A * vb->x - cb.B * vb->y;
|
||||
for (vertex = vb->next; vertex != va; vertex = vertex->next) {
|
||||
shadow_vertex = vertex->shadow_vertex;
|
||||
if (shadow_vertex != NULL &&
|
||||
(shadow_vertex == va || shadow_vertex == vb || shadow_vertex == vc))
|
||||
continue;
|
||||
x = vertex->x;
|
||||
y = vertex->y;
|
||||
if (right(ba.A, ba.B, ba.C, x, y) &&
|
||||
right(ac.A, ac.B, ac.C, x, y) && right(cb.A, cb.B, cb.C, x, y))
|
||||
return GL_FALSE;
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
clip_ear(GLUtriangulatorObj * tobj, tess_vertex * v, tess_contour * contour)
|
||||
{
|
||||
emit_triangle(tobj, v->previous, v, v->next);
|
||||
/* the first in the list */
|
||||
if (contour->vertices == v) {
|
||||
contour->vertices = v->next;
|
||||
contour->last_vertex->next = v->next;
|
||||
v->next->previous = contour->last_vertex;
|
||||
}
|
||||
else
|
||||
/* the last ? */
|
||||
if (contour->last_vertex == v) {
|
||||
contour->vertices->previous = v->previous;
|
||||
v->previous->next = v->next;
|
||||
contour->last_vertex = v->previous;
|
||||
}
|
||||
else {
|
||||
v->next->previous = v->previous;
|
||||
v->previous->next = v->next;
|
||||
}
|
||||
free(v);
|
||||
--(contour->vertex_cnt);
|
||||
}
|
||||
|
||||
static void
|
||||
clip_ear_with_edge_flag(GLUtriangulatorObj * tobj,
|
||||
tess_vertex * v, tess_contour * contour)
|
||||
{
|
||||
emit_triangle_with_edge_flag(tobj, v->previous, v->previous->edge_flag,
|
||||
v, v->edge_flag, v->next, GL_FALSE);
|
||||
v->previous->edge_flag = GL_FALSE;
|
||||
/* the first in the list */
|
||||
if (contour->vertices == v) {
|
||||
contour->vertices = v->next;
|
||||
contour->last_vertex->next = v->next;
|
||||
v->next->previous = contour->last_vertex;
|
||||
}
|
||||
else
|
||||
/* the last ? */
|
||||
if (contour->last_vertex == v) {
|
||||
contour->vertices->previous = v->previous;
|
||||
v->previous->next = v->next;
|
||||
contour->last_vertex = v->previous;
|
||||
}
|
||||
else {
|
||||
v->next->previous = v->previous;
|
||||
v->previous->next = v->next;
|
||||
}
|
||||
free(v);
|
||||
--(contour->vertex_cnt);
|
||||
}
|
||||
|
||||
static void
|
||||
triangulate_ccw(GLUtriangulatorObj * tobj, tess_contour * contour)
|
||||
{
|
||||
tess_vertex *vertex;
|
||||
GLuint vertex_cnt = contour->vertex_cnt;
|
||||
|
||||
while (vertex_cnt > 3) {
|
||||
vertex = contour->vertices;
|
||||
while (diagonal_ccw(vertex, vertex->next->next, tobj, contour) ==
|
||||
GL_FALSE && tobj->error == GLU_NO_ERROR)
|
||||
vertex = vertex->next;
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
return;
|
||||
clip_ear(tobj, vertex->next, contour);
|
||||
--vertex_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
triangulate_cw(GLUtriangulatorObj * tobj, tess_contour * contour)
|
||||
{
|
||||
tess_vertex *vertex;
|
||||
GLuint vertex_cnt = contour->vertex_cnt;
|
||||
|
||||
while (vertex_cnt > 3) {
|
||||
vertex = contour->vertices;
|
||||
while (diagonal_cw(vertex, vertex->next->next, tobj, contour) ==
|
||||
GL_FALSE && tobj->error == GLU_NO_ERROR)
|
||||
vertex = vertex->next;
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
return;
|
||||
clip_ear(tobj, vertex->next, contour);
|
||||
--vertex_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
triangulate_ccw_with_edge_flag(GLUtriangulatorObj * tobj,
|
||||
tess_contour * contour)
|
||||
{
|
||||
tess_vertex *vertex;
|
||||
GLuint vertex_cnt = contour->vertex_cnt;
|
||||
|
||||
while (vertex_cnt > 3) {
|
||||
vertex = contour->vertices;
|
||||
while (diagonal_ccw(vertex, vertex->next->next, tobj, contour) ==
|
||||
GL_FALSE && tobj->error == GLU_NO_ERROR)
|
||||
vertex = vertex->next;
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
return;
|
||||
clip_ear_with_edge_flag(tobj, vertex->next, contour);
|
||||
--vertex_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
triangulate_cw_with_edge_flag(GLUtriangulatorObj * tobj,
|
||||
tess_contour * contour)
|
||||
{
|
||||
tess_vertex *vertex;
|
||||
GLuint vertex_cnt = contour->vertex_cnt;
|
||||
|
||||
while (vertex_cnt > 3) {
|
||||
vertex = contour->vertices;
|
||||
while (diagonal_cw(vertex, vertex->next->next, tobj, contour) ==
|
||||
GL_FALSE && tobj->error == GLU_NO_ERROR)
|
||||
vertex = vertex->next;
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
return;
|
||||
clip_ear_with_edge_flag(tobj, vertex->next, contour);
|
||||
--vertex_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tess_tesselate(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_contour *contour;
|
||||
|
||||
for (contour = tobj->contours; contour != NULL; contour = contour->next) {
|
||||
if (contour->orientation == GLU_CCW) {
|
||||
triangulate_ccw(tobj, contour);
|
||||
}
|
||||
else {
|
||||
triangulate_cw(tobj, contour);
|
||||
}
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
return;
|
||||
|
||||
/* emit the last triangle */
|
||||
emit_triangle(tobj, contour->vertices, contour->vertices->next,
|
||||
contour->vertices->next->next);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tess_tesselate_with_edge_flag(GLUtriangulatorObj * tobj)
|
||||
{
|
||||
tess_contour *contour;
|
||||
|
||||
edge_flag = GL_TRUE;
|
||||
/* first callback with edgeFlag set to GL_TRUE */
|
||||
(tobj->callbacks.edgeFlag) (GL_TRUE);
|
||||
|
||||
for (contour = tobj->contours; contour != NULL; contour = contour->next) {
|
||||
if (contour->orientation == GLU_CCW)
|
||||
triangulate_ccw_with_edge_flag(tobj, contour);
|
||||
else
|
||||
triangulate_cw_with_edge_flag(tobj, contour);
|
||||
if (tobj->error != GLU_NO_ERROR)
|
||||
return;
|
||||
/* emit the last triangle */
|
||||
emit_triangle_with_edge_flag(tobj, contour->vertices,
|
||||
contour->vertices->edge_flag,
|
||||
contour->vertices->next,
|
||||
contour->vertices->next->edge_flag,
|
||||
contour->vertices->next->next,
|
||||
contour->vertices->next->next->edge_flag);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
emit_triangle(GLUtriangulatorObj * tobj,
|
||||
tess_vertex * v1, tess_vertex * v2, tess_vertex * v3)
|
||||
{
|
||||
(tobj->callbacks.begin) (GL_TRIANGLES);
|
||||
(tobj->callbacks.vertex) (v1->data);
|
||||
(tobj->callbacks.vertex) (v2->data);
|
||||
(tobj->callbacks.vertex) (v3->data);
|
||||
(tobj->callbacks.end) ();
|
||||
}
|
||||
|
||||
static void
|
||||
emit_triangle_with_edge_flag(GLUtriangulatorObj * tobj,
|
||||
tess_vertex * v1,
|
||||
GLboolean edge_flag1,
|
||||
tess_vertex * v2,
|
||||
GLboolean edge_flag2,
|
||||
tess_vertex * v3, GLboolean edge_flag3)
|
||||
{
|
||||
(tobj->callbacks.begin) (GL_TRIANGLES);
|
||||
if (edge_flag1 != edge_flag) {
|
||||
edge_flag = (edge_flag == GL_TRUE ? GL_FALSE : GL_TRUE);
|
||||
(tobj->callbacks.edgeFlag) (edge_flag);
|
||||
}
|
||||
(tobj->callbacks.vertex) (v1->data);
|
||||
if (edge_flag2 != edge_flag) {
|
||||
edge_flag = (edge_flag == GL_TRUE ? GL_FALSE : GL_TRUE);
|
||||
(tobj->callbacks.edgeFlag) (edge_flag);
|
||||
}
|
||||
(tobj->callbacks.vertex) (v2->data);
|
||||
if (edge_flag3 != edge_flag) {
|
||||
edge_flag = (edge_flag == GL_TRUE ? GL_FALSE : GL_TRUE);
|
||||
(tobj->callbacks.edgeFlag) (edge_flag);
|
||||
}
|
||||
(tobj->callbacks.vertex) (v3->data);
|
||||
(tobj->callbacks.end) ();
|
||||
}
|
||||
@@ -1,43 +1,11 @@
|
||||
# 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
|
||||
MESA = ../..
|
||||
|
||||
MARK = $(MESA)/src-glut
|
||||
default: libglut.so.3.7 install
|
||||
include $(MESA)/Makefile.include
|
||||
|
||||
|
||||
.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
|
||||
INCLUDES = -I$(MESA)/include -I$(MARK)
|
||||
|
||||
CORE_SOURCES = \
|
||||
bitmap.c \
|
||||
@@ -64,35 +32,19 @@ MARK_SOURCES = \
|
||||
|
||||
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
|
||||
OBJS = $(SOURCES:.c=.o)
|
||||
|
||||
LIBS = -L$(MESA)/lib -lGL -lGLU -lm
|
||||
|
||||
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
|
||||
rm -f $(MESA)/lib/libglut.so*
|
||||
install -D libglut.so.3.7 $(MESA)/lib/libglut.so.3.7
|
||||
ln -s libglut.so.3.7 $(MESA)/lib/libglut.so.3
|
||||
ln -s libglut.so.3 $(MESA)/lib/libglut.so
|
||||
|
||||
|
||||
-include $(SOURCES:.c=.d)
|
||||
|
||||
.SUFFIXES: .c .d
|
||||
|
||||
.c.d:
|
||||
$(CC) -M $(INCLUDES) $< > $@
|
||||
|
||||
@@ -12,8 +12,8 @@ glutBitmapCharacter(GLUTbitmapFont font, int c)
|
||||
{
|
||||
const BitmapCharRec *ch;
|
||||
BitmapFontPtr fontinfo;
|
||||
GLint swapbytes, lsbfirst, rowlength;
|
||||
GLint skiprows, skippixels, alignment;
|
||||
GLfloat swapbytes, lsbfirst, rowlength;
|
||||
GLfloat skiprows, skippixels, alignment;
|
||||
|
||||
#if defined(_WIN32)
|
||||
fontinfo = (BitmapFontPtr) __glutFont(font);
|
||||
@@ -27,30 +27,30 @@ glutBitmapCharacter(GLUTbitmapFont font, int c)
|
||||
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);
|
||||
/* glGetFloatv(GL_UNPACK_SWAP_BYTES, &swapbytes); */
|
||||
/* glGetFloatv(GL_UNPACK_LSB_FIRST, &lsbfirst); */
|
||||
/* glGetFloatv(GL_UNPACK_ROW_LENGTH, &rowlength); */
|
||||
/* glGetFloatv(GL_UNPACK_SKIP_ROWS, &skiprows); */
|
||||
/* glGetFloatv(GL_UNPACK_SKIP_PIXELS, &skippixels); */
|
||||
glGetFloatv(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);
|
||||
/* 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);
|
||||
/* glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); */
|
||||
/* glPixelStorei(GL_UNPACK_LSB_FIRST, (int)lsbfirst); */
|
||||
/* glPixelStorei(GL_UNPACK_ROW_LENGTH, (int)rowlength); */
|
||||
/* glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); */
|
||||
/* glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); */
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, (int)alignment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,6 @@ void APIENTRY glutInit (int *argcp, char **argv)
|
||||
void APIENTRY glutInitDisplayMode (unsigned int mode)
|
||||
{
|
||||
g_display_mode = mode;
|
||||
|
||||
/* pc_install_keyb(); */
|
||||
/* g_mouse = pc_install_mouse(); */
|
||||
}
|
||||
|
||||
|
||||
@@ -60,103 +57,3 @@ void APIENTRY glutInitWindowSize (int width, int 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ drawBox(GLfloat size, GLenum type)
|
||||
|
||||
for (i = 5; i >= 0; i--) {
|
||||
glBegin(type);
|
||||
glNormal3fv(&n[i][0]);
|
||||
/* glNormal3fv(&n[i][0]); */
|
||||
glVertex3fv(&v[faces[i][0]][0]);
|
||||
glVertex3fv(&v[faces[i][1]][0]);
|
||||
glVertex3fv(&v[faces[i][2]][0]);
|
||||
@@ -205,9 +205,9 @@ doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
|
||||
sinPhi = sin(phi);
|
||||
dist = R + r * cosPhi;
|
||||
|
||||
glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||
/* glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); */
|
||||
glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||
glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
|
||||
/* glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); */
|
||||
glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
|
||||
}
|
||||
glEnd();
|
||||
@@ -222,10 +222,10 @@ void APIENTRY
|
||||
glutWireTorus(GLdouble innerRadius, GLdouble outerRadius,
|
||||
GLint nsides, GLint rings)
|
||||
{
|
||||
glPushAttrib(GL_POLYGON_BIT);
|
||||
/* glPushAttrib(GL_POLYGON_BIT); */
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
doughnut(innerRadius, outerRadius, nsides, rings);
|
||||
glPopAttrib();
|
||||
/* glPopAttrib(); */
|
||||
}
|
||||
|
||||
void APIENTRY
|
||||
@@ -318,7 +318,7 @@ pentagon(int a, int b, int c, int d, int e, GLenum shadeType)
|
||||
normalize(n0);
|
||||
|
||||
glBegin(shadeType);
|
||||
glNormal3fv(n0);
|
||||
/* glNormal3fv(n0); */
|
||||
glVertex3fv(&dodec[a][0]);
|
||||
glVertex3fv(&dodec[b][0]);
|
||||
glVertex3fv(&dodec[c][0]);
|
||||
@@ -377,7 +377,7 @@ recorditem(GLfloat * n1, GLfloat * n2, GLfloat * n3,
|
||||
normalize(q1);
|
||||
|
||||
glBegin(shadeType);
|
||||
glNormal3fv(q1);
|
||||
/* glNormal3fv(q1); */
|
||||
glVertex3fv(n1);
|
||||
glVertex3fv(n2);
|
||||
glVertex3fv(n3);
|
||||
|
||||
@@ -143,6 +143,7 @@ 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;
|
||||
|
||||
#if 0
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
|
||||
glEnable(GL_AUTO_NORMAL);
|
||||
glEnable(GL_NORMALIZE);
|
||||
@@ -194,6 +195,7 @@ teapot(GLint grid, GLdouble scale, GLenum type)
|
||||
}
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* CENTRY */
|
||||
|
||||
@@ -218,3 +218,50 @@ void APIENTRY glutShowWindow (void)
|
||||
void APIENTRY glutHideWindow (void)
|
||||
{
|
||||
}
|
||||
|
||||
void APIENTRY glutMainLoop (void)
|
||||
{
|
||||
GLboolean idle;
|
||||
GLboolean have_event;
|
||||
XEvent evt;
|
||||
|
||||
glutPostRedisplay();
|
||||
if (reshape_func) reshape_func(g_width, g_height);
|
||||
|
||||
while (GL_TRUE) {
|
||||
idle = GL_TRUE;
|
||||
|
||||
|
||||
if (idle_func)
|
||||
have_event = XCheckWindowEvent( dpy, win, ~0, &evt );
|
||||
else
|
||||
have_event = XNextEvent( dpy, &evt );
|
||||
|
||||
if (have_event) {
|
||||
fprintf(stderr, "got event type %d\n", evt.type);
|
||||
idle = GL_FALSE;
|
||||
switch(evt.type) {
|
||||
case MapNotify:
|
||||
if (visibility_func) visibility_func(GLUT_VISIBLE);
|
||||
break;
|
||||
case UnmapNotify:
|
||||
if (visibility_func) visibility_func(GLUT_NOT_VISIBLE);
|
||||
break;
|
||||
case Expose:
|
||||
g_redisplay = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_redisplay && display_func) {
|
||||
idle = GL_FALSE;
|
||||
g_redisplay = GL_FALSE;
|
||||
|
||||
display_func();
|
||||
}
|
||||
|
||||
if (idle && idle_func) {
|
||||
idle_func();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
src/kernel/agpgart/NOTES
Normal file
1
src/kernel/agpgart/NOTES
Normal file
@@ -0,0 +1 @@
|
||||
This directory not really of interest to anybody... Feel free to ignore.
|
||||
1690
src/kernel/agpgart/agp.c
Normal file
1690
src/kernel/agpgart/agp.c
Normal file
File diff suppressed because it is too large
Load Diff
377
src/kernel/agpgart/agp.h
Normal file
377
src/kernel/agpgart/agp.h
Normal file
@@ -0,0 +1,377 @@
|
||||
/*
|
||||
* AGPGART module version 0.99
|
||||
* Copyright (C) 1999 Jeff Hartmann
|
||||
* Copyright (C) 1999 Precision Insight, Inc.
|
||||
* Copyright (C) 1999 Xi Graphics, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* JEFF HARTMANN, 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 _AGP_BACKEND_PRIV_H
|
||||
#define _AGP_BACKEND_PRIV_H 1
|
||||
|
||||
#include <asm/agp.h> /* for flush_agp_cache() */
|
||||
|
||||
extern struct agp_bridge_data agp_bridge;
|
||||
|
||||
/* Generic routines. */
|
||||
void agp_generic_agp_enable(u32 mode);
|
||||
int agp_generic_create_gatt_table(void);
|
||||
int agp_generic_free_gatt_table(void);
|
||||
agp_memory *agp_create_memory(int scratch_pages);
|
||||
int agp_generic_insert_memory(agp_memory * mem, off_t pg_start, int type);
|
||||
int agp_generic_remove_memory(agp_memory * mem, off_t pg_start, int type);
|
||||
agp_memory *agp_generic_alloc_by_type(size_t page_count, int type);
|
||||
void agp_generic_free_by_type(agp_memory * curr);
|
||||
void *agp_generic_alloc_page(void);
|
||||
void agp_generic_destroy_page(void *addr);
|
||||
int agp_generic_suspend(void);
|
||||
void agp_generic_resume(void);
|
||||
void agp_free_key(int key);
|
||||
|
||||
/* chipset specific init routines. */
|
||||
int __init ali_generic_setup (struct pci_dev *pdev);
|
||||
int __init amd_irongate_setup (struct pci_dev *pdev);
|
||||
int __init amd_8151_setup (struct pci_dev *pdev);
|
||||
int __init hp_zx1_setup (struct pci_dev *pdev);
|
||||
int __init intel_i460_setup (struct pci_dev *pdev);
|
||||
int __init intel_generic_setup (struct pci_dev *pdev);
|
||||
int __init intel_i810_setup(struct pci_dev *i810_dev);
|
||||
int __init intel_815_setup(struct pci_dev *pdev);
|
||||
int __init intel_i830_setup(struct pci_dev *i830_dev);
|
||||
int __init intel_820_setup (struct pci_dev *pdev);
|
||||
int __init intel_830mp_setup (struct pci_dev *pdev);
|
||||
int __init intel_840_setup (struct pci_dev *pdev);
|
||||
int __init intel_845_setup (struct pci_dev *pdev);
|
||||
int __init intel_850_setup (struct pci_dev *pdev);
|
||||
int __init intel_860_setup (struct pci_dev *pdev);
|
||||
int __init serverworks_setup (struct pci_dev *pdev);
|
||||
int __init sis_generic_setup (struct pci_dev *pdev);
|
||||
int __init via_generic_setup (struct pci_dev *pdev);
|
||||
|
||||
#define AGPGART_MODULE_NAME "agpgart"
|
||||
#define PFX AGPGART_MODULE_NAME ": "
|
||||
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
static void ipi_handler(void *null)
|
||||
{
|
||||
flush_agp_cache();
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) global_cache_flush(void)
|
||||
{
|
||||
if (smp_call_function(ipi_handler, NULL, 1, 1) != 0)
|
||||
panic(PFX "timed out waiting for the other CPUs!\n");
|
||||
flush_agp_cache();
|
||||
}
|
||||
#else
|
||||
static void global_cache_flush(void)
|
||||
{
|
||||
flush_agp_cache();
|
||||
}
|
||||
#endif /* !CONFIG_SMP */
|
||||
|
||||
enum aper_size_type {
|
||||
U8_APER_SIZE,
|
||||
U16_APER_SIZE,
|
||||
U32_APER_SIZE,
|
||||
LVL2_APER_SIZE,
|
||||
FIXED_APER_SIZE
|
||||
};
|
||||
|
||||
struct gatt_mask {
|
||||
unsigned long mask;
|
||||
u32 type;
|
||||
/* totally device specific, for integrated chipsets that
|
||||
* might have different types of memory masks. For other
|
||||
* devices this will probably be ignored */
|
||||
};
|
||||
|
||||
struct aper_size_info_8 {
|
||||
int size;
|
||||
int num_entries;
|
||||
int page_order;
|
||||
u8 size_value;
|
||||
};
|
||||
|
||||
struct aper_size_info_16 {
|
||||
int size;
|
||||
int num_entries;
|
||||
int page_order;
|
||||
u16 size_value;
|
||||
};
|
||||
|
||||
struct aper_size_info_32 {
|
||||
int size;
|
||||
int num_entries;
|
||||
int page_order;
|
||||
u32 size_value;
|
||||
};
|
||||
|
||||
struct aper_size_info_lvl2 {
|
||||
int size;
|
||||
int num_entries;
|
||||
u32 size_value;
|
||||
};
|
||||
|
||||
struct aper_size_info_fixed {
|
||||
int size;
|
||||
int num_entries;
|
||||
int page_order;
|
||||
};
|
||||
|
||||
struct agp_bridge_data {
|
||||
struct agp_version *version;
|
||||
void *aperture_sizes;
|
||||
void *previous_size;
|
||||
void *current_size;
|
||||
void *dev_private_data;
|
||||
struct pci_dev *dev;
|
||||
struct gatt_mask *masks;
|
||||
unsigned long *gatt_table;
|
||||
unsigned long *gatt_table_real;
|
||||
unsigned long scratch_page;
|
||||
unsigned long gart_bus_addr;
|
||||
unsigned long gatt_bus_addr;
|
||||
u32 mode;
|
||||
enum chipset_type type;
|
||||
enum aper_size_type size_type;
|
||||
unsigned long *key_list;
|
||||
atomic_t current_memory_agp;
|
||||
atomic_t agp_in_use;
|
||||
int max_memory_agp; /* in number of pages */
|
||||
int needs_scratch_page;
|
||||
int aperture_size_idx;
|
||||
int num_aperture_sizes;
|
||||
int num_of_masks;
|
||||
int capndx;
|
||||
int cant_use_aperture;
|
||||
|
||||
/* Links to driver specific functions */
|
||||
|
||||
int (*fetch_size) (void);
|
||||
int (*configure) (void);
|
||||
void (*agp_enable) (u32);
|
||||
void (*cleanup) (void);
|
||||
void (*tlb_flush) (agp_memory *);
|
||||
unsigned long (*mask_memory) (unsigned long, int);
|
||||
void (*cache_flush) (void);
|
||||
int (*create_gatt_table) (void);
|
||||
int (*free_gatt_table) (void);
|
||||
int (*insert_memory) (agp_memory *, off_t, int);
|
||||
int (*remove_memory) (agp_memory *, off_t, int);
|
||||
agp_memory *(*alloc_by_type) (size_t, int);
|
||||
void (*free_by_type) (agp_memory *);
|
||||
void *(*agp_alloc_page) (void);
|
||||
void (*agp_destroy_page) (void *);
|
||||
int (*suspend)(void);
|
||||
void (*resume)(void);
|
||||
|
||||
};
|
||||
|
||||
#define OUTREG64(mmap, addr, val) __raw_writeq((val), (mmap)+(addr))
|
||||
#define OUTREG32(mmap, addr, val) __raw_writel((val), (mmap)+(addr))
|
||||
#define OUTREG16(mmap, addr, val) __raw_writew((val), (mmap)+(addr))
|
||||
#define OUTREG8(mmap, addr, val) __raw_writeb((val), (mmap)+(addr))
|
||||
|
||||
#define INREG64(mmap, addr) __raw_readq((mmap)+(addr))
|
||||
#define INREG32(mmap, addr) __raw_readl((mmap)+(addr))
|
||||
#define INREG16(mmap, addr) __raw_readw((mmap)+(addr))
|
||||
#define INREG8(mmap, addr) __raw_readb((mmap)+(addr))
|
||||
|
||||
#define KB(x) ((x) * 1024)
|
||||
#define MB(x) (KB (KB (x)))
|
||||
#define GB(x) (MB (KB (x)))
|
||||
|
||||
#define CACHE_FLUSH agp_bridge.cache_flush
|
||||
#define A_SIZE_8(x) ((struct aper_size_info_8 *) x)
|
||||
#define A_SIZE_16(x) ((struct aper_size_info_16 *) x)
|
||||
#define A_SIZE_32(x) ((struct aper_size_info_32 *) x)
|
||||
#define A_SIZE_LVL2(x) ((struct aper_size_info_lvl2 *) x)
|
||||
#define A_SIZE_FIX(x) ((struct aper_size_info_fixed *) x)
|
||||
#define A_IDX8() (A_SIZE_8(agp_bridge.aperture_sizes) + i)
|
||||
#define A_IDX16() (A_SIZE_16(agp_bridge.aperture_sizes) + i)
|
||||
#define A_IDX32() (A_SIZE_32(agp_bridge.aperture_sizes) + i)
|
||||
#define A_IDXLVL2() (A_SIZE_LVL2(agp_bridge.aperture_sizes) + i)
|
||||
#define A_IDXFIX() (A_SIZE_FIX(agp_bridge.aperture_sizes) + i)
|
||||
#define MAXKEY (4096 * 32)
|
||||
|
||||
#define PGE_EMPTY(p) (!(p) || (p) == (unsigned long) agp_bridge.scratch_page)
|
||||
|
||||
/* intel register */
|
||||
#define INTEL_APBASE 0x10
|
||||
#define INTEL_APSIZE 0xb4
|
||||
#define INTEL_ATTBASE 0xb8
|
||||
#define INTEL_AGPCTRL 0xb0
|
||||
#define INTEL_NBXCFG 0x50
|
||||
#define INTEL_ERRSTS 0x91
|
||||
|
||||
/* Intel 460GX Registers */
|
||||
#define INTEL_I460_APBASE 0x10
|
||||
#define INTEL_I460_BAPBASE 0x98
|
||||
#define INTEL_I460_GXBCTL 0xa0
|
||||
#define INTEL_I460_AGPSIZ 0xa2
|
||||
#define INTEL_I460_ATTBASE 0xfe200000
|
||||
#define INTEL_I460_GATT_VALID (1UL << 24)
|
||||
#define INTEL_I460_GATT_COHERENT (1UL << 25)
|
||||
|
||||
/* intel i830 registers */
|
||||
#define I830_GMCH_CTRL 0x52
|
||||
#define I830_GMCH_ENABLED 0x4
|
||||
#define I830_GMCH_MEM_MASK 0x1
|
||||
#define I830_GMCH_MEM_64M 0x1
|
||||
#define I830_GMCH_MEM_128M 0
|
||||
#define I830_GMCH_GMS_MASK 0x70
|
||||
#define I830_GMCH_GMS_DISABLED 0x00
|
||||
#define I830_GMCH_GMS_LOCAL 0x10
|
||||
#define I830_GMCH_GMS_STOLEN_512 0x20
|
||||
#define I830_GMCH_GMS_STOLEN_1024 0x30
|
||||
#define I830_GMCH_GMS_STOLEN_8192 0x40
|
||||
#define I830_RDRAM_CHANNEL_TYPE 0x03010
|
||||
#define I830_RDRAM_ND(x) (((x) & 0x20) >> 5)
|
||||
#define I830_RDRAM_DDT(x) (((x) & 0x18) >> 3)
|
||||
|
||||
/* This one is for I830MP w. an external graphic card */
|
||||
#define INTEL_I830_ERRSTS 0x92
|
||||
|
||||
/* intel 815 register */
|
||||
#define INTEL_815_APCONT 0x51
|
||||
#define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
|
||||
|
||||
/* intel i820 registers */
|
||||
#define INTEL_I820_RDCR 0x51
|
||||
#define INTEL_I820_ERRSTS 0xc8
|
||||
|
||||
/* intel i840 registers */
|
||||
#define INTEL_I840_MCHCFG 0x50
|
||||
#define INTEL_I840_ERRSTS 0xc8
|
||||
|
||||
/* intel i845 registers */
|
||||
#define INTEL_I845_AGPM 0x51
|
||||
#define INTEL_I845_ERRSTS 0xc8
|
||||
|
||||
/* intel i850 registers */
|
||||
#define INTEL_I850_MCHCFG 0x50
|
||||
#define INTEL_I850_ERRSTS 0xc8
|
||||
|
||||
/* intel i860 registers */
|
||||
#define INTEL_I860_MCHCFG 0x50
|
||||
#define INTEL_I860_ERRSTS 0xc8
|
||||
|
||||
/* intel i810 registers */
|
||||
#define I810_GMADDR 0x10
|
||||
#define I810_MMADDR 0x14
|
||||
#define I810_PTE_BASE 0x10000
|
||||
#define I810_PTE_MAIN_UNCACHED 0x00000000
|
||||
#define I810_PTE_LOCAL 0x00000002
|
||||
#define I810_PTE_VALID 0x00000001
|
||||
#define I810_SMRAM_MISCC 0x70
|
||||
#define I810_GFX_MEM_WIN_SIZE 0x00010000
|
||||
#define I810_GFX_MEM_WIN_32M 0x00010000
|
||||
#define I810_GMS 0x000000c0
|
||||
#define I810_GMS_DISABLE 0x00000000
|
||||
#define I810_PGETBL_CTL 0x2020
|
||||
#define I810_PGETBL_ENABLED 0x00000001
|
||||
#define I810_DRAM_CTL 0x3000
|
||||
#define I810_DRAM_ROW_0 0x00000001
|
||||
#define I810_DRAM_ROW_0_SDRAM 0x00000001
|
||||
|
||||
|
||||
|
||||
/* VIA register */
|
||||
#define VIA_APBASE 0x10
|
||||
#define VIA_GARTCTRL 0x80
|
||||
#define VIA_APSIZE 0x84
|
||||
#define VIA_ATTBASE 0x88
|
||||
|
||||
/* SiS registers */
|
||||
#define SIS_APBASE 0x10
|
||||
#define SIS_ATTBASE 0x90
|
||||
#define SIS_APSIZE 0x94
|
||||
#define SIS_TLBCNTRL 0x97
|
||||
#define SIS_TLBFLUSH 0x98
|
||||
|
||||
/* AMD registers */
|
||||
#define AMD_APBASE 0x10
|
||||
#define AMD_MMBASE 0x14
|
||||
#define AMD_APSIZE 0xac
|
||||
#define AMD_MODECNTL 0xb0
|
||||
#define AMD_MODECNTL2 0xb2
|
||||
#define AMD_GARTENABLE 0x02 /* In mmio region (16-bit register) */
|
||||
#define AMD_ATTBASE 0x04 /* In mmio region (32-bit register) */
|
||||
#define AMD_TLBFLUSH 0x0c /* In mmio region (32-bit register) */
|
||||
#define AMD_CACHEENTRY 0x10 /* In mmio region (32-bit register) */
|
||||
|
||||
#define AMD_8151_APSIZE 0xb4
|
||||
#define AMD_8151_GARTBLOCK 0xb8
|
||||
|
||||
#define AMD_X86_64_GARTAPERTURECTL 0x90
|
||||
#define AMD_X86_64_GARTAPERTUREBASE 0x94
|
||||
#define AMD_X86_64_GARTTABLEBASE 0x98
|
||||
#define AMD_X86_64_GARTCACHECTL 0x9c
|
||||
#define AMD_X86_64_GARTEN 1<<0
|
||||
|
||||
#define AMD_8151_VMAPERTURE 0x10
|
||||
#define AMD_8151_AGP_CTL 0xb0
|
||||
#define AMD_8151_APERTURESIZE 0xb4
|
||||
#define AMD_8151_GARTPTR 0xb8
|
||||
#define AMD_8151_GTLBEN 1<<7
|
||||
#define AMD_8151_APEREN 1<<8
|
||||
|
||||
/* ALi registers */
|
||||
#define ALI_APBASE 0x10
|
||||
#define ALI_AGPCTRL 0xb8
|
||||
#define ALI_ATTBASE 0xbc
|
||||
#define ALI_TLBCTRL 0xc0
|
||||
#define ALI_TAGCTRL 0xc4
|
||||
#define ALI_CACHE_FLUSH_CTRL 0xD0
|
||||
#define ALI_CACHE_FLUSH_ADDR_MASK 0xFFFFF000
|
||||
#define ALI_CACHE_FLUSH_EN 0x100
|
||||
|
||||
/* Serverworks Registers */
|
||||
#define SVWRKS_APSIZE 0x10
|
||||
#define SVWRKS_SIZE_MASK 0xfe000000
|
||||
|
||||
#define SVWRKS_MMBASE 0x14
|
||||
#define SVWRKS_CACHING 0x4b
|
||||
#define SVWRKS_FEATURE 0x68
|
||||
|
||||
/* func 1 registers */
|
||||
#define SVWRKS_AGP_ENABLE 0x60
|
||||
#define SVWRKS_COMMAND 0x04
|
||||
|
||||
/* Memory mapped registers */
|
||||
#define SVWRKS_GART_CACHE 0x02
|
||||
#define SVWRKS_GATTBASE 0x04
|
||||
#define SVWRKS_TLBFLUSH 0x10
|
||||
#define SVWRKS_POSTFLUSH 0x14
|
||||
#define SVWRKS_DIRFLUSH 0x0c
|
||||
|
||||
/* HP ZX1 SBA registers */
|
||||
#define HP_ZX1_CTRL 0x200
|
||||
#define HP_ZX1_IBASE 0x300
|
||||
#define HP_ZX1_IMASK 0x308
|
||||
#define HP_ZX1_PCOM 0x310
|
||||
#define HP_ZX1_TCNFG 0x318
|
||||
#define HP_ZX1_PDIR_BASE 0x320
|
||||
#define HP_ZX1_CACHE_FLUSH 0x428
|
||||
|
||||
#endif /* _AGP_BACKEND_PRIV_H */
|
||||
1086
src/kernel/agpgart/frontend.c
Normal file
1086
src/kernel/agpgart/frontend.c
Normal file
File diff suppressed because it is too large
Load Diff
594
src/kernel/agpgart/i810_agp.c
Normal file
594
src/kernel/agpgart/i810_agp.c
Normal file
@@ -0,0 +1,594 @@
|
||||
/*
|
||||
* AGPGART module version 0.99
|
||||
* Copyright (C) 1999 Jeff Hartmann
|
||||
* Copyright (C) 1999 Precision Insight, Inc.
|
||||
* Copyright (C) 1999 Xi Graphics, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* JEFF HARTMANN, 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.
|
||||
*
|
||||
* TODO:
|
||||
* - Allocate more than order 0 pages to avoid too much linear map splitting.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/agp_backend.h>
|
||||
#include "agp.h"
|
||||
|
||||
static struct aper_size_info_fixed intel_i810_sizes[] =
|
||||
{
|
||||
{64, 16384, 4},
|
||||
/* The 32M mode still requires a 64k gatt */
|
||||
{32, 8192, 4}
|
||||
};
|
||||
|
||||
#define AGP_DCACHE_MEMORY 1
|
||||
#define AGP_PHYS_MEMORY 2
|
||||
|
||||
static struct gatt_mask intel_i810_masks[] =
|
||||
{
|
||||
{mask: I810_PTE_VALID, type: 0},
|
||||
{mask: (I810_PTE_VALID | I810_PTE_LOCAL), type: AGP_DCACHE_MEMORY},
|
||||
{mask: I810_PTE_VALID, type: 0}
|
||||
};
|
||||
|
||||
static struct _intel_i810_private {
|
||||
struct pci_dev *i810_dev; /* device one */
|
||||
volatile u8 *registers;
|
||||
int num_dcache_entries;
|
||||
} intel_i810_private;
|
||||
|
||||
static int intel_i810_fetch_size(void)
|
||||
{
|
||||
u32 smram_miscc;
|
||||
struct aper_size_info_fixed *values;
|
||||
|
||||
pci_read_config_dword(agp_bridge.dev, I810_SMRAM_MISCC, &smram_miscc);
|
||||
values = A_SIZE_FIX(agp_bridge.aperture_sizes);
|
||||
|
||||
if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) {
|
||||
printk(KERN_WARNING PFX "i810 is disabled\n");
|
||||
return 0;
|
||||
}
|
||||
if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) {
|
||||
agp_bridge.previous_size =
|
||||
agp_bridge.current_size = (void *) (values + 1);
|
||||
agp_bridge.aperture_size_idx = 1;
|
||||
return values[1].size;
|
||||
} else {
|
||||
agp_bridge.previous_size =
|
||||
agp_bridge.current_size = (void *) (values);
|
||||
agp_bridge.aperture_size_idx = 0;
|
||||
return values[0].size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_i810_configure(void)
|
||||
{
|
||||
struct aper_size_info_fixed *current_size;
|
||||
u32 temp;
|
||||
int i;
|
||||
|
||||
current_size = A_SIZE_FIX(agp_bridge.current_size);
|
||||
|
||||
pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp);
|
||||
temp &= 0xfff80000;
|
||||
|
||||
intel_i810_private.registers =
|
||||
(volatile u8 *) ioremap(temp, 128 * 4096);
|
||||
|
||||
if ((INREG32(intel_i810_private.registers, I810_DRAM_CTL)
|
||||
& I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
|
||||
/* This will need to be dynamically assigned */
|
||||
printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n");
|
||||
intel_i810_private.num_dcache_entries = 1024;
|
||||
}
|
||||
pci_read_config_dword(intel_i810_private.i810_dev, I810_GMADDR, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
OUTREG32(intel_i810_private.registers, I810_PGETBL_CTL,
|
||||
agp_bridge.gatt_bus_addr | I810_PGETBL_ENABLED);
|
||||
CACHE_FLUSH();
|
||||
|
||||
if (agp_bridge.needs_scratch_page == TRUE) {
|
||||
for (i = 0; i < current_size->num_entries; i++) {
|
||||
OUTREG32(intel_i810_private.registers,
|
||||
I810_PTE_BASE + (i * 4),
|
||||
agp_bridge.scratch_page);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void intel_i810_cleanup(void)
|
||||
{
|
||||
OUTREG32(intel_i810_private.registers, I810_PGETBL_CTL, 0);
|
||||
iounmap((void *) intel_i810_private.registers);
|
||||
}
|
||||
|
||||
static void intel_i810_tlbflush(agp_memory * mem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void intel_i810_agp_enable(u32 mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int intel_i810_insert_entries(agp_memory * mem, off_t pg_start,
|
||||
int type)
|
||||
{
|
||||
int i, j, num_entries;
|
||||
void *temp;
|
||||
|
||||
temp = agp_bridge.current_size;
|
||||
num_entries = A_SIZE_FIX(temp)->num_entries;
|
||||
|
||||
if ((pg_start + mem->page_count) > num_entries) {
|
||||
return -EINVAL;
|
||||
}
|
||||
for (j = pg_start; j < (pg_start + mem->page_count); j++) {
|
||||
if (!PGE_EMPTY(agp_bridge.gatt_table[j])) {
|
||||
return -EBUSY;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != 0 || mem->type != 0) {
|
||||
if ((type == AGP_DCACHE_MEMORY) &&
|
||||
(mem->type == AGP_DCACHE_MEMORY)) {
|
||||
/* special insert */
|
||||
CACHE_FLUSH();
|
||||
for (i = pg_start;
|
||||
i < (pg_start + mem->page_count); i++) {
|
||||
OUTREG32(intel_i810_private.registers,
|
||||
I810_PTE_BASE + (i * 4),
|
||||
(i * 4096) | I810_PTE_LOCAL |
|
||||
I810_PTE_VALID);
|
||||
}
|
||||
CACHE_FLUSH();
|
||||
agp_bridge.tlb_flush(mem);
|
||||
return 0;
|
||||
}
|
||||
if((type == AGP_PHYS_MEMORY) &&
|
||||
(mem->type == AGP_PHYS_MEMORY)) {
|
||||
goto insert;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
insert:
|
||||
CACHE_FLUSH();
|
||||
for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
|
||||
OUTREG32(intel_i810_private.registers,
|
||||
I810_PTE_BASE + (j * 4), mem->memory[i]);
|
||||
}
|
||||
CACHE_FLUSH();
|
||||
|
||||
agp_bridge.tlb_flush(mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_i810_remove_entries(agp_memory * mem, off_t pg_start,
|
||||
int type)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = pg_start; i < (mem->page_count + pg_start); i++) {
|
||||
OUTREG32(intel_i810_private.registers,
|
||||
I810_PTE_BASE + (i * 4),
|
||||
agp_bridge.scratch_page);
|
||||
}
|
||||
|
||||
CACHE_FLUSH();
|
||||
agp_bridge.tlb_flush(mem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
|
||||
{
|
||||
agp_memory *new;
|
||||
|
||||
if (type == AGP_DCACHE_MEMORY) {
|
||||
if (pg_count != intel_i810_private.num_dcache_entries) {
|
||||
return NULL;
|
||||
}
|
||||
new = agp_create_memory(1);
|
||||
|
||||
if (new == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
new->type = AGP_DCACHE_MEMORY;
|
||||
new->page_count = pg_count;
|
||||
new->num_scratch_pages = 0;
|
||||
vfree(new->memory);
|
||||
MOD_INC_USE_COUNT;
|
||||
return new;
|
||||
}
|
||||
if(type == AGP_PHYS_MEMORY) {
|
||||
void *addr;
|
||||
/* The I810 requires a physical address to program
|
||||
* it's mouse pointer into hardware. However the
|
||||
* Xserver still writes to it through the agp
|
||||
* aperture
|
||||
*/
|
||||
if (pg_count != 1) {
|
||||
return NULL;
|
||||
}
|
||||
new = agp_create_memory(1);
|
||||
|
||||
if (new == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
MOD_INC_USE_COUNT;
|
||||
addr = agp_bridge.agp_alloc_page();
|
||||
|
||||
if (addr == NULL) {
|
||||
/* Free this structure */
|
||||
agp_free_memory(new);
|
||||
return NULL;
|
||||
}
|
||||
new->memory[0] = agp_bridge.mask_memory(virt_to_phys(addr), type);
|
||||
new->page_count = 1;
|
||||
new->num_scratch_pages = 1;
|
||||
new->type = AGP_PHYS_MEMORY;
|
||||
new->physical = virt_to_phys((void *) new->memory[0]);
|
||||
return new;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void intel_i810_free_by_type(agp_memory * curr)
|
||||
{
|
||||
agp_free_key(curr->key);
|
||||
if(curr->type == AGP_PHYS_MEMORY) {
|
||||
agp_bridge.agp_destroy_page(
|
||||
phys_to_virt(curr->memory[0]));
|
||||
vfree(curr->memory);
|
||||
}
|
||||
kfree(curr);
|
||||
MOD_DEC_USE_COUNT;
|
||||
}
|
||||
|
||||
static unsigned long intel_i810_mask_memory(unsigned long addr, int type)
|
||||
{
|
||||
/* Type checking must be done elsewhere */
|
||||
return addr | agp_bridge.masks[type].mask;
|
||||
}
|
||||
|
||||
int __init intel_i810_setup(struct pci_dev *i810_dev)
|
||||
{
|
||||
intel_i810_private.i810_dev = i810_dev;
|
||||
|
||||
agp_bridge.masks = intel_i810_masks;
|
||||
agp_bridge.num_of_masks = 2;
|
||||
agp_bridge.aperture_sizes = (void *) intel_i810_sizes;
|
||||
agp_bridge.size_type = FIXED_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 2;
|
||||
agp_bridge.dev_private_data = (void *) &intel_i810_private;
|
||||
agp_bridge.needs_scratch_page = TRUE;
|
||||
agp_bridge.configure = intel_i810_configure;
|
||||
agp_bridge.fetch_size = intel_i810_fetch_size;
|
||||
agp_bridge.cleanup = intel_i810_cleanup;
|
||||
agp_bridge.tlb_flush = intel_i810_tlbflush;
|
||||
agp_bridge.mask_memory = intel_i810_mask_memory;
|
||||
agp_bridge.agp_enable = intel_i810_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = intel_i810_insert_entries;
|
||||
agp_bridge.remove_memory = intel_i810_remove_entries;
|
||||
agp_bridge.alloc_by_type = intel_i810_alloc_by_type;
|
||||
agp_bridge.free_by_type = intel_i810_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = agp_generic_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct aper_size_info_fixed intel_i830_sizes[] =
|
||||
{
|
||||
{128, 32768, 5},
|
||||
/* The 64M mode still requires a 128k gatt */
|
||||
{64, 16384, 5}
|
||||
};
|
||||
|
||||
static struct _intel_i830_private {
|
||||
struct pci_dev *i830_dev; /* device one */
|
||||
volatile u8 *registers;
|
||||
int gtt_entries;
|
||||
} intel_i830_private;
|
||||
|
||||
static void intel_i830_init_gtt_entries(void)
|
||||
{
|
||||
u16 gmch_ctrl;
|
||||
int gtt_entries;
|
||||
u8 rdct;
|
||||
static const int ddt[4] = { 0, 16, 32, 64 };
|
||||
|
||||
pci_read_config_word(agp_bridge.dev,I830_GMCH_CTRL,&gmch_ctrl);
|
||||
|
||||
switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
|
||||
case I830_GMCH_GMS_STOLEN_512:
|
||||
gtt_entries = KB(512) - KB(132);
|
||||
printk(KERN_INFO PFX "detected %dK stolen memory.\n",gtt_entries / KB(1));
|
||||
break;
|
||||
case I830_GMCH_GMS_STOLEN_1024:
|
||||
gtt_entries = MB(1) - KB(132);
|
||||
printk(KERN_INFO PFX "detected %dK stolen memory.\n",gtt_entries / KB(1));
|
||||
break;
|
||||
case I830_GMCH_GMS_STOLEN_8192:
|
||||
gtt_entries = MB(8) - KB(132);
|
||||
printk(KERN_INFO PFX "detected %dK stolen memory.\n",gtt_entries / KB(1));
|
||||
break;
|
||||
case I830_GMCH_GMS_LOCAL:
|
||||
rdct = INREG8(intel_i830_private.registers,I830_RDRAM_CHANNEL_TYPE);
|
||||
gtt_entries = (I830_RDRAM_ND(rdct) + 1) * MB(ddt[I830_RDRAM_DDT(rdct)]);
|
||||
printk(KERN_INFO PFX "detected %dK local memory.\n",gtt_entries / KB(1));
|
||||
break;
|
||||
default:
|
||||
printk(KERN_INFO PFX "no video memory detected.\n");
|
||||
gtt_entries = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
gtt_entries /= KB(4);
|
||||
|
||||
intel_i830_private.gtt_entries = gtt_entries;
|
||||
}
|
||||
|
||||
/* The intel i830 automatically initializes the agp aperture during POST.
|
||||
* Use the memory already set aside for in the GTT.
|
||||
*/
|
||||
static int intel_i830_create_gatt_table(void)
|
||||
{
|
||||
int page_order;
|
||||
struct aper_size_info_fixed *size;
|
||||
int num_entries;
|
||||
u32 temp;
|
||||
|
||||
size = agp_bridge.current_size;
|
||||
page_order = size->page_order;
|
||||
num_entries = size->num_entries;
|
||||
agp_bridge.gatt_table_real = 0;
|
||||
|
||||
pci_read_config_dword(intel_i830_private.i830_dev,I810_MMADDR,&temp);
|
||||
temp &= 0xfff80000;
|
||||
|
||||
intel_i830_private.registers = (volatile u8 *) ioremap(temp,128 * 4096);
|
||||
if (!intel_i830_private.registers) return (-ENOMEM);
|
||||
|
||||
temp = INREG32(intel_i830_private.registers,I810_PGETBL_CTL) & 0xfffff000;
|
||||
CACHE_FLUSH();
|
||||
|
||||
/* we have to call this as early as possible after the MMIO base address is known */
|
||||
intel_i830_init_gtt_entries();
|
||||
|
||||
agp_bridge.gatt_table = NULL;
|
||||
|
||||
agp_bridge.gatt_bus_addr = temp;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Return the gatt table to a sane state. Use the top of stolen
|
||||
* memory for the GTT.
|
||||
*/
|
||||
static int intel_i830_free_gatt_table(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int intel_i830_fetch_size(void)
|
||||
{
|
||||
u16 gmch_ctrl;
|
||||
struct aper_size_info_fixed *values;
|
||||
|
||||
pci_read_config_word(agp_bridge.dev,I830_GMCH_CTRL,&gmch_ctrl);
|
||||
values = A_SIZE_FIX(agp_bridge.aperture_sizes);
|
||||
|
||||
if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) {
|
||||
agp_bridge.previous_size = agp_bridge.current_size = (void *) values;
|
||||
agp_bridge.aperture_size_idx = 0;
|
||||
return(values[0].size);
|
||||
} else {
|
||||
agp_bridge.previous_size = agp_bridge.current_size = (void *) values;
|
||||
agp_bridge.aperture_size_idx = 1;
|
||||
return(values[1].size);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int intel_i830_configure(void)
|
||||
{
|
||||
struct aper_size_info_fixed *current_size;
|
||||
u32 temp;
|
||||
u16 gmch_ctrl;
|
||||
int i;
|
||||
|
||||
current_size = A_SIZE_FIX(agp_bridge.current_size);
|
||||
|
||||
pci_read_config_dword(intel_i830_private.i830_dev,I810_GMADDR,&temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
pci_read_config_word(agp_bridge.dev,I830_GMCH_CTRL,&gmch_ctrl);
|
||||
gmch_ctrl |= I830_GMCH_ENABLED;
|
||||
pci_write_config_word(agp_bridge.dev,I830_GMCH_CTRL,gmch_ctrl);
|
||||
|
||||
OUTREG32(intel_i830_private.registers,I810_PGETBL_CTL,agp_bridge.gatt_bus_addr | I810_PGETBL_ENABLED);
|
||||
CACHE_FLUSH();
|
||||
|
||||
if (agp_bridge.needs_scratch_page == TRUE)
|
||||
for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++)
|
||||
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (i * 4),agp_bridge.scratch_page);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void intel_i830_cleanup(void)
|
||||
{
|
||||
iounmap((void *) intel_i830_private.registers);
|
||||
}
|
||||
|
||||
static int intel_i830_insert_entries(agp_memory *mem,off_t pg_start,int type)
|
||||
{
|
||||
int i,j,num_entries;
|
||||
void *temp;
|
||||
|
||||
temp = agp_bridge.current_size;
|
||||
num_entries = A_SIZE_FIX(temp)->num_entries;
|
||||
|
||||
if (pg_start < intel_i830_private.gtt_entries) {
|
||||
printk (KERN_DEBUG "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n",
|
||||
pg_start,intel_i830_private.gtt_entries);
|
||||
|
||||
printk ("Trying to insert into local/stolen memory\n");
|
||||
return (-EINVAL);
|
||||
}
|
||||
|
||||
if ((pg_start + mem->page_count) > num_entries)
|
||||
return (-EINVAL);
|
||||
|
||||
/* The i830 can't check the GTT for entries since its read only,
|
||||
* depend on the caller to make the correct offset decisions.
|
||||
*/
|
||||
|
||||
if ((type != 0 && type != AGP_PHYS_MEMORY) ||
|
||||
(mem->type != 0 && mem->type != AGP_PHYS_MEMORY))
|
||||
return (-EINVAL);
|
||||
|
||||
CACHE_FLUSH();
|
||||
|
||||
for (i = 0, j = pg_start; i < mem->page_count; i++, j++)
|
||||
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (j * 4),mem->memory[i]);
|
||||
|
||||
CACHE_FLUSH();
|
||||
|
||||
agp_bridge.tlb_flush(mem);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int intel_i830_remove_entries(agp_memory *mem,off_t pg_start,int type)
|
||||
{
|
||||
int i;
|
||||
|
||||
CACHE_FLUSH ();
|
||||
|
||||
if (pg_start < intel_i830_private.gtt_entries) {
|
||||
printk ("Trying to disable local/stolen memory\n");
|
||||
return (-EINVAL);
|
||||
}
|
||||
|
||||
for (i = pg_start; i < (mem->page_count + pg_start); i++)
|
||||
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (i * 4),agp_bridge.scratch_page);
|
||||
|
||||
CACHE_FLUSH();
|
||||
|
||||
agp_bridge.tlb_flush(mem);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static agp_memory *intel_i830_alloc_by_type(size_t pg_count,int type)
|
||||
{
|
||||
agp_memory *nw;
|
||||
|
||||
/* always return NULL for now */
|
||||
if (type == AGP_DCACHE_MEMORY) return(NULL);
|
||||
|
||||
if (type == AGP_PHYS_MEMORY) {
|
||||
void *addr;
|
||||
|
||||
/* The i830 requires a physical address to program
|
||||
* it's mouse pointer into hardware. However the
|
||||
* Xserver still writes to it through the agp
|
||||
* aperture
|
||||
*/
|
||||
|
||||
if (pg_count != 1) return(NULL);
|
||||
|
||||
nw = agp_create_memory(1);
|
||||
|
||||
if (nw == NULL) return(NULL);
|
||||
|
||||
MOD_INC_USE_COUNT;
|
||||
addr = agp_bridge.agp_alloc_page();
|
||||
if (addr == NULL) {
|
||||
/* free this structure */
|
||||
agp_free_memory(nw);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
nw->memory[0] = agp_bridge.mask_memory(virt_to_phys(addr),type);
|
||||
nw->page_count = 1;
|
||||
nw->num_scratch_pages = 1;
|
||||
nw->type = AGP_PHYS_MEMORY;
|
||||
nw->physical = virt_to_phys(addr);
|
||||
return(nw);
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int __init intel_i830_setup(struct pci_dev *i830_dev)
|
||||
{
|
||||
intel_i830_private.i830_dev = i830_dev;
|
||||
|
||||
agp_bridge.masks = intel_i810_masks;
|
||||
agp_bridge.num_of_masks = 3;
|
||||
agp_bridge.aperture_sizes = (void *) intel_i830_sizes;
|
||||
agp_bridge.size_type = FIXED_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 2;
|
||||
|
||||
agp_bridge.dev_private_data = (void *) &intel_i830_private;
|
||||
agp_bridge.needs_scratch_page = TRUE;
|
||||
|
||||
agp_bridge.configure = intel_i830_configure;
|
||||
agp_bridge.fetch_size = intel_i830_fetch_size;
|
||||
agp_bridge.cleanup = intel_i830_cleanup;
|
||||
agp_bridge.tlb_flush = intel_i810_tlbflush;
|
||||
agp_bridge.mask_memory = intel_i810_mask_memory;
|
||||
agp_bridge.agp_enable = intel_i810_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
|
||||
agp_bridge.create_gatt_table = intel_i830_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = intel_i830_free_gatt_table;
|
||||
|
||||
agp_bridge.insert_memory = intel_i830_insert_entries;
|
||||
agp_bridge.remove_memory = intel_i830_remove_entries;
|
||||
agp_bridge.alloc_by_type = intel_i830_alloc_by_type;
|
||||
agp_bridge.free_by_type = intel_i810_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = agp_generic_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
731
src/kernel/agpgart/i8x0_agp.c
Normal file
731
src/kernel/agpgart/i8x0_agp.c
Normal file
@@ -0,0 +1,731 @@
|
||||
/*
|
||||
* AGPGART module version 0.99
|
||||
* Copyright (C) 1999 Jeff Hartmann
|
||||
* Copyright (C) 1999 Precision Insight, Inc.
|
||||
* Copyright (C) 1999 Xi Graphics, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* JEFF HARTMANN, 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.
|
||||
*
|
||||
* TODO:
|
||||
* - Allocate more than order 0 pages to avoid too much linear map splitting.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/agp_backend.h>
|
||||
#include "agp.h"
|
||||
|
||||
|
||||
static int intel_fetch_size(void)
|
||||
{
|
||||
int i;
|
||||
u16 temp;
|
||||
struct aper_size_info_16 *values;
|
||||
|
||||
pci_read_config_word(agp_bridge.dev, INTEL_APSIZE, &temp);
|
||||
values = A_SIZE_16(agp_bridge.aperture_sizes);
|
||||
|
||||
for (i = 0; i < agp_bridge.num_aperture_sizes; i++) {
|
||||
if (temp == values[i].size_value) {
|
||||
agp_bridge.previous_size =
|
||||
agp_bridge.current_size = (void *) (values + i);
|
||||
agp_bridge.aperture_size_idx = i;
|
||||
return values[i].size;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_8xx_fetch_size(void)
|
||||
{
|
||||
int i;
|
||||
u8 temp;
|
||||
struct aper_size_info_8 *values;
|
||||
|
||||
pci_read_config_byte(agp_bridge.dev, INTEL_APSIZE, &temp);
|
||||
|
||||
/* Intel 815 chipsets have a _weird_ APSIZE register with only
|
||||
* one non-reserved bit, so mask the others out ... */
|
||||
if (agp_bridge.type == INTEL_I815)
|
||||
temp &= (1 << 3);
|
||||
|
||||
values = A_SIZE_8(agp_bridge.aperture_sizes);
|
||||
|
||||
for (i = 0; i < agp_bridge.num_aperture_sizes; i++) {
|
||||
if (temp == values[i].size_value) {
|
||||
agp_bridge.previous_size =
|
||||
agp_bridge.current_size = (void *) (values + i);
|
||||
agp_bridge.aperture_size_idx = i;
|
||||
return values[i].size;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void intel_tlbflush(agp_memory * mem)
|
||||
{
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x2200);
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x2280);
|
||||
}
|
||||
|
||||
|
||||
static void intel_8xx_tlbflush(agp_memory * mem)
|
||||
{
|
||||
u32 temp;
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_AGPCTRL, &temp);
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, temp & ~(1 << 7));
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_AGPCTRL, &temp);
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, temp | (1 << 7));
|
||||
}
|
||||
|
||||
|
||||
static void intel_cleanup(void)
|
||||
{
|
||||
u16 temp;
|
||||
struct aper_size_info_16 *previous_size;
|
||||
|
||||
previous_size = A_SIZE_16(agp_bridge.previous_size);
|
||||
pci_read_config_word(agp_bridge.dev, INTEL_NBXCFG, &temp);
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_NBXCFG, temp & ~(1 << 9));
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_APSIZE,
|
||||
previous_size->size_value);
|
||||
}
|
||||
|
||||
|
||||
static void intel_8xx_cleanup(void)
|
||||
{
|
||||
u16 temp;
|
||||
struct aper_size_info_8 *previous_size;
|
||||
|
||||
previous_size = A_SIZE_8(agp_bridge.previous_size);
|
||||
pci_read_config_word(agp_bridge.dev, INTEL_NBXCFG, &temp);
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_NBXCFG, temp & ~(1 << 9));
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
previous_size->size_value);
|
||||
}
|
||||
|
||||
|
||||
static int intel_configure(void)
|
||||
{
|
||||
u32 temp;
|
||||
u16 temp2;
|
||||
struct aper_size_info_16 *current_size;
|
||||
|
||||
current_size = A_SIZE_16(agp_bridge.current_size);
|
||||
|
||||
/* aperture size */
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_APSIZE,
|
||||
current_size->size_value);
|
||||
|
||||
/* address to map to */
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_APBASE, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
/* attbase - aperture base */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_ATTBASE,
|
||||
agp_bridge.gatt_bus_addr);
|
||||
|
||||
/* agpctrl */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x2280);
|
||||
|
||||
/* paccfg/nbxcfg */
|
||||
pci_read_config_word(agp_bridge.dev, INTEL_NBXCFG, &temp2);
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_NBXCFG,
|
||||
(temp2 & ~(1 << 10)) | (1 << 9));
|
||||
/* clear any possible error conditions */
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_ERRSTS + 1, 7);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_815_configure(void)
|
||||
{
|
||||
u32 temp, addr;
|
||||
u8 temp2;
|
||||
struct aper_size_info_8 *current_size;
|
||||
|
||||
current_size = A_SIZE_8(agp_bridge.current_size);
|
||||
|
||||
/* aperture size */
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
current_size->size_value);
|
||||
|
||||
/* address to map to */
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_APBASE, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
/* attbase - aperture base */
|
||||
/* the Intel 815 chipset spec. says that bits 29-31 in the
|
||||
* ATTBASE register are reserved -> try not to write them */
|
||||
if (agp_bridge.gatt_bus_addr & INTEL_815_ATTBASE_MASK)
|
||||
panic("gatt bus addr too high");
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_ATTBASE, &addr);
|
||||
addr &= INTEL_815_ATTBASE_MASK;
|
||||
addr |= agp_bridge.gatt_bus_addr;
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_ATTBASE, addr);
|
||||
|
||||
/* agpctrl */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x0000);
|
||||
|
||||
/* apcont */
|
||||
pci_read_config_byte(agp_bridge.dev, INTEL_815_APCONT, &temp2);
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_815_APCONT, temp2 | (1 << 1));
|
||||
|
||||
/* clear any possible error conditions */
|
||||
/* Oddness : this chipset seems to have no ERRSTS register ! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void intel_820_tlbflush(agp_memory * mem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void intel_820_cleanup(void)
|
||||
{
|
||||
u8 temp;
|
||||
struct aper_size_info_8 *previous_size;
|
||||
|
||||
previous_size = A_SIZE_8(agp_bridge.previous_size);
|
||||
pci_read_config_byte(agp_bridge.dev, INTEL_I820_RDCR, &temp);
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_I820_RDCR,
|
||||
temp & ~(1 << 1));
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
previous_size->size_value);
|
||||
}
|
||||
|
||||
|
||||
static int intel_820_configure(void)
|
||||
{
|
||||
u32 temp;
|
||||
u8 temp2;
|
||||
struct aper_size_info_8 *current_size;
|
||||
|
||||
current_size = A_SIZE_8(agp_bridge.current_size);
|
||||
|
||||
/* aperture size */
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
current_size->size_value);
|
||||
|
||||
/* address to map to */
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_APBASE, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
/* attbase - aperture base */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_ATTBASE,
|
||||
agp_bridge.gatt_bus_addr);
|
||||
|
||||
/* agpctrl */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x0000);
|
||||
|
||||
/* global enable aperture access */
|
||||
/* This flag is not accessed through MCHCFG register as in */
|
||||
/* i850 chipset. */
|
||||
pci_read_config_byte(agp_bridge.dev, INTEL_I820_RDCR, &temp2);
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_I820_RDCR,
|
||||
temp2 | (1 << 1));
|
||||
/* clear any possible AGP-related error conditions */
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I820_ERRSTS, 0x001c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_840_configure(void)
|
||||
{
|
||||
u32 temp;
|
||||
u16 temp2;
|
||||
struct aper_size_info_8 *current_size;
|
||||
|
||||
current_size = A_SIZE_8(agp_bridge.current_size);
|
||||
|
||||
/* aperture size */
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
current_size->size_value);
|
||||
|
||||
/* address to map to */
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_APBASE, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
/* attbase - aperture base */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_ATTBASE,
|
||||
agp_bridge.gatt_bus_addr);
|
||||
|
||||
/* agpctrl */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x0000);
|
||||
|
||||
/* mcgcfg */
|
||||
pci_read_config_word(agp_bridge.dev, INTEL_I840_MCHCFG, &temp2);
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I840_MCHCFG,
|
||||
temp2 | (1 << 9));
|
||||
/* clear any possible error conditions */
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I840_ERRSTS, 0xc000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_845_configure(void)
|
||||
{
|
||||
u32 temp;
|
||||
u8 temp2;
|
||||
struct aper_size_info_8 *current_size;
|
||||
|
||||
current_size = A_SIZE_8(agp_bridge.current_size);
|
||||
|
||||
/* aperture size */
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
current_size->size_value);
|
||||
|
||||
/* address to map to */
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_APBASE, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
/* attbase - aperture base */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_ATTBASE,
|
||||
agp_bridge.gatt_bus_addr);
|
||||
|
||||
/* agpctrl */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x0000);
|
||||
|
||||
/* agpm */
|
||||
pci_read_config_byte(agp_bridge.dev, INTEL_I845_AGPM, &temp2);
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_I845_AGPM,
|
||||
temp2 | (1 << 1));
|
||||
/* clear any possible error conditions */
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I845_ERRSTS, 0x001c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void intel_845_resume(void)
|
||||
{
|
||||
intel_845_configure();
|
||||
}
|
||||
|
||||
static int intel_850_configure(void)
|
||||
{
|
||||
u32 temp;
|
||||
u16 temp2;
|
||||
struct aper_size_info_8 *current_size;
|
||||
|
||||
current_size = A_SIZE_8(agp_bridge.current_size);
|
||||
|
||||
/* aperture size */
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
current_size->size_value);
|
||||
|
||||
/* address to map to */
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_APBASE, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
/* attbase - aperture base */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_ATTBASE,
|
||||
agp_bridge.gatt_bus_addr);
|
||||
|
||||
/* agpctrl */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x0000);
|
||||
|
||||
/* mcgcfg */
|
||||
pci_read_config_word(agp_bridge.dev, INTEL_I850_MCHCFG, &temp2);
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I850_MCHCFG,
|
||||
temp2 | (1 << 9));
|
||||
/* clear any possible AGP-related error conditions */
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I850_ERRSTS, 0x001c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_860_configure(void)
|
||||
{
|
||||
u32 temp;
|
||||
u16 temp2;
|
||||
struct aper_size_info_8 *current_size;
|
||||
|
||||
current_size = A_SIZE_8(agp_bridge.current_size);
|
||||
|
||||
/* aperture size */
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
current_size->size_value);
|
||||
|
||||
/* address to map to */
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_APBASE, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
/* attbase - aperture base */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_ATTBASE,
|
||||
agp_bridge.gatt_bus_addr);
|
||||
|
||||
/* agpctrl */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x0000);
|
||||
|
||||
/* mcgcfg */
|
||||
pci_read_config_word(agp_bridge.dev, INTEL_I860_MCHCFG, &temp2);
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I860_MCHCFG,
|
||||
temp2 | (1 << 9));
|
||||
/* clear any possible AGP-related error conditions */
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I860_ERRSTS, 0xf700);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intel_830mp_configure(void)
|
||||
{
|
||||
u32 temp;
|
||||
u16 temp2;
|
||||
struct aper_size_info_8 *current_size;
|
||||
|
||||
current_size = A_SIZE_8(agp_bridge.current_size);
|
||||
|
||||
/* aperture size */
|
||||
pci_write_config_byte(agp_bridge.dev, INTEL_APSIZE,
|
||||
current_size->size_value);
|
||||
|
||||
/* address to map to */
|
||||
pci_read_config_dword(agp_bridge.dev, INTEL_APBASE, &temp);
|
||||
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
/* attbase - aperture base */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_ATTBASE,
|
||||
agp_bridge.gatt_bus_addr);
|
||||
|
||||
/* agpctrl */
|
||||
pci_write_config_dword(agp_bridge.dev, INTEL_AGPCTRL, 0x0000);
|
||||
|
||||
/* gmch */
|
||||
pci_read_config_word(agp_bridge.dev, INTEL_NBXCFG, &temp2);
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_NBXCFG,
|
||||
temp2 | (1 << 9));
|
||||
/* clear any possible AGP-related error conditions */
|
||||
pci_write_config_word(agp_bridge.dev, INTEL_I830_ERRSTS, 0x1c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned long intel_mask_memory(unsigned long addr, int type)
|
||||
{
|
||||
/* Memory type is ignored */
|
||||
|
||||
return addr | agp_bridge.masks[0].mask;
|
||||
}
|
||||
|
||||
static void intel_resume(void)
|
||||
{
|
||||
intel_configure();
|
||||
}
|
||||
|
||||
/* Setup function */
|
||||
static struct gatt_mask intel_generic_masks[] =
|
||||
{
|
||||
{mask: 0x00000017, type: 0}
|
||||
};
|
||||
|
||||
static struct aper_size_info_8 intel_815_sizes[2] =
|
||||
{
|
||||
{64, 16384, 4, 0},
|
||||
{32, 8192, 3, 8},
|
||||
};
|
||||
|
||||
static struct aper_size_info_8 intel_8xx_sizes[7] =
|
||||
{
|
||||
{256, 65536, 6, 0},
|
||||
{128, 32768, 5, 32},
|
||||
{64, 16384, 4, 48},
|
||||
{32, 8192, 3, 56},
|
||||
{16, 4096, 2, 60},
|
||||
{8, 2048, 1, 62},
|
||||
{4, 1024, 0, 63}
|
||||
};
|
||||
|
||||
static struct aper_size_info_16 intel_generic_sizes[7] =
|
||||
{
|
||||
{256, 65536, 6, 0},
|
||||
{128, 32768, 5, 32},
|
||||
{64, 16384, 4, 48},
|
||||
{32, 8192, 3, 56},
|
||||
{16, 4096, 2, 60},
|
||||
{8, 2048, 1, 62},
|
||||
{4, 1024, 0, 63}
|
||||
};
|
||||
|
||||
static struct aper_size_info_8 intel_830mp_sizes[4] =
|
||||
{
|
||||
{256, 65536, 6, 0},
|
||||
{128, 32768, 5, 32},
|
||||
{64, 16384, 4, 48},
|
||||
{32, 8192, 3, 56}
|
||||
};
|
||||
|
||||
int __init intel_generic_setup (struct pci_dev *pdev)
|
||||
{
|
||||
agp_bridge.masks = intel_generic_masks;
|
||||
agp_bridge.num_of_masks = 1;
|
||||
agp_bridge.aperture_sizes = (void *) intel_generic_sizes;
|
||||
agp_bridge.size_type = U16_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 7;
|
||||
agp_bridge.dev_private_data = NULL;
|
||||
agp_bridge.needs_scratch_page = FALSE;
|
||||
agp_bridge.configure = intel_configure;
|
||||
agp_bridge.fetch_size = intel_fetch_size;
|
||||
agp_bridge.cleanup = intel_cleanup;
|
||||
agp_bridge.tlb_flush = intel_tlbflush;
|
||||
agp_bridge.mask_memory = intel_mask_memory;
|
||||
agp_bridge.agp_enable = agp_generic_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = agp_generic_insert_memory;
|
||||
agp_bridge.remove_memory = agp_generic_remove_memory;
|
||||
agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
|
||||
agp_bridge.free_by_type = agp_generic_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = intel_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
(void) pdev; /* unused */
|
||||
}
|
||||
|
||||
int __init intel_815_setup (struct pci_dev *pdev)
|
||||
{
|
||||
agp_bridge.masks = intel_generic_masks;
|
||||
agp_bridge.num_of_masks = 1;
|
||||
agp_bridge.aperture_sizes = (void *) intel_815_sizes;
|
||||
agp_bridge.size_type = U8_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 2;
|
||||
agp_bridge.dev_private_data = NULL;
|
||||
agp_bridge.needs_scratch_page = FALSE;
|
||||
agp_bridge.configure = intel_815_configure;
|
||||
agp_bridge.fetch_size = intel_8xx_fetch_size;
|
||||
agp_bridge.cleanup = intel_8xx_cleanup;
|
||||
agp_bridge.tlb_flush = intel_8xx_tlbflush;
|
||||
agp_bridge.mask_memory = intel_mask_memory;
|
||||
agp_bridge.agp_enable = agp_generic_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = agp_generic_insert_memory;
|
||||
agp_bridge.remove_memory = agp_generic_remove_memory;
|
||||
agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
|
||||
agp_bridge.free_by_type = agp_generic_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = agp_generic_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int __init intel_820_setup (struct pci_dev *pdev)
|
||||
{
|
||||
agp_bridge.masks = intel_generic_masks;
|
||||
agp_bridge.num_of_masks = 1;
|
||||
agp_bridge.aperture_sizes = (void *) intel_8xx_sizes;
|
||||
agp_bridge.size_type = U8_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 7;
|
||||
agp_bridge.dev_private_data = NULL;
|
||||
agp_bridge.needs_scratch_page = FALSE;
|
||||
agp_bridge.configure = intel_820_configure;
|
||||
agp_bridge.fetch_size = intel_8xx_fetch_size;
|
||||
agp_bridge.cleanup = intel_820_cleanup;
|
||||
agp_bridge.tlb_flush = intel_820_tlbflush;
|
||||
agp_bridge.mask_memory = intel_mask_memory;
|
||||
agp_bridge.agp_enable = agp_generic_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = agp_generic_insert_memory;
|
||||
agp_bridge.remove_memory = agp_generic_remove_memory;
|
||||
agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
|
||||
agp_bridge.free_by_type = agp_generic_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = agp_generic_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
(void) pdev; /* unused */
|
||||
}
|
||||
|
||||
int __init intel_830mp_setup (struct pci_dev *pdev)
|
||||
{
|
||||
agp_bridge.masks = intel_generic_masks;
|
||||
agp_bridge.num_of_masks = 1;
|
||||
agp_bridge.aperture_sizes = (void *) intel_830mp_sizes;
|
||||
agp_bridge.size_type = U8_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 4;
|
||||
agp_bridge.dev_private_data = NULL;
|
||||
agp_bridge.needs_scratch_page = FALSE;
|
||||
agp_bridge.configure = intel_830mp_configure;
|
||||
agp_bridge.fetch_size = intel_8xx_fetch_size;
|
||||
agp_bridge.cleanup = intel_8xx_cleanup;
|
||||
agp_bridge.tlb_flush = intel_8xx_tlbflush;
|
||||
agp_bridge.mask_memory = intel_mask_memory;
|
||||
agp_bridge.agp_enable = agp_generic_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = agp_generic_insert_memory;
|
||||
agp_bridge.remove_memory = agp_generic_remove_memory;
|
||||
agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
|
||||
agp_bridge.free_by_type = agp_generic_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = agp_generic_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
(void) pdev; /* unused */
|
||||
}
|
||||
|
||||
int __init intel_840_setup (struct pci_dev *pdev)
|
||||
{
|
||||
agp_bridge.masks = intel_generic_masks;
|
||||
agp_bridge.num_of_masks = 1;
|
||||
agp_bridge.aperture_sizes = (void *) intel_8xx_sizes;
|
||||
agp_bridge.size_type = U8_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 7;
|
||||
agp_bridge.dev_private_data = NULL;
|
||||
agp_bridge.needs_scratch_page = FALSE;
|
||||
agp_bridge.configure = intel_840_configure;
|
||||
agp_bridge.fetch_size = intel_8xx_fetch_size;
|
||||
agp_bridge.cleanup = intel_8xx_cleanup;
|
||||
agp_bridge.tlb_flush = intel_8xx_tlbflush;
|
||||
agp_bridge.mask_memory = intel_mask_memory;
|
||||
agp_bridge.agp_enable = agp_generic_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = agp_generic_insert_memory;
|
||||
agp_bridge.remove_memory = agp_generic_remove_memory;
|
||||
agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
|
||||
agp_bridge.free_by_type = agp_generic_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = agp_generic_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
(void) pdev; /* unused */
|
||||
}
|
||||
|
||||
int __init intel_845_setup (struct pci_dev *pdev)
|
||||
{
|
||||
agp_bridge.masks = intel_generic_masks;
|
||||
agp_bridge.num_of_masks = 1;
|
||||
agp_bridge.aperture_sizes = (void *) intel_8xx_sizes;
|
||||
agp_bridge.size_type = U8_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 7;
|
||||
agp_bridge.dev_private_data = NULL;
|
||||
agp_bridge.needs_scratch_page = FALSE;
|
||||
agp_bridge.configure = intel_845_configure;
|
||||
agp_bridge.fetch_size = intel_8xx_fetch_size;
|
||||
agp_bridge.cleanup = intel_8xx_cleanup;
|
||||
agp_bridge.tlb_flush = intel_8xx_tlbflush;
|
||||
agp_bridge.mask_memory = intel_mask_memory;
|
||||
agp_bridge.agp_enable = agp_generic_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = agp_generic_insert_memory;
|
||||
agp_bridge.remove_memory = agp_generic_remove_memory;
|
||||
agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
|
||||
agp_bridge.free_by_type = agp_generic_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = intel_845_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
(void) pdev; /* unused */
|
||||
}
|
||||
|
||||
int __init intel_850_setup (struct pci_dev *pdev)
|
||||
{
|
||||
agp_bridge.masks = intel_generic_masks;
|
||||
agp_bridge.num_of_masks = 1;
|
||||
agp_bridge.aperture_sizes = (void *) intel_8xx_sizes;
|
||||
agp_bridge.size_type = U8_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 7;
|
||||
agp_bridge.dev_private_data = NULL;
|
||||
agp_bridge.needs_scratch_page = FALSE;
|
||||
agp_bridge.configure = intel_850_configure;
|
||||
agp_bridge.fetch_size = intel_8xx_fetch_size;
|
||||
agp_bridge.cleanup = intel_8xx_cleanup;
|
||||
agp_bridge.tlb_flush = intel_8xx_tlbflush;
|
||||
agp_bridge.mask_memory = intel_mask_memory;
|
||||
agp_bridge.agp_enable = agp_generic_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = agp_generic_insert_memory;
|
||||
agp_bridge.remove_memory = agp_generic_remove_memory;
|
||||
agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
|
||||
agp_bridge.free_by_type = agp_generic_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = agp_generic_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
(void) pdev; /* unused */
|
||||
}
|
||||
|
||||
int __init intel_860_setup (struct pci_dev *pdev)
|
||||
{
|
||||
agp_bridge.masks = intel_generic_masks;
|
||||
agp_bridge.num_of_masks = 1;
|
||||
agp_bridge.aperture_sizes = (void *) intel_8xx_sizes;
|
||||
agp_bridge.size_type = U8_APER_SIZE;
|
||||
agp_bridge.num_aperture_sizes = 7;
|
||||
agp_bridge.dev_private_data = NULL;
|
||||
agp_bridge.needs_scratch_page = FALSE;
|
||||
agp_bridge.configure = intel_860_configure;
|
||||
agp_bridge.fetch_size = intel_8xx_fetch_size;
|
||||
agp_bridge.cleanup = intel_8xx_cleanup;
|
||||
agp_bridge.tlb_flush = intel_8xx_tlbflush;
|
||||
agp_bridge.mask_memory = intel_mask_memory;
|
||||
agp_bridge.agp_enable = agp_generic_agp_enable;
|
||||
agp_bridge.cache_flush = global_cache_flush;
|
||||
agp_bridge.create_gatt_table = agp_generic_create_gatt_table;
|
||||
agp_bridge.free_gatt_table = agp_generic_free_gatt_table;
|
||||
agp_bridge.insert_memory = agp_generic_insert_memory;
|
||||
agp_bridge.remove_memory = agp_generic_remove_memory;
|
||||
agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
|
||||
agp_bridge.free_by_type = agp_generic_free_by_type;
|
||||
agp_bridge.agp_alloc_page = agp_generic_alloc_page;
|
||||
agp_bridge.agp_destroy_page = agp_generic_destroy_page;
|
||||
agp_bridge.suspend = agp_generic_suspend;
|
||||
agp_bridge.resume = agp_generic_resume;
|
||||
agp_bridge.cant_use_aperture = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
(void) pdev; /* unused */
|
||||
}
|
||||
|
||||
1
src/kernel/fbdev/radeonfb-2.5/NOTES
Normal file
1
src/kernel/fbdev/radeonfb-2.5/NOTES
Normal file
@@ -0,0 +1 @@
|
||||
This directory not really of interest to anybody... Feel free to ignore.
|
||||
3168
src/kernel/fbdev/radeonfb-2.5/radeonfb.c
Normal file
3168
src/kernel/fbdev/radeonfb-2.5/radeonfb.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -136,6 +136,7 @@
|
||||
#define PCI_DEVICE_ID_COMPAQ_TACHYON 0xa0fc
|
||||
#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10
|
||||
#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32
|
||||
#define PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE 0xae33
|
||||
#define PCI_DEVICE_ID_COMPAQ_NETEL10 0xae34
|
||||
#define PCI_DEVICE_ID_COMPAQ_NETFLEX3I 0xae35
|
||||
#define PCI_DEVICE_ID_COMPAQ_NETEL100D 0xae40
|
||||
@@ -143,6 +144,7 @@
|
||||
#define PCI_DEVICE_ID_COMPAQ_NETEL100I 0xb011
|
||||
#define PCI_DEVICE_ID_COMPAQ_CISS 0xb060
|
||||
#define PCI_DEVICE_ID_COMPAQ_CISSB 0xb178
|
||||
#define PCI_DEVICE_ID_COMPAQ_CISSC 0x0046
|
||||
#define PCI_DEVICE_ID_COMPAQ_THUNDER 0xf130
|
||||
#define PCI_DEVICE_ID_COMPAQ_NETFLEX3B 0xf150
|
||||
|
||||
@@ -172,6 +174,8 @@
|
||||
#define PCI_DEVICE_ID_LSI_FC929_LAN 0x0623
|
||||
#define PCI_DEVICE_ID_LSI_FC919 0x0624
|
||||
#define PCI_DEVICE_ID_LSI_FC919_LAN 0x0625
|
||||
#define PCI_DEVICE_ID_LSI_FC929X 0x0626
|
||||
#define PCI_DEVICE_ID_LSI_FC919X 0x0628
|
||||
#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701
|
||||
#define PCI_DEVICE_ID_LSI_61C102 0x0901
|
||||
#define PCI_DEVICE_ID_LSI_63C815 0x1000
|
||||
@@ -254,12 +258,9 @@
|
||||
#define PCI_DEVICE_ID_ATI_RAGE128_U1 0x5446
|
||||
#define PCI_DEVICE_ID_ATI_RAGE128_U2 0x544C
|
||||
#define PCI_DEVICE_ID_ATI_RAGE128_U3 0x5452
|
||||
/* Radeon M4 */
|
||||
/* Rage M4 */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_LE 0x4d45
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_LF 0x4d46
|
||||
/* Radeon NV-100 */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_N1 0x5159
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_N2 0x515a
|
||||
/* Radeon R100 */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_QD 0x5144
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_QE 0x5145
|
||||
@@ -274,6 +275,8 @@
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_QO 0x514f
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Ql 0x516c
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_BB 0x4242
|
||||
/* Radeon R200 (9100) */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_QM 0x514d
|
||||
/* Radeon RV200 (7500) */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_QW 0x5157
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_QX 0x5158
|
||||
@@ -282,11 +285,22 @@
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Ie 0x4965
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_If 0x4966
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967
|
||||
/* Radeon RV280 (9200) */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Y_ 0x5960
|
||||
/* Radeon R300 (9700) */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_ND 0x4e44
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_NE 0x4e45
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_AE 0x4145
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_AF 0x4146
|
||||
/* Radeon R300 (9500) */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_AD 0x4144
|
||||
/* Radeon R350 (9800) */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_NH 0x4e48
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_NI 0x4e49
|
||||
/* Radeon RV350 (9600) */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_AP 0x4150
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_AR 0x4152
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_NF 0x4e46
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_NG 0x4e47
|
||||
/* Radeon M6 */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_LY 0x4c59
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_LZ 0x4c5a
|
||||
@@ -294,11 +308,14 @@
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_LW 0x4c57
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_LX 0x4c58
|
||||
/* Radeon M9 */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Ld 0x4964
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Le 0x4965
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4966
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4967
|
||||
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Ld 0x4c64
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Le 0x4c65
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4c66
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4c67
|
||||
/* Radeon P/M */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_LR 0x4c52
|
||||
/* RadeonIGP */
|
||||
#define PCI_DEVICE_ID_ATI_RADEON_IGP 0xCAB0
|
||||
|
||||
#define PCI_VENDOR_ID_VLSI 0x1004
|
||||
#define PCI_DEVICE_ID_VLSI_82C592 0x0005
|
||||
@@ -322,6 +339,12 @@
|
||||
#define PCI_DEVICE_ID_NS_87560_USB 0x0012
|
||||
#define PCI_DEVICE_ID_NS_83815 0x0020
|
||||
#define PCI_DEVICE_ID_NS_83820 0x0022
|
||||
#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500
|
||||
#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501
|
||||
#define PCI_DEVICE_ID_NS_SCx200_IDE 0x0502
|
||||
#define PCI_DEVICE_ID_NS_SCx200_AUDIO 0x0503
|
||||
#define PCI_DEVICE_ID_NS_SCx200_VIDEO 0x0504
|
||||
#define PCI_DEVICE_ID_NS_SCx200_XBUS 0x0505
|
||||
#define PCI_DEVICE_ID_NS_87410 0xd001
|
||||
|
||||
#define PCI_VENDOR_ID_TSENG 0x100c
|
||||
@@ -381,9 +404,10 @@
|
||||
#define PCI_DEVICE_ID_IBM_MPIC 0x0046
|
||||
#define PCI_DEVICE_ID_IBM_3780IDSP 0x007d
|
||||
#define PCI_DEVICE_ID_IBM_CHUKAR 0x0096
|
||||
#define PCI_DEVICE_ID_IBM_CPC700 0x00f9
|
||||
#define PCI_DEVICE_ID_IBM_CPC710_PCI64 0x00fc
|
||||
#define PCI_DEVICE_ID_IBM_CPC710_PCI32 0x0105
|
||||
#define PCI_DEVICE_ID_IBM_405GP 0x0156
|
||||
#define PCI_DEVICE_ID_IBM_405GP 0x0156
|
||||
#define PCI_DEVICE_ID_IBM_SERVERAIDI960 0x01bd
|
||||
#define PCI_DEVICE_ID_IBM_MPIC_2 0xffff
|
||||
|
||||
@@ -406,7 +430,7 @@
|
||||
#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006
|
||||
#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007
|
||||
#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C
|
||||
#define PCI_DEVIDE_ID_AMD_FE_GATE_700D 0x700D
|
||||
#define PCI_DEVICE_ID_AMD_FE_GATE_700D 0x700D
|
||||
#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E
|
||||
#define PCI_DEVICE_ID_AMD_FE_GATE_700F 0x700F
|
||||
#define PCI_DEVICE_ID_AMD_COBRA_7400 0x7400
|
||||
@@ -421,13 +445,20 @@
|
||||
#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411
|
||||
#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413
|
||||
#define PCI_DEVICE_ID_AMD_VIPER_7414 0x7414
|
||||
#define PCI_DEVICE_ID_AMD_VIPER_7440 0x7440
|
||||
#define PCI_DEVICE_ID_AMD_VIPER_7441 0x7441
|
||||
#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443
|
||||
#define PCI_DEVICE_ID_AMD_VIPER_7448 0x7448
|
||||
#define PCI_DEVICE_ID_AMD_VIPER_7449 0x7449
|
||||
#define PCI_DEVICE_ID_AMD_OPUS_7440 0x7440
|
||||
# define PCI_DEVICE_ID_AMD_VIPER_7440 PCI_DEVICE_ID_AMD_OPUS_7440
|
||||
#define PCI_DEVICE_ID_AMD_OPUS_7441 0x7441
|
||||
# define PCI_DEVICE_ID_AMD_VIPER_7441 PCI_DEVICE_ID_AMD_OPUS_7441
|
||||
#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443
|
||||
# define PCI_DEVICE_ID_AMD_VIPER_7443 PCI_DEVICE_ID_AMD_OPUS_7443
|
||||
#define PCI_DEVICE_ID_AMD_OPUS_7448 0x7448
|
||||
# define PCI_DEVICE_ID_AMD_VIPER_7448 PCI_DEVICE_ID_AMD_OPUS_7448
|
||||
#define PCI_DEVICE_ID_AMD_OPUS_7449 0x7449
|
||||
# define PCI_DEVICE_ID_AMD_VIPER_7449 PCI_DEVICE_ID_AMD_OPUS_7449
|
||||
#define PCI_DEVICE_ID_AMD_8111_LAN 0x7462
|
||||
#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469
|
||||
#define PCI_DEVICE_ID_AMD_8111_AC97 0x746d
|
||||
#define PCI_DEVICE_ID_AMD_8131_APIC 0x7450
|
||||
|
||||
#define PCI_VENDOR_ID_TRIDENT 0x1023
|
||||
#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000
|
||||
@@ -511,20 +542,28 @@
|
||||
#define PCI_DEVICE_ID_SI_635 0x0635
|
||||
#define PCI_DEVICE_ID_SI_640 0x0640
|
||||
#define PCI_DEVICE_ID_SI_645 0x0645
|
||||
#define PCI_DEVICE_ID_SI_646 0x0646
|
||||
#define PCI_DEVICE_ID_SI_646 0x0646
|
||||
#define PCI_DEVICE_ID_SI_648 0x0648
|
||||
#define PCI_DEVICE_ID_SI_650 0x0650
|
||||
#define PCI_DEVICE_ID_SI_651 0x0651
|
||||
#define PCI_DEVICE_ID_SI_652 0x0652
|
||||
#define PCI_DEVICE_ID_SI_730 0x0730
|
||||
#define PCI_DEVICE_ID_SI_630_VGA 0x6300
|
||||
#define PCI_DEVICE_ID_SI_730_VGA 0x7300
|
||||
#define PCI_DEVICE_ID_SI_735 0x0735
|
||||
#define PCI_DEVICE_ID_SI_740 0x0740
|
||||
#define PCI_DEVICE_ID_SI_745 0x0745
|
||||
#define PCI_DEVICE_ID_SI_746 0x0746
|
||||
#define PCI_DEVICE_ID_SI_748 0x0748
|
||||
#define PCI_DEVICE_ID_SI_750 0x0750
|
||||
#define PCI_DEVICE_ID_SI_751 0x0751
|
||||
#define PCI_DEVICE_ID_SI_752 0x0752
|
||||
#define PCI_DEVICE_ID_SI_900 0x0900
|
||||
#define PCI_DEVICE_ID_SI_5107 0x5107
|
||||
#define PCI_DEVICE_ID_SI_5300 0x5300
|
||||
#define PCI_DEVICE_ID_SI_5511 0x5511
|
||||
#define PCI_DEVICE_ID_SI_5513 0x5513
|
||||
#define PCI_DEVICE_ID_SI_5518 0x5518
|
||||
#define PCI_DEVICE_ID_SI_5571 0x5571
|
||||
#define PCI_DEVICE_ID_SI_5591 0x5591
|
||||
#define PCI_DEVICE_ID_SI_5597 0x5597
|
||||
@@ -609,6 +648,7 @@
|
||||
#define PCI_DEVICE_ID_TI_4410 0xac41
|
||||
#define PCI_DEVICE_ID_TI_4451 0xac42
|
||||
#define PCI_DEVICE_ID_TI_1420 0xac51
|
||||
#define PCI_DEVICE_ID_TI_1510 0xac56
|
||||
|
||||
#define PCI_VENDOR_ID_SONY 0x104d
|
||||
#define PCI_DEVICE_ID_SONY_CXD3222 0x8039
|
||||
@@ -702,6 +742,10 @@
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_FW2 0x0030
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2 0x0032
|
||||
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034
|
||||
#define PCI_DEVICE_ID_APPLE_KEYLARGO_I 0x003e
|
||||
#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645
|
||||
|
||||
#define PCI_VENDOR_ID_YAMAHA 0x1073
|
||||
#define PCI_DEVICE_ID_YAMAHA_724 0x0004
|
||||
@@ -774,7 +818,9 @@
|
||||
#define PCI_DEVICE_ID_CMD_648 0x0648
|
||||
#define PCI_DEVICE_ID_CMD_649 0x0649
|
||||
#define PCI_DEVICE_ID_CMD_670 0x0670
|
||||
#define PCI_DEVICE_ID_CMD_680 0x0680
|
||||
|
||||
#define PCI_DEVICE_ID_SII_680 0x0680
|
||||
#define PCI_DEVICE_ID_SII_3112 0x3112
|
||||
|
||||
#define PCI_VENDOR_ID_VISION 0x1098
|
||||
#define PCI_DEVICE_ID_VISION_QD8500 0x0001
|
||||
@@ -835,6 +881,14 @@
|
||||
#define PCI_DEVICE_ID_3COM_3C905TX 0x9050
|
||||
#define PCI_DEVICE_ID_3COM_3C905T4 0x9051
|
||||
#define PCI_DEVICE_ID_3COM_3C905B_TX 0x9055
|
||||
#define PCI_DEVICE_ID_3COM_3CR990 0x9900
|
||||
#define PCI_DEVICE_ID_3COM_3CR990_TX_95 0x9902
|
||||
#define PCI_DEVICE_ID_3COM_3CR990_TX_97 0x9903
|
||||
#define PCI_DEVICE_ID_3COM_3CR990B 0x9904
|
||||
#define PCI_DEVICE_ID_3COM_3CR990_FX 0x9905
|
||||
#define PCI_DEVICE_ID_3COM_3CR990SVR95 0x9908
|
||||
#define PCI_DEVICE_ID_3COM_3CR990SVR97 0x9909
|
||||
#define PCI_DEVICE_ID_3COM_3CR990SVR 0x990a
|
||||
|
||||
#define PCI_VENDOR_ID_SMC 0x10b8
|
||||
#define PCI_DEVICE_ID_SMC_EPIC100 0x0005
|
||||
@@ -900,29 +954,46 @@
|
||||
#define PCI_DEVICE_ID_CERN_HIPPI_DST 0x0021
|
||||
#define PCI_DEVICE_ID_CERN_HIPPI_SRC 0x0022
|
||||
|
||||
#define PCI_VENDOR_ID_NVIDIA 0x10de
|
||||
#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020
|
||||
#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028
|
||||
#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029
|
||||
#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C
|
||||
#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D
|
||||
#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO 0x0112
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153
|
||||
#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2 0x01a0
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1 0x0201
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2 0x0202
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC 0x0203
|
||||
#define PCI_VENDOR_ID_NVIDIA 0x10de
|
||||
#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020
|
||||
#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028
|
||||
#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029
|
||||
#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C
|
||||
#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D
|
||||
#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO 0x0112
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460 0x0170
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440 0x0171
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420 0x0172
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO 0x0174
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO 0x0175
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32 0x0176
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL 0x0178
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64 0x0179
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_200 0x017A
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL 0x017B
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL 0x017C
|
||||
#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2 0x01a0
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1 0x0201
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2 0x0202
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC 0x0203
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600 0x0250
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400 0x0251
|
||||
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200 0x0253
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259
|
||||
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B
|
||||
|
||||
#define PCI_VENDOR_ID_IMS 0x10e0
|
||||
#define PCI_DEVICE_ID_IMS_8849 0x8849
|
||||
@@ -1020,6 +1091,10 @@
|
||||
#define PCI_DEVICE_ID_VIA_8233C_0 0x3109
|
||||
#define PCI_DEVICE_ID_VIA_8361 0x3112
|
||||
#define PCI_DEVICE_ID_VIA_8233A 0x3147
|
||||
#define PCI_DEVICE_ID_VIA_P4X333 0x3168
|
||||
#define PCI_DEVICE_ID_VIA_8235 0x3177
|
||||
#define PCI_DEVICE_ID_VIA_8377_0 0x3189
|
||||
#define PCI_DEVICE_ID_VIA_8377_0 0x3189
|
||||
#define PCI_DEVICE_ID_VIA_86C100A 0x6100
|
||||
#define PCI_DEVICE_ID_VIA_8231 0x8231
|
||||
#define PCI_DEVICE_ID_VIA_8231_4 0x8235
|
||||
@@ -1117,6 +1192,7 @@
|
||||
#define PCI_DEVICE_ID_SYSKONNECT_FP 0x4000
|
||||
#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200
|
||||
#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300
|
||||
#define PCI_DEVICE_ID_SYSKONNECT_YU 0x4320
|
||||
|
||||
#define PCI_VENDOR_ID_VMIC 0x114a
|
||||
#define PCI_DEVICE_ID_VMIC_VME 0x7587
|
||||
@@ -1158,6 +1234,7 @@
|
||||
#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211
|
||||
#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212
|
||||
#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213
|
||||
#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 0x0217
|
||||
#define PCI_DEVICE_ID_SERVERWORKS_OSB4USB 0x0220
|
||||
#define PCI_DEVICE_ID_SERVERWORKS_CSB5USB PCI_DEVICE_ID_SERVERWORKS_OSB4USB
|
||||
#define PCI_DEVICE_ID_SERVERWORKS_CSB6USB 0x0221
|
||||
@@ -1578,6 +1655,9 @@
|
||||
#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d
|
||||
#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6
|
||||
#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7
|
||||
#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8
|
||||
#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6
|
||||
#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7
|
||||
|
||||
#define PCI_VENDOR_ID_SYBA 0x1592
|
||||
#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782
|
||||
@@ -1590,7 +1670,7 @@
|
||||
#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0
|
||||
|
||||
#define PCI_VENDOR_ID_PDC 0x15e9
|
||||
#define PCI_DEVICE_ID_PDC_1841 0x1841
|
||||
#define PCI_DEVICE_ID_PDC_ADMA100 0x1841
|
||||
|
||||
#define PCI_VENDOR_ID_ALTIMA 0x173b
|
||||
#define PCI_DEVICE_ID_ALTIMA_AC1000 0x03e8
|
||||
@@ -1602,6 +1682,9 @@
|
||||
#define PCI_VENDOR_ID_TEKRAM 0x1de1
|
||||
#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
|
||||
|
||||
#define PCI_VENDOR_ID_HINT 0x3388
|
||||
#define PCI_DEVICE_ID_HINT_VXPROII_IDE 0x8013
|
||||
|
||||
#define PCI_VENDOR_ID_3DLABS 0x3d3d
|
||||
#define PCI_DEVICE_ID_3DLABS_300SX 0x0001
|
||||
#define PCI_DEVICE_ID_3DLABS_500TX 0x0002
|
||||
@@ -1663,7 +1746,11 @@
|
||||
#define PCI_DEVICE_ID_INTEL_82430 0x0486
|
||||
#define PCI_DEVICE_ID_INTEL_82434 0x04a3
|
||||
#define PCI_DEVICE_ID_INTEL_I960 0x0960
|
||||
#define PCI_DEVICE_ID_INTEL_I960RM 0x0962
|
||||
#define PCI_DEVICE_ID_INTEL_82562ET 0x1031
|
||||
|
||||
#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130
|
||||
|
||||
#define PCI_DEVICE_ID_INTEL_82559ER 0x1209
|
||||
#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
|
||||
#define PCI_DEVICE_ID_INTEL_82092AA_1 0x1222
|
||||
@@ -1719,9 +1806,9 @@
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_2 0x2452
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_3 0x2453
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_9 0x2459
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_11 0x245b
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_13 0x245d
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_14 0x245e
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_11 0x245B
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_14 0x245D
|
||||
#define PCI_DEVICE_ID_INTEL_82801E_15 0x245E
|
||||
#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480
|
||||
#define PCI_DEVICE_ID_INTEL_82801CA_2 0x2482
|
||||
#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483
|
||||
@@ -1741,6 +1828,16 @@
|
||||
#define PCI_DEVICE_ID_INTEL_82801DB_7 0x24c7
|
||||
#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb
|
||||
#define PCI_DEVICE_ID_INTEL_82801DB_13 0x24cd
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_2 0x24d2
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_3 0x24d3
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_4 0x24d4
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_7 0x24d7
|
||||
#define PCI_DEVICE_ID_INTEL_82801DB_10 0x24ca
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db
|
||||
#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd
|
||||
#define PCI_DEVICE_ID_INTEL_80310 0x530d
|
||||
#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120
|
||||
#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121
|
||||
@@ -1762,6 +1859,7 @@
|
||||
#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4
|
||||
#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5
|
||||
#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
|
||||
#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb
|
||||
|
||||
#define PCI_VENDOR_ID_COMPUTONE 0x8e0e
|
||||
#define PCI_DEVICE_ID_COMPUTONE_IP2EX 0x0291
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -8,8 +8,8 @@
|
||||
#define ATY_RADEON_CRT_ON 0x00000002
|
||||
|
||||
|
||||
#define FBIO_RADEON_GET_MIRROR _IOR('@', 3, sizeof(__u32*))
|
||||
#define FBIO_RADEON_SET_MIRROR _IOW('@', 4, sizeof(__u32*))
|
||||
#define FBIO_RADEON_GET_MIRROR _IOR('@', 3, __u32)
|
||||
#define FBIO_RADEON_SET_MIRROR _IOW('@', 4, __u32)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* \file mm.c
|
||||
* \brief Memory block management.
|
||||
*/
|
||||
|
||||
/*
|
||||
* GLX Hardware Device Driver common code
|
||||
* Copyright (C) 1999 Keith Whitwell
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
@@ -19,20 +23,29 @@
|
||||
* 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"
|
||||
#include "hwlog.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;
|
||||
@@ -52,6 +65,19 @@ void mmDumpMemInfo( memHeap_t *heap )
|
||||
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)
|
||||
{
|
||||
@@ -71,6 +97,22 @@ memHeap_t *mmInit(int ofs,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \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)
|
||||
@@ -111,6 +153,27 @@ static TMemBlock* SliceBlock(TMemBlock *p,
|
||||
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;
|
||||
@@ -140,6 +203,17 @@ PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch)
|
||||
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) {
|
||||
@@ -152,6 +226,18 @@ static __inline__ int Join2Blocks(TMemBlock *p)
|
||||
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;
|
||||
@@ -185,6 +271,14 @@ int mmFreeMem(PMemBlock b)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Destroy the memory heap.
|
||||
*
|
||||
* \param heap memory heap.
|
||||
*
|
||||
* \internal
|
||||
* Frees each block in the heap.
|
||||
*/
|
||||
void mmDestroy(memHeap_t *heap)
|
||||
{
|
||||
TMemBlock *p,*q;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* \file mm.h
|
||||
* \brief Memory block management.
|
||||
*/
|
||||
|
||||
/*
|
||||
* GLX Hardware Device Driver common code
|
||||
* Copyright (C) 1999 Keith Whitwell
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
@@ -25,58 +29,57 @@
|
||||
#ifndef MM_INC
|
||||
#define MM_INC
|
||||
|
||||
/**
|
||||
* \brief Memory block/heap.
|
||||
*/
|
||||
struct mem_block_t {
|
||||
struct mem_block_t *next;
|
||||
struct mem_block_t *heap;
|
||||
int ofs,size;
|
||||
int align;
|
||||
int free:1;
|
||||
int reserved:1;
|
||||
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;
|
||||
|
||||
/* a heap is just the first block in a chain */
|
||||
/**
|
||||
* \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; }
|
||||
|
||||
/*
|
||||
* input: total size in bytes
|
||||
* return: a heap pointer if OK, NULL if error
|
||||
*/
|
||||
memHeap_t *mmInit( int ofs, int size );
|
||||
|
||||
/*
|
||||
* Allocate 'size' bytes with 2^align2 bytes alignment,
|
||||
* restrict the search to free memory after 'startSearch'
|
||||
* depth and back buffers should be in different 4mb banks
|
||||
* to get better page hits if possible
|
||||
* input: size = size of block
|
||||
* align2 = 2^align2 bytes alignment
|
||||
* startSearch = linear offset from start of heap to begin search
|
||||
* return: pointer to the allocated block, 0 if error
|
||||
*/
|
||||
PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2,
|
||||
int startSearch );
|
||||
|
||||
/*
|
||||
* Free block starts at offset
|
||||
* input: pointer to a block
|
||||
* return: 0 if OK, -1 if error
|
||||
*/
|
||||
int mmFreeMem( PMemBlock b );
|
||||
|
||||
/*
|
||||
* destroy MM
|
||||
*/
|
||||
void mmDestroy( memHeap_t *mmInit );
|
||||
void mmDestroy( memHeap_t *heap );
|
||||
|
||||
/* For debuging purpose. */
|
||||
void mmDumpMemInfo( memHeap_t *mmInit );
|
||||
void mmDumpMemInfo( memHeap_t *heap );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* \file mm.c
|
||||
* \brief Memory block management.
|
||||
*/
|
||||
|
||||
/*
|
||||
* GLX Hardware Device Driver common code
|
||||
* Copyright (C) 1999 Keith Whitwell
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
@@ -19,20 +23,29 @@
|
||||
* 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"
|
||||
#include "hwlog.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;
|
||||
@@ -52,6 +65,19 @@ void mmDumpMemInfo( memHeap_t *heap )
|
||||
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)
|
||||
{
|
||||
@@ -71,6 +97,22 @@ memHeap_t *mmInit(int ofs,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \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)
|
||||
@@ -111,6 +153,27 @@ static TMemBlock* SliceBlock(TMemBlock *p,
|
||||
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;
|
||||
@@ -140,6 +203,17 @@ PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2, int startSearch)
|
||||
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) {
|
||||
@@ -152,6 +226,18 @@ static __inline__ int Join2Blocks(TMemBlock *p)
|
||||
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;
|
||||
@@ -185,6 +271,14 @@ int mmFreeMem(PMemBlock b)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Destroy the memory heap.
|
||||
*
|
||||
* \param heap memory heap.
|
||||
*
|
||||
* \internal
|
||||
* Frees each block in the heap.
|
||||
*/
|
||||
void mmDestroy(memHeap_t *heap)
|
||||
{
|
||||
TMemBlock *p,*q;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* \file mm.h
|
||||
* \brief Memory block management.
|
||||
*/
|
||||
|
||||
/*
|
||||
* GLX Hardware Device Driver common code
|
||||
* Copyright (C) 1999 Keith Whitwell
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
@@ -25,58 +29,57 @@
|
||||
#ifndef MM_INC
|
||||
#define MM_INC
|
||||
|
||||
/**
|
||||
* \brief Memory block/heap.
|
||||
*/
|
||||
struct mem_block_t {
|
||||
struct mem_block_t *next;
|
||||
struct mem_block_t *heap;
|
||||
int ofs,size;
|
||||
int align;
|
||||
int free:1;
|
||||
int reserved:1;
|
||||
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;
|
||||
|
||||
/* a heap is just the first block in a chain */
|
||||
/**
|
||||
* \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; }
|
||||
|
||||
/*
|
||||
* input: total size in bytes
|
||||
* return: a heap pointer if OK, NULL if error
|
||||
*/
|
||||
memHeap_t *mmInit( int ofs, int size );
|
||||
|
||||
/*
|
||||
* Allocate 'size' bytes with 2^align2 bytes alignment,
|
||||
* restrict the search to free memory after 'startSearch'
|
||||
* depth and back buffers should be in different 4mb banks
|
||||
* to get better page hits if possible
|
||||
* input: size = size of block
|
||||
* align2 = 2^align2 bytes alignment
|
||||
* startSearch = linear offset from start of heap to begin search
|
||||
* return: pointer to the allocated block, 0 if error
|
||||
*/
|
||||
PMemBlock mmAllocMem( memHeap_t *heap, int size, int align2,
|
||||
int startSearch );
|
||||
|
||||
/*
|
||||
* Free block starts at offset
|
||||
* input: pointer to a block
|
||||
* return: 0 if OK, -1 if error
|
||||
*/
|
||||
int mmFreeMem( PMemBlock b );
|
||||
|
||||
/*
|
||||
* destroy MM
|
||||
*/
|
||||
void mmDestroy( memHeap_t *mmInit );
|
||||
void mmDestroy( memHeap_t *heap );
|
||||
|
||||
/* For debuging purpose. */
|
||||
void mmDumpMemInfo( memHeap_t *mmInit );
|
||||
void mmDumpMemInfo( memHeap_t *heap );
|
||||
|
||||
#endif
|
||||
|
||||
118
src/mesa/drivers/dri/r200/Makefile
Normal file
118
src/mesa/drivers/dri/r200/Makefile
Normal file
@@ -0,0 +1,118 @@
|
||||
# $Id: Makefile,v 1.1.2.2 2003/04/15 09:47:37 keithw Exp $
|
||||
|
||||
# Mesa 3-D graphics library
|
||||
# Version: 5.0
|
||||
# Copyright (C) 1995-2002 Brian Paul
|
||||
|
||||
|
||||
|
||||
MESA = ../../..
|
||||
default: r200_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
|
||||
|
||||
DEFINES = \
|
||||
-DGLX_DIRECT_RENDERING \
|
||||
-Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -DMALLOC_0_RETURNS_NULL -DGLXEXT -DXF86DRI -DGLX_DIRECT_RENDERING -DGLX_USE_DLOPEN -DGLX_USE_MESA -DX_BYTE_ORDER=X_LITTLE_ENDIAN \
|
||||
-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
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
MINIGLX_SOURCES = server/radeon_dri.c
|
||||
|
||||
DRIVER_SOURCES = r200_context.c \
|
||||
r200_ioctl.c \
|
||||
r200_lock.c \
|
||||
r200_screen.c \
|
||||
r200_state.c \
|
||||
r200_state_init.c \
|
||||
../common/mm.c \
|
||||
r200_cmdbuf.c \
|
||||
r200_pixel.c \
|
||||
r200_tex.c \
|
||||
r200_texmem.c \
|
||||
r200_texstate.c \
|
||||
r200_tcl.c \
|
||||
r200_swtcl.c \
|
||||
r200_span.c \
|
||||
r200_maos.c \
|
||||
r200_sanity.c \
|
||||
r200_vtxfmt.c \
|
||||
r200_vtxfmt_c.c \
|
||||
r200_vtxfmt_sse.c \
|
||||
r200_vtxfmt_x86.c
|
||||
|
||||
|
||||
INCLUDES = $(MINIGLX_INCLUDES) \
|
||||
$(SHARED_INCLUDES)
|
||||
|
||||
|
||||
C_SOURCES = $(DRIVER_SOURCES) \
|
||||
$(MINIGLX_SOURCES)
|
||||
MESA_MODULES = $(FULL_MESA)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
SYMLINKS = server/Makefile \
|
||||
server/radeon_common.h \
|
||||
server/radeon_dri.c \
|
||||
server/radeon_dri.h \
|
||||
server/radeon.h \
|
||||
server/radeon_macros.h \
|
||||
server/radeon_reg.h \
|
||||
server/radeon_sarea.h \
|
||||
|
||||
|
||||
$(SYMLINKS):
|
||||
rm -f $@ && ln -s ../../radeon/$@ $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
clean: clean_here
|
||||
|
||||
clean_here:
|
||||
rm -f $(SYMLINKS)
|
||||
|
||||
# Build the subset or full driver?
|
||||
#
|
||||
r200_dri.so: $(SYMLINKS) $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile
|
||||
rm -f $@ && gcc -o $@ -shared $(OBJECTS) $(MESA_MODULES) $(WINOBJ) $(WINLIB) -lGL -lc -lm -Wl,-rpath,../../../lib
|
||||
rm -f $(MESA)/lib/r200_dri.so && \
|
||||
install r200_dri.so $(MESA)/lib/r200_dri.so
|
||||
|
||||
##### DEPENDENCIES #####
|
||||
|
||||
-include $(C_SOURCES:.c=.d)
|
||||
344
src/mesa/drivers/dri/r200/r200_cmdbuf.c
Normal file
344
src/mesa/drivers/dri/r200/r200_cmdbuf.c
Normal file
@@ -0,0 +1,344 @@
|
||||
/* $XFree86$ */
|
||||
/*
|
||||
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
|
||||
|
||||
The Weather Channel (TM) funded Tungsten Graphics to develop the
|
||||
initial release of the Radeon 8500 driver under the XFree86 license.
|
||||
This notice must be preserved.
|
||||
|
||||
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 THE COPYRIGHT OWNER(S) 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:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "context.h"
|
||||
#include "swrast/swrast.h"
|
||||
#include "simple_list.h"
|
||||
|
||||
#include "r200_context.h"
|
||||
#include "r200_state.h"
|
||||
#include "r200_ioctl.h"
|
||||
#include "r200_tcl.h"
|
||||
#include "r200_sanity.h"
|
||||
#include "radeon_reg.h"
|
||||
|
||||
static void print_state_atom( struct r200_state_atom *state )
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(stderr, "emit %s/%d\n", state->name, state->cmd_size);
|
||||
|
||||
if (0 & R200_DEBUG & DEBUG_VERBOSE)
|
||||
for (i = 0 ; i < state->cmd_size ; i++)
|
||||
fprintf(stderr, "\t%s[%d]: %x\n", state->name, i, state->cmd[i]);
|
||||
|
||||
}
|
||||
|
||||
static void r200_emit_state_list( r200ContextPtr rmesa,
|
||||
struct r200_state_atom *list )
|
||||
{
|
||||
struct r200_state_atom *state, *tmp;
|
||||
char *dest;
|
||||
|
||||
foreach_s( state, tmp, list ) {
|
||||
if (state->check( rmesa->glCtx, state->idx )) {
|
||||
dest = r200AllocCmdBuf( rmesa, state->cmd_size * 4, __FUNCTION__);
|
||||
memcpy( dest, state->cmd, state->cmd_size * 4);
|
||||
move_to_head( &(rmesa->hw.clean), state );
|
||||
if (R200_DEBUG & DEBUG_STATE)
|
||||
print_state_atom( state );
|
||||
}
|
||||
else if (R200_DEBUG & DEBUG_STATE)
|
||||
fprintf(stderr, "skip state %s\n", state->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void r200EmitState( r200ContextPtr rmesa )
|
||||
{
|
||||
struct r200_state_atom *state, *tmp;
|
||||
|
||||
if (R200_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
/* Somewhat overkill:
|
||||
*/
|
||||
if ( rmesa->lost_context) {
|
||||
if (R200_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;
|
||||
}
|
||||
else {
|
||||
move_to_tail( &rmesa->hw.dirty, &rmesa->hw.mtl[0] );
|
||||
/* odd bug? -- isosurf, cycle between reflect & lit */
|
||||
}
|
||||
|
||||
r200_emit_state_list( rmesa, &rmesa->hw.dirty );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Fire a section of the retained (indexed_verts) buffer as a regular
|
||||
* primtive.
|
||||
*/
|
||||
extern void r200EmitVbufPrim( r200ContextPtr rmesa,
|
||||
GLuint primitive,
|
||||
GLuint vertex_nr )
|
||||
{
|
||||
drmRadeonCmdHeader *cmd;
|
||||
|
||||
assert(!(primitive & R200_VF_PRIM_WALK_IND));
|
||||
|
||||
r200EmitState( rmesa );
|
||||
|
||||
if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_PRIMS))
|
||||
fprintf(stderr, "%s cmd_used/4: %d prim %x nr %d\n", __FUNCTION__,
|
||||
rmesa->store.cmd_used/4, primitive, vertex_nr);
|
||||
|
||||
cmd = (drmRadeonCmdHeader *)r200AllocCmdBuf( rmesa, 3 * sizeof(*cmd),
|
||||
__FUNCTION__ );
|
||||
cmd[0].i = 0;
|
||||
cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
|
||||
cmd[1].i = R200_CP_CMD_3D_DRAW_VBUF_2;
|
||||
cmd[2].i = (primitive |
|
||||
R200_VF_PRIM_WALK_LIST |
|
||||
R200_VF_COLOR_ORDER_RGBA |
|
||||
(vertex_nr << R200_VF_VERTEX_NUMBER_SHIFT));
|
||||
|
||||
|
||||
if (R200_DEBUG & DEBUG_SYNC) {
|
||||
fprintf(stderr, "\nSyncing\n\n");
|
||||
R200_FIREVERTICES( rmesa );
|
||||
r200Finish( rmesa->glCtx );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void r200FlushElts( r200ContextPtr rmesa )
|
||||
{
|
||||
int *cmd = (int *)(rmesa->store.cmd_buf + rmesa->store.elts_start);
|
||||
int dwords;
|
||||
int nr = (rmesa->store.cmd_used - (rmesa->store.elts_start + 12)) / 2;
|
||||
|
||||
if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_PRIMS))
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
assert( rmesa->dma.flush == r200FlushElts );
|
||||
rmesa->dma.flush = 0;
|
||||
|
||||
/* Cope with odd number of elts:
|
||||
*/
|
||||
rmesa->store.cmd_used = (rmesa->store.cmd_used + 2) & ~2;
|
||||
dwords = (rmesa->store.cmd_used - rmesa->store.elts_start) / 4;
|
||||
|
||||
cmd[1] |= (dwords - 3) << 16;
|
||||
cmd[2] |= nr << R200_VF_VERTEX_NUMBER_SHIFT;
|
||||
|
||||
if (R200_DEBUG & DEBUG_SYNC) {
|
||||
fprintf(stderr, "\nSyncing in %s\n\n", __FUNCTION__);
|
||||
R200_FIREVERTICES( rmesa );
|
||||
r200Finish( rmesa->glCtx );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
|
||||
GLuint primitive,
|
||||
GLuint min_nr )
|
||||
{
|
||||
drmRadeonCmdHeader *cmd;
|
||||
GLushort *retval;
|
||||
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s %d prim %x\n", __FUNCTION__, min_nr, primitive);
|
||||
|
||||
assert((primitive & R200_VF_PRIM_WALK_IND));
|
||||
|
||||
r200EmitState( rmesa );
|
||||
|
||||
cmd = (drmRadeonCmdHeader *)r200AllocCmdBuf( rmesa,
|
||||
12 + min_nr*2,
|
||||
__FUNCTION__ );
|
||||
cmd[0].i = 0;
|
||||
cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
|
||||
cmd[1].i = R200_CP_CMD_3D_DRAW_INDX_2;
|
||||
cmd[2].i = (primitive |
|
||||
R200_VF_PRIM_WALK_IND |
|
||||
R200_VF_COLOR_ORDER_RGBA);
|
||||
|
||||
|
||||
retval = (GLushort *)(cmd+3);
|
||||
|
||||
if (R200_DEBUG & DEBUG_PRIMS)
|
||||
fprintf(stderr, "%s: header 0x%x prim %x \n",
|
||||
__FUNCTION__,
|
||||
cmd[1].i, primitive);
|
||||
|
||||
assert(!rmesa->dma.flush);
|
||||
rmesa->dma.flush = r200FlushElts;
|
||||
|
||||
rmesa->store.elts_start = ((char *)cmd) - rmesa->store.cmd_buf;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void r200EmitVertexAOS( r200ContextPtr rmesa,
|
||||
GLuint vertex_size,
|
||||
GLuint offset )
|
||||
{
|
||||
drmRadeonCmdHeader *cmd;
|
||||
|
||||
if (R200_DEBUG & (DEBUG_PRIMS|DEBUG_IOCTL))
|
||||
fprintf(stderr, "%s: vertex_size 0x%x offset 0x%x \n",
|
||||
__FUNCTION__, vertex_size, offset);
|
||||
|
||||
cmd = (drmRadeonCmdHeader *)r200AllocCmdBuf( rmesa, 5 * sizeof(int),
|
||||
__FUNCTION__ );
|
||||
|
||||
cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
|
||||
cmd[1].i = R200_CP_CMD_3D_LOAD_VBPNTR | (2 << 16);
|
||||
cmd[2].i = 1;
|
||||
cmd[3].i = vertex_size | (vertex_size << 8);
|
||||
cmd[4].i = offset;
|
||||
}
|
||||
|
||||
|
||||
void r200EmitAOS( r200ContextPtr rmesa,
|
||||
struct r200_dma_region **component,
|
||||
GLuint nr,
|
||||
GLuint offset )
|
||||
{
|
||||
drmRadeonCmdHeader *cmd;
|
||||
int sz = 3 + ((nr/2)*3) + ((nr&1)*2);
|
||||
int i;
|
||||
int *tmp;
|
||||
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s nr arrays: %d\n", __FUNCTION__, nr);
|
||||
|
||||
cmd = (drmRadeonCmdHeader *)r200AllocCmdBuf( rmesa, sz * sizeof(int),
|
||||
__FUNCTION__ );
|
||||
cmd[0].i = 0;
|
||||
cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
|
||||
cmd[1].i = R200_CP_CMD_3D_LOAD_VBPNTR | ((sz-3) << 16);
|
||||
cmd[2].i = nr;
|
||||
tmp = &cmd[0].i;
|
||||
cmd += 3;
|
||||
|
||||
for (i = 0 ; i < nr ; i++) {
|
||||
if (i & 1) {
|
||||
cmd[0].i |= ((component[i]->aos_stride << 24) |
|
||||
(component[i]->aos_size << 16));
|
||||
cmd[2].i = (component[i]->aos_start +
|
||||
offset * component[i]->aos_stride * 4);
|
||||
cmd += 3;
|
||||
}
|
||||
else {
|
||||
cmd[0].i = ((component[i]->aos_stride << 8) |
|
||||
(component[i]->aos_size << 0));
|
||||
cmd[1].i = (component[i]->aos_start +
|
||||
offset * component[i]->aos_stride * 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (R200_DEBUG & DEBUG_VERTS) {
|
||||
fprintf(stderr, "%s:\n", __FUNCTION__);
|
||||
for (i = 0 ; i < sz ; i++)
|
||||
fprintf(stderr, " %d: %x\n", i, tmp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void r200EmitBlit( r200ContextPtr rmesa,
|
||||
GLuint color_fmt,
|
||||
GLuint src_pitch,
|
||||
GLuint src_offset,
|
||||
GLuint dst_pitch,
|
||||
GLuint dst_offset,
|
||||
GLint srcx, GLint srcy,
|
||||
GLint dstx, GLint dsty,
|
||||
GLuint w, GLuint h )
|
||||
{
|
||||
drmRadeonCmdHeader *cmd;
|
||||
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
|
||||
__FUNCTION__,
|
||||
src_pitch, src_offset, srcx, srcy,
|
||||
dst_pitch, dst_offset, dstx, dsty,
|
||||
w, h);
|
||||
|
||||
assert( (src_pitch & 63) == 0 );
|
||||
assert( (dst_pitch & 63) == 0 );
|
||||
assert( (src_offset & 1023) == 0 );
|
||||
assert( (dst_offset & 1023) == 0 );
|
||||
assert( w < (1<<16) );
|
||||
assert( h < (1<<16) );
|
||||
|
||||
cmd = (drmRadeonCmdHeader *)r200AllocCmdBuf( rmesa, 8 * sizeof(int),
|
||||
__FUNCTION__ );
|
||||
|
||||
|
||||
cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
|
||||
cmd[1].i = R200_CP_CMD_BITBLT_MULTI | (5 << 16);
|
||||
cmd[2].i = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
|
||||
RADEON_GMC_DST_PITCH_OFFSET_CNTL |
|
||||
RADEON_GMC_BRUSH_NONE |
|
||||
(color_fmt << 8) |
|
||||
RADEON_GMC_SRC_DATATYPE_COLOR |
|
||||
RADEON_ROP3_S |
|
||||
RADEON_DP_SRC_SOURCE_MEMORY |
|
||||
RADEON_GMC_CLR_CMP_CNTL_DIS |
|
||||
RADEON_GMC_WR_MSK_DIS );
|
||||
|
||||
cmd[3].i = ((src_pitch/64)<<22) | (src_offset >> 10);
|
||||
cmd[4].i = ((dst_pitch/64)<<22) | (dst_offset >> 10);
|
||||
cmd[5].i = (srcx << 16) | srcy;
|
||||
cmd[6].i = (dstx << 16) | dsty; /* dst */
|
||||
cmd[7].i = (w << 16) | h;
|
||||
}
|
||||
|
||||
|
||||
void r200EmitWait( r200ContextPtr rmesa, GLuint flags )
|
||||
{
|
||||
if (rmesa->dri.drmMinor >= 6) {
|
||||
drmRadeonCmdHeader *cmd;
|
||||
|
||||
assert( !(flags & ~(RADEON_WAIT_2D|RADEON_WAIT_3D)) );
|
||||
|
||||
cmd = (drmRadeonCmdHeader *)r200AllocCmdBuf( rmesa, 1 * sizeof(int),
|
||||
__FUNCTION__ );
|
||||
cmd[0].i = 0;
|
||||
cmd[0].wait.cmd_type = RADEON_CMD_WAIT;
|
||||
cmd[0].wait.flags = flags;
|
||||
}
|
||||
}
|
||||
673
src/mesa/drivers/dri/r200/r200_context.c
Normal file
673
src/mesa/drivers/dri/r200/r200_context.c
Normal file
@@ -0,0 +1,673 @@
|
||||
/* $XFree86$ */
|
||||
/*
|
||||
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
|
||||
|
||||
The Weather Channel (TM) funded Tungsten Graphics to develop the
|
||||
initial release of the Radeon 8500 driver under the XFree86 license.
|
||||
This notice must be preserved.
|
||||
|
||||
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 THE COPYRIGHT OWNER(S) 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:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "api_arrayelt.h"
|
||||
#include "context.h"
|
||||
#include "simple_list.h"
|
||||
#include "imports.h"
|
||||
#include "matrix.h"
|
||||
#include "state.h"
|
||||
#include "extensions.h"
|
||||
#include "state.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "array_cache/acache.h"
|
||||
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
#include "r200_context.h"
|
||||
#include "r200_ioctl.h"
|
||||
#include "r200_state.h"
|
||||
#include "r200_span.h"
|
||||
#include "r200_pixel.h"
|
||||
#include "r200_tex.h"
|
||||
#include "r200_swtcl.h"
|
||||
#include "r200_tcl.h"
|
||||
#include "r200_vtxfmt.h"
|
||||
#include "r200_maos.h"
|
||||
|
||||
#if defined(USE_X86_ASM)
|
||||
#include "X86/common_x86_asm.h"
|
||||
#endif
|
||||
|
||||
#define R200_DATE "20021125"
|
||||
|
||||
#ifndef R200_DEBUG
|
||||
int R200_DEBUG = (0);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Return the width and height of the given buffer.
|
||||
*/
|
||||
static void r200GetBufferSize( GLframebuffer *buffer,
|
||||
GLuint *width, GLuint *height )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
r200ContextPtr rmesa = R200_CONTEXT(ctx);
|
||||
|
||||
LOCK_HARDWARE( rmesa );
|
||||
*width = rmesa->dri.drawable->w;
|
||||
*height = rmesa->dri.drawable->h;
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
}
|
||||
|
||||
/* Return various strings for glGetString().
|
||||
*/
|
||||
static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
|
||||
{
|
||||
r200ContextPtr rmesa = R200_CONTEXT(ctx);
|
||||
static char buffer[128];
|
||||
|
||||
switch ( name ) {
|
||||
case GL_VENDOR:
|
||||
return (GLubyte *)"Tungsten Graphics, Inc.";
|
||||
|
||||
case GL_RENDERER:
|
||||
sprintf( buffer, "Mesa DRI R200 " R200_DATE);
|
||||
|
||||
/* Append any chipset-specific information. None yet.
|
||||
*/
|
||||
|
||||
/* Append any AGP-specific information.
|
||||
*/
|
||||
switch ( rmesa->r200Screen->AGPMode ) {
|
||||
case 1:
|
||||
strncat( buffer, " AGP 1x", 7 );
|
||||
break;
|
||||
case 2:
|
||||
strncat( buffer, " AGP 2x", 7 );
|
||||
break;
|
||||
case 4:
|
||||
strncat( buffer, " AGP 4x", 7 );
|
||||
break;
|
||||
}
|
||||
|
||||
/* Append any CPU-specific information.
|
||||
*/
|
||||
#ifdef USE_X86_ASM
|
||||
if ( _mesa_x86_cpu_features ) {
|
||||
strncat( buffer, " x86", 4 );
|
||||
}
|
||||
#ifdef USE_MMX_ASM
|
||||
if ( cpu_has_mmx ) {
|
||||
strncat( buffer, "/MMX", 4 );
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_3DNOW_ASM
|
||||
if ( cpu_has_3dnow ) {
|
||||
strncat( buffer, "/3DNow!", 7 );
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_SSE_ASM
|
||||
if ( cpu_has_xmm ) {
|
||||
strncat( buffer, "/SSE", 4 );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if ( !(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE) ) {
|
||||
strncat( buffer, " TCL", 4 );
|
||||
}
|
||||
else {
|
||||
strncat( buffer, " NO-TCL", 7 );
|
||||
}
|
||||
|
||||
return (GLubyte *)buffer;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Initialize the extensions supported by this driver.
|
||||
*/
|
||||
static void r200InitExtensions( GLcontext *ctx, r200ScreenPtr r200Screen )
|
||||
{
|
||||
_mesa_enable_imaging_extensions( ctx );
|
||||
|
||||
_mesa_enable_extension( ctx, "GL_ARB_multitexture" );
|
||||
if (r200Screen->drmSupportsCubeMaps)
|
||||
_mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
|
||||
_mesa_enable_extension( ctx, "GL_ARB_texture_env_add" );
|
||||
_mesa_enable_extension( ctx, "GL_ARB_texture_env_combine" );
|
||||
_mesa_enable_extension( ctx, "GL_ARB_texture_env_dot3" );
|
||||
_mesa_enable_extension( ctx, "GL_ARB_texture_mirrored_repeat" );
|
||||
_mesa_enable_extension( ctx, "GL_ARB_texture_border_clamp" );
|
||||
|
||||
_mesa_enable_extension( ctx, "GL_ATI_texture_env_combine3" );
|
||||
_mesa_enable_extension( ctx, "GL_ATI_texture_mirror_once" );
|
||||
|
||||
_mesa_enable_extension( ctx, "GL_EXT_blend_logic_op" );
|
||||
/*_mesa_enable_extension( ctx, "GL_EXT_fog_coord" );*/
|
||||
_mesa_enable_extension( ctx, "GL_EXT_stencil_wrap" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_edge_clamp" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_env_combine" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_env_dot3" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_filter_anisotropic" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_lod_bias" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_secondary_color" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_blend_subtract" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_blend_minmax" );
|
||||
|
||||
/* _mesa_enable_extension( ctx, "GL_EXT_fog_coord" ); */
|
||||
|
||||
_mesa_enable_extension( ctx, "GL_MESA_pack_invert" );
|
||||
_mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );
|
||||
_mesa_enable_extension( ctx, "GL_NV_texture_rectangle" );
|
||||
}
|
||||
|
||||
extern const struct gl_pipeline_stage _r200_render_stage;
|
||||
extern const struct gl_pipeline_stage _r200_tcl_stage;
|
||||
|
||||
static const struct gl_pipeline_stage *r200_pipeline[] = {
|
||||
|
||||
/* Try and go straight to t&l
|
||||
*/
|
||||
&_r200_tcl_stage,
|
||||
|
||||
/* Catch any t&l fallbacks
|
||||
*/
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
&_tnl_fog_coordinate_stage,
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
|
||||
/* Try again to go to tcl?
|
||||
* - no good for asymmetric-twoside (do with multipass)
|
||||
* - no good for asymmetric-unfilled (do with multipass)
|
||||
* - good for material
|
||||
* - good for texgen
|
||||
* - need to manipulate a bit of state
|
||||
*
|
||||
* - worth it/not worth it?
|
||||
*/
|
||||
|
||||
/* Else do them here.
|
||||
*/
|
||||
&_r200_render_stage,
|
||||
&_tnl_render_stage, /* FALLBACK: */
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Initialize the driver's misc functions.
|
||||
*/
|
||||
static void r200InitDriverFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.GetBufferSize = r200GetBufferSize;
|
||||
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
|
||||
ctx->Driver.GetString = r200GetString;
|
||||
|
||||
ctx->Driver.Error = NULL;
|
||||
ctx->Driver.DrawPixels = NULL;
|
||||
ctx->Driver.Bitmap = NULL;
|
||||
}
|
||||
|
||||
static void add_debug_flags( const char *debug )
|
||||
{
|
||||
if (strstr(debug, "fall"))
|
||||
R200_DEBUG |= DEBUG_FALLBACKS;
|
||||
|
||||
if (strstr(debug, "tex"))
|
||||
R200_DEBUG |= DEBUG_TEXTURE;
|
||||
|
||||
if (strstr(debug, "ioctl"))
|
||||
R200_DEBUG |= DEBUG_IOCTL;
|
||||
|
||||
if (strstr(debug, "prim"))
|
||||
R200_DEBUG |= DEBUG_PRIMS;
|
||||
|
||||
if (strstr(debug, "vert"))
|
||||
R200_DEBUG |= DEBUG_VERTS;
|
||||
|
||||
if (strstr(debug, "state"))
|
||||
R200_DEBUG |= DEBUG_STATE;
|
||||
|
||||
if (strstr(debug, "code"))
|
||||
R200_DEBUG |= DEBUG_CODEGEN;
|
||||
|
||||
if (strstr(debug, "vfmt") || strstr(debug, "vtxf"))
|
||||
R200_DEBUG |= DEBUG_VFMT;
|
||||
|
||||
if (strstr(debug, "verb"))
|
||||
R200_DEBUG |= DEBUG_VERBOSE;
|
||||
|
||||
if (strstr(debug, "dri"))
|
||||
R200_DEBUG |= DEBUG_DRI;
|
||||
|
||||
if (strstr(debug, "dma"))
|
||||
R200_DEBUG |= DEBUG_DMA;
|
||||
|
||||
if (strstr(debug, "san"))
|
||||
R200_DEBUG |= DEBUG_SANITY;
|
||||
|
||||
if (strstr(debug, "sync"))
|
||||
R200_DEBUG |= DEBUG_SYNC;
|
||||
|
||||
if (strstr(debug, "pix"))
|
||||
R200_DEBUG |= DEBUG_PIXEL;
|
||||
|
||||
if (strstr(debug, "mem"))
|
||||
R200_DEBUG |= DEBUG_MEMORY;
|
||||
}
|
||||
|
||||
/* Create the device specific context.
|
||||
*/
|
||||
GLboolean r200CreateContext( const __GLcontextModes *glVisual,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
{
|
||||
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
|
||||
r200ScreenPtr r200Screen = (r200ScreenPtr)(sPriv->private);
|
||||
r200ContextPtr rmesa;
|
||||
GLcontext *ctx, *shareCtx;
|
||||
int i, memPerUnit;
|
||||
|
||||
assert(glVisual);
|
||||
assert(driContextPriv);
|
||||
assert(r200Screen);
|
||||
|
||||
/* Allocate the R200 context */
|
||||
rmesa = (r200ContextPtr) CALLOC( sizeof(*rmesa) );
|
||||
if ( !rmesa )
|
||||
return GL_FALSE;
|
||||
|
||||
/* Allocate the Mesa context */
|
||||
if (sharedContextPrivate)
|
||||
shareCtx = ((r200ContextPtr) 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 r200 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;
|
||||
rmesa->dri.drmMinor = sPriv->drmMinor;
|
||||
|
||||
rmesa->r200Screen = r200Screen;
|
||||
rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
|
||||
r200Screen->sarea_priv_offset);
|
||||
|
||||
|
||||
rmesa->dma.buf0_address = rmesa->r200Screen->buffers->list[0].address;
|
||||
|
||||
for ( i = 0 ; i < r200Screen->numTexHeaps ; i++ ) {
|
||||
make_empty_list( &rmesa->texture.objects[i] );
|
||||
rmesa->texture.heap[i] = mmInit( 0, r200Screen->texSize[i] );
|
||||
rmesa->texture.age[i] = -1;
|
||||
}
|
||||
rmesa->texture.numHeaps = r200Screen->numTexHeaps;
|
||||
make_empty_list( &rmesa->texture.swapped );
|
||||
|
||||
rmesa->swtcl.RenderIndex = ~0;
|
||||
rmesa->lost_context = 1;
|
||||
|
||||
/* 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;
|
||||
memPerUnit = r200Screen->texSize[RADEON_CARD_HEAP] / 2;
|
||||
|
||||
/* XXX the following code could go into a utility file */
|
||||
if (memPerUnit >= 4 * 2048 * 2048) {
|
||||
ctx->Const.MaxTextureLevels = 12; /* 2048x2048 */
|
||||
}
|
||||
else if (memPerUnit >= 4 * 1024 * 1024) {
|
||||
ctx->Const.MaxTextureLevels = 11; /* 1024x1024 */
|
||||
}
|
||||
else if (memPerUnit >= 4 * 512 * 512) {
|
||||
ctx->Const.MaxTextureLevels = 10; /* 512x512 */
|
||||
}
|
||||
else {
|
||||
ctx->Const.MaxTextureLevels = 9; /* 256x256 */
|
||||
}
|
||||
|
||||
#if ENABLE_HW_3D_TEXTURE
|
||||
if (memPerUnit >= 4 * 256 * 256 * 256) {
|
||||
ctx->Const.Max3DTextureLevels = 9; /* 256x256x256 */
|
||||
}
|
||||
else if (memPerUnit >= 4 * 64 * 64 * 64) {
|
||||
ctx->Const.Max3DTextureLevels = 8; /* 128x128x128 */
|
||||
}
|
||||
else if (memPerUnit >= 4 * 32 * 32 * 32) {
|
||||
ctx->Const.Max3DTextureLevels = 7; /* 64x64x64 */
|
||||
}
|
||||
else { /* 256KBytes */
|
||||
ctx->Const.Max3DTextureLevels = 6; /* 32x32x32 */
|
||||
}
|
||||
#endif
|
||||
|
||||
if (memPerUnit >= 4 * 6 * 2048 * 2048) {
|
||||
ctx->Const.MaxCubeTextureLevels = 12; /* 2048x2048 */
|
||||
}
|
||||
if (memPerUnit >= 4 * 6 * 1024 * 1024) {
|
||||
ctx->Const.MaxCubeTextureLevels = 11; /* 1024x1024 */
|
||||
}
|
||||
else if (memPerUnit >= 4 * 6 * 512 * 512) {
|
||||
ctx->Const.MaxCubeTextureLevels = 10; /* 512x512 */
|
||||
}
|
||||
else if (memPerUnit >= 4 * 6 * 256 * 256) {
|
||||
ctx->Const.MaxCubeTextureLevels = 9; /* 256x256 */
|
||||
}
|
||||
else { /* 393216 bytes */
|
||||
ctx->Const.MaxCubeTextureLevels = 8; /* 128x128 */
|
||||
}
|
||||
|
||||
ctx->Const.MaxTextureUnits = 2;
|
||||
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;
|
||||
|
||||
/* Initialize the software rasterizer and helper modules.
|
||||
*/
|
||||
_swrast_CreateContext( ctx );
|
||||
_ac_CreateContext( ctx );
|
||||
_tnl_CreateContext( ctx );
|
||||
_swsetup_CreateContext( ctx );
|
||||
_ae_create_context( ctx );
|
||||
|
||||
/* Install the customized pipeline:
|
||||
*/
|
||||
_tnl_destroy_pipeline( ctx );
|
||||
_tnl_install_pipeline( ctx, r200_pipeline );
|
||||
ctx->Driver.FlushVertices = r200FlushVertices;
|
||||
|
||||
/* Try and keep materials and vertices separate:
|
||||
*/
|
||||
_tnl_isolate_materials( ctx, GL_TRUE );
|
||||
|
||||
|
||||
/* Configure swrast to match hardware characteristics:
|
||||
*/
|
||||
_swrast_allow_pixel_fog( ctx, GL_FALSE );
|
||||
_swrast_allow_vertex_fog( ctx, GL_TRUE );
|
||||
|
||||
|
||||
_math_matrix_ctr( &rmesa->TexGenMatrix[0] );
|
||||
_math_matrix_ctr( &rmesa->TexGenMatrix[1] );
|
||||
_math_matrix_ctr( &rmesa->tmpmat );
|
||||
_math_matrix_set_identity( &rmesa->TexGenMatrix[0] );
|
||||
_math_matrix_set_identity( &rmesa->TexGenMatrix[1] );
|
||||
_math_matrix_set_identity( &rmesa->tmpmat );
|
||||
|
||||
r200InitExtensions( ctx, r200Screen );
|
||||
r200InitDriverFuncs( ctx );
|
||||
r200InitIoctlFuncs( ctx );
|
||||
r200InitStateFuncs( ctx );
|
||||
r200InitSpanFuncs( ctx );
|
||||
r200InitPixelFuncs( ctx );
|
||||
r200InitTextureFuncs( ctx );
|
||||
r200InitState( rmesa );
|
||||
r200InitSwtcl( ctx );
|
||||
|
||||
rmesa->iw.irq_seq = -1;
|
||||
rmesa->irqsEmitted = 0;
|
||||
rmesa->do_irqs = (rmesa->dri.drmMinor >= 6 &&
|
||||
!getenv("R200_NO_IRQS") &&
|
||||
rmesa->r200Screen->irq);
|
||||
|
||||
if (!rmesa->do_irqs)
|
||||
fprintf(stderr,
|
||||
"IRQ's not enabled, falling back to busy waits: %d %d %d\n",
|
||||
rmesa->dri.drmMinor,
|
||||
!!getenv("R200_NO_IRQS"),
|
||||
rmesa->r200Screen->irq);
|
||||
|
||||
|
||||
rmesa->do_usleeps = !getenv("R200_NO_USLEEPS");
|
||||
rmesa->prefer_agp_client_texturing =
|
||||
(getenv("R200_AGP_CLIENT_TEXTURES") != 0);
|
||||
|
||||
|
||||
#if DO_DEBUG
|
||||
if (getenv("R200_DEBUG"))
|
||||
add_debug_flags( getenv("R200_DEBUG") );
|
||||
if (getenv("RADEON_DEBUG"))
|
||||
add_debug_flags( getenv("RADEON_DEBUG") );
|
||||
#endif
|
||||
|
||||
if (getenv("R200_NO_RAST")) {
|
||||
fprintf(stderr, "disabling 3D acceleration\n");
|
||||
FALLBACK(rmesa, R200_FALLBACK_DISABLE, 1);
|
||||
}
|
||||
else if (getenv("R200_NO_TCL")) {
|
||||
fprintf(stderr, "disabling TCL support\n");
|
||||
TCL_FALLBACK(rmesa->glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);
|
||||
}
|
||||
else {
|
||||
if (!getenv("R200_NO_VTXFMT")) {
|
||||
r200VtxfmtInit( ctx );
|
||||
}
|
||||
_tnl_need_dlist_norm_lengths( ctx, GL_FALSE );
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Destroy the device specific context.
|
||||
*/
|
||||
/* Destroy the Mesa and driver specific context data.
|
||||
*/
|
||||
void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
|
||||
r200ContextPtr current = ctx ? R200_CONTEXT(ctx) : NULL;
|
||||
|
||||
/* check if we're deleting the currently bound context */
|
||||
if (rmesa == current) {
|
||||
R200_FIREVERTICES( rmesa );
|
||||
_mesa_make_current2(NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Free r200 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.
|
||||
*/
|
||||
r200TexObjPtr t, next_t;
|
||||
int i;
|
||||
|
||||
for ( i = 0 ; i < rmesa->texture.numHeaps ; i++ ) {
|
||||
foreach_s ( t, next_t, &rmesa->texture.objects[i] ) {
|
||||
r200DestroyTexObj( rmesa, t );
|
||||
}
|
||||
mmDestroy( rmesa->texture.heap[i] );
|
||||
rmesa->texture.heap[i] = NULL;
|
||||
}
|
||||
|
||||
foreach_s ( t, next_t, &rmesa->texture.swapped ) {
|
||||
r200DestroyTexObj( rmesa, t );
|
||||
}
|
||||
}
|
||||
|
||||
_swsetup_DestroyContext( rmesa->glCtx );
|
||||
_tnl_DestroyContext( rmesa->glCtx );
|
||||
_ac_DestroyContext( rmesa->glCtx );
|
||||
_swrast_DestroyContext( rmesa->glCtx );
|
||||
|
||||
r200DestroySwtcl( rmesa->glCtx );
|
||||
|
||||
r200ReleaseArrays( rmesa->glCtx, ~0 );
|
||||
|
||||
if (rmesa->dma.current.buf) {
|
||||
r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
|
||||
r200FlushCmdBuf( rmesa, __FUNCTION__ );
|
||||
}
|
||||
|
||||
if (!rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)
|
||||
if (!getenv("R200_NO_VTXFMT"))
|
||||
r200VtxfmtDestroy( rmesa->glCtx );
|
||||
|
||||
/* 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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
r200SwapBuffers( __DRIdrawablePrivate *dPriv )
|
||||
{
|
||||
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
|
||||
r200ContextPtr rmesa;
|
||||
GLcontext *ctx;
|
||||
rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
ctx = rmesa->glCtx;
|
||||
if (ctx->Visual.doubleBufferMode) {
|
||||
_mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
|
||||
if ( rmesa->doPageFlip ) {
|
||||
r200PageFlip( dPriv );
|
||||
}
|
||||
else {
|
||||
r200CopyBuffer( dPriv );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* XXX this shouldn't be an error but we can't handle it for now */
|
||||
_mesa_problem(NULL, "r200SwapBuffers: drawable has no context!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Force the context `c' to be the current context and associate with it
|
||||
* buffer `b'.
|
||||
*/
|
||||
GLboolean
|
||||
r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
__DRIdrawablePrivate *driReadPriv )
|
||||
{
|
||||
if ( driContextPriv ) {
|
||||
r200ContextPtr newR200Ctx =
|
||||
(r200ContextPtr) driContextPriv->driverPrivate;
|
||||
|
||||
if (R200_DEBUG & DEBUG_DRI)
|
||||
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, newR200Ctx->glCtx);
|
||||
|
||||
if ( newR200Ctx->dri.drawable != driDrawPriv ) {
|
||||
newR200Ctx->dri.drawable = driDrawPriv;
|
||||
r200UpdateWindow( newR200Ctx->glCtx );
|
||||
r200UpdateViewportOffset( newR200Ctx->glCtx );
|
||||
}
|
||||
|
||||
_mesa_make_current2( newR200Ctx->glCtx,
|
||||
(GLframebuffer *) driDrawPriv->driverPrivate,
|
||||
(GLframebuffer *) driReadPriv->driverPrivate );
|
||||
|
||||
if ( !newR200Ctx->glCtx->Viewport.Width ) {
|
||||
_mesa_set_viewport( newR200Ctx->glCtx, 0, 0,
|
||||
driDrawPriv->w, driDrawPriv->h );
|
||||
}
|
||||
|
||||
if (newR200Ctx->vb.enabled)
|
||||
r200VtxfmtMakeCurrent( newR200Ctx->glCtx );
|
||||
|
||||
_mesa_update_state( newR200Ctx->glCtx );
|
||||
r200ValidateState( newR200Ctx->glCtx );
|
||||
|
||||
} else {
|
||||
if (R200_DEBUG & DEBUG_DRI)
|
||||
fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
|
||||
_mesa_make_current( 0, 0 );
|
||||
}
|
||||
|
||||
if (R200_DEBUG & DEBUG_DRI)
|
||||
fprintf(stderr, "End %s\n", __FUNCTION__);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* Force the context `c' to be unbound from its buffer.
|
||||
*/
|
||||
GLboolean
|
||||
r200UnbindContext( __DRIcontextPrivate *driContextPriv )
|
||||
{
|
||||
r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
|
||||
|
||||
if (R200_DEBUG & DEBUG_DRI)
|
||||
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, rmesa->glCtx);
|
||||
|
||||
r200VtxfmtUnbindContext( rmesa->glCtx );
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
944
src/mesa/drivers/dri/r200/r200_context.h
Normal file
944
src/mesa/drivers/dri/r200/r200_context.h
Normal file
@@ -0,0 +1,944 @@
|
||||
/* $XFree86$ */
|
||||
/*
|
||||
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
|
||||
|
||||
The Weather Channel (TM) funded Tungsten Graphics to develop the
|
||||
initial release of the Radeon 8500 driver under the XFree86 license.
|
||||
This notice must be preserved.
|
||||
|
||||
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 THE COPYRIGHT OWNER(S) 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:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#ifndef __R200_CONTEXT_H__
|
||||
#define __R200_CONTEXT_H__
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
#include "dri_util.h"
|
||||
#include "radeon_common.h"
|
||||
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "r200_reg.h"
|
||||
|
||||
#define ENABLE_HW_3D_TEXTURE 0 /* XXX this is temporary! */
|
||||
|
||||
struct r200_context;
|
||||
typedef struct r200_context r200ContextRec;
|
||||
typedef struct r200_context *r200ContextPtr;
|
||||
|
||||
#include "r200_lock.h"
|
||||
#include "r200_screen.h"
|
||||
#include "mm.h"
|
||||
|
||||
/* Flags for software fallback cases */
|
||||
/* See correponding strings in r200_swtcl.c */
|
||||
#define R200_FALLBACK_TEXTURE 0x1
|
||||
#define R200_FALLBACK_DRAW_BUFFER 0x2
|
||||
#define R200_FALLBACK_STENCIL 0x4
|
||||
#define R200_FALLBACK_RENDER_MODE 0x8
|
||||
#define R200_FALLBACK_BLEND_EQ 0x10
|
||||
#define R200_FALLBACK_BLEND_FUNC 0x20
|
||||
#define R200_FALLBACK_DISABLE 0x40
|
||||
|
||||
/* The blit width for texture uploads
|
||||
*/
|
||||
#define BLIT_WIDTH_BYTES 1024
|
||||
|
||||
/* Use the templated vertex format:
|
||||
*/
|
||||
#define COLOR_IS_RGBA
|
||||
#define TAG(x) r200##x
|
||||
#include "tnl_dd/t_dd_vertex.h"
|
||||
#undef TAG
|
||||
|
||||
typedef void (*r200_tri_func)( r200ContextPtr,
|
||||
r200Vertex *,
|
||||
r200Vertex *,
|
||||
r200Vertex * );
|
||||
|
||||
typedef void (*r200_line_func)( r200ContextPtr,
|
||||
r200Vertex *,
|
||||
r200Vertex * );
|
||||
|
||||
typedef void (*r200_point_func)( r200ContextPtr,
|
||||
r200Vertex * );
|
||||
|
||||
|
||||
struct r200_colorbuffer_state {
|
||||
GLuint clear;
|
||||
GLint drawOffset, drawPitch;
|
||||
};
|
||||
|
||||
|
||||
struct r200_depthbuffer_state {
|
||||
GLfloat scale;
|
||||
};
|
||||
|
||||
struct r200_pixel_state {
|
||||
GLint readOffset, readPitch;
|
||||
};
|
||||
|
||||
struct r200_scissor_state {
|
||||
XF86DRIClipRectRec rect;
|
||||
GLboolean enabled;
|
||||
|
||||
GLuint numClipRects; /* Cliprects active */
|
||||
GLuint numAllocedClipRects; /* Cliprects available */
|
||||
XF86DRIClipRectPtr pClipRects;
|
||||
};
|
||||
|
||||
struct r200_stencilbuffer_state {
|
||||
GLboolean hwBuffer;
|
||||
GLuint clear; /* rb3d_stencilrefmask value */
|
||||
};
|
||||
|
||||
struct r200_stipple_state {
|
||||
GLuint mask[32];
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define TEX_0 0x1
|
||||
#define TEX_1 0x2
|
||||
#define TEX_ALL 0x3
|
||||
|
||||
typedef struct r200_tex_obj r200TexObj, *r200TexObjPtr;
|
||||
|
||||
/* Texture object in locally shared texture space.
|
||||
*/
|
||||
struct r200_tex_obj {
|
||||
r200TexObjPtr next, prev;
|
||||
|
||||
struct gl_texture_object *tObj; /* Mesa texture object */
|
||||
|
||||
PMemBlock memBlock; /* Memory block containing texture */
|
||||
GLuint bufAddr; /* Offset to start of locally
|
||||
shared texture block */
|
||||
|
||||
GLuint dirty_images[6]; /* Flags for whether or not
|
||||
images need to be uploaded to
|
||||
local or AGP texture space.
|
||||
Six cube faces. */
|
||||
|
||||
GLuint dirty_state; /* Flags (1 per texunit) for
|
||||
whether or not this texobj
|
||||
has dirty hardware state
|
||||
(pp_*) that needs to be
|
||||
brought into the
|
||||
texunit. */
|
||||
|
||||
GLint heap; /* Texture heap currently stored in */
|
||||
|
||||
drmRadeonTexImage image[6][RADEON_MAX_TEXTURE_LEVELS];
|
||||
/* Six, for the cube faces */
|
||||
|
||||
GLint totalSize; /* Total size of the texture
|
||||
including all mipmap levels,
|
||||
and all six cube faces */
|
||||
|
||||
GLuint pp_txfilter; /* hardware register values */
|
||||
GLuint pp_txformat;
|
||||
GLuint pp_txformat_x;
|
||||
GLuint pp_txoffset; /* Image location in texmem.
|
||||
All cube faces follow. */
|
||||
GLuint pp_txsize; /* npot only */
|
||||
GLuint pp_txpitch; /* npot only */
|
||||
GLuint pp_border_color;
|
||||
GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
|
||||
|
||||
/* texObj->Image[firstLevel] through texObj->Image[lastLevel] are the
|
||||
* images to upload.
|
||||
*/
|
||||
GLint firstLevel;
|
||||
GLint lastLevel;
|
||||
};
|
||||
|
||||
|
||||
struct r200_texture_env_state {
|
||||
r200TexObjPtr texobj;
|
||||
GLenum format;
|
||||
GLenum envMode;
|
||||
};
|
||||
|
||||
#define R200_MAX_TEXTURE_UNITS 3
|
||||
|
||||
struct r200_texture_state {
|
||||
struct r200_texture_env_state unit[R200_MAX_TEXTURE_UNITS];
|
||||
};
|
||||
|
||||
|
||||
struct r200_state_atom {
|
||||
struct r200_state_atom *next, *prev;
|
||||
const char *name; /* for debug */
|
||||
int cmd_size; /* size in bytes */
|
||||
GLuint idx;
|
||||
int *cmd; /* one or more cmd's */
|
||||
int *lastcmd; /* one or more cmd's */
|
||||
GLboolean (*check)( GLcontext *, int ); /* is this state active? */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Trying to keep these relatively short as the variables are becoming
|
||||
* extravagently long. Drop the R200_ off the front of everything -
|
||||
* I think we know we're in the r200 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 /* why */
|
||||
#define CTX_RB3D_COLORPITCH 13 /* why */
|
||||
#define CTX_STATE_SIZE 14
|
||||
|
||||
#define SET_CMD_0 0
|
||||
#define SET_SE_CNTL 1
|
||||
#define SET_RE_CNTL 2 /* replace se_coord_fmt */
|
||||
#define SET_STATE_SIZE 3
|
||||
|
||||
#define VTE_CMD_0 0
|
||||
#define VTE_SE_VTE_CNTL 1
|
||||
#define VTE_STATE_SIZE 2
|
||||
|
||||
#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 ZBS_CMD_0 0
|
||||
#define ZBS_SE_ZBIAS_FACTOR 1
|
||||
#define ZBS_SE_ZBIAS_CONSTANT 2
|
||||
#define ZBS_STATE_SIZE 3
|
||||
|
||||
#define MSC_CMD_0 0
|
||||
#define MSC_RE_MISC 1
|
||||
#define MSC_STATE_SIZE 2
|
||||
|
||||
#define TAM_CMD_0 0
|
||||
#define TAM_DEBUG3 1
|
||||
#define TAM_STATE_SIZE 2
|
||||
|
||||
#define TEX_CMD_0 0
|
||||
#define TEX_PP_TXFILTER 1 /*2c00*/
|
||||
#define TEX_PP_TXFORMAT 2 /*2c04*/
|
||||
#define TEX_PP_TXFORMAT_X 3 /*2c08*/
|
||||
#define TEX_PP_TXSIZE 4 /*2c0c*/
|
||||
#define TEX_PP_TXPITCH 5 /*2c10*/
|
||||
#define TEX_PP_BORDER_COLOR 6 /*2c14*/
|
||||
#define TEX_CMD_1 7
|
||||
#define TEX_PP_TXOFFSET 8 /*2d00 */
|
||||
#define TEX_STATE_SIZE 9
|
||||
|
||||
#define CUBE_CMD_0 0 /* 1 register follows */
|
||||
#define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */
|
||||
#define CUBE_CMD_1 2 /* 5 registers follow */
|
||||
#define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */
|
||||
#define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */
|
||||
#define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */
|
||||
#define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */
|
||||
#define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */
|
||||
#define CUBE_STATE_SIZE 8
|
||||
|
||||
#define PIX_CMD_0 0
|
||||
#define PIX_PP_TXCBLEND 1
|
||||
#define PIX_PP_TXCBLEND2 2
|
||||
#define PIX_PP_TXABLEND 3
|
||||
#define PIX_PP_TXABLEND2 4
|
||||
#define PIX_STATE_SIZE 5
|
||||
|
||||
#define TF_CMD_0 0
|
||||
#define TF_TFACTOR_0 1
|
||||
#define TF_TFACTOR_1 2
|
||||
#define TF_TFACTOR_2 3
|
||||
#define TF_TFACTOR_3 4
|
||||
#define TF_TFACTOR_4 5
|
||||
#define TF_TFACTOR_5 6
|
||||
#define TF_STATE_SIZE 7
|
||||
|
||||
#define TCL_CMD_0 0
|
||||
#define TCL_LIGHT_MODEL_CTL_0 1
|
||||
#define TCL_LIGHT_MODEL_CTL_1 2
|
||||
#define TCL_PER_LIGHT_CTL_0 3
|
||||
#define TCL_PER_LIGHT_CTL_1 4
|
||||
#define TCL_PER_LIGHT_CTL_2 5
|
||||
#define TCL_PER_LIGHT_CTL_3 6
|
||||
#define TCL_CMD_1 7
|
||||
#define TCL_UCP_VERT_BLEND_CTL 8
|
||||
#define TCL_STATE_SIZE 9
|
||||
|
||||
#define MSL_CMD_0 0
|
||||
#define MSL_MATRIX_SELECT_0 1
|
||||
#define MSL_MATRIX_SELECT_1 2
|
||||
#define MSL_MATRIX_SELECT_2 3
|
||||
#define MSL_MATRIX_SELECT_3 4
|
||||
#define MSL_MATRIX_SELECT_4 5
|
||||
#define MSL_STATE_SIZE 6
|
||||
|
||||
#define TCG_CMD_0 0
|
||||
#define TCG_TEX_PROC_CTL_2 1
|
||||
#define TCG_TEX_PROC_CTL_3 2
|
||||
#define TCG_TEX_PROC_CTL_0 3
|
||||
#define TCG_TEX_PROC_CTL_1 4
|
||||
#define TCG_TEX_CYL_WRAP_CTL 5
|
||||
#define TCG_STATE_SIZE 6
|
||||
|
||||
#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_CMD_1 17
|
||||
#define MTL_SHININESS 18
|
||||
#define MTL_STATE_SIZE 19
|
||||
|
||||
#define VAP_CMD_0 0
|
||||
#define VAP_SE_VAP_CNTL 1
|
||||
#define VAP_STATE_SIZE 2
|
||||
|
||||
/* Replaces a lot of packet info from radeon
|
||||
*/
|
||||
#define VTX_CMD_0 0
|
||||
#define VTX_VTXFMT_0 1
|
||||
#define VTX_VTXFMT_1 2
|
||||
#define VTX_TCL_OUTPUT_VTXFMT_0 3
|
||||
#define VTX_TCL_OUTPUT_VTXFMT_1 4
|
||||
#define VTX_CMD_1 5
|
||||
#define VTX_TCL_OUTPUT_COMPSEL 6
|
||||
#define VTX_CMD_2 7
|
||||
#define VTX_STATE_CNTL 8
|
||||
#define VTX_STATE_SIZE 9
|
||||
|
||||
|
||||
#define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\
|
||||
R200_VTX_COLOR_MASK)
|
||||
|
||||
#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_DCM 27
|
||||
#define LIT_SPOT_EXPONENT 28
|
||||
#define LIT_SPOT_CUTOFF 29
|
||||
#define LIT_SPECULAR_THRESH 30
|
||||
#define LIT_RANGE_CUTOFF 31 /* ? */
|
||||
#define LIT_RANGE_ATTEN 32 /* ? */
|
||||
#define LIT_STATE_SIZE 33
|
||||
|
||||
/* 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
|
||||
|
||||
/* CST - constant state
|
||||
*/
|
||||
#define CST_CMD_0 0
|
||||
#define CST_PP_CNTL_X 1
|
||||
#define CST_CMD_1 2
|
||||
#define CST_RB3D_DEPTHXY_OFFSET 3
|
||||
#define CST_CMD_2 4
|
||||
#define CST_RE_AUX_SCISSOR_CNTL 5
|
||||
#define CST_CMD_3 6
|
||||
#define CST_RE_SCISSOR_TL_0 7
|
||||
#define CST_RE_SCISSOR_BR_0 8
|
||||
#define CST_CMD_4 9
|
||||
#define CST_SE_VAP_CNTL_STATUS 10
|
||||
#define CST_CMD_5 11
|
||||
#define CST_RE_POINTSIZE 12
|
||||
#define CST_CMD_6 13
|
||||
#define CST_SE_TCL_INPUT_VTX_0 14
|
||||
#define CST_SE_TCL_INPUT_VTX_1 15
|
||||
#define CST_SE_TCL_INPUT_VTX_2 16
|
||||
#define CST_SE_TCL_INPUT_VTX_3 17
|
||||
#define CST_STATE_SIZE 18
|
||||
|
||||
|
||||
|
||||
|
||||
struct r200_hw_state {
|
||||
/* All state should be on one of these lists:
|
||||
*/
|
||||
struct r200_state_atom dirty; /* dirty list head placeholder */
|
||||
struct r200_state_atom clean; /* clean list head placeholder */
|
||||
|
||||
/* Hardware state, stored as cmdbuf commands:
|
||||
* -- Need to doublebuffer for
|
||||
* - reviving state after loss of context
|
||||
* - eliding noop statechange loops? (except line stipple count)
|
||||
*/
|
||||
struct r200_state_atom ctx;
|
||||
struct r200_state_atom set;
|
||||
struct r200_state_atom vte;
|
||||
struct r200_state_atom lin;
|
||||
struct r200_state_atom msk;
|
||||
struct r200_state_atom vpt;
|
||||
struct r200_state_atom vap;
|
||||
struct r200_state_atom vtx;
|
||||
struct r200_state_atom tcl;
|
||||
struct r200_state_atom msl;
|
||||
struct r200_state_atom tcg;
|
||||
struct r200_state_atom msc;
|
||||
struct r200_state_atom cst;
|
||||
struct r200_state_atom tam;
|
||||
struct r200_state_atom tf;
|
||||
struct r200_state_atom tex[2];
|
||||
struct r200_state_atom cube[2];
|
||||
struct r200_state_atom zbs;
|
||||
struct r200_state_atom mtl[2];
|
||||
struct r200_state_atom mat[5];
|
||||
struct r200_state_atom lit[8]; /* includes vec, scl commands */
|
||||
struct r200_state_atom ucp[6];
|
||||
struct r200_state_atom pix[6]; /* pixshader stages */
|
||||
struct r200_state_atom eye; /* eye pos */
|
||||
struct r200_state_atom grd; /* guard band clipping */
|
||||
struct r200_state_atom fog;
|
||||
struct r200_state_atom glt;
|
||||
};
|
||||
|
||||
struct r200_state {
|
||||
/* Derived state for internal purposes:
|
||||
*/
|
||||
struct r200_colorbuffer_state color;
|
||||
struct r200_depthbuffer_state depth;
|
||||
struct r200_pixel_state pixel;
|
||||
struct r200_scissor_state scissor;
|
||||
struct r200_stencilbuffer_state stencil;
|
||||
struct r200_stipple_state stipple;
|
||||
struct r200_texture_state texture;
|
||||
};
|
||||
|
||||
struct r200_texture {
|
||||
r200TexObj objects[R200_NR_TEX_HEAPS];
|
||||
r200TexObj swapped;
|
||||
|
||||
memHeap_t *heap[R200_NR_TEX_HEAPS];
|
||||
GLint age[R200_NR_TEX_HEAPS];
|
||||
|
||||
GLint numHeaps;
|
||||
};
|
||||
|
||||
/* Need refcounting on dma buffers:
|
||||
*/
|
||||
struct r200_dma_buffer {
|
||||
int refcount; /* the number of retained regions in buf */
|
||||
drmBufPtr buf;
|
||||
};
|
||||
|
||||
#define GET_START(rvb) (rmesa->r200Screen->agp_buffer_offset + \
|
||||
(rvb)->address - rmesa->dma.buf0_address + \
|
||||
(rvb)->start)
|
||||
|
||||
/* A retained region, eg vertices for indexed vertices.
|
||||
*/
|
||||
struct r200_dma_region {
|
||||
struct r200_dma_buffer *buf;
|
||||
char *address; /* == buf->address */
|
||||
int start, end, ptr; /* offsets from start of buf */
|
||||
int aos_start;
|
||||
int aos_stride;
|
||||
int aos_size;
|
||||
};
|
||||
|
||||
|
||||
struct r200_dma {
|
||||
/* Active dma region. Allocations for vertices and retained
|
||||
* regions come from here. Also used for emitting random vertices,
|
||||
* these may be flushed by calling flush_current();
|
||||
*/
|
||||
struct r200_dma_region current;
|
||||
|
||||
void (*flush)( r200ContextPtr );
|
||||
|
||||
char *buf0_address; /* start of buf[0], for index calcs */
|
||||
GLuint nr_released_bufs; /* flush after so many buffers released */
|
||||
};
|
||||
|
||||
struct r200_dri_mirror {
|
||||
__DRIcontextPrivate *context; /* DRI context */
|
||||
__DRIscreenPrivate *screen; /* DRI screen */
|
||||
__DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */
|
||||
|
||||
drmContext hwContext;
|
||||
drmLock *hwLock;
|
||||
int fd;
|
||||
int drmMinor;
|
||||
};
|
||||
|
||||
|
||||
#define R200_CMD_BUF_SZ (8*1024)
|
||||
|
||||
struct r200_store {
|
||||
GLuint statenr;
|
||||
GLuint primnr;
|
||||
char cmd_buf[R200_CMD_BUF_SZ];
|
||||
int cmd_used;
|
||||
int elts_start;
|
||||
};
|
||||
|
||||
|
||||
/* r200_tcl.c
|
||||
*/
|
||||
struct r200_tcl_info {
|
||||
GLuint vertex_format;
|
||||
GLint last_offset;
|
||||
GLuint hw_primitive;
|
||||
|
||||
struct r200_dma_region *aos_components[8];
|
||||
GLuint nr_aos_components;
|
||||
|
||||
GLuint *Elts;
|
||||
|
||||
struct r200_dma_region indexed_verts;
|
||||
struct r200_dma_region obj;
|
||||
struct r200_dma_region rgba;
|
||||
struct r200_dma_region spec;
|
||||
struct r200_dma_region fog;
|
||||
struct r200_dma_region tex[R200_MAX_TEXTURE_UNITS];
|
||||
struct r200_dma_region norm;
|
||||
};
|
||||
|
||||
|
||||
/* r200_swtcl.c
|
||||
*/
|
||||
struct r200_swtcl_info {
|
||||
GLuint SetupIndex;
|
||||
GLuint SetupNewInputs;
|
||||
GLuint RenderIndex;
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_stride_shift;
|
||||
GLuint vertex_format;
|
||||
char *verts;
|
||||
|
||||
/* Fallback rasterization functions
|
||||
*/
|
||||
r200_point_func draw_point;
|
||||
r200_line_func draw_line;
|
||||
r200_tri_func draw_tri;
|
||||
|
||||
GLuint hw_primitive;
|
||||
GLenum render_primitive;
|
||||
GLuint numverts;
|
||||
|
||||
struct r200_dma_region indexed_verts;
|
||||
};
|
||||
|
||||
|
||||
struct r200_ioctl {
|
||||
GLuint vertex_offset;
|
||||
GLuint vertex_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define R200_MAX_PRIMS 64
|
||||
|
||||
|
||||
/* Want to keep a cache of these around. Each is parameterized by
|
||||
* only a single value which has only a small range. Only expect a
|
||||
* few, so just rescan the list each time?
|
||||
*/
|
||||
struct dynfn {
|
||||
struct dynfn *next, *prev;
|
||||
int key[2];
|
||||
char *code;
|
||||
};
|
||||
|
||||
struct dfn_lists {
|
||||
struct dynfn Vertex2f;
|
||||
struct dynfn Vertex2fv;
|
||||
struct dynfn Vertex3f;
|
||||
struct dynfn Vertex3fv;
|
||||
struct dynfn Color4ub;
|
||||
struct dynfn Color4ubv;
|
||||
struct dynfn Color3ub;
|
||||
struct dynfn Color3ubv;
|
||||
struct dynfn Color4f;
|
||||
struct dynfn Color4fv;
|
||||
struct dynfn Color3f;
|
||||
struct dynfn Color3fv;
|
||||
struct dynfn SecondaryColor3ubEXT;
|
||||
struct dynfn SecondaryColor3ubvEXT;
|
||||
struct dynfn SecondaryColor3fEXT;
|
||||
struct dynfn SecondaryColor3fvEXT;
|
||||
struct dynfn Normal3f;
|
||||
struct dynfn Normal3fv;
|
||||
struct dynfn TexCoord2f;
|
||||
struct dynfn TexCoord2fv;
|
||||
struct dynfn TexCoord1f;
|
||||
struct dynfn TexCoord1fv;
|
||||
struct dynfn MultiTexCoord2fARB;
|
||||
struct dynfn MultiTexCoord2fvARB;
|
||||
struct dynfn MultiTexCoord1fARB;
|
||||
struct dynfn MultiTexCoord1fvARB;
|
||||
};
|
||||
|
||||
struct _vb;
|
||||
|
||||
struct dfn_generators {
|
||||
struct dynfn *(*Vertex2f)( GLcontext *, const int * );
|
||||
struct dynfn *(*Vertex2fv)( GLcontext *, const int * );
|
||||
struct dynfn *(*Vertex3f)( GLcontext *, const int * );
|
||||
struct dynfn *(*Vertex3fv)( GLcontext *, const int * );
|
||||
struct dynfn *(*Color4ub)( GLcontext *, const int * );
|
||||
struct dynfn *(*Color4ubv)( GLcontext *, const int * );
|
||||
struct dynfn *(*Color3ub)( GLcontext *, const int * );
|
||||
struct dynfn *(*Color3ubv)( GLcontext *, const int * );
|
||||
struct dynfn *(*Color4f)( GLcontext *, const int * );
|
||||
struct dynfn *(*Color4fv)( GLcontext *, const int * );
|
||||
struct dynfn *(*Color3f)( GLcontext *, const int * );
|
||||
struct dynfn *(*Color3fv)( GLcontext *, const int * );
|
||||
struct dynfn *(*SecondaryColor3ubEXT)( GLcontext *, const int * );
|
||||
struct dynfn *(*SecondaryColor3ubvEXT)( GLcontext *, const int * );
|
||||
struct dynfn *(*SecondaryColor3fEXT)( GLcontext *, const int * );
|
||||
struct dynfn *(*SecondaryColor3fvEXT)( GLcontext *, const int * );
|
||||
struct dynfn *(*Normal3f)( GLcontext *, const int * );
|
||||
struct dynfn *(*Normal3fv)( GLcontext *, const int * );
|
||||
struct dynfn *(*TexCoord2f)( GLcontext *, const int * );
|
||||
struct dynfn *(*TexCoord2fv)( GLcontext *, const int * );
|
||||
struct dynfn *(*TexCoord1f)( GLcontext *, const int * );
|
||||
struct dynfn *(*TexCoord1fv)( GLcontext *, const int * );
|
||||
struct dynfn *(*MultiTexCoord2fARB)( GLcontext *, const int * );
|
||||
struct dynfn *(*MultiTexCoord2fvARB)( GLcontext *, const int * );
|
||||
struct dynfn *(*MultiTexCoord1fARB)( GLcontext *, const int * );
|
||||
struct dynfn *(*MultiTexCoord1fvARB)( GLcontext *, const int * );
|
||||
};
|
||||
|
||||
|
||||
struct r200_vb {
|
||||
/* Keep these first: referenced from codegen templates:
|
||||
*/
|
||||
GLint counter, initial_counter;
|
||||
GLint *dmaptr;
|
||||
void (*notify)( void );
|
||||
GLint vertex_size;
|
||||
|
||||
/* A maximum total of 15 elements per vertex: 3 floats for position, 3
|
||||
* floats for normal, 4 floats for color, 4 bytes for secondary color,
|
||||
* 2 floats for each texture unit (4 floats total).
|
||||
*
|
||||
* As soon as the 3rd TMU is supported or cube maps (or 3D textures) are
|
||||
* supported, this value will grow.
|
||||
*
|
||||
* The position data is never actually stored here, so 3 elements could be
|
||||
* trimmed out of the buffer.
|
||||
*/
|
||||
union { float f; int i; r200_color_t color; } vertex[15];
|
||||
|
||||
GLfloat *normalptr;
|
||||
GLfloat *floatcolorptr;
|
||||
r200_color_t *colorptr;
|
||||
GLfloat *floatspecptr;
|
||||
r200_color_t *specptr;
|
||||
GLfloat *texcoordptr[2];
|
||||
|
||||
GLcontext *context; /* current context : Single thread only! */
|
||||
};
|
||||
|
||||
struct r200_prim {
|
||||
GLuint start;
|
||||
GLuint end;
|
||||
GLuint prim;
|
||||
};
|
||||
|
||||
struct r200_vbinfo {
|
||||
GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */
|
||||
GLuint primflags;
|
||||
GLboolean enabled; /* R200_NO_VTXFMT//R200_NO_TCL env vars */
|
||||
GLboolean installed;
|
||||
GLboolean fell_back;
|
||||
GLboolean recheck;
|
||||
GLint initial_counter;
|
||||
GLint nrverts;
|
||||
GLuint vtxfmt_0, vtxfmt_1;
|
||||
|
||||
GLuint installed_vertex_format;
|
||||
GLuint installed_color_3f_sz;
|
||||
|
||||
struct r200_prim primlist[R200_MAX_PRIMS];
|
||||
int nrprims;
|
||||
|
||||
struct dfn_lists dfn_cache;
|
||||
struct dfn_generators codegen;
|
||||
GLvertexformat vtxfmt;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct r200_context {
|
||||
GLcontext *glCtx; /* Mesa context */
|
||||
|
||||
/* Driver and hardware state management
|
||||
*/
|
||||
struct r200_hw_state hw;
|
||||
struct r200_state state;
|
||||
|
||||
/* Texture object bookkeeping
|
||||
*/
|
||||
struct r200_texture texture;
|
||||
|
||||
|
||||
/* Rasterization and vertex state:
|
||||
*/
|
||||
GLuint TclFallback;
|
||||
GLuint Fallback;
|
||||
GLuint NewGLState;
|
||||
|
||||
|
||||
/* Temporaries for translating away float colors:
|
||||
*/
|
||||
struct gl_client_array UbyteColor;
|
||||
struct gl_client_array UbyteSecondaryColor;
|
||||
|
||||
/* Vertex buffers
|
||||
*/
|
||||
struct r200_ioctl ioctl;
|
||||
struct r200_dma dma;
|
||||
struct r200_store store;
|
||||
|
||||
/* Page flipping
|
||||
*/
|
||||
GLuint doPageFlip;
|
||||
|
||||
/* Busy waiting
|
||||
*/
|
||||
GLuint do_usleeps;
|
||||
GLuint do_irqs;
|
||||
GLuint irqsEmitted;
|
||||
drmRadeonIrqWait iw;
|
||||
|
||||
/* Clientdata textures;
|
||||
*/
|
||||
GLuint prefer_agp_client_texturing;
|
||||
|
||||
/* Drawable, cliprect and scissor information
|
||||
*/
|
||||
GLuint numClipRects; /* Cliprects for the draw buffer */
|
||||
XF86DRIClipRectPtr pClipRects;
|
||||
unsigned int lastStamp;
|
||||
GLboolean lost_context;
|
||||
r200ScreenPtr r200Screen; /* Screen private DRI data */
|
||||
RADEONSAREAPrivPtr sarea; /* Private SAREA data */
|
||||
|
||||
/* TCL stuff
|
||||
*/
|
||||
GLmatrix TexGenMatrix[R200_MAX_TEXTURE_UNITS];
|
||||
GLboolean recheck_texgen[R200_MAX_TEXTURE_UNITS];
|
||||
GLboolean TexGenNeedNormals[R200_MAX_TEXTURE_UNITS];
|
||||
GLuint TexMatEnabled;
|
||||
GLuint TexMatCompSel;
|
||||
GLuint TexGenEnabled;
|
||||
GLuint TexGenInputs;
|
||||
GLuint TexGenCompSel;
|
||||
GLmatrix tmpmat;
|
||||
|
||||
/* VBI
|
||||
*/
|
||||
GLuint vbl_seq;
|
||||
|
||||
/* r200_tcl.c
|
||||
*/
|
||||
struct r200_tcl_info tcl;
|
||||
|
||||
/* r200_swtcl.c
|
||||
*/
|
||||
struct r200_swtcl_info swtcl;
|
||||
|
||||
/* r200_vtxfmt.c
|
||||
*/
|
||||
struct r200_vbinfo vb;
|
||||
|
||||
/* Mirrors of some DRI state
|
||||
*/
|
||||
struct r200_dri_mirror dri;
|
||||
};
|
||||
|
||||
#define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx))
|
||||
|
||||
|
||||
static __inline GLuint r200PackColor( 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;
|
||||
}
|
||||
}
|
||||
|
||||
#define R200_OLD_PACKETS 0
|
||||
|
||||
|
||||
extern void r200DestroyContext( __DRIcontextPrivate *driContextPriv );
|
||||
extern GLboolean r200CreateContext( const __GLcontextModes *glVisual,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate);
|
||||
extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv );
|
||||
extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
__DRIdrawablePrivate *driReadPriv );
|
||||
extern GLboolean r200UnbindContext( __DRIcontextPrivate *driContextPriv );
|
||||
|
||||
/* ================================================================
|
||||
* Debugging:
|
||||
*/
|
||||
#define DO_DEBUG 1
|
||||
|
||||
#if DO_DEBUG
|
||||
extern int R200_DEBUG;
|
||||
#else
|
||||
#define R200_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
|
||||
#define DEBUG_SYNC 0x1000
|
||||
#define DEBUG_PIXEL 0x2000
|
||||
#define DEBUG_MEMORY 0x4000
|
||||
|
||||
#endif
|
||||
#endif /* __R200_CONTEXT_H__ */
|
||||
934
src/mesa/drivers/dri/r200/r200_ioctl.c
Normal file
934
src/mesa/drivers/dri/r200/r200_ioctl.c
Normal file
@@ -0,0 +1,934 @@
|
||||
/* $XFree86$ */
|
||||
/*
|
||||
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
|
||||
|
||||
The Weather Channel (TM) funded Tungsten Graphics to develop the
|
||||
initial release of the Radeon 8500 driver under the XFree86 license.
|
||||
This notice must be preserved.
|
||||
|
||||
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 THE COPYRIGHT OWNER(S) 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:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "context.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#include "r200_context.h"
|
||||
#include "r200_state.h"
|
||||
#include "r200_ioctl.h"
|
||||
#include "r200_tcl.h"
|
||||
#include "r200_sanity.h"
|
||||
#include "radeon_reg.h"
|
||||
|
||||
#include <unistd.h> /* for usleep() */
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#define R200_TIMEOUT 512
|
||||
#define R200_IDLE_RETRY 16
|
||||
|
||||
|
||||
static void do_usleep( int nr, const char *caller )
|
||||
{
|
||||
//if (1) fprintf(stderr, "usleep %d in %s\n", nr, caller );
|
||||
if (1) usleep( nr );
|
||||
}
|
||||
|
||||
static void r200WaitForIdle( r200ContextPtr rmesa );
|
||||
|
||||
|
||||
int r200FlushCmdBufLocked( r200ContextPtr rmesa, const char * caller )
|
||||
{
|
||||
int ret, i;
|
||||
drmRadeonCmdBuffer cmd;
|
||||
|
||||
if (R200_DEBUG & DEBUG_IOCTL) {
|
||||
fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
|
||||
|
||||
if (0 & R200_DEBUG & DEBUG_VERBOSE)
|
||||
for (i = 0 ; i < rmesa->store.cmd_used ; i += 4 )
|
||||
fprintf(stderr, "%d: %x\n", i/4,
|
||||
*(int *)(&rmesa->store.cmd_buf[i]));
|
||||
}
|
||||
|
||||
if (R200_DEBUG & DEBUG_DMA)
|
||||
fprintf(stderr, "%s: Releasing %d buffers\n", __FUNCTION__,
|
||||
rmesa->dma.nr_released_bufs);
|
||||
|
||||
|
||||
if (R200_DEBUG & DEBUG_SANITY) {
|
||||
if (rmesa->state.scissor.enabled)
|
||||
ret = r200SanityCmdBuffer( rmesa,
|
||||
rmesa->state.scissor.numClipRects,
|
||||
rmesa->state.scissor.pClipRects);
|
||||
else
|
||||
ret = r200SanityCmdBuffer( rmesa,
|
||||
rmesa->numClipRects,
|
||||
rmesa->pClipRects);
|
||||
if (ret) {
|
||||
fprintf(stderr, "drmSanityCommandWrite: %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (R200_DEBUG & DEBUG_MEMORY) {
|
||||
if (!r200ValidateTexObjs( rmesa )) {
|
||||
fprintf(stderr, " -- tex memory is inconsistent - expect mangled textures\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cmd.bufsz = rmesa->store.cmd_used;
|
||||
cmd.buf = rmesa->store.cmd_buf;
|
||||
|
||||
if (rmesa->state.scissor.enabled) {
|
||||
cmd.nbox = rmesa->state.scissor.numClipRects;
|
||||
cmd.boxes = (drmClipRect *)rmesa->state.scissor.pClipRects;
|
||||
} else {
|
||||
cmd.nbox = rmesa->numClipRects;
|
||||
cmd.boxes = (drmClipRect *)rmesa->pClipRects;
|
||||
}
|
||||
|
||||
ret = drmCommandWrite( rmesa->dri.fd,
|
||||
DRM_RADEON_CMDBUF,
|
||||
&cmd, sizeof(cmd) );
|
||||
|
||||
if (ret)
|
||||
fprintf(stderr, "drmCommandWrite: %d\n", ret);
|
||||
|
||||
if (R200_DEBUG & DEBUG_SYNC) {
|
||||
fprintf(stderr, "\nSyncing in %s\n\n", __FUNCTION__);
|
||||
r200WaitForIdleLocked( rmesa );
|
||||
}
|
||||
|
||||
|
||||
out:
|
||||
rmesa->store.primnr = 0;
|
||||
rmesa->store.statenr = 0;
|
||||
rmesa->store.cmd_used = 0;
|
||||
rmesa->dma.nr_released_bufs = 0;
|
||||
/* rmesa->lost_context = 0; */
|
||||
rmesa->lost_context = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Note: does not emit any commands to avoid recursion on
|
||||
* r200AllocCmdBuf.
|
||||
*/
|
||||
void r200FlushCmdBuf( r200ContextPtr rmesa, const char *caller )
|
||||
{
|
||||
int ret;
|
||||
|
||||
LOCK_HARDWARE( rmesa );
|
||||
|
||||
ret = r200FlushCmdBufLocked( rmesa, caller );
|
||||
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
|
||||
if (ret) {
|
||||
fprintf(stderr, "drmRadeonCmdBuffer: %d (exiting)\n", ret);
|
||||
exit(ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* =============================================================
|
||||
* Hardware vertex buffer handling
|
||||
*/
|
||||
|
||||
|
||||
void r200RefillCurrentDmaRegion( r200ContextPtr rmesa )
|
||||
{
|
||||
struct r200_dma_buffer *dmabuf;
|
||||
int fd = rmesa->dri.fd;
|
||||
int index = 0;
|
||||
int size = 0;
|
||||
drmDMAReq dma;
|
||||
int ret;
|
||||
|
||||
if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
if (rmesa->dma.flush) {
|
||||
rmesa->dma.flush( rmesa );
|
||||
}
|
||||
|
||||
if (rmesa->dma.current.buf)
|
||||
r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
|
||||
|
||||
if (rmesa->dma.nr_released_bufs > 4)
|
||||
r200FlushCmdBuf( rmesa, __FUNCTION__ );
|
||||
|
||||
dma.context = rmesa->dri.hwContext;
|
||||
dma.send_count = 0;
|
||||
dma.send_list = NULL;
|
||||
dma.send_sizes = NULL;
|
||||
dma.flags = 0;
|
||||
dma.request_count = 1;
|
||||
dma.request_size = RADEON_BUFFER_SIZE;
|
||||
dma.request_list = &index;
|
||||
dma.request_sizes = &size;
|
||||
dma.granted_count = 0;
|
||||
|
||||
LOCK_HARDWARE(rmesa); /* no need to validate */
|
||||
|
||||
while (1) {
|
||||
ret = drmDMA( fd, &dma );
|
||||
if (ret == 0)
|
||||
break;
|
||||
|
||||
if (rmesa->dma.nr_released_bufs) {
|
||||
r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
|
||||
}
|
||||
|
||||
if (rmesa->do_usleeps) {
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
do_usleep(1, __FUNCTION__);
|
||||
LOCK_HARDWARE( rmesa );
|
||||
}
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE(rmesa);
|
||||
|
||||
if (R200_DEBUG & DEBUG_DMA)
|
||||
fprintf(stderr, "Allocated buffer %d\n", index);
|
||||
|
||||
dmabuf = CALLOC_STRUCT( r200_dma_buffer );
|
||||
dmabuf->buf = &rmesa->r200Screen->buffers->list[index];
|
||||
dmabuf->refcount = 1;
|
||||
|
||||
rmesa->dma.current.buf = dmabuf;
|
||||
rmesa->dma.current.address = dmabuf->buf->address;
|
||||
rmesa->dma.current.end = dmabuf->buf->total;
|
||||
rmesa->dma.current.start = 0;
|
||||
rmesa->dma.current.ptr = 0;
|
||||
}
|
||||
|
||||
void r200ReleaseDmaRegion( r200ContextPtr rmesa,
|
||||
struct r200_dma_region *region,
|
||||
const char *caller )
|
||||
{
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
|
||||
|
||||
if (!region->buf)
|
||||
return;
|
||||
|
||||
if (rmesa->dma.flush)
|
||||
rmesa->dma.flush( rmesa );
|
||||
|
||||
if (--region->buf->refcount == 0) {
|
||||
drmRadeonCmdHeader *cmd;
|
||||
|
||||
if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
|
||||
fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
|
||||
region->buf->buf->idx);
|
||||
|
||||
cmd = (drmRadeonCmdHeader *)r200AllocCmdBuf( rmesa, sizeof(*cmd),
|
||||
__FUNCTION__ );
|
||||
cmd->dma.cmd_type = RADEON_CMD_DMA_DISCARD;
|
||||
cmd->dma.buf_idx = region->buf->buf->idx;
|
||||
FREE(region->buf);
|
||||
rmesa->dma.nr_released_bufs++;
|
||||
}
|
||||
|
||||
region->buf = 0;
|
||||
region->start = 0;
|
||||
}
|
||||
|
||||
/* Allocates a region from rmesa->dma.current. If there isn't enough
|
||||
* space in current, grab a new buffer (and discard what was left of current)
|
||||
*/
|
||||
void r200AllocDmaRegion( r200ContextPtr rmesa,
|
||||
struct r200_dma_region *region,
|
||||
int bytes,
|
||||
int alignment )
|
||||
{
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
|
||||
|
||||
if (rmesa->dma.flush)
|
||||
rmesa->dma.flush( rmesa );
|
||||
|
||||
if (region->buf)
|
||||
r200ReleaseDmaRegion( rmesa, region, __FUNCTION__ );
|
||||
|
||||
alignment--;
|
||||
rmesa->dma.current.start = rmesa->dma.current.ptr =
|
||||
(rmesa->dma.current.ptr + alignment) & ~alignment;
|
||||
|
||||
if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end )
|
||||
r200RefillCurrentDmaRegion( rmesa );
|
||||
|
||||
region->start = rmesa->dma.current.start;
|
||||
region->ptr = rmesa->dma.current.start;
|
||||
region->end = rmesa->dma.current.start + bytes;
|
||||
region->address = rmesa->dma.current.address;
|
||||
region->buf = rmesa->dma.current.buf;
|
||||
region->buf->refcount++;
|
||||
|
||||
rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
|
||||
rmesa->dma.current.start =
|
||||
rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;
|
||||
}
|
||||
|
||||
void r200AllocDmaRegionVerts( r200ContextPtr rmesa,
|
||||
struct r200_dma_region *region,
|
||||
int numverts,
|
||||
int vertsize,
|
||||
int alignment )
|
||||
{
|
||||
r200AllocDmaRegion( rmesa, region, vertsize * numverts, alignment );
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
* SwapBuffers with client-side throttling
|
||||
*/
|
||||
|
||||
static GLuint r200GetLastFrame(r200ContextPtr rmesa)
|
||||
{
|
||||
drmRadeonGetParam gp;
|
||||
int ret;
|
||||
GLuint frame;
|
||||
|
||||
gp.param = RADEON_PARAM_LAST_FRAME;
|
||||
gp.value = (int *)&frame;
|
||||
ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_GETPARAM,
|
||||
&gp, sizeof(gp) );
|
||||
if ( ret ) {
|
||||
fprintf( stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, ret );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
static void r200EmitIrqLocked( r200ContextPtr rmesa )
|
||||
{
|
||||
drmRadeonIrqEmit ie;
|
||||
int ret;
|
||||
|
||||
ie.irq_seq = &rmesa->iw.irq_seq;
|
||||
ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_IRQ_EMIT,
|
||||
&ie, sizeof(ie) );
|
||||
if ( ret ) {
|
||||
fprintf( stderr, "%s: drmRadeonIrqEmit: %d\n", __FUNCTION__, ret );
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void r200WaitIrq( r200ContextPtr rmesa )
|
||||
{
|
||||
int ret;
|
||||
|
||||
do {
|
||||
ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_IRQ_WAIT,
|
||||
&rmesa->iw, sizeof(rmesa->iw) );
|
||||
} while (ret && (errno == EINTR || errno == EAGAIN));
|
||||
|
||||
if ( ret ) {
|
||||
fprintf( stderr, "%s: drmRadeonIrqWait: %d\n", __FUNCTION__, ret );
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void r200WaitForFrameCompletion( r200ContextPtr rmesa )
|
||||
{
|
||||
RADEONSAREAPrivPtr sarea = rmesa->sarea;
|
||||
|
||||
if (rmesa->do_irqs) {
|
||||
if (r200GetLastFrame(rmesa) < sarea->last_frame) {
|
||||
if (!rmesa->irqsEmitted) {
|
||||
while (r200GetLastFrame (rmesa) < sarea->last_frame)
|
||||
;
|
||||
}
|
||||
else {
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
r200WaitIrq( rmesa );
|
||||
LOCK_HARDWARE( rmesa );
|
||||
}
|
||||
rmesa->irqsEmitted = 10;
|
||||
}
|
||||
|
||||
if (rmesa->irqsEmitted) {
|
||||
r200EmitIrqLocked( rmesa );
|
||||
rmesa->irqsEmitted--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (r200GetLastFrame (rmesa) < sarea->last_frame) {
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
if (rmesa->do_usleeps)
|
||||
do_usleep(1, __FUNCTION__);
|
||||
LOCK_HARDWARE( rmesa );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Copy the back color buffer to the front color buffer.
|
||||
*/
|
||||
void r200CopyBuffer( const __DRIdrawablePrivate *dPriv )
|
||||
{
|
||||
r200ContextPtr rmesa;
|
||||
GLint nbox, i, ret;
|
||||
|
||||
assert(dPriv);
|
||||
assert(dPriv->driContextPriv);
|
||||
assert(dPriv->driContextPriv->driverPrivate);
|
||||
|
||||
rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
|
||||
if ( R200_DEBUG & DEBUG_IOCTL ) {
|
||||
fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, rmesa->glCtx );
|
||||
}
|
||||
|
||||
R200_FIREVERTICES( rmesa );
|
||||
|
||||
LOCK_HARDWARE( rmesa );
|
||||
|
||||
|
||||
/* Throttle the frame rate -- only allow one pending swap buffers
|
||||
* request at a time.
|
||||
*/
|
||||
r200WaitForFrameCompletion( rmesa );
|
||||
|
||||
r200WaitForVBlank( rmesa );
|
||||
|
||||
nbox = rmesa->dri.drawable->numClipRects; /* must be in locked region */
|
||||
|
||||
for ( i = 0 ; i < nbox ; ) {
|
||||
GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS , nbox );
|
||||
XF86DRIClipRectPtr box = rmesa->dri.drawable->pClipRects;
|
||||
XF86DRIClipRectPtr b = rmesa->sarea->boxes;
|
||||
GLint n = 0;
|
||||
|
||||
for ( ; i < nr ; i++ ) {
|
||||
*b++ = box[i];
|
||||
n++;
|
||||
}
|
||||
rmesa->sarea->nbox = n;
|
||||
|
||||
ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_SWAP );
|
||||
|
||||
if ( ret ) {
|
||||
fprintf( stderr, "DRM_R200_SWAP_BUFFERS: return = %d\n", ret );
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
rmesa->lost_context = 1;
|
||||
}
|
||||
|
||||
void r200PageFlip( const __DRIdrawablePrivate *dPriv )
|
||||
{
|
||||
r200ContextPtr rmesa;
|
||||
GLint ret;
|
||||
|
||||
assert(dPriv);
|
||||
assert(dPriv->driContextPriv);
|
||||
assert(dPriv->driContextPriv->driverPrivate);
|
||||
|
||||
rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
|
||||
if ( R200_DEBUG & DEBUG_IOCTL ) {
|
||||
fprintf(stderr, "%s: pfCurrentPage: %d\n", __FUNCTION__,
|
||||
rmesa->sarea->pfCurrentPage);
|
||||
}
|
||||
|
||||
R200_FIREVERTICES( rmesa );
|
||||
LOCK_HARDWARE( rmesa );
|
||||
|
||||
if (!rmesa->dri.drawable->numClipRects) {
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
usleep( 10000 ); /* throttle invisible client 10ms */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Need to do this for the perf box placement:
|
||||
*/
|
||||
{
|
||||
XF86DRIClipRectPtr box = rmesa->dri.drawable->pClipRects;
|
||||
XF86DRIClipRectPtr b = rmesa->sarea->boxes;
|
||||
b[0] = box[0];
|
||||
rmesa->sarea->nbox = 1;
|
||||
}
|
||||
|
||||
/* Throttle the frame rate -- only allow a few pending swap buffers
|
||||
* request at a time.
|
||||
*/
|
||||
r200WaitForFrameCompletion( rmesa );
|
||||
|
||||
r200WaitForVBlank( rmesa );
|
||||
|
||||
ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_FLIP );
|
||||
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
|
||||
if ( ret ) {
|
||||
fprintf( stderr, "DRM_R200_FLIP: return = %d\n", ret );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if ( rmesa->sarea->pfCurrentPage == 1 ) {
|
||||
rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
|
||||
rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
|
||||
} else {
|
||||
rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
|
||||
rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
|
||||
}
|
||||
|
||||
R200_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;
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Buffer clear
|
||||
*/
|
||||
static void r200Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
|
||||
GLint cx, GLint cy, GLint cw, GLint ch )
|
||||
{
|
||||
r200ContextPtr rmesa = R200_CONTEXT(ctx);
|
||||
__DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
|
||||
GLuint flags = 0;
|
||||
GLuint color_mask = 0;
|
||||
GLint ret, i;
|
||||
|
||||
if ( R200_DEBUG & DEBUG_IOCTL ) {
|
||||
fprintf( stderr, "%s: all=%d cx=%d cy=%d cw=%d ch=%d\n",
|
||||
__FUNCTION__, all, cx, cy, cw, ch );
|
||||
}
|
||||
|
||||
{
|
||||
LOCK_HARDWARE( rmesa );
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
if ( dPriv->numClipRects == 0 )
|
||||
return;
|
||||
}
|
||||
|
||||
r200EmitState( rmesa );
|
||||
|
||||
/* Need to cope with lostcontext here as kernel relies on
|
||||
* some residual state:
|
||||
*/
|
||||
R200_FIREVERTICES( rmesa );
|
||||
|
||||
if ( mask & DD_FRONT_LEFT_BIT ) {
|
||||
flags |= RADEON_FRONT;
|
||||
color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
|
||||
mask &= ~DD_FRONT_LEFT_BIT;
|
||||
}
|
||||
|
||||
if ( mask & DD_BACK_LEFT_BIT ) {
|
||||
flags |= RADEON_BACK;
|
||||
color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
|
||||
mask &= ~DD_BACK_LEFT_BIT;
|
||||
}
|
||||
|
||||
if ( mask & DD_DEPTH_BIT ) {
|
||||
if ( ctx->Depth.Mask ) flags |= RADEON_DEPTH; /* FIXME: ??? */
|
||||
mask &= ~DD_DEPTH_BIT;
|
||||
}
|
||||
|
||||
if ( (mask & DD_STENCIL_BIT) && rmesa->state.stencil.hwBuffer ) {
|
||||
flags |= RADEON_STENCIL;
|
||||
mask &= ~DD_STENCIL_BIT;
|
||||
}
|
||||
|
||||
if ( mask )
|
||||
_swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
|
||||
|
||||
if ( !flags )
|
||||
return;
|
||||
|
||||
/* Flip top to bottom */
|
||||
cx += dPriv->x;
|
||||
cy = dPriv->y + dPriv->h - cy - ch;
|
||||
|
||||
LOCK_HARDWARE( rmesa );
|
||||
|
||||
/* Throttle the number of clear ioctls we do.
|
||||
*/
|
||||
while ( 1 ) {
|
||||
drmRadeonGetParam gp;
|
||||
int ret;
|
||||
int clear;
|
||||
|
||||
gp.param = RADEON_PARAM_LAST_CLEAR;
|
||||
gp.value = (int *)&clear;
|
||||
ret = drmCommandWriteRead( rmesa->dri.fd,
|
||||
DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
|
||||
|
||||
if ( ret ) {
|
||||
fprintf( stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, ret );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Clear throttling needs more thought.
|
||||
*/
|
||||
if ( rmesa->sarea->last_clear - clear <= 25 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (rmesa->do_usleeps) {
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
do_usleep(1, __FUNCTION__);
|
||||
LOCK_HARDWARE( rmesa );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for ( i = 0 ; i < dPriv->numClipRects ; ) {
|
||||
GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, dPriv->numClipRects );
|
||||
XF86DRIClipRectPtr box = dPriv->pClipRects;
|
||||
XF86DRIClipRectPtr b = rmesa->sarea->boxes;
|
||||
drmRadeonClearType clear;
|
||||
drmRadeonClearRect depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
|
||||
GLint n = 0;
|
||||
|
||||
if ( !all ) {
|
||||
for ( ; i < nr ; i++ ) {
|
||||
GLint x = box[i].x1;
|
||||
GLint y = box[i].y1;
|
||||
GLint w = box[i].x2 - x;
|
||||
GLint h = box[i].y2 - y;
|
||||
|
||||
if ( x < cx ) w -= cx - x, x = cx;
|
||||
if ( y < cy ) h -= cy - y, y = cy;
|
||||
if ( x + w > cx + cw ) w = cx + cw - x;
|
||||
if ( y + h > cy + ch ) h = cy + ch - y;
|
||||
if ( w <= 0 ) continue;
|
||||
if ( h <= 0 ) continue;
|
||||
|
||||
b->x1 = x;
|
||||
b->y1 = y;
|
||||
b->x2 = x + w;
|
||||
b->y2 = y + h;
|
||||
b++;
|
||||
n++;
|
||||
}
|
||||
} else {
|
||||
for ( ; i < nr ; i++ ) {
|
||||
*b++ = box[i];
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
rmesa->sarea->nbox = n;
|
||||
|
||||
clear.flags = flags;
|
||||
clear.clear_color = rmesa->state.color.clear;
|
||||
clear.clear_depth = 0; /* not used */
|
||||
clear.color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
|
||||
clear.depth_mask = rmesa->state.stencil.clear;
|
||||
clear.depth_boxes = depth_boxes;
|
||||
|
||||
n--;
|
||||
b = rmesa->sarea->boxes;
|
||||
for ( ; n >= 0 ; n-- ) {
|
||||
depth_boxes[n].f[RADEON_CLEAR_X1] = (float)b[n].x1;
|
||||
depth_boxes[n].f[RADEON_CLEAR_Y1] = (float)b[n].y1;
|
||||
depth_boxes[n].f[RADEON_CLEAR_X2] = (float)b[n].x2;
|
||||
depth_boxes[n].f[RADEON_CLEAR_Y2] = (float)b[n].y2;
|
||||
depth_boxes[n].f[RADEON_CLEAR_DEPTH] = ctx->Depth.Clear;
|
||||
}
|
||||
|
||||
ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_CLEAR,
|
||||
&clear, sizeof(drmRadeonClearType));
|
||||
|
||||
|
||||
if ( ret ) {
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
fprintf( stderr, "DRM_RADEON_CLEAR: return = %d\n", ret );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
rmesa->lost_context = 1;
|
||||
}
|
||||
|
||||
|
||||
void r200WaitForIdleLocked( r200ContextPtr rmesa )
|
||||
{
|
||||
int ret;
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_CP_IDLE);
|
||||
if (ret)
|
||||
do_usleep( 1, __FUNCTION__ );
|
||||
} while (ret && ++i < 100);
|
||||
|
||||
if ( ret < 0 ) {
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
fprintf( stderr, "Error: R200 timed out... exiting\n" );
|
||||
exit( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
static void r200WaitForIdle( r200ContextPtr rmesa )
|
||||
{
|
||||
LOCK_HARDWARE(rmesa);
|
||||
r200WaitForIdleLocked( rmesa );
|
||||
UNLOCK_HARDWARE(rmesa);
|
||||
}
|
||||
|
||||
|
||||
void r200WaitForVBlank( r200ContextPtr rmesa )
|
||||
{
|
||||
#if 0
|
||||
drmVBlank vbl;
|
||||
int ret;
|
||||
|
||||
if ( !rmesa->r200Screen->irq )
|
||||
return;
|
||||
|
||||
if ( getenv("LIBGL_SYNC_REFRESH") ) {
|
||||
/* Wait for until the next vertical blank */
|
||||
vbl.request.type = DRM_VBLANK_RELATIVE;
|
||||
vbl.request.sequence = 1;
|
||||
} else if ( getenv("LIBGL_THROTTLE_REFRESH") ) {
|
||||
/* Wait for at least one vertical blank since the last call */
|
||||
vbl.request.type = DRM_VBLANK_ABSOLUTE;
|
||||
vbl.request.sequence = rmesa->vbl_seq + 1;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
|
||||
if ((ret = drmWaitVBlank( rmesa->dri.fd, &vbl ))) {
|
||||
fprintf(stderr, "%s: drmWaitVBlank returned %d, IRQs don't seem to be"
|
||||
" working correctly.\nTry running with LIBGL_THROTTLE_REFRESH"
|
||||
" and LIBL_SYNC_REFRESH unset.\n", __FUNCTION__, ret);
|
||||
exit(1);
|
||||
} else if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s: drmWaitVBlank returned %d\n", __FUNCTION__, ret);
|
||||
|
||||
rmesa->vbl_seq = vbl.reply.sequence;
|
||||
|
||||
LOCK_HARDWARE( rmesa );
|
||||
#endif
|
||||
}
|
||||
|
||||
void r200Flush( GLcontext *ctx )
|
||||
{
|
||||
r200ContextPtr rmesa = R200_CONTEXT( ctx );
|
||||
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s\n", __FUNCTION__);
|
||||
|
||||
if (rmesa->dma.flush)
|
||||
rmesa->dma.flush( rmesa );
|
||||
|
||||
if (!is_empty_list(&rmesa->hw.dirty))
|
||||
r200EmitState( rmesa );
|
||||
|
||||
if (rmesa->store.cmd_used)
|
||||
r200FlushCmdBuf( rmesa, __FUNCTION__ );
|
||||
}
|
||||
|
||||
/* Make sure all commands have been sent to the hardware and have
|
||||
* completed processing.
|
||||
*/
|
||||
void r200Finish( GLcontext *ctx )
|
||||
{
|
||||
r200ContextPtr rmesa = R200_CONTEXT(ctx);
|
||||
r200Flush( ctx );
|
||||
|
||||
if (rmesa->do_irqs) {
|
||||
LOCK_HARDWARE( rmesa );
|
||||
r200EmitIrqLocked( rmesa );
|
||||
UNLOCK_HARDWARE( rmesa );
|
||||
r200WaitIrq( rmesa );
|
||||
}
|
||||
else
|
||||
r200WaitForIdle( rmesa );
|
||||
}
|
||||
|
||||
|
||||
/* This version of AllocateMemoryNV allocates only agp memory, and
|
||||
* only does so after the point at which the driver has been
|
||||
* initialized.
|
||||
*
|
||||
* Theoretically a valid context isn't required. However, in this
|
||||
* implementation, it is, as I'm using the hardware lock to protect
|
||||
* the kernel data structures, and the current context to get the
|
||||
* device fd.
|
||||
*/
|
||||
void *r200AllocateMemoryNV(GLsizei size, GLfloat readfreq,
|
||||
GLfloat writefreq, GLfloat priority)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
r200ContextPtr rmesa;
|
||||
int region_offset;
|
||||
drmRadeonMemAlloc alloc;
|
||||
int ret;
|
||||
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s sz %d %f/%f/%f\n", __FUNCTION__, size, readfreq,
|
||||
writefreq, priority);
|
||||
|
||||
if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || rmesa->r200Screen->IsPCI )
|
||||
return NULL;
|
||||
|
||||
if (getenv("R200_NO_ALLOC"))
|
||||
return NULL;
|
||||
|
||||
if (rmesa->dri.drmMinor < 6)
|
||||
return NULL;
|
||||
|
||||
alloc.region = RADEON_MEM_REGION_AGP;
|
||||
alloc.alignment = 0;
|
||||
alloc.size = size;
|
||||
alloc.region_offset = ®ion_offset;
|
||||
|
||||
ret = drmCommandWriteRead( rmesa->r200Screen->driScreen->fd,
|
||||
DRM_RADEON_ALLOC,
|
||||
&alloc, sizeof(alloc));
|
||||
|
||||
if (ret) {
|
||||
fprintf(stderr, "%s: DRM_RADEON_ALLOC ret %d\n", __FUNCTION__, ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
{
|
||||
char *region_start = (char *)rmesa->r200Screen->agpTextures.map;
|
||||
return (void *)(region_start + region_offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Called via glXFreeMemoryNV() */
|
||||
void r200FreeMemoryNV(GLvoid *pointer)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
r200ContextPtr rmesa;
|
||||
int region_offset;
|
||||
drmRadeonMemFree memfree;
|
||||
int ret;
|
||||
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "%s %p\n", __FUNCTION__, pointer);
|
||||
|
||||
if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || rmesa->r200Screen->IsPCI ) {
|
||||
fprintf(stderr, "%s: no context\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rmesa->dri.drmMinor < 6)
|
||||
return;
|
||||
|
||||
region_offset = (char *)pointer - (char *)rmesa->r200Screen->agpTextures.map;
|
||||
|
||||
if (region_offset < 0 ||
|
||||
region_offset > rmesa->r200Screen->agpTextures.size) {
|
||||
fprintf(stderr, "offset %d outside range 0..%d\n", region_offset,
|
||||
rmesa->r200Screen->agpTextures.size);
|
||||
return;
|
||||
}
|
||||
|
||||
memfree.region = RADEON_MEM_REGION_AGP;
|
||||
memfree.region_offset = region_offset;
|
||||
|
||||
ret = drmCommandWrite( rmesa->r200Screen->driScreen->fd,
|
||||
DRM_RADEON_FREE,
|
||||
&memfree, sizeof(memfree));
|
||||
|
||||
if (ret)
|
||||
fprintf(stderr, "%s: DRM_RADEON_FREE ret %d\n", __FUNCTION__, ret);
|
||||
}
|
||||
|
||||
/* Called via glXGetAGPOffsetMESA() */
|
||||
GLuint r200GetAGPOffset(const GLvoid *pointer)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
r200ContextPtr rmesa;
|
||||
GLuint card_offset;
|
||||
|
||||
if (!ctx || !(rmesa = R200_CONTEXT(ctx)) ) {
|
||||
fprintf(stderr, "%s: no context\n", __FUNCTION__);
|
||||
return ~0;
|
||||
}
|
||||
|
||||
if (!r200IsAgpMemory( rmesa, pointer, 0 ))
|
||||
return ~0;
|
||||
|
||||
if (rmesa->dri.drmMinor < 6)
|
||||
return ~0;
|
||||
|
||||
card_offset = r200AgpOffsetFromVirtual( rmesa, pointer );
|
||||
|
||||
return card_offset - rmesa->r200Screen->agp_base;
|
||||
}
|
||||
|
||||
|
||||
GLboolean r200IsAgpMemory( r200ContextPtr rmesa, const GLvoid *pointer,
|
||||
GLint size )
|
||||
{
|
||||
int offset = (char *)pointer - (char *)rmesa->r200Screen->agpTextures.map;
|
||||
int valid = (size >= 0 &&
|
||||
offset >= 0 &&
|
||||
offset + size < rmesa->r200Screen->agpTextures.size);
|
||||
|
||||
if (R200_DEBUG & DEBUG_IOCTL)
|
||||
fprintf(stderr, "r200IsAgpMemory( %p ) : %d\n", pointer, valid );
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
GLuint r200AgpOffsetFromVirtual( r200ContextPtr rmesa, const GLvoid *pointer )
|
||||
{
|
||||
int offset = (char *)pointer - (char *)rmesa->r200Screen->agpTextures.map;
|
||||
|
||||
if (offset < 0 || offset > rmesa->r200Screen->agpTextures.size)
|
||||
return ~0;
|
||||
else
|
||||
return rmesa->r200Screen->agp_texture_offset + offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void r200InitIoctlFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.Clear = r200Clear;
|
||||
ctx->Driver.Finish = r200Finish;
|
||||
ctx->Driver.Flush = r200Flush;
|
||||
}
|
||||
|
||||
188
src/mesa/drivers/dri/r200/r200_ioctl.h
Normal file
188
src/mesa/drivers/dri/r200/r200_ioctl.h
Normal file
@@ -0,0 +1,188 @@
|
||||
/* $XFree86$ */
|
||||
/*
|
||||
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
|
||||
|
||||
The Weather Channel (TM) funded Tungsten Graphics to develop the
|
||||
initial release of the Radeon 8500 driver under the XFree86 license.
|
||||
This notice must be preserved.
|
||||
|
||||
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 THE COPYRIGHT OWNER(S) 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:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#ifndef __R200_IOCTL_H__
|
||||
#define __R200_IOCTL_H__
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
#include "simple_list.h"
|
||||
#include "radeon_dri.h"
|
||||
#include "r200_lock.h"
|
||||
|
||||
#include "xf86drm.h"
|
||||
#include "radeon_common.h"
|
||||
|
||||
extern void r200EmitState( r200ContextPtr rmesa );
|
||||
extern void r200EmitVertexAOS( r200ContextPtr rmesa,
|
||||
GLuint vertex_size,
|
||||
GLuint offset );
|
||||
|
||||
extern void r200EmitVbufPrim( r200ContextPtr rmesa,
|
||||
GLuint primitive,
|
||||
GLuint vertex_nr );
|
||||
|
||||
extern void r200FlushElts( r200ContextPtr rmesa );
|
||||
|
||||
extern GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
|
||||
GLuint primitive,
|
||||
GLuint min_nr );
|
||||
|
||||
extern void r200EmitAOS( r200ContextPtr rmesa,
|
||||
struct r200_dma_region **regions,
|
||||
GLuint n,
|
||||
GLuint offset );
|
||||
|
||||
extern void r200EmitBlit( r200ContextPtr rmesa,
|
||||
GLuint color_fmt,
|
||||
GLuint src_pitch,
|
||||
GLuint src_offset,
|
||||
GLuint dst_pitch,
|
||||
GLuint dst_offset,
|
||||
GLint srcx, GLint srcy,
|
||||
GLint dstx, GLint dsty,
|
||||
GLuint w, GLuint h );
|
||||
|
||||
extern void r200EmitWait( r200ContextPtr rmesa, GLuint flags );
|
||||
|
||||
extern void r200FlushCmdBuf( r200ContextPtr rmesa, const char * );
|
||||
extern int r200FlushCmdBufLocked( r200ContextPtr rmesa, const char * caller );
|
||||
|
||||
extern void r200RefillCurrentDmaRegion( r200ContextPtr rmesa );
|
||||
|
||||
extern void r200AllocDmaRegion( r200ContextPtr rmesa,
|
||||
struct r200_dma_region *region,
|
||||
int bytes,
|
||||
int alignment );
|
||||
|
||||
extern void r200AllocDmaRegionVerts( r200ContextPtr rmesa,
|
||||
struct r200_dma_region *region,
|
||||
int numverts,
|
||||
int vertsize,
|
||||
int alignment );
|
||||
|
||||
extern void r200ReleaseDmaRegion( r200ContextPtr rmesa,
|
||||
struct r200_dma_region *region,
|
||||
const char *caller );
|
||||
|
||||
extern void r200CopyBuffer( const __DRIdrawablePrivate *drawable );
|
||||
extern void r200PageFlip( const __DRIdrawablePrivate *drawable );
|
||||
extern void r200Flush( GLcontext *ctx );
|
||||
extern void r200Finish( GLcontext *ctx );
|
||||
extern void r200WaitForIdleLocked( r200ContextPtr rmesa );
|
||||
extern void r200WaitForVBlank( r200ContextPtr rmesa );
|
||||
extern void r200InitIoctlFuncs( GLcontext *ctx );
|
||||
|
||||
extern void *r200AllocateMemoryNV( GLsizei size, GLfloat readfreq,
|
||||
GLfloat writefreq, GLfloat priority );
|
||||
extern void r200FreeMemoryNV( GLvoid *pointer );
|
||||
extern GLuint r200GetAGPOffset( const GLvoid *pointer );
|
||||
extern GLboolean r200IsAgpMemory( r200ContextPtr rmesa, const GLvoid *pointer,
|
||||
GLint size );
|
||||
|
||||
extern GLuint r200AgpOffsetFromVirtual( r200ContextPtr rmesa,
|
||||
const GLvoid *pointer );
|
||||
|
||||
/* ================================================================
|
||||
* Helper macros:
|
||||
*/
|
||||
|
||||
/* Close off the last primitive, if it exists.
|
||||
*/
|
||||
#define R200_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.
|
||||
*/
|
||||
#define R200_STATECHANGE( rmesa, ATOM ) \
|
||||
do { \
|
||||
R200_NEWPRIM( rmesa ); \
|
||||
move_to_head( &(rmesa->hw.dirty), &(rmesa->hw.ATOM)); \
|
||||
} while (0)
|
||||
|
||||
#define R200_DB_STATE( ATOM ) \
|
||||
memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
|
||||
rmesa->hw.ATOM.cmd_size * 4)
|
||||
|
||||
static __inline int R200_DB_STATECHANGE(
|
||||
r200ContextPtr rmesa,
|
||||
struct r200_state_atom *atom )
|
||||
{
|
||||
if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size*4)) {
|
||||
int *tmp;
|
||||
R200_NEWPRIM( rmesa );
|
||||
move_to_head( &(rmesa->hw.dirty), atom );
|
||||
tmp = atom->cmd;
|
||||
atom->cmd = atom->lastcmd;
|
||||
atom->lastcmd = tmp;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Fire the buffered vertices no matter what.
|
||||
*/
|
||||
#define R200_FIREVERTICES( rmesa ) \
|
||||
do { \
|
||||
if ( rmesa->store.cmd_used || rmesa->dma.flush ) { \
|
||||
r200Flush( rmesa->glCtx ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Alloc space in the command buffer
|
||||
*/
|
||||
static __inline char *r200AllocCmdBuf( r200ContextPtr rmesa,
|
||||
int bytes, const char *where )
|
||||
{
|
||||
if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
|
||||
r200FlushCmdBuf( rmesa, __FUNCTION__ );
|
||||
|
||||
{
|
||||
char *head = rmesa->store.cmd_buf + rmesa->store.cmd_used;
|
||||
rmesa->store.cmd_used += bytes;
|
||||
return head;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif /* __R200_IOCTL_H__ */
|
||||
118
src/mesa/drivers/dri/r200/r200_lock.c
Normal file
118
src/mesa/drivers/dri/r200/r200_lock.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/* $XFree86$ */
|
||||
/*
|
||||
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
|
||||
|
||||
The Weather Channel (TM) funded Tungsten Graphics to develop the
|
||||
initial release of the Radeon 8500 driver under the XFree86 license.
|
||||
This notice must be preserved.
|
||||
|
||||
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 THE COPYRIGHT OWNER(S) 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:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#include "r200_context.h"
|
||||
#include "r200_lock.h"
|
||||
#include "r200_tex.h"
|
||||
#include "r200_state.h"
|
||||
#include "r200_ioctl.h"
|
||||
|
||||
#if DEBUG_LOCKING
|
||||
char *prevLockFile = NULL;
|
||||
int prevLockLine = 0;
|
||||
#endif
|
||||
|
||||
/* Turn on/off page flipping according to the flags in the sarea:
|
||||
*/
|
||||
static void
|
||||
r200UpdatePageFlipping( r200ContextPtr rmesa )
|
||||
{
|
||||
int use_back;
|
||||
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->r200Screen->backOffset;
|
||||
rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
|
||||
} else {
|
||||
rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
|
||||
rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
|
||||
}
|
||||
|
||||
R200_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 r200GetLock( r200ContextPtr 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 ) {
|
||||
r200UpdatePageFlipping( rmesa );
|
||||
if (rmesa->glCtx->Color._DrawDestMask == BACK_LEFT_BIT)
|
||||
r200SetCliprects( rmesa, GL_BACK_LEFT );
|
||||
else
|
||||
r200SetCliprects( rmesa, GL_FRONT_LEFT );
|
||||
r200UpdateViewportOffset( 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 ( sarea->texAge[i] != rmesa->texture.age[i] ) {
|
||||
r200AgeTextures( rmesa, i );
|
||||
}
|
||||
}
|
||||
}
|
||||
111
src/mesa/drivers/dri/r200/r200_lock.h
Normal file
111
src/mesa/drivers/dri/r200/r200_lock.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* $XFree86$ */
|
||||
/*
|
||||
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
|
||||
|
||||
The Weather Channel (TM) funded Tungsten Graphics to develop the
|
||||
initial release of the Radeon 8500 driver under the XFree86 license.
|
||||
This notice must be preserved.
|
||||
|
||||
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 THE COPYRIGHT OWNER(S) 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:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#ifndef __R200_LOCK_H__
|
||||
#define __R200_LOCK_H__
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
extern void r200GetLock( r200ContextPtr rmesa, GLuint flags );
|
||||
|
||||
/* Turn DEBUG_LOCKING on to find locking conflicts.
|
||||
*/
|
||||
#define DEBUG_LOCKING 0
|
||||
|
||||
#if DEBUG_LOCKING
|
||||
extern char *prevLockFile;
|
||||
extern int prevLockLine;
|
||||
|
||||
#define DEBUG_LOCK() \
|
||||
do { \
|
||||
prevLockFile = (__FILE__); \
|
||||
prevLockLine = (__LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_RESET() \
|
||||
do { \
|
||||
prevLockFile = 0; \
|
||||
prevLockLine = 0; \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_CHECK_LOCK() \
|
||||
do { \
|
||||
if ( prevLockFile ) { \
|
||||
fprintf( stderr, \
|
||||
"LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
|
||||
prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
|
||||
exit( 1 ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define DEBUG_LOCK()
|
||||
#define DEBUG_RESET()
|
||||
#define DEBUG_CHECK_LOCK()
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* !!! We may want to separate locks from locks with validation. This
|
||||
* could be used to improve performance for those things commands that
|
||||
* do not do any drawing !!!
|
||||
*/
|
||||
|
||||
|
||||
/* Lock the hardware and validate our state.
|
||||
*/
|
||||
#define LOCK_HARDWARE( rmesa ) \
|
||||
do { \
|
||||
char __ret = 0; \
|
||||
DEBUG_CHECK_LOCK(); \
|
||||
DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext, \
|
||||
(DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
|
||||
if ( __ret ) \
|
||||
r200GetLock( rmesa, 0 ); \
|
||||
DEBUG_LOCK(); \
|
||||
} while (0)
|
||||
|
||||
/* Unlock the hardware.
|
||||
*/
|
||||
#define UNLOCK_HARDWARE( rmesa ) \
|
||||
do { \
|
||||
DRM_UNLOCK( rmesa->dri.fd, \
|
||||
rmesa->dri.hwLock, \
|
||||
rmesa->dri.hwContext ); \
|
||||
DEBUG_RESET(); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
#endif /* __R200_LOCK_H__ */
|
||||
12
src/mesa/drivers/dri/r200/r200_maos.c
Normal file
12
src/mesa/drivers/dri/r200/r200_maos.c
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
/* If using new packets, can choose either verts or arrays.
|
||||
* Otherwise, must use verts.
|
||||
*/
|
||||
#include "r200_context.h"
|
||||
#define R200_MAOS_VERTS 0
|
||||
#if (R200_MAOS_VERTS) || (R200_OLD_PACKETS)
|
||||
#include "r200_maos_verts.c"
|
||||
#else
|
||||
#include "r200_maos_arrays.c"
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user