3 * Copyright 2003 Tungsten Graphics, inc.
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:
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
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.
26 * Keith Whitwell <keithw@tungstengraphics.com>
29 #include "main/glheader.h"
30 #include "main/context.h"
31 #include "main/colormac.h"
32 #include "main/simple_list.h"
38 * These functions take the NDC coordinates pointed to by 'in', apply the
39 * NDC->Viewport mapping and store the results at 'v'.
42 static INLINE void insert_4f_viewport_4( const struct vf_attr *a, GLubyte *v,
45 GLfloat *out = (GLfloat *)v;
46 const GLfloat *scale = a->vf->vp;
47 const GLfloat *trans = a->vf->vp + 4;
49 out[0] = scale[0] * in[0] + trans[0];
50 out[1] = scale[1] * in[1] + trans[1];
51 out[2] = scale[2] * in[2] + trans[2];
55 static INLINE void insert_4f_viewport_3( const struct vf_attr *a, GLubyte *v,
58 GLfloat *out = (GLfloat *)v;
59 const GLfloat *scale = a->vf->vp;
60 const GLfloat *trans = a->vf->vp + 4;
62 out[0] = scale[0] * in[0] + trans[0];
63 out[1] = scale[1] * in[1] + trans[1];
64 out[2] = scale[2] * in[2] + trans[2];
68 static INLINE void insert_4f_viewport_2( const struct vf_attr *a, GLubyte *v,
71 GLfloat *out = (GLfloat *)v;
72 const GLfloat *scale = a->vf->vp;
73 const GLfloat *trans = a->vf->vp + 4;
75 out[0] = scale[0] * in[0] + trans[0];
76 out[1] = scale[1] * in[1] + trans[1];
81 static INLINE void insert_4f_viewport_1( const struct vf_attr *a, GLubyte *v,
84 GLfloat *out = (GLfloat *)v;
85 const GLfloat *scale = a->vf->vp;
86 const GLfloat *trans = a->vf->vp + 4;
88 out[0] = scale[0] * in[0] + trans[0];
94 static INLINE void insert_3f_viewport_3( const struct vf_attr *a, GLubyte *v,
97 GLfloat *out = (GLfloat *)v;
98 const GLfloat *scale = a->vf->vp;
99 const GLfloat *trans = a->vf->vp + 4;
101 out[0] = scale[0] * in[0] + trans[0];
102 out[1] = scale[1] * in[1] + trans[1];
103 out[2] = scale[2] * in[2] + trans[2];
106 static INLINE void insert_3f_viewport_2( const struct vf_attr *a, GLubyte *v,
109 GLfloat *out = (GLfloat *)v;
110 const GLfloat *scale = a->vf->vp;
111 const GLfloat *trans = a->vf->vp + 4;
113 out[0] = scale[0] * in[0] + trans[0];
114 out[1] = scale[1] * in[1] + trans[1];
115 out[2] = scale[2] * in[2] + trans[2];
118 static INLINE void insert_3f_viewport_1( const struct vf_attr *a, GLubyte *v,
121 GLfloat *out = (GLfloat *)v;
122 const GLfloat *scale = a->vf->vp;
123 const GLfloat *trans = a->vf->vp + 4;
125 out[0] = scale[0] * in[0] + trans[0];
130 static INLINE void insert_2f_viewport_2( const struct vf_attr *a, GLubyte *v,
133 GLfloat *out = (GLfloat *)v;
134 const GLfloat *scale = a->vf->vp;
135 const GLfloat *trans = a->vf->vp + 4;
137 out[0] = scale[0] * in[0] + trans[0];
138 out[1] = scale[1] * in[1] + trans[1];
141 static INLINE void insert_2f_viewport_1( const struct vf_attr *a, GLubyte *v,
144 GLfloat *out = (GLfloat *)v;
145 const GLfloat *scale = a->vf->vp;
146 const GLfloat *trans = a->vf->vp + 4;
148 out[0] = scale[0] * in[0] + trans[0];
154 * These functions do the same as above, except for the viewport mapping.
157 static INLINE void insert_4f_4( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
159 GLfloat *out = (GLfloat *)(v);
168 static INLINE void insert_4f_3( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
170 GLfloat *out = (GLfloat *)(v);
179 static INLINE void insert_4f_2( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
181 GLfloat *out = (GLfloat *)(v);
190 static INLINE void insert_4f_1( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
192 GLfloat *out = (GLfloat *)(v);
201 static INLINE void insert_3f_xyw_4( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
203 GLfloat *out = (GLfloat *)(v);
211 static INLINE void insert_3f_xyw_err( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
213 (void) a; (void) v; (void) in;
217 static INLINE void insert_3f_3( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
219 GLfloat *out = (GLfloat *)(v);
227 static INLINE void insert_3f_2( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
229 GLfloat *out = (GLfloat *)(v);
237 static INLINE void insert_3f_1( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
239 GLfloat *out = (GLfloat *)(v);
248 static INLINE void insert_2f_2( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
250 GLfloat *out = (GLfloat *)(v);
257 static INLINE void insert_2f_1( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
259 GLfloat *out = (GLfloat *)(v);
266 static INLINE void insert_1f_1( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
268 GLfloat *out = (GLfloat *)(v);
274 static INLINE void insert_null( const struct vf_attr *a, GLubyte *v, const GLfloat *in )
276 (void) a; (void) v; (void) in;
279 static INLINE void insert_4chan_4f_rgba_4( const struct vf_attr *a, GLubyte *v,
282 GLchan *c = (GLchan *)v;
284 UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
285 UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
286 UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]);
287 UNCLAMPED_FLOAT_TO_CHAN(c[3], in[3]);
290 static INLINE void insert_4chan_4f_rgba_3( const struct vf_attr *a, GLubyte *v,
293 GLchan *c = (GLchan *)v;
295 UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
296 UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
297 UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]);
301 static INLINE void insert_4chan_4f_rgba_2( const struct vf_attr *a, GLubyte *v,
304 GLchan *c = (GLchan *)v;
306 UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
307 UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
312 static INLINE void insert_4chan_4f_rgba_1( const struct vf_attr *a, GLubyte *v,
315 GLchan *c = (GLchan *)v;
317 UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
323 static INLINE void insert_4ub_4f_rgba_4( const struct vf_attr *a, GLubyte *v,
327 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
328 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
329 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
330 UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
333 static INLINE void insert_4ub_4f_rgba_3( const struct vf_attr *a, GLubyte *v,
337 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
338 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
339 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
343 static INLINE void insert_4ub_4f_rgba_2( const struct vf_attr *a, GLubyte *v,
347 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
348 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
353 static INLINE void insert_4ub_4f_rgba_1( const struct vf_attr *a, GLubyte *v,
357 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
363 static INLINE void insert_4ub_4f_bgra_4( const struct vf_attr *a, GLubyte *v,
367 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
368 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
369 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
370 UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
373 static INLINE void insert_4ub_4f_bgra_3( const struct vf_attr *a, GLubyte *v,
377 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
378 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
379 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
383 static INLINE void insert_4ub_4f_bgra_2( const struct vf_attr *a, GLubyte *v,
387 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
388 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
393 static INLINE void insert_4ub_4f_bgra_1( const struct vf_attr *a, GLubyte *v,
397 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
403 static INLINE void insert_4ub_4f_argb_4( const struct vf_attr *a, GLubyte *v,
407 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
408 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
409 UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
410 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
413 static INLINE void insert_4ub_4f_argb_3( const struct vf_attr *a, GLubyte *v,
417 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
418 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
419 UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
423 static INLINE void insert_4ub_4f_argb_2( const struct vf_attr *a, GLubyte *v,
427 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
428 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
433 static INLINE void insert_4ub_4f_argb_1( const struct vf_attr *a, GLubyte *v,
437 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
443 static INLINE void insert_4ub_4f_abgr_4( const struct vf_attr *a, GLubyte *v,
447 UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
448 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
449 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
450 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
453 static INLINE void insert_4ub_4f_abgr_3( const struct vf_attr *a, GLubyte *v,
457 UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
458 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
459 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
463 static INLINE void insert_4ub_4f_abgr_2( const struct vf_attr *a, GLubyte *v,
467 UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
468 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
473 static INLINE void insert_4ub_4f_abgr_1( const struct vf_attr *a, GLubyte *v,
477 UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
483 static INLINE void insert_3ub_3f_rgb_3( const struct vf_attr *a, GLubyte *v,
487 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
488 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
489 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
492 static INLINE void insert_3ub_3f_rgb_2( const struct vf_attr *a, GLubyte *v,
496 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
497 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
501 static INLINE void insert_3ub_3f_rgb_1( const struct vf_attr *a, GLubyte *v,
505 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
510 static INLINE void insert_3ub_3f_bgr_3( const struct vf_attr *a, GLubyte *v,
514 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
515 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
516 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
519 static INLINE void insert_3ub_3f_bgr_2( const struct vf_attr *a, GLubyte *v,
523 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
524 UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
528 static INLINE void insert_3ub_3f_bgr_1( const struct vf_attr *a, GLubyte *v,
532 UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
538 static INLINE void insert_1ub_1f_1( const struct vf_attr *a, GLubyte *v,
542 UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
546 /***********************************************************************
547 * Functions to perform the reverse operations to the above, for
548 * swrast translation and clip-interpolation.
550 * Currently always extracts a full 4 floats.
553 static void extract_4f_viewport( const struct vf_attr *a, GLfloat *out,
556 const GLfloat *in = (const GLfloat *)v;
557 const GLfloat *scale = a->vf->vp;
558 const GLfloat *trans = a->vf->vp + 4;
560 /* Although included for completeness, the position coordinate is
561 * usually handled differently during clipping.
563 out[0] = (in[0] - trans[0]) / scale[0];
564 out[1] = (in[1] - trans[1]) / scale[1];
565 out[2] = (in[2] - trans[2]) / scale[2];
569 static void extract_3f_viewport( const struct vf_attr *a, GLfloat *out,
572 const GLfloat *in = (const GLfloat *)v;
573 const GLfloat *scale = a->vf->vp;
574 const GLfloat *trans = a->vf->vp + 4;
576 out[0] = (in[0] - trans[0]) / scale[0];
577 out[1] = (in[1] - trans[1]) / scale[1];
578 out[2] = (in[2] - trans[2]) / scale[2];
583 static void extract_2f_viewport( const struct vf_attr *a, GLfloat *out,
586 const GLfloat *in = (const GLfloat *)v;
587 const GLfloat *scale = a->vf->vp;
588 const GLfloat *trans = a->vf->vp + 4;
590 out[0] = (in[0] - trans[0]) / scale[0];
591 out[1] = (in[1] - trans[1]) / scale[1];
597 static void extract_4f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
599 const GLfloat *in = (const GLfloat *)v;
608 static void extract_3f_xyw( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
610 const GLfloat *in = (const GLfloat *)v;
620 static void extract_3f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
622 const GLfloat *in = (const GLfloat *)v;
632 static void extract_2f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
634 const GLfloat *in = (const GLfloat *)v;
643 static void extract_1f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
645 const GLfloat *in = (const GLfloat *)v;
654 static void extract_4chan_4f_rgba( const struct vf_attr *a, GLfloat *out,
657 GLchan *c = (GLchan *)v;
660 out[0] = CHAN_TO_FLOAT(c[0]);
661 out[1] = CHAN_TO_FLOAT(c[1]);
662 out[2] = CHAN_TO_FLOAT(c[2]);
663 out[3] = CHAN_TO_FLOAT(c[3]);
666 static void extract_4ub_4f_rgba( const struct vf_attr *a, GLfloat *out,
670 out[0] = UBYTE_TO_FLOAT(v[0]);
671 out[1] = UBYTE_TO_FLOAT(v[1]);
672 out[2] = UBYTE_TO_FLOAT(v[2]);
673 out[3] = UBYTE_TO_FLOAT(v[3]);
676 static void extract_4ub_4f_bgra( const struct vf_attr *a, GLfloat *out,
680 out[2] = UBYTE_TO_FLOAT(v[0]);
681 out[1] = UBYTE_TO_FLOAT(v[1]);
682 out[0] = UBYTE_TO_FLOAT(v[2]);
683 out[3] = UBYTE_TO_FLOAT(v[3]);
686 static void extract_4ub_4f_argb( const struct vf_attr *a, GLfloat *out,
690 out[3] = UBYTE_TO_FLOAT(v[0]);
691 out[0] = UBYTE_TO_FLOAT(v[1]);
692 out[1] = UBYTE_TO_FLOAT(v[2]);
693 out[2] = UBYTE_TO_FLOAT(v[3]);
696 static void extract_4ub_4f_abgr( const struct vf_attr *a, GLfloat *out,
700 out[3] = UBYTE_TO_FLOAT(v[0]);
701 out[2] = UBYTE_TO_FLOAT(v[1]);
702 out[1] = UBYTE_TO_FLOAT(v[2]);
703 out[0] = UBYTE_TO_FLOAT(v[3]);
706 static void extract_3ub_3f_rgb( const struct vf_attr *a, GLfloat *out,
710 out[0] = UBYTE_TO_FLOAT(v[0]);
711 out[1] = UBYTE_TO_FLOAT(v[1]);
712 out[2] = UBYTE_TO_FLOAT(v[2]);
716 static void extract_3ub_3f_bgr( const struct vf_attr *a, GLfloat *out,
720 out[2] = UBYTE_TO_FLOAT(v[0]);
721 out[1] = UBYTE_TO_FLOAT(v[1]);
722 out[0] = UBYTE_TO_FLOAT(v[2]);
726 static void extract_1ub_1f( const struct vf_attr *a, GLfloat *out, const GLubyte *v )
729 out[0] = UBYTE_TO_FLOAT(v[0]);
736 const struct vf_format_info vf_format_info[EMIT_MAX] =
740 { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 },
745 { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 },
746 2 * sizeof(GLfloat) },
750 { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 },
751 3 * sizeof(GLfloat) },
755 { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 },
756 4 * sizeof(GLfloat) },
760 { insert_2f_viewport_1, insert_2f_viewport_2, insert_2f_viewport_2,
761 insert_2f_viewport_2 },
762 2 * sizeof(GLfloat) },
766 { insert_3f_viewport_1, insert_3f_viewport_2, insert_3f_viewport_3,
767 insert_3f_viewport_3 },
768 3 * sizeof(GLfloat) },
772 { insert_4f_viewport_1, insert_4f_viewport_2, insert_4f_viewport_3,
773 insert_4f_viewport_4 },
774 4 * sizeof(GLfloat) },
778 { insert_3f_xyw_err, insert_3f_xyw_err, insert_3f_xyw_err,
780 3 * sizeof(GLfloat) },
784 { insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1 },
789 { insert_3ub_3f_rgb_1, insert_3ub_3f_rgb_2, insert_3ub_3f_rgb_3,
790 insert_3ub_3f_rgb_3 },
791 3 * sizeof(GLubyte) },
795 { insert_3ub_3f_bgr_1, insert_3ub_3f_bgr_2, insert_3ub_3f_bgr_3,
796 insert_3ub_3f_bgr_3 },
797 3 * sizeof(GLubyte) },
801 { insert_4ub_4f_rgba_1, insert_4ub_4f_rgba_2, insert_4ub_4f_rgba_3,
802 insert_4ub_4f_rgba_4 },
803 4 * sizeof(GLubyte) },
807 { insert_4ub_4f_bgra_1, insert_4ub_4f_bgra_2, insert_4ub_4f_bgra_3,
808 insert_4ub_4f_bgra_4 },
809 4 * sizeof(GLubyte) },
813 { insert_4ub_4f_argb_1, insert_4ub_4f_argb_2, insert_4ub_4f_argb_3,
814 insert_4ub_4f_argb_4 },
815 4 * sizeof(GLubyte) },
819 { insert_4ub_4f_abgr_1, insert_4ub_4f_abgr_2, insert_4ub_4f_abgr_3,
820 insert_4ub_4f_abgr_4 },
821 4 * sizeof(GLubyte) },
824 extract_4chan_4f_rgba,
825 { insert_4chan_4f_rgba_1, insert_4chan_4f_rgba_2, insert_4chan_4f_rgba_3,
826 insert_4chan_4f_rgba_4 },
827 4 * sizeof(GLchan) },
831 { NULL, NULL, NULL, NULL },
839 /***********************************************************************
840 * Hardwired fastpaths for emitting whole vertices or groups of
843 #define EMIT5(NR, F0, F1, F2, F3, F4, NAME) \
844 static void NAME( struct vertex_fetch *vf, \
848 struct vf_attr *a = vf->attr; \
851 for (i = 0 ; i < count ; i++, v += vf->vertex_stride) { \
853 F0( &a[0], v + a[0].vertoffset, (GLfloat *)a[0].inputptr ); \
854 a[0].inputptr += a[0].inputstride; \
858 F1( &a[1], v + a[1].vertoffset, (GLfloat *)a[1].inputptr ); \
859 a[1].inputptr += a[1].inputstride; \
863 F2( &a[2], v + a[2].vertoffset, (GLfloat *)a[2].inputptr ); \
864 a[2].inputptr += a[2].inputstride; \
868 F3( &a[3], v + a[3].vertoffset, (GLfloat *)a[3].inputptr ); \
869 a[3].inputptr += a[3].inputstride; \
873 F4( &a[4], v + a[4].vertoffset, (GLfloat *)a[4].inputptr ); \
874 a[4].inputptr += a[4].inputstride; \
880 #define EMIT2(F0, F1, NAME) EMIT5(2, F0, F1, insert_null, \
881 insert_null, insert_null, NAME)
883 #define EMIT3(F0, F1, F2, NAME) EMIT5(3, F0, F1, F2, insert_null, \
886 #define EMIT4(F0, F1, F2, F3, NAME) EMIT5(4, F0, F1, F2, F3, \
890 EMIT2(insert_3f_viewport_3, insert_4ub_4f_rgba_4, emit_viewport3_rgba4)
891 EMIT2(insert_3f_viewport_3, insert_4ub_4f_bgra_4, emit_viewport3_bgra4)
892 EMIT2(insert_3f_3, insert_4ub_4f_rgba_4, emit_xyz3_rgba4)
894 EMIT3(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_viewport4_rgba4_st2)
895 EMIT3(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, emit_viewport4_bgra4_st2)
896 EMIT3(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_xyzw4_rgba4_st2)
898 EMIT4(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_viewport4_rgba4_st2_st2)
899 EMIT4(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, insert_2f_2, emit_viewport4_bgra4_st2_st2)
900 EMIT4(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_xyzw4_rgba4_st2_st2)
903 /* Use the codegen paths to select one of a number of hardwired
906 void vf_generate_hardwired_emit( struct vertex_fetch *vf )
908 vf_emit_func func = NULL;
910 /* Does it fit a hardwired fastpath? Help! this is growing out of
913 switch (vf->attr_count) {
915 if (vf->attr[0].do_insert == insert_3f_viewport_3) {
916 if (vf->attr[1].do_insert == insert_4ub_4f_bgra_4)
917 func = emit_viewport3_bgra4;
918 else if (vf->attr[1].do_insert == insert_4ub_4f_rgba_4)
919 func = emit_viewport3_rgba4;
921 else if (vf->attr[0].do_insert == insert_3f_3 &&
922 vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
923 func = emit_xyz3_rgba4;
927 if (vf->attr[2].do_insert == insert_2f_2) {
928 if (vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
929 if (vf->attr[0].do_insert == insert_4f_viewport_4)
930 func = emit_viewport4_rgba4_st2;
931 else if (vf->attr[0].do_insert == insert_4f_4)
932 func = emit_xyzw4_rgba4_st2;
934 else if (vf->attr[1].do_insert == insert_4ub_4f_bgra_4 &&
935 vf->attr[0].do_insert == insert_4f_viewport_4)
936 func = emit_viewport4_bgra4_st2;
940 if (vf->attr[2].do_insert == insert_2f_2 &&
941 vf->attr[3].do_insert == insert_2f_2) {
942 if (vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
943 if (vf->attr[0].do_insert == insert_4f_viewport_4)
944 func = emit_viewport4_rgba4_st2_st2;
945 else if (vf->attr[0].do_insert == insert_4f_4)
946 func = emit_xyzw4_rgba4_st2_st2;
948 else if (vf->attr[1].do_insert == insert_4ub_4f_bgra_4 &&
949 vf->attr[0].do_insert == insert_4f_viewport_4)
950 func = emit_viewport4_bgra4_st2_st2;
958 /***********************************************************************
959 * Generic (non-codegen) functions for whole vertices or groups of
963 void vf_generic_emit( struct vertex_fetch *vf,
967 struct vf_attr *a = vf->attr;
968 const GLuint attr_count = vf->attr_count;
969 const GLuint stride = vf->vertex_stride;
972 for (i = 0 ; i < count ; i++, v += stride) {
973 for (j = 0; j < attr_count; j++) {
974 GLfloat *in = (GLfloat *)a[j].inputptr;
975 a[j].inputptr += a[j].inputstride;
976 a[j].do_insert( &a[j], v + a[j].vertoffset, in );