~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/mesa/vf/vf_generic.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * Copyright 2003 Tungsten Graphics, inc.
 
4
 * All Rights Reserved.
 
5
 *
 
6
 * Permission is hereby granted, free of charge, to any person obtaining a
 
7
 * copy of this software and associated documentation files (the "Software"),
 
8
 * to deal in the Software without restriction, including without limitation
 
9
 * on the rights to use, copy, modify, merge, publish, distribute, sub
 
10
 * license, and/or sell copies of the Software, and to permit persons to whom
 
11
 * the Software is furnished to do so, subject to the following conditions:
 
12
 *
 
13
 * The above copyright notice and this permission notice (including the next
 
14
 * paragraph) shall be included in all copies or substantial portions of the
 
15
 * Software.
 
16
 *
 
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
 
20
 * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
 
21
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 
22
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 
23
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 
24
 *
 
25
 * Authors:
 
26
 *    Keith Whitwell <keithw@tungstengraphics.com>
 
27
 */
 
28
 
 
29
#include "main/glheader.h"
 
30
#include "main/context.h"
 
31
#include "main/colormac.h"
 
32
#include "main/macros.h"
 
33
#include "main/simple_list.h"
 
34
 
 
35
#include "vf/vf.h"
 
36
 
 
37
 
 
38
/*
 
39
 * These functions take the NDC coordinates pointed to by 'in', apply the
 
40
 * NDC->Viewport mapping and store the results at 'v'.
 
41
 */
 
42
 
 
43
static INLINE void insert_4f_viewport_4( const struct vf_attr *a, GLubyte *v,
 
44
                                         const GLfloat *in )
 
45
{
 
46
   GLfloat *out = (GLfloat *)v;
 
47
   const GLfloat *scale = a->vf->vp;
 
48
   const GLfloat *trans = a->vf->vp + 4;
 
49
   
 
50
   out[0] = scale[0] * in[0] + trans[0];
 
51
   out[1] = scale[1] * in[1] + trans[1];
 
52
   out[2] = scale[2] * in[2] + trans[2];
 
53
   out[3] = in[3];
 
54
}
 
55
 
 
56
static INLINE void insert_4f_viewport_3( const struct vf_attr *a, GLubyte *v,
 
57
                                         const GLfloat *in )
 
58
{
 
59
   GLfloat *out = (GLfloat *)v;
 
60
   const GLfloat *scale = a->vf->vp;
 
61
   const GLfloat *trans = a->vf->vp + 4;
 
62
   
 
63
   out[0] = scale[0] * in[0] + trans[0];
 
64
   out[1] = scale[1] * in[1] + trans[1];
 
65
   out[2] = scale[2] * in[2] + trans[2];
 
66
   out[3] = 1;
 
67
}
 
68
 
 
69
static INLINE void insert_4f_viewport_2( const struct vf_attr *a, GLubyte *v,
 
70
                                         const GLfloat *in )
 
71
{
 
72
   GLfloat *out = (GLfloat *)v;
 
73
   const GLfloat *scale = a->vf->vp;
 
74
   const GLfloat *trans = a->vf->vp + 4;
 
75
   
 
76
   out[0] = scale[0] * in[0] + trans[0];
 
77
   out[1] = scale[1] * in[1] + trans[1];
 
78
   out[2] =                    trans[2];
 
79
   out[3] = 1;
 
80
}
 
81
 
 
82
static INLINE void insert_4f_viewport_1( const struct vf_attr *a, GLubyte *v,
 
83
                                         const GLfloat *in )
 
84
{
 
85
   GLfloat *out = (GLfloat *)v;
 
86
   const GLfloat *scale = a->vf->vp;
 
87
   const GLfloat *trans = a->vf->vp + 4;
 
88
   
 
89
   out[0] = scale[0] * in[0] + trans[0];
 
90
   out[1] =                    trans[1];
 
91
   out[2] =                    trans[2];
 
92
   out[3] = 1;
 
93
}
 
94
 
 
95
static INLINE void insert_3f_viewport_3( const struct vf_attr *a, GLubyte *v,
 
96
                                         const GLfloat *in )
 
97
{
 
98
   GLfloat *out = (GLfloat *)v;
 
99
   const GLfloat *scale = a->vf->vp;
 
100
   const GLfloat *trans = a->vf->vp + 4;
 
101
   
 
102
   out[0] = scale[0] * in[0] + trans[0];
 
103
   out[1] = scale[1] * in[1] + trans[1];
 
104
   out[2] = scale[2] * in[2] + trans[2];
 
105
}
 
106
 
 
107
static INLINE void insert_3f_viewport_2( const struct vf_attr *a, GLubyte *v,
 
108
                                         const GLfloat *in )
 
109
{
 
110
   GLfloat *out = (GLfloat *)v;
 
111
   const GLfloat *scale = a->vf->vp;
 
112
   const GLfloat *trans = a->vf->vp + 4;
 
113
   
 
114
   out[0] = scale[0] * in[0] + trans[0];
 
115
   out[1] = scale[1] * in[1] + trans[1];
 
116
   out[2] = scale[2] * in[2] + trans[2];
 
117
}
 
118
 
 
119
static INLINE void insert_3f_viewport_1( const struct vf_attr *a, GLubyte *v,
 
120
                                         const GLfloat *in )
 
121
{
 
122
   GLfloat *out = (GLfloat *)v;
 
123
   const GLfloat *scale = a->vf->vp;
 
124
   const GLfloat *trans = a->vf->vp + 4;
 
125
   
 
126
   out[0] = scale[0] * in[0] + trans[0];
 
127
   out[1] =                    trans[1];
 
128
   out[2] =                    trans[2];
 
129
}
 
130
 
 
131
static INLINE void insert_2f_viewport_2( const struct vf_attr *a, GLubyte *v,
 
132
                                         const GLfloat *in )
 
133
{
 
134
   GLfloat *out = (GLfloat *)v;
 
135
   const GLfloat *scale = a->vf->vp;
 
136
   const GLfloat *trans = a->vf->vp + 4;
 
137
   
 
138
   out[0] = scale[0] * in[0] + trans[0];
 
139
   out[1] = scale[1] * in[1] + trans[1];
 
140
}
 
141
 
 
142
static INLINE void insert_2f_viewport_1( const struct vf_attr *a, GLubyte *v,
 
143
                                         const GLfloat *in )
 
144
{
 
145
   GLfloat *out = (GLfloat *)v;
 
146
   const GLfloat *scale = a->vf->vp;
 
147
   const GLfloat *trans = a->vf->vp + 4;
 
148
   
 
149
   out[0] = scale[0] * in[0] + trans[0];
 
150
   out[1] = trans[1];
 
151
}
 
152
 
 
153
 
 
154
/*
 
155
 * These functions do the same as above, except for the viewport mapping.
 
156
 */
 
157
 
 
158
static INLINE void insert_4f_4( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
159
{
 
160
   GLfloat *out = (GLfloat *)(v);
 
161
   (void) a;
 
162
   
 
163
   out[0] = in[0];
 
164
   out[1] = in[1];
 
165
   out[2] = in[2];
 
166
   out[3] = in[3];
 
167
}
 
168
 
 
169
static INLINE void insert_4f_3( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
170
{
 
171
   GLfloat *out = (GLfloat *)(v);
 
172
   (void) a;
 
173
   
 
174
   out[0] = in[0];
 
175
   out[1] = in[1];
 
176
   out[2] = in[2];
 
177
   out[3] = 1;
 
178
}
 
179
 
 
180
static INLINE void insert_4f_2( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
181
{
 
182
   GLfloat *out = (GLfloat *)(v);
 
183
   (void) a;
 
184
   
 
185
   out[0] = in[0];
 
186
   out[1] = in[1];
 
187
   out[2] = 0;
 
188
   out[3] = 1;
 
189
}
 
190
 
 
191
static INLINE void insert_4f_1( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
192
{
 
193
   GLfloat *out = (GLfloat *)(v);
 
194
   (void) a;
 
195
   
 
196
   out[0] = in[0];
 
197
   out[1] = 0;
 
198
   out[2] = 0;
 
199
   out[3] = 1;
 
200
}
 
201
 
 
202
static INLINE void insert_3f_xyw_4( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
203
{
 
204
   GLfloat *out = (GLfloat *)(v);
 
205
   (void) a;
 
206
   
 
207
   out[0] = in[0];
 
208
   out[1] = in[1];
 
209
   out[2] = in[3];
 
210
}
 
211
 
 
212
static INLINE void insert_3f_xyw_err( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
213
{
 
214
   (void) a; (void) v; (void) in;
 
215
   exit(1);
 
216
}
 
217
 
 
218
static INLINE void insert_3f_3( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
219
{
 
220
   GLfloat *out = (GLfloat *)(v);
 
221
   (void) a;
 
222
   
 
223
   out[0] = in[0];
 
224
   out[1] = in[1];
 
225
   out[2] = in[2];
 
226
}
 
227
 
 
228
static INLINE void insert_3f_2( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
229
{
 
230
   GLfloat *out = (GLfloat *)(v);
 
231
   (void) a;
 
232
   
 
233
   out[0] = in[0];
 
234
   out[1] = in[1];
 
235
   out[2] = 0;
 
236
}
 
237
 
 
238
static INLINE void insert_3f_1( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
239
{
 
240
   GLfloat *out = (GLfloat *)(v);
 
241
   (void) a;
 
242
   
 
243
   out[0] = in[0];
 
244
   out[1] = 0;
 
245
   out[2] = 0;
 
246
}
 
247
 
 
248
 
 
249
static INLINE void insert_2f_2( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
250
{
 
251
   GLfloat *out = (GLfloat *)(v);
 
252
   (void) a;
 
253
   
 
254
   out[0] = in[0];
 
255
   out[1] = in[1];
 
256
}
 
257
 
 
258
static INLINE void insert_2f_1( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
259
{
 
260
   GLfloat *out = (GLfloat *)(v);
 
261
   (void) a;
 
262
   
 
263
   out[0] = in[0];
 
264
   out[1] = 0;
 
265
}
 
266
 
 
267
static INLINE void insert_1f_1( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
268
{
 
269
   GLfloat *out = (GLfloat *)(v);
 
270
   (void) a;
 
271
 
 
272
   out[0] = in[0];
 
273
}
 
274
 
 
275
static INLINE void insert_null( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
 
276
{
 
277
   (void) a; (void) v; (void) in;
 
278
}
 
279
 
 
280
static INLINE void insert_4chan_4f_rgba_4( const struct vf_attr *a, GLubyte *v, 
 
281
                                           const GLfloat *in )
 
282
{
 
283
   GLchan *c = (GLchan *)v;
 
284
   (void) a;
 
285
   UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); 
 
286
   UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); 
 
287
   UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]); 
 
288
   UNCLAMPED_FLOAT_TO_CHAN(c[3], in[3]);
 
289
}
 
290
 
 
291
static INLINE void insert_4chan_4f_rgba_3( const struct vf_attr *a, GLubyte *v, 
 
292
                                           const GLfloat *in )
 
293
{
 
294
   GLchan *c = (GLchan *)v;
 
295
   (void) a;
 
296
   UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); 
 
297
   UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); 
 
298
   UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]); 
 
299
   c[3] = CHAN_MAX;
 
300
}
 
301
 
 
302
static INLINE void insert_4chan_4f_rgba_2( const struct vf_attr *a, GLubyte *v, 
 
303
                                           const GLfloat *in )
 
304
{
 
305
   GLchan *c = (GLchan *)v;
 
306
   (void) a;
 
307
   UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); 
 
308
   UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]); 
 
309
   c[2] = 0;
 
310
   c[3] = CHAN_MAX;
 
311
}
 
312
 
 
313
static INLINE void insert_4chan_4f_rgba_1( const struct vf_attr *a, GLubyte *v, 
 
314
                                           const GLfloat *in )
 
315
{
 
316
   GLchan *c = (GLchan *)v;
 
317
   (void) a;
 
318
   UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]); 
 
319
   c[1] = 0;
 
320
   c[2] = 0;
 
321
   c[3] = CHAN_MAX;
 
322
}
 
323
 
 
324
static INLINE void insert_4ub_4f_rgba_4( const struct vf_attr *a, GLubyte *v, 
 
325
                                         const GLfloat *in )
 
326
{
 
327
   (void) a;
 
328
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
 
329
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
330
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
 
331
   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
 
332
}
 
333
 
 
334
static INLINE void insert_4ub_4f_rgba_3( const struct vf_attr *a, GLubyte *v, 
 
335
                                         const GLfloat *in )
 
336
{
 
337
   (void) a;
 
338
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
 
339
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
340
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
 
341
   v[3] = 0xff;
 
342
}
 
343
 
 
344
static INLINE void insert_4ub_4f_rgba_2( const struct vf_attr *a, GLubyte *v, 
 
345
                                         const GLfloat *in )
 
346
{
 
347
   (void) a;
 
348
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
 
349
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
350
   v[2] = 0;
 
351
   v[3] = 0xff;
 
352
}
 
353
 
 
354
static INLINE void insert_4ub_4f_rgba_1( const struct vf_attr *a, GLubyte *v, 
 
355
                                         const GLfloat *in )
 
356
{
 
357
   (void) a;
 
358
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
 
359
   v[1] = 0;
 
360
   v[2] = 0;
 
361
   v[3] = 0xff;
 
362
}
 
363
 
 
364
static INLINE void insert_4ub_4f_bgra_4( const struct vf_attr *a, GLubyte *v, 
 
365
                                         const GLfloat *in )
 
366
{
 
367
   (void) a;
 
368
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
 
369
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
370
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
 
371
   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
 
372
}
 
373
 
 
374
static INLINE void insert_4ub_4f_bgra_3( const struct vf_attr *a, GLubyte *v, 
 
375
                                         const GLfloat *in )
 
376
{
 
377
   (void) a;
 
378
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
 
379
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
380
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
 
381
   v[3] = 0xff;
 
382
}
 
383
 
 
384
static INLINE void insert_4ub_4f_bgra_2( const struct vf_attr *a, GLubyte *v, 
 
385
                                         const GLfloat *in )
 
386
{
 
387
   (void) a;
 
388
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
 
389
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
390
   v[0] = 0;
 
391
   v[3] = 0xff;
 
392
}
 
393
 
 
394
static INLINE void insert_4ub_4f_bgra_1( const struct vf_attr *a, GLubyte *v, 
 
395
                                         const GLfloat *in )
 
396
{
 
397
   (void) a;
 
398
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
 
399
   v[1] = 0;
 
400
   v[0] = 0;
 
401
   v[3] = 0xff;
 
402
}
 
403
 
 
404
static INLINE void insert_4ub_4f_argb_4( const struct vf_attr *a, GLubyte *v, 
 
405
                                         const GLfloat *in )
 
406
{
 
407
   (void) a;
 
408
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
 
409
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
 
410
   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
 
411
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
 
412
}
 
413
 
 
414
static INLINE void insert_4ub_4f_argb_3( const struct vf_attr *a, GLubyte *v, 
 
415
                                         const GLfloat *in )
 
416
{
 
417
   (void) a;
 
418
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
 
419
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
 
420
   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
 
421
   v[0] = 0xff;
 
422
}
 
423
 
 
424
static INLINE void insert_4ub_4f_argb_2( const struct vf_attr *a, GLubyte *v, 
 
425
                                         const GLfloat *in )
 
426
{
 
427
   (void) a;
 
428
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
 
429
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
 
430
   v[3] = 0x00;
 
431
   v[0] = 0xff;
 
432
}
 
433
 
 
434
static INLINE void insert_4ub_4f_argb_1( const struct vf_attr *a, GLubyte *v, 
 
435
                                         const GLfloat *in )
 
436
{
 
437
   (void) a;
 
438
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
 
439
   v[2] = 0x00;
 
440
   v[3] = 0x00;
 
441
   v[0] = 0xff;
 
442
}
 
443
 
 
444
static INLINE void insert_4ub_4f_abgr_4( const struct vf_attr *a, GLubyte *v, 
 
445
                                         const GLfloat *in )
 
446
{
 
447
   (void) a;
 
448
   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
 
449
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
 
450
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
 
451
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
 
452
}
 
453
 
 
454
static INLINE void insert_4ub_4f_abgr_3( const struct vf_attr *a, GLubyte *v, 
 
455
                                         const GLfloat *in )
 
456
{
 
457
   (void) a;
 
458
   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
 
459
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
 
460
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
 
461
   v[0] = 0xff;
 
462
}
 
463
 
 
464
static INLINE void insert_4ub_4f_abgr_2( const struct vf_attr *a, GLubyte *v, 
 
465
                                         const GLfloat *in )
 
466
{
 
467
   (void) a;
 
468
   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
 
469
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
 
470
   v[1] = 0x00;
 
471
   v[0] = 0xff;
 
472
}
 
473
 
 
474
static INLINE void insert_4ub_4f_abgr_1( const struct vf_attr *a, GLubyte *v, 
 
475
                                         const GLfloat *in )
 
476
{
 
477
   (void) a;
 
478
   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
 
479
   v[2] = 0x00;
 
480
   v[1] = 0x00;
 
481
   v[0] = 0xff;
 
482
}
 
483
 
 
484
static INLINE void insert_3ub_3f_rgb_3( const struct vf_attr *a, GLubyte *v, 
 
485
                                        const GLfloat *in )
 
486
{
 
487
   (void) a;
 
488
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
 
489
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
490
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
 
491
}
 
492
 
 
493
static INLINE void insert_3ub_3f_rgb_2( const struct vf_attr *a, GLubyte *v, 
 
494
                                        const GLfloat *in )
 
495
{
 
496
   (void) a;
 
497
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
 
498
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
499
   v[2] = 0;
 
500
}
 
501
 
 
502
static INLINE void insert_3ub_3f_rgb_1( const struct vf_attr *a, GLubyte *v, 
 
503
                                        const GLfloat *in )
 
504
{
 
505
   (void) a;
 
506
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
 
507
   v[1] = 0;
 
508
   v[2] = 0;
 
509
}
 
510
 
 
511
static INLINE void insert_3ub_3f_bgr_3( const struct vf_attr *a, GLubyte *v, 
 
512
                                        const GLfloat *in )
 
513
{
 
514
   (void) a;
 
515
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
 
516
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
517
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
 
518
}
 
519
 
 
520
static INLINE void insert_3ub_3f_bgr_2( const struct vf_attr *a, GLubyte *v, 
 
521
                                        const GLfloat *in )
 
522
{
 
523
   (void) a;
 
524
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
 
525
   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
 
526
   v[0] = 0;
 
527
}
 
528
 
 
529
static INLINE void insert_3ub_3f_bgr_1( const struct vf_attr *a, GLubyte *v, 
 
530
                                        const GLfloat *in )
 
531
{
 
532
   (void) a;
 
533
   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
 
534
   v[1] = 0;
 
535
   v[0] = 0;
 
536
}
 
537
 
 
538
 
 
539
static INLINE void insert_1ub_1f_1( const struct vf_attr *a, GLubyte *v, 
 
540
                                    const GLfloat *in )
 
541
{
 
542
   (void) a;
 
543
   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
 
544
}
 
545
 
 
546
 
 
547
/***********************************************************************
 
548
 * Functions to perform the reverse operations to the above, for
 
549
 * swrast translation and clip-interpolation.
 
550
 * 
 
551
 * Currently always extracts a full 4 floats.
 
552
 */
 
553
 
 
554
static void extract_4f_viewport( const struct vf_attr *a, GLfloat *out, 
 
555
                                 const GLubyte *v )
 
556
{
 
557
   const GLfloat *in = (const GLfloat *)v;
 
558
   const GLfloat *scale = a->vf->vp;
 
559
   const GLfloat *trans = a->vf->vp + 4;
 
560
   
 
561
   /* Although included for completeness, the position coordinate is
 
562
    * usually handled differently during clipping.
 
563
    */
 
564
   out[0] = (in[0] - trans[0]) / scale[0];
 
565
   out[1] = (in[1] - trans[1]) / scale[1];
 
566
   out[2] = (in[2] - trans[2]) / scale[2];
 
567
   out[3] = in[3];
 
568
}
 
569
 
 
570
static void extract_3f_viewport( const struct vf_attr *a, GLfloat *out, 
 
571
                                 const GLubyte *v )
 
572
{
 
573
   const GLfloat *in = (const GLfloat *)v;
 
574
   const GLfloat *scale = a->vf->vp;
 
575
   const GLfloat *trans = a->vf->vp + 4;
 
576
   
 
577
   out[0] = (in[0] - trans[0]) / scale[0];
 
578
   out[1] = (in[1] - trans[1]) / scale[1];
 
579
   out[2] = (in[2] - trans[2]) / scale[2];
 
580
   out[3] = 1;
 
581
}
 
582
 
 
583
 
 
584
static void extract_2f_viewport( const struct vf_attr *a, GLfloat *out, 
 
585
                                 const GLubyte *v )
 
586
{
 
587
   const GLfloat *in = (const GLfloat *)v;
 
588
   const GLfloat *scale = a->vf->vp;
 
589
   const GLfloat *trans = a->vf->vp + 4;
 
590
   
 
591
   out[0] = (in[0] - trans[0]) / scale[0];
 
592
   out[1] = (in[1] - trans[1]) / scale[1];
 
593
   out[2] = 0;
 
594
   out[3] = 1;
 
595
}
 
596
 
 
597
 
 
598
static void extract_4f( const struct vf_attr *a, GLfloat *out, const GLubyte *v  )
 
599
{
 
600
   const GLfloat *in = (const GLfloat *)v;
 
601
   (void) a;
 
602
   
 
603
   out[0] = in[0];
 
604
   out[1] = in[1];
 
605
   out[2] = in[2];
 
606
   out[3] = in[3];
 
607
}
 
608
 
 
609
static void extract_3f_xyw( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
 
610
{
 
611
   const GLfloat *in = (const GLfloat *)v;
 
612
   (void) a;
 
613
   
 
614
   out[0] = in[0];
 
615
   out[1] = in[1];
 
616
   out[2] = 0;
 
617
   out[3] = in[2];
 
618
}
 
619
 
 
620
 
 
621
static void extract_3f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
 
622
{
 
623
   const GLfloat *in = (const GLfloat *)v;
 
624
   (void) a;
 
625
   
 
626
   out[0] = in[0];
 
627
   out[1] = in[1];
 
628
   out[2] = in[2];
 
629
   out[3] = 1;
 
630
}
 
631
 
 
632
 
 
633
static void extract_2f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
 
634
{
 
635
   const GLfloat *in = (const GLfloat *)v;
 
636
   (void) a;
 
637
   
 
638
   out[0] = in[0];
 
639
   out[1] = in[1];
 
640
   out[2] = 0;
 
641
   out[3] = 1;
 
642
}
 
643
 
 
644
static void extract_1f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
 
645
{
 
646
   const GLfloat *in = (const GLfloat *)v;
 
647
   (void) a;
 
648
   
 
649
   out[0] = in[0];
 
650
   out[1] = 0;
 
651
   out[2] = 0;
 
652
   out[3] = 1;
 
653
}
 
654
 
 
655
static void extract_4chan_4f_rgba( const struct vf_attr *a, GLfloat *out, 
 
656
                                   const GLubyte *v )
 
657
{
 
658
   GLchan *c = (GLchan *)v;
 
659
   (void) a;
 
660
 
 
661
   out[0] = CHAN_TO_FLOAT(c[0]);
 
662
   out[1] = CHAN_TO_FLOAT(c[1]);
 
663
   out[2] = CHAN_TO_FLOAT(c[2]);
 
664
   out[3] = CHAN_TO_FLOAT(c[3]);
 
665
}
 
666
 
 
667
static void extract_4ub_4f_rgba( const struct vf_attr *a, GLfloat *out, 
 
668
                                 const GLubyte *v )
 
669
{
 
670
   (void) a;
 
671
   out[0] = UBYTE_TO_FLOAT(v[0]);
 
672
   out[1] = UBYTE_TO_FLOAT(v[1]);
 
673
   out[2] = UBYTE_TO_FLOAT(v[2]);
 
674
   out[3] = UBYTE_TO_FLOAT(v[3]);
 
675
}
 
676
 
 
677
static void extract_4ub_4f_bgra( const struct vf_attr *a, GLfloat *out, 
 
678
                                 const GLubyte *v )
 
679
{
 
680
   (void) a;
 
681
   out[2] = UBYTE_TO_FLOAT(v[0]);
 
682
   out[1] = UBYTE_TO_FLOAT(v[1]);
 
683
   out[0] = UBYTE_TO_FLOAT(v[2]);
 
684
   out[3] = UBYTE_TO_FLOAT(v[3]);
 
685
}
 
686
 
 
687
static void extract_4ub_4f_argb( const struct vf_attr *a, GLfloat *out, 
 
688
                                 const GLubyte *v )
 
689
{
 
690
   (void) a;
 
691
   out[3] = UBYTE_TO_FLOAT(v[0]);
 
692
   out[0] = UBYTE_TO_FLOAT(v[1]);
 
693
   out[1] = UBYTE_TO_FLOAT(v[2]);
 
694
   out[2] = UBYTE_TO_FLOAT(v[3]);
 
695
}
 
696
 
 
697
static void extract_4ub_4f_abgr( const struct vf_attr *a, GLfloat *out, 
 
698
                                 const GLubyte *v )
 
699
{
 
700
   (void) a;
 
701
   out[3] = UBYTE_TO_FLOAT(v[0]);
 
702
   out[2] = UBYTE_TO_FLOAT(v[1]);
 
703
   out[1] = UBYTE_TO_FLOAT(v[2]);
 
704
   out[0] = UBYTE_TO_FLOAT(v[3]);
 
705
}
 
706
 
 
707
static void extract_3ub_3f_rgb( const struct vf_attr *a, GLfloat *out, 
 
708
                                const GLubyte *v )
 
709
{
 
710
   (void) a;
 
711
   out[0] = UBYTE_TO_FLOAT(v[0]);
 
712
   out[1] = UBYTE_TO_FLOAT(v[1]);
 
713
   out[2] = UBYTE_TO_FLOAT(v[2]);
 
714
   out[3] = 1;
 
715
}
 
716
 
 
717
static void extract_3ub_3f_bgr( const struct vf_attr *a, GLfloat *out, 
 
718
                                const GLubyte *v )
 
719
{
 
720
   (void) a;
 
721
   out[2] = UBYTE_TO_FLOAT(v[0]);
 
722
   out[1] = UBYTE_TO_FLOAT(v[1]);
 
723
   out[0] = UBYTE_TO_FLOAT(v[2]);
 
724
   out[3] = 1;
 
725
}
 
726
 
 
727
static void extract_1ub_1f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
 
728
{
 
729
   (void) a;
 
730
   out[0] = UBYTE_TO_FLOAT(v[0]);
 
731
   out[1] = 0;
 
732
   out[2] = 0;
 
733
   out[3] = 1;
 
734
}
 
735
 
 
736
 
 
737
const struct vf_format_info vf_format_info[EMIT_MAX] = 
 
738
{
 
739
   { "1f",
 
740
     extract_1f,
 
741
     { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 },
 
742
     sizeof(GLfloat) },
 
743
 
 
744
   { "2f",
 
745
     extract_2f,
 
746
     { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 },
 
747
     2 * sizeof(GLfloat) },
 
748
 
 
749
   { "3f",
 
750
     extract_3f,
 
751
     { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 },
 
752
     3 * sizeof(GLfloat) },
 
753
 
 
754
   { "4f",
 
755
     extract_4f,
 
756
     { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 },
 
757
     4 * sizeof(GLfloat) },
 
758
 
 
759
   { "2f_viewport",
 
760
     extract_2f_viewport,
 
761
     { insert_2f_viewport_1, insert_2f_viewport_2, insert_2f_viewport_2,
 
762
       insert_2f_viewport_2 },
 
763
     2 * sizeof(GLfloat) },
 
764
 
 
765
   { "3f_viewport",
 
766
     extract_3f_viewport,
 
767
     { insert_3f_viewport_1, insert_3f_viewport_2, insert_3f_viewport_3,
 
768
       insert_3f_viewport_3 },
 
769
     3 * sizeof(GLfloat) },
 
770
 
 
771
   { "4f_viewport",
 
772
     extract_4f_viewport,
 
773
     { insert_4f_viewport_1, insert_4f_viewport_2, insert_4f_viewport_3,
 
774
       insert_4f_viewport_4 }, 
 
775
     4 * sizeof(GLfloat) },
 
776
 
 
777
   { "3f_xyw",
 
778
     extract_3f_xyw,
 
779
     { insert_3f_xyw_err, insert_3f_xyw_err, insert_3f_xyw_err, 
 
780
       insert_3f_xyw_4 },
 
781
     3 * sizeof(GLfloat) },
 
782
 
 
783
   { "1ub_1f",
 
784
     extract_1ub_1f,
 
785
     { insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1 },
 
786
     sizeof(GLubyte) },
 
787
 
 
788
   { "3ub_3f_rgb",
 
789
     extract_3ub_3f_rgb,
 
790
     { insert_3ub_3f_rgb_1, insert_3ub_3f_rgb_2, insert_3ub_3f_rgb_3,
 
791
       insert_3ub_3f_rgb_3 },
 
792
     3 * sizeof(GLubyte) },
 
793
 
 
794
   { "3ub_3f_bgr",
 
795
     extract_3ub_3f_bgr,
 
796
     { insert_3ub_3f_bgr_1, insert_3ub_3f_bgr_2, insert_3ub_3f_bgr_3,
 
797
       insert_3ub_3f_bgr_3 },
 
798
     3 * sizeof(GLubyte) },
 
799
 
 
800
   { "4ub_4f_rgba",
 
801
     extract_4ub_4f_rgba,
 
802
     { insert_4ub_4f_rgba_1, insert_4ub_4f_rgba_2, insert_4ub_4f_rgba_3, 
 
803
       insert_4ub_4f_rgba_4 },
 
804
     4 * sizeof(GLubyte) },
 
805
 
 
806
   { "4ub_4f_bgra",
 
807
     extract_4ub_4f_bgra,
 
808
     { insert_4ub_4f_bgra_1, insert_4ub_4f_bgra_2, insert_4ub_4f_bgra_3,
 
809
       insert_4ub_4f_bgra_4 },
 
810
     4 * sizeof(GLubyte) },
 
811
 
 
812
   { "4ub_4f_argb",
 
813
     extract_4ub_4f_argb,
 
814
     { insert_4ub_4f_argb_1, insert_4ub_4f_argb_2, insert_4ub_4f_argb_3,
 
815
       insert_4ub_4f_argb_4 },
 
816
     4 * sizeof(GLubyte) },
 
817
 
 
818
   { "4ub_4f_abgr",
 
819
     extract_4ub_4f_abgr,
 
820
     { insert_4ub_4f_abgr_1, insert_4ub_4f_abgr_2, insert_4ub_4f_abgr_3,
 
821
       insert_4ub_4f_abgr_4 },
 
822
     4 * sizeof(GLubyte) },
 
823
 
 
824
   { "4chan_4f_rgba",
 
825
     extract_4chan_4f_rgba,
 
826
     { insert_4chan_4f_rgba_1, insert_4chan_4f_rgba_2, insert_4chan_4f_rgba_3,
 
827
       insert_4chan_4f_rgba_4 },
 
828
     4 * sizeof(GLchan) },
 
829
 
 
830
   { "pad",
 
831
     NULL,
 
832
     { NULL, NULL, NULL, NULL },
 
833
     0 }
 
834
 
 
835
};
 
836
 
 
837
 
 
838
 
 
839
    
 
840
/***********************************************************************
 
841
 * Hardwired fastpaths for emitting whole vertices or groups of
 
842
 * vertices
 
843
 */
 
844
#define EMIT5(NR, F0, F1, F2, F3, F4, NAME)                             \
 
845
static void NAME( struct vertex_fetch *vf,                              \
 
846
                  GLuint count,                                         \
 
847
                  GLubyte *v )                                          \
 
848
{                                                                       \
 
849
   struct vf_attr *a = vf->attr;                                \
 
850
   GLuint i;                                                            \
 
851
                                                                        \
 
852
   for (i = 0 ; i < count ; i++, v += vf->vertex_stride) {              \
 
853
      if (NR > 0) {                                                     \
 
854
         F0( &a[0], v + a[0].vertoffset, (GLfloat *)a[0].inputptr );    \
 
855
         a[0].inputptr += a[0].inputstride;                             \
 
856
      }                                                                 \
 
857
                                                                        \
 
858
      if (NR > 1) {                                                     \
 
859
         F1( &a[1], v + a[1].vertoffset, (GLfloat *)a[1].inputptr );    \
 
860
         a[1].inputptr += a[1].inputstride;                             \
 
861
      }                                                                 \
 
862
                                                                        \
 
863
      if (NR > 2) {                                                     \
 
864
         F2( &a[2], v + a[2].vertoffset, (GLfloat *)a[2].inputptr );    \
 
865
         a[2].inputptr += a[2].inputstride;                             \
 
866
      }                                                                 \
 
867
                                                                        \
 
868
      if (NR > 3) {                                                     \
 
869
         F3( &a[3], v + a[3].vertoffset, (GLfloat *)a[3].inputptr );    \
 
870
         a[3].inputptr += a[3].inputstride;                             \
 
871
      }                                                                 \
 
872
                                                                        \
 
873
      if (NR > 4) {                                                     \
 
874
         F4( &a[4], v + a[4].vertoffset, (GLfloat *)a[4].inputptr );    \
 
875
         a[4].inputptr += a[4].inputstride;                             \
 
876
      }                                                                 \
 
877
   }                                                                    \
 
878
}
 
879
 
 
880
   
 
881
#define EMIT2(F0, F1, NAME) EMIT5(2, F0, F1, insert_null, \
 
882
                                  insert_null, insert_null, NAME)
 
883
 
 
884
#define EMIT3(F0, F1, F2, NAME) EMIT5(3, F0, F1, F2, insert_null, \
 
885
                                      insert_null, NAME)
 
886
   
 
887
#define EMIT4(F0, F1, F2, F3, NAME) EMIT5(4, F0, F1, F2, F3, \
 
888
                                          insert_null, NAME)
 
889
   
 
890
 
 
891
EMIT2(insert_3f_viewport_3, insert_4ub_4f_rgba_4, emit_viewport3_rgba4)
 
892
EMIT2(insert_3f_viewport_3, insert_4ub_4f_bgra_4, emit_viewport3_bgra4)
 
893
EMIT2(insert_3f_3, insert_4ub_4f_rgba_4, emit_xyz3_rgba4)
 
894
 
 
895
EMIT3(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_viewport4_rgba4_st2)
 
896
EMIT3(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2,  emit_viewport4_bgra4_st2)
 
897
EMIT3(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_xyzw4_rgba4_st2)
 
898
 
 
899
EMIT4(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_viewport4_rgba4_st2_st2)
 
900
EMIT4(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, insert_2f_2,  emit_viewport4_bgra4_st2_st2)
 
901
EMIT4(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_xyzw4_rgba4_st2_st2)
 
902
 
 
903
 
 
904
/* Use the codegen paths to select one of a number of hardwired
 
905
 * fastpaths.
 
906
 */
 
907
void vf_generate_hardwired_emit( struct vertex_fetch *vf )
 
908
{
 
909
   vf_emit_func func = NULL;
 
910
 
 
911
   /* Does it fit a hardwired fastpath?  Help! this is growing out of
 
912
    * control!
 
913
    */
 
914
   switch (vf->attr_count) {
 
915
   case 2:
 
916
      if (vf->attr[0].do_insert == insert_3f_viewport_3) {
 
917
         if (vf->attr[1].do_insert == insert_4ub_4f_bgra_4) 
 
918
            func = emit_viewport3_bgra4;
 
919
         else if (vf->attr[1].do_insert == insert_4ub_4f_rgba_4) 
 
920
            func = emit_viewport3_rgba4;
 
921
      }
 
922
      else if (vf->attr[0].do_insert == insert_3f_3 &&
 
923
               vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
 
924
         func = emit_xyz3_rgba4; 
 
925
      }
 
926
      break;
 
927
   case 3:
 
928
      if (vf->attr[2].do_insert == insert_2f_2) {
 
929
         if (vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
 
930
            if (vf->attr[0].do_insert == insert_4f_viewport_4)
 
931
               func = emit_viewport4_rgba4_st2;
 
932
            else if (vf->attr[0].do_insert == insert_4f_4) 
 
933
               func = emit_xyzw4_rgba4_st2;
 
934
         }
 
935
         else if (vf->attr[1].do_insert == insert_4ub_4f_bgra_4 &&
 
936
                  vf->attr[0].do_insert == insert_4f_viewport_4)
 
937
            func = emit_viewport4_bgra4_st2;
 
938
      }
 
939
      break;
 
940
   case 4:
 
941
      if (vf->attr[2].do_insert == insert_2f_2 &&
 
942
          vf->attr[3].do_insert == insert_2f_2) {
 
943
         if (vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
 
944
            if (vf->attr[0].do_insert == insert_4f_viewport_4)
 
945
               func = emit_viewport4_rgba4_st2_st2;
 
946
            else if (vf->attr[0].do_insert == insert_4f_4) 
 
947
               func = emit_xyzw4_rgba4_st2_st2;
 
948
         }
 
949
         else if (vf->attr[1].do_insert == insert_4ub_4f_bgra_4 &&
 
950
                  vf->attr[0].do_insert == insert_4f_viewport_4)
 
951
            func = emit_viewport4_bgra4_st2_st2;
 
952
      }
 
953
      break;
 
954
   }
 
955
 
 
956
   vf->emit = func;
 
957
}
 
958
 
 
959
/***********************************************************************
 
960
 * Generic (non-codegen) functions for whole vertices or groups of
 
961
 * vertices
 
962
 */
 
963
 
 
964
void vf_generic_emit( struct vertex_fetch *vf,
 
965
                      GLuint count,
 
966
                      GLubyte *v )
 
967
{
 
968
   struct vf_attr *a = vf->attr;
 
969
   const GLuint attr_count = vf->attr_count;
 
970
   const GLuint stride = vf->vertex_stride;
 
971
   GLuint i, j;
 
972
 
 
973
   for (i = 0 ; i < count ; i++, v += stride) {
 
974
      for (j = 0; j < attr_count; j++) {
 
975
         GLfloat *in = (GLfloat *)a[j].inputptr;
 
976
         a[j].inputptr += a[j].inputstride;
 
977
         a[j].do_insert( &a[j], v + a[j].vertoffset, in );
 
978
      }
 
979
   }
 
980
}
 
981
 
 
982