ab70f5c97bcf8e5055ac274ea5b6a13dae7bd967
2 * Mesa 3-D graphics library
5 * Copyright (C) 1999 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Keith Whitwell <keithw@valinux.com>
32 #include "ss_triangle.h"
33 #include "ss_context.h"
35 #define SS_FLAT_BIT 0x1
36 #define SS_OFFSET_BIT 0x2
37 #define SS_TWOSIDE_BIT 0x4
38 #define SS_UNFILLED_BIT 0x10
39 #define SS_COPY_EXTRAS 0x20 /* optimization */
40 #define SS_MAX_TRIFUNC 0x40
42 static triangle_func tri_tab
[SS_MAX_TRIFUNC
];
43 static line_func line_tab
[SS_MAX_TRIFUNC
];
44 static points_func points_tab
[SS_MAX_TRIFUNC
];
45 static quad_func quad_tab
[SS_MAX_TRIFUNC
];
48 #define SS_COLOR(a,b) COPY_4UBV(a,b)
49 #define SS_SPEC(a,b) COPY_4UBV(a,b)
50 #define SS_IND(a,b) (a = b)
54 #include "ss_tritmp.h"
56 #define IND (SS_FLAT_BIT)
57 #define TAG(x) x##_flat
58 #include "ss_tritmp.h"
60 #define IND (SS_OFFSET_BIT)
61 #define TAG(x) x##_offset
62 #include "ss_tritmp.h"
64 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT)
65 #define TAG(x) x##_flat_offset
66 #include "ss_tritmp.h"
68 #define IND (SS_TWOSIDE_BIT)
69 #define TAG(x) x##_twoside
70 #include "ss_tritmp.h"
72 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT)
73 #define TAG(x) x##_flat_twoside
74 #include "ss_tritmp.h"
76 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
77 #define TAG(x) x##_offset_twoside
78 #include "ss_tritmp.h"
80 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT)
81 #define TAG(x) x##_flat_offset_twoside
82 #include "ss_tritmp.h"
84 #define IND (SS_UNFILLED_BIT)
85 #define TAG(x) x##_unfilled
86 #include "ss_tritmp.h"
88 #define IND (SS_FLAT_BIT|SS_UNFILLED_BIT)
89 #define TAG(x) x##_flat_unfilled
90 #include "ss_tritmp.h"
92 #define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
93 #define TAG(x) x##_offset_unfilled
94 #include "ss_tritmp.h"
96 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_UNFILLED_BIT)
97 #define TAG(x) x##_flat_offset_unfilled
98 #include "ss_tritmp.h"
100 #define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
101 #define TAG(x) x##_twoside_unfilled
102 #include "ss_tritmp.h"
104 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
105 #define TAG(x) x##_flat_twoside_unfilled
106 #include "ss_tritmp.h"
108 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
109 #define TAG(x) x##_offset_twoside_unfilled
110 #include "ss_tritmp.h"
112 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
113 #define TAG(x) x##_flat_offset_twoside_unfilled
114 #include "ss_tritmp.h"
116 #define IND (0|SS_COPY_EXTRAS)
117 #define TAG(x) x##_spec
118 #include "ss_tritmp.h"
120 #define IND (SS_FLAT_BIT|SS_COPY_EXTRAS)
121 #define TAG(x) x##_flat_spec
122 #include "ss_tritmp.h"
124 #define IND (SS_OFFSET_BIT|SS_COPY_EXTRAS)
125 #define TAG(x) x##_offset_spec
126 #include "ss_tritmp.h"
128 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_COPY_EXTRAS)
129 #define TAG(x) x##_flat_offset_spec
130 #include "ss_tritmp.h"
132 #define IND (SS_TWOSIDE_BIT|SS_COPY_EXTRAS)
133 #define TAG(x) x##_twoside_spec
134 #include "ss_tritmp.h"
136 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS)
137 #define TAG(x) x##_flat_twoside_spec
138 #include "ss_tritmp.h"
140 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS)
141 #define TAG(x) x##_offset_twoside_spec
142 #include "ss_tritmp.h"
144 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS)
145 #define TAG(x) x##_flat_offset_twoside_spec
146 #include "ss_tritmp.h"
148 #define IND (SS_UNFILLED_BIT|SS_COPY_EXTRAS)
149 #define TAG(x) x##_unfilled_spec
150 #include "ss_tritmp.h"
152 #define IND (SS_FLAT_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
153 #define TAG(x) x##_flat_unfilled_spec
154 #include "ss_tritmp.h"
156 #define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
157 #define TAG(x) x##_offset_unfilled_spec
158 #include "ss_tritmp.h"
160 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
161 #define TAG(x) x##_flat_offset_unfilled_spec
162 #include "ss_tritmp.h"
164 #define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
165 #define TAG(x) x##_twoside_unfilled_spec
166 #include "ss_tritmp.h"
168 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
169 #define TAG(x) x##_flat_twoside_unfilled_spec
170 #include "ss_tritmp.h"
172 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
173 #define TAG(x) x##_offset_twoside_unfilled_spec
174 #include "ss_tritmp.h"
176 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
177 #define TAG(x) x##_flat_offset_twoside_unfilled_spec
178 #include "ss_tritmp.h"
181 void _swsetup_trifuncs_init( GLcontext
*ctx
)
191 init_offset_twoside();
192 init_flat_offset_twoside();
194 init_flat_unfilled();
195 init_offset_unfilled();
196 init_flat_offset_unfilled();
197 init_twoside_unfilled();
198 init_flat_twoside_unfilled();
199 init_offset_twoside_unfilled();
200 init_flat_offset_twoside_unfilled();
205 init_flat_offset_spec();
207 init_flat_twoside_spec();
208 init_offset_twoside_spec();
209 init_flat_offset_twoside_spec();
210 init_unfilled_spec();
211 init_flat_unfilled_spec();
212 init_offset_unfilled_spec();
213 init_flat_offset_unfilled_spec();
214 init_twoside_unfilled_spec();
215 init_flat_twoside_unfilled_spec();
216 init_offset_twoside_unfilled_spec();
217 init_flat_offset_twoside_unfilled_spec();
221 void _swsetup_choose_trifuncs( GLcontext
*ctx
)
223 SScontext
*swsetup
= SWSETUP_CONTEXT(ctx
);
226 if (ctx
->Light
.ShadeModel
== GL_FLAT
)
229 if (ctx
->Polygon
._OffsetAny
)
230 ind
|= SS_OFFSET_BIT
;
232 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
233 ind
|= SS_TWOSIDE_BIT
;
235 if (ctx
->Polygon
._Unfilled
)
236 ind
|= SS_UNFILLED_BIT
;
238 if ((ctx
->_TriangleCaps
& DD_SEPERATE_SPECULAR
) ||
239 ctx
->RenderMode
== GL_SELECT
||
240 !ctx
->Visual
.RGBAflag
)
241 ind
|= SS_COPY_EXTRAS
;
243 swsetup
->Triangle
= tri_tab
[ind
];
244 swsetup
->Line
= line_tab
[ind
];
245 swsetup
->Points
= points_tab
[ind
];
246 swsetup
->Quad
= quad_tab
[ind
];