1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 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.
*
* Authors:
* Keith Whitwell <keithw@valinux.com>
*/
#include "glheader.h"
#include "macros.h"
#include "swrast/swrast.h"
#include "tnl/t_context.h"
#include "math/m_vector.h"
#include "ss_context.h"
#include "ss_vb.h"
/* Provides a RasterSetup function which prebuilds vertices for the
* software rasterizer. This is required for the triangle functions
* in this module, but not the rest of the swrast module.
*/
typedef void (*SetupFunc)( GLcontext *ctx,
GLuint start, GLuint end, GLuint newinputs );
#define COLOR 0x1
#define INDEX 0x2
#define TEX0 0x4
#define MULTITEX 0x8
#define SPEC 0x10
#define FOG 0x20
#define POINT 0x40
#define MAX_SETUPFUNC 0x80
static SetupFunc setup_func[MAX_SETUPFUNC];
#define IND (0)
#define TAG(x) x##_none
#include "ss_vbtmp.h"
#define IND (COLOR)
#define TAG(x) x##_color
#include "ss_vbtmp.h"
#define IND (COLOR|SPEC)
#define TAG(x) x##_color_spec
#include "ss_vbtmp.h"
#define IND (COLOR|FOG)
#define TAG(x) x##_color_fog
#include "ss_vbtmp.h"
#define IND (COLOR|SPEC|FOG)
#define TAG(x) x##_color_spec_fog
#include "ss_vbtmp.h"
#define IND (COLOR|TEX0)
#define TAG(x) x##_color_tex0
#include "ss_vbtmp.h"
#define IND (COLOR|TEX0|SPEC)
#define TAG(x) x##_color_tex0_spec
#include "ss_vbtmp.h"
#define IND (COLOR|TEX0|FOG)
#define TAG(x) x##_color_tex0_fog
#include "ss_vbtmp.h"
#define IND (COLOR|TEX0|SPEC|FOG)
#define TAG(x) x##_color_tex0_spec_fog
#include "ss_vbtmp.h"
#define IND (COLOR|MULTITEX)
#define TAG(x) x##_color_multitex
#include "ss_vbtmp.h"
#define IND (COLOR|MULTITEX|SPEC)
#define TAG(x) x##_color_multitex_spec
#include "ss_vbtmp.h"
#define IND (COLOR|MULTITEX|FOG)
#define TAG(x) x##_color_multitex_fog
#include "ss_vbtmp.h"
#define IND (COLOR|MULTITEX|SPEC|FOG)
#define TAG(x) x##_color_multitex_spec_fog
#include "ss_vbtmp.h"
#define IND (COLOR|POINT)
#define TAG(x) x##_color_point
#include "ss_vbtmp.h"
#define IND (COLOR|SPEC|POINT)
#define TAG(x) x##_color_spec_point
#include "ss_vbtmp.h"
#define IND (COLOR|FOG|POINT)
#define TAG(x) x##_color_fog_point
#include "ss_vbtmp.h"
#define IND (COLOR|SPEC|FOG|POINT)
#define TAG(x) x##_color_spec_fog_point
#include "ss_vbtmp.h"
#define IND (COLOR|TEX0|POINT)
#define TAG(x) x##_color_tex0_point
#include "ss_vbtmp.h"
#define IND (COLOR|TEX0|SPEC|POINT)
#define TAG(x) x##_color_tex0_spec_point
#include "ss_vbtmp.h"
#define IND (COLOR|TEX0|FOG|POINT)
#define TAG(x) x##_color_tex0_fog_point
#include "ss_vbtmp.h"
#define IND (COLOR|TEX0|SPEC|FOG|POINT)
#define TAG(x) x##_color_tex0_spec_fog_point
#include "ss_vbtmp.h"
#define IND (COLOR|MULTITEX|POINT)
#define TAG(x) x##_color_multitex_point
#include "ss_vbtmp.h"
#define IND (COLOR|MULTITEX|SPEC|POINT)
#define TAG(x) x##_color_multitex_spec_point
#include "ss_vbtmp.h"
#define IND (COLOR|MULTITEX|FOG|POINT)
#define TAG(x) x##_color_multitex_fog_point
#include "ss_vbtmp.h"
#define IND (COLOR|MULTITEX|SPEC|FOG|POINT)
#define TAG(x) x##_color_multitex_spec_fog_point
#include "ss_vbtmp.h"
#define IND (INDEX)
#define TAG(x) x##_index
#include "ss_vbtmp.h"
#define IND (INDEX|TEX0)
#define TAG(x) x##_index_tex0
#include "ss_vbtmp.h"
#define IND (INDEX|FOG)
#define TAG(x) x##_index_fog
#include "ss_vbtmp.h"
#define IND (INDEX|TEX0|FOG)
#define TAG(x) x##_index_tex0_fog
#include "ss_vbtmp.h"
#define IND (INDEX|POINT)
#define TAG(x) x##_index_point
#include "ss_vbtmp.h"
#define IND (INDEX|TEX0|POINT)
#define TAG(x) x##_index_tex0_point
#include "ss_vbtmp.h"
#define IND (INDEX|FOG|POINT)
#define TAG(x) x##_index_fog_point
#include "ss_vbtmp.h"
#define IND (INDEX|TEX0|FOG|POINT)
#define TAG(x) x##_index_tex0_fog_point
#include "ss_vbtmp.h"
static void
rs_invalid( GLcontext *ctx, GLuint start, GLuint end, GLuint newinputs )
{
fprintf(stderr, "swrast_setup: invalid setup function\n");
(void) (ctx && start && end && newinputs);
}
void
_swsetup_vb_init( GLcontext *ctx )
{
int i;
(void) ctx;
for (i = 0 ; i < Elements(setup_func) ; i++)
setup_func[i] = rs_invalid;
setup_func[0] = rs_none;
setup_func[COLOR] = rs_color;
setup_func[COLOR|SPEC] = rs_color_spec;
setup_func[COLOR|FOG] = rs_color_fog;
setup_func[COLOR|SPEC|FOG] = rs_color_spec_fog;
setup_func[COLOR|TEX0] = rs_color_tex0;
setup_func[COLOR|TEX0|SPEC] = rs_color_tex0_spec;
setup_func[COLOR|TEX0|FOG] = rs_color_tex0_fog;
setup_func[COLOR|TEX0|SPEC|FOG] = rs_color_tex0_spec_fog;
setup_func[COLOR|MULTITEX] = rs_color_multitex;
setup_func[COLOR|MULTITEX|SPEC] = rs_color_multitex_spec;
setup_func[COLOR|MULTITEX|FOG] = rs_color_multitex_fog;
setup_func[COLOR|MULTITEX|SPEC|FOG] = rs_color_multitex_spec_fog;
setup_func[COLOR|POINT] = rs_color_point;
setup_func[COLOR|SPEC|POINT] = rs_color_spec_point;
setup_func[COLOR|FOG|POINT] = rs_color_fog_point;
setup_func[COLOR|SPEC|FOG|POINT] = rs_color_spec_fog_point;
setup_func[COLOR|TEX0|POINT] = rs_color_tex0_point;
setup_func[COLOR|TEX0|SPEC|POINT] = rs_color_tex0_spec_point;
setup_func[COLOR|TEX0|FOG|POINT] = rs_color_tex0_fog_point;
setup_func[COLOR|TEX0|SPEC|FOG|POINT] = rs_color_tex0_spec_fog_point;
setup_func[COLOR|MULTITEX|POINT] = rs_color_multitex_point;
setup_func[COLOR|MULTITEX|SPEC|POINT] = rs_color_multitex_spec_point;
setup_func[COLOR|MULTITEX|FOG|POINT] = rs_color_multitex_fog_point;
setup_func[COLOR|MULTITEX|SPEC|FOG|POINT] = rs_color_multitex_spec_fog_point;
setup_func[INDEX] = rs_index;
setup_func[INDEX|TEX0] = rs_index_tex0;
setup_func[INDEX|FOG] = rs_index_fog;
setup_func[INDEX|TEX0|FOG] = rs_index_tex0_fog;
setup_func[INDEX|POINT] = rs_index_point;
setup_func[INDEX|TEX0|POINT] = rs_index_tex0_point;
setup_func[INDEX|FOG|POINT] = rs_index_fog_point;
setup_func[INDEX|TEX0|FOG|POINT] = rs_index_tex0_fog_point;
}
static void printSetupFlags(char *msg, GLuint flags )
{
fprintf(stderr, "%s(%x): %s%s%s%s%s%s%s\n",
msg,
(int)flags,
(flags & COLOR) ? "color, " : "",
(flags & INDEX) ? "index, " : "",
(flags & TEX0) ? "tex0, " : "",
(flags & MULTITEX) ? "multitex, " : "",
(flags & SPEC) ? "spec, " : "",
(flags & FOG) ? "fog, " : "",
(flags & POINT) ? "point, " : "");
}
void
_swsetup_choose_rastersetup_func(GLcontext *ctx)
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
int funcindex = 0;
if (ctx->RenderMode == GL_RENDER) {
if (ctx->Visual.rgbMode) {
funcindex = COLOR;
if (ctx->Texture._ReallyEnabled & ~0xf)
funcindex |= MULTITEX;
else if (ctx->Texture._ReallyEnabled & 0xf)
funcindex |= TEX0;
if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
ctx->Fog.ColorSumEnabled)
funcindex |= SPEC;
}
else {
funcindex = INDEX;
}
if (ctx->Point._Attenuated)
funcindex |= POINT;
if (ctx->Fog.Enabled)
funcindex |= FOG;
}
else if (ctx->RenderMode == GL_FEEDBACK) {
if (ctx->Visual.rgbMode)
funcindex = (COLOR | TEX0); /* is feedback color subject to fogging? */
else
funcindex = (INDEX | TEX0);
}
else
funcindex = 0;
/* printSetupFlags("software setup func", funcindex); */
swsetup->BuildProjVerts = setup_func[funcindex];
ASSERT(setup_func[funcindex] != rs_invalid);
}
|