962f811875c8ac4bce0f89dbbe40b9e8fc741399
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 "tnl/t_context.h"
34 #include "ss_triangle.h"
35 #include "ss_context.h"
37 #define SS_FLAT_BIT 0x1
38 #define SS_OFFSET_BIT 0x2
39 #define SS_TWOSIDE_BIT 0x4
40 #define SS_UNFILLED_BIT 0x10
41 #define SS_COPY_EXTRAS 0x20 /* optimization */
42 #define SS_MAX_TRIFUNC 0x40
44 static triangle_func tri_tab
[SS_MAX_TRIFUNC
];
45 static line_func line_tab
[SS_MAX_TRIFUNC
];
46 static points_func points_tab
[SS_MAX_TRIFUNC
];
47 static quad_func quad_tab
[SS_MAX_TRIFUNC
];
50 #define SS_COLOR(a,b) COPY_4UBV(a,b)
51 #define SS_SPEC(a,b) COPY_4UBV(a,b)
52 #define SS_IND(a,b) (a = b)
56 #include "ss_tritmp.h"
58 #define IND (SS_FLAT_BIT)
59 #define TAG(x) x##_flat
60 #include "ss_tritmp.h"
62 #define IND (SS_OFFSET_BIT)
63 #define TAG(x) x##_offset
64 #include "ss_tritmp.h"
66 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT)
67 #define TAG(x) x##_flat_offset
68 #include "ss_tritmp.h"
70 #define IND (SS_TWOSIDE_BIT)
71 #define TAG(x) x##_twoside
72 #include "ss_tritmp.h"
74 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT)
75 #define TAG(x) x##_flat_twoside
76 #include "ss_tritmp.h"
78 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
79 #define TAG(x) x##_offset_twoside
80 #include "ss_tritmp.h"
82 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT)
83 #define TAG(x) x##_flat_offset_twoside
84 #include "ss_tritmp.h"
86 #define IND (SS_UNFILLED_BIT)
87 #define TAG(x) x##_unfilled
88 #include "ss_tritmp.h"
90 #define IND (SS_FLAT_BIT|SS_UNFILLED_BIT)
91 #define TAG(x) x##_flat_unfilled
92 #include "ss_tritmp.h"
94 #define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
95 #define TAG(x) x##_offset_unfilled
96 #include "ss_tritmp.h"
98 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_UNFILLED_BIT)
99 #define TAG(x) x##_flat_offset_unfilled
100 #include "ss_tritmp.h"
102 #define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
103 #define TAG(x) x##_twoside_unfilled
104 #include "ss_tritmp.h"
106 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
107 #define TAG(x) x##_flat_twoside_unfilled
108 #include "ss_tritmp.h"
110 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
111 #define TAG(x) x##_offset_twoside_unfilled
112 #include "ss_tritmp.h"
114 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
115 #define TAG(x) x##_flat_offset_twoside_unfilled
116 #include "ss_tritmp.h"
118 #define IND (0|SS_COPY_EXTRAS)
119 #define TAG(x) x##_spec
120 #include "ss_tritmp.h"
122 #define IND (SS_FLAT_BIT|SS_COPY_EXTRAS)
123 #define TAG(x) x##_flat_spec
124 #include "ss_tritmp.h"
126 #define IND (SS_OFFSET_BIT|SS_COPY_EXTRAS)
127 #define TAG(x) x##_offset_spec
128 #include "ss_tritmp.h"
130 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_COPY_EXTRAS)
131 #define TAG(x) x##_flat_offset_spec
132 #include "ss_tritmp.h"
134 #define IND (SS_TWOSIDE_BIT|SS_COPY_EXTRAS)
135 #define TAG(x) x##_twoside_spec
136 #include "ss_tritmp.h"
138 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS)
139 #define TAG(x) x##_flat_twoside_spec
140 #include "ss_tritmp.h"
142 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS)
143 #define TAG(x) x##_offset_twoside_spec
144 #include "ss_tritmp.h"
146 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS)
147 #define TAG(x) x##_flat_offset_twoside_spec
148 #include "ss_tritmp.h"
150 #define IND (SS_UNFILLED_BIT|SS_COPY_EXTRAS)
151 #define TAG(x) x##_unfilled_spec
152 #include "ss_tritmp.h"
154 #define IND (SS_FLAT_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
155 #define TAG(x) x##_flat_unfilled_spec
156 #include "ss_tritmp.h"
158 #define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
159 #define TAG(x) x##_offset_unfilled_spec
160 #include "ss_tritmp.h"
162 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
163 #define TAG(x) x##_flat_offset_unfilled_spec
164 #include "ss_tritmp.h"
166 #define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
167 #define TAG(x) x##_twoside_unfilled_spec
168 #include "ss_tritmp.h"
170 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
171 #define TAG(x) x##_flat_twoside_unfilled_spec
172 #include "ss_tritmp.h"
174 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
175 #define TAG(x) x##_offset_twoside_unfilled_spec
176 #include "ss_tritmp.h"
178 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS)
179 #define TAG(x) x##_flat_offset_twoside_unfilled_spec
180 #include "ss_tritmp.h"
183 void _swsetup_trifuncs_init( GLcontext
*ctx
)
193 init_offset_twoside();
194 init_flat_offset_twoside();
196 init_flat_unfilled();
197 init_offset_unfilled();
198 init_flat_offset_unfilled();
199 init_twoside_unfilled();
200 init_flat_twoside_unfilled();
201 init_offset_twoside_unfilled();
202 init_flat_offset_twoside_unfilled();
207 init_flat_offset_spec();
209 init_flat_twoside_spec();
210 init_offset_twoside_spec();
211 init_flat_offset_twoside_spec();
212 init_unfilled_spec();
213 init_flat_unfilled_spec();
214 init_offset_unfilled_spec();
215 init_flat_offset_unfilled_spec();
216 init_twoside_unfilled_spec();
217 init_flat_twoside_unfilled_spec();
218 init_offset_twoside_unfilled_spec();
219 init_flat_offset_twoside_unfilled_spec();
223 void _swsetup_choose_trifuncs( GLcontext
*ctx
)
225 SScontext
*swsetup
= SWSETUP_CONTEXT(ctx
);
228 if (ctx
->Light
.ShadeModel
== GL_FLAT
)
231 if (ctx
->Polygon
._OffsetAny
)
232 ind
|= SS_OFFSET_BIT
;
234 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
235 ind
|= SS_TWOSIDE_BIT
;
237 if (ctx
->Polygon
._Unfilled
)
238 ind
|= SS_UNFILLED_BIT
;
240 if ((ctx
->_TriangleCaps
& DD_SEPERATE_SPECULAR
) ||
241 ctx
->RenderMode
== GL_SELECT
||
242 !ctx
->Visual
.RGBAflag
)
243 ind
|= SS_COPY_EXTRAS
;
245 swsetup
->Triangle
= tri_tab
[ind
];
246 swsetup
->Line
= line_tab
[ind
];
247 swsetup
->Points
= points_tab
[ind
];
248 swsetup
->Quad
= quad_tab
[ind
];