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/macros.h"
33 #include "main/simple_list.h"
39 * These functions take the NDC coordinates pointed to by 'in', apply the
40 * NDC->Viewport mapping and store the results at 'v'.
43 static INLINE
void insert_4f_viewport_4( const struct vf_attr
*a
, GLubyte
*v
,
46 GLfloat
*out
= (GLfloat
*)v
;
47 const GLfloat
*scale
= a
->vf
->vp
;
48 const GLfloat
*trans
= a
->vf
->vp
+ 4;
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];
56 static INLINE
void insert_4f_viewport_3( const struct vf_attr
*a
, GLubyte
*v
,
59 GLfloat
*out
= (GLfloat
*)v
;
60 const GLfloat
*scale
= a
->vf
->vp
;
61 const GLfloat
*trans
= a
->vf
->vp
+ 4;
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];
69 static INLINE
void insert_4f_viewport_2( const struct vf_attr
*a
, GLubyte
*v
,
72 GLfloat
*out
= (GLfloat
*)v
;
73 const GLfloat
*scale
= a
->vf
->vp
;
74 const GLfloat
*trans
= a
->vf
->vp
+ 4;
76 out
[0] = scale
[0] * in
[0] + trans
[0];
77 out
[1] = scale
[1] * in
[1] + trans
[1];
82 static INLINE
void insert_4f_viewport_1( const struct vf_attr
*a
, GLubyte
*v
,
85 GLfloat
*out
= (GLfloat
*)v
;
86 const GLfloat
*scale
= a
->vf
->vp
;
87 const GLfloat
*trans
= a
->vf
->vp
+ 4;
89 out
[0] = scale
[0] * in
[0] + trans
[0];
95 static INLINE
void insert_3f_viewport_3( const struct vf_attr
*a
, GLubyte
*v
,
98 GLfloat
*out
= (GLfloat
*)v
;
99 const GLfloat
*scale
= a
->vf
->vp
;
100 const GLfloat
*trans
= a
->vf
->vp
+ 4;
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];
107 static INLINE
void insert_3f_viewport_2( const struct vf_attr
*a
, GLubyte
*v
,
110 GLfloat
*out
= (GLfloat
*)v
;
111 const GLfloat
*scale
= a
->vf
->vp
;
112 const GLfloat
*trans
= a
->vf
->vp
+ 4;
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];
119 static INLINE
void insert_3f_viewport_1( const struct vf_attr
*a
, GLubyte
*v
,
122 GLfloat
*out
= (GLfloat
*)v
;
123 const GLfloat
*scale
= a
->vf
->vp
;
124 const GLfloat
*trans
= a
->vf
->vp
+ 4;
126 out
[0] = scale
[0] * in
[0] + trans
[0];
131 static INLINE
void insert_2f_viewport_2( const struct vf_attr
*a
, GLubyte
*v
,
134 GLfloat
*out
= (GLfloat
*)v
;
135 const GLfloat
*scale
= a
->vf
->vp
;
136 const GLfloat
*trans
= a
->vf
->vp
+ 4;
138 out
[0] = scale
[0] * in
[0] + trans
[0];
139 out
[1] = scale
[1] * in
[1] + trans
[1];
142 static INLINE
void insert_2f_viewport_1( const struct vf_attr
*a
, GLubyte
*v
,
145 GLfloat
*out
= (GLfloat
*)v
;
146 const GLfloat
*scale
= a
->vf
->vp
;
147 const GLfloat
*trans
= a
->vf
->vp
+ 4;
149 out
[0] = scale
[0] * in
[0] + trans
[0];
155 * These functions do the same as above, except for the viewport mapping.
158 static INLINE
void insert_4f_4( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
160 GLfloat
*out
= (GLfloat
*)(v
);
169 static INLINE
void insert_4f_3( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
171 GLfloat
*out
= (GLfloat
*)(v
);
180 static INLINE
void insert_4f_2( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
182 GLfloat
*out
= (GLfloat
*)(v
);
191 static INLINE
void insert_4f_1( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
193 GLfloat
*out
= (GLfloat
*)(v
);
202 static INLINE
void insert_3f_xyw_4( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
204 GLfloat
*out
= (GLfloat
*)(v
);
212 static INLINE
void insert_3f_xyw_err( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
214 (void) a
; (void) v
; (void) in
;
218 static INLINE
void insert_3f_3( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
220 GLfloat
*out
= (GLfloat
*)(v
);
228 static INLINE
void insert_3f_2( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
230 GLfloat
*out
= (GLfloat
*)(v
);
238 static INLINE
void insert_3f_1( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
240 GLfloat
*out
= (GLfloat
*)(v
);
249 static INLINE
void insert_2f_2( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
251 GLfloat
*out
= (GLfloat
*)(v
);
258 static INLINE
void insert_2f_1( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
260 GLfloat
*out
= (GLfloat
*)(v
);
267 static INLINE
void insert_1f_1( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
269 GLfloat
*out
= (GLfloat
*)(v
);
275 static INLINE
void insert_null( const struct vf_attr
*a
, GLubyte
*v
, const GLfloat
*in
)
277 (void) a
; (void) v
; (void) in
;
280 static INLINE
void insert_4chan_4f_rgba_4( const struct vf_attr
*a
, GLubyte
*v
,
283 GLchan
*c
= (GLchan
*)v
;
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]);
291 static INLINE
void insert_4chan_4f_rgba_3( const struct vf_attr
*a
, GLubyte
*v
,
294 GLchan
*c
= (GLchan
*)v
;
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]);
302 static INLINE
void insert_4chan_4f_rgba_2( const struct vf_attr
*a
, GLubyte
*v
,
305 GLchan
*c
= (GLchan
*)v
;
307 UNCLAMPED_FLOAT_TO_CHAN(c
[0], in
[0]);
308 UNCLAMPED_FLOAT_TO_CHAN(c
[1], in
[1]);
313 static INLINE
void insert_4chan_4f_rgba_1( const struct vf_attr
*a
, GLubyte
*v
,
316 GLchan
*c
= (GLchan
*)v
;
318 UNCLAMPED_FLOAT_TO_CHAN(c
[0], in
[0]);
324 static INLINE
void insert_4ub_4f_rgba_4( const struct vf_attr
*a
, GLubyte
*v
,
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]);
334 static INLINE
void insert_4ub_4f_rgba_3( const struct vf_attr
*a
, GLubyte
*v
,
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]);
344 static INLINE
void insert_4ub_4f_rgba_2( const struct vf_attr
*a
, GLubyte
*v
,
348 UNCLAMPED_FLOAT_TO_UBYTE(v
[0], in
[0]);
349 UNCLAMPED_FLOAT_TO_UBYTE(v
[1], in
[1]);
354 static INLINE
void insert_4ub_4f_rgba_1( const struct vf_attr
*a
, GLubyte
*v
,
358 UNCLAMPED_FLOAT_TO_UBYTE(v
[0], in
[0]);
364 static INLINE
void insert_4ub_4f_bgra_4( const struct vf_attr
*a
, GLubyte
*v
,
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]);
374 static INLINE
void insert_4ub_4f_bgra_3( const struct vf_attr
*a
, GLubyte
*v
,
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]);
384 static INLINE
void insert_4ub_4f_bgra_2( const struct vf_attr
*a
, GLubyte
*v
,
388 UNCLAMPED_FLOAT_TO_UBYTE(v
[2], in
[0]);
389 UNCLAMPED_FLOAT_TO_UBYTE(v
[1], in
[1]);
394 static INLINE
void insert_4ub_4f_bgra_1( const struct vf_attr
*a
, GLubyte
*v
,
398 UNCLAMPED_FLOAT_TO_UBYTE(v
[2], in
[0]);
404 static INLINE
void insert_4ub_4f_argb_4( const struct vf_attr
*a
, GLubyte
*v
,
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]);
414 static INLINE
void insert_4ub_4f_argb_3( const struct vf_attr
*a
, GLubyte
*v
,
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]);
424 static INLINE
void insert_4ub_4f_argb_2( const struct vf_attr
*a
, GLubyte
*v
,
428 UNCLAMPED_FLOAT_TO_UBYTE(v
[1], in
[0]);
429 UNCLAMPED_FLOAT_TO_UBYTE(v
[2], in
[1]);
434 static INLINE
void insert_4ub_4f_argb_1( const struct vf_attr
*a
, GLubyte
*v
,
438 UNCLAMPED_FLOAT_TO_UBYTE(v
[1], in
[0]);
444 static INLINE
void insert_4ub_4f_abgr_4( const struct vf_attr
*a
, GLubyte
*v
,
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]);
454 static INLINE
void insert_4ub_4f_abgr_3( const struct vf_attr
*a
, GLubyte
*v
,
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]);
464 static INLINE
void insert_4ub_4f_abgr_2( const struct vf_attr
*a
, GLubyte
*v
,
468 UNCLAMPED_FLOAT_TO_UBYTE(v
[3], in
[0]);
469 UNCLAMPED_FLOAT_TO_UBYTE(v
[2], in
[1]);
474 static INLINE
void insert_4ub_4f_abgr_1( const struct vf_attr
*a
, GLubyte
*v
,
478 UNCLAMPED_FLOAT_TO_UBYTE(v
[3], in
[0]);
484 static INLINE
void insert_3ub_3f_rgb_3( const struct vf_attr
*a
, GLubyte
*v
,
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]);
493 static INLINE
void insert_3ub_3f_rgb_2( const struct vf_attr
*a
, GLubyte
*v
,
497 UNCLAMPED_FLOAT_TO_UBYTE(v
[0], in
[0]);
498 UNCLAMPED_FLOAT_TO_UBYTE(v
[1], in
[1]);
502 static INLINE
void insert_3ub_3f_rgb_1( const struct vf_attr
*a
, GLubyte
*v
,
506 UNCLAMPED_FLOAT_TO_UBYTE(v
[0], in
[0]);
511 static INLINE
void insert_3ub_3f_bgr_3( const struct vf_attr
*a
, GLubyte
*v
,
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]);
520 static INLINE
void insert_3ub_3f_bgr_2( const struct vf_attr
*a
, GLubyte
*v
,
524 UNCLAMPED_FLOAT_TO_UBYTE(v
[2], in
[0]);
525 UNCLAMPED_FLOAT_TO_UBYTE(v
[1], in
[1]);
529 static INLINE
void insert_3ub_3f_bgr_1( const struct vf_attr
*a
, GLubyte
*v
,
533 UNCLAMPED_FLOAT_TO_UBYTE(v
[2], in
[0]);
539 static INLINE
void insert_1ub_1f_1( const struct vf_attr
*a
, GLubyte
*v
,
543 UNCLAMPED_FLOAT_TO_UBYTE(v
[0], in
[0]);
547 /***********************************************************************
548 * Functions to perform the reverse operations to the above, for
549 * swrast translation and clip-interpolation.
551 * Currently always extracts a full 4 floats.
554 static void extract_4f_viewport( const struct vf_attr
*a
, GLfloat
*out
,
557 const GLfloat
*in
= (const GLfloat
*)v
;
558 const GLfloat
*scale
= a
->vf
->vp
;
559 const GLfloat
*trans
= a
->vf
->vp
+ 4;
561 /* Although included for completeness, the position coordinate is
562 * usually handled differently during clipping.
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];
570 static void extract_3f_viewport( const struct vf_attr
*a
, GLfloat
*out
,
573 const GLfloat
*in
= (const GLfloat
*)v
;
574 const GLfloat
*scale
= a
->vf
->vp
;
575 const GLfloat
*trans
= a
->vf
->vp
+ 4;
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];
584 static void extract_2f_viewport( const struct vf_attr
*a
, GLfloat
*out
,
587 const GLfloat
*in
= (const GLfloat
*)v
;
588 const GLfloat
*scale
= a
->vf
->vp
;
589 const GLfloat
*trans
= a
->vf
->vp
+ 4;
591 out
[0] = (in
[0] - trans
[0]) / scale
[0];
592 out
[1] = (in
[1] - trans
[1]) / scale
[1];
598 static void extract_4f( const struct vf_attr
*a
, GLfloat
*out
, const GLubyte
*v
)
600 const GLfloat
*in
= (const GLfloat
*)v
;
609 static void extract_3f_xyw( const struct vf_attr
*a
, GLfloat
*out
, const GLubyte
*v
)
611 const GLfloat
*in
= (const GLfloat
*)v
;
621 static void extract_3f( const struct vf_attr
*a
, GLfloat
*out
, const GLubyte
*v
)
623 const GLfloat
*in
= (const GLfloat
*)v
;
633 static void extract_2f( const struct vf_attr
*a
, GLfloat
*out
, const GLubyte
*v
)
635 const GLfloat
*in
= (const GLfloat
*)v
;
644 static void extract_1f( const struct vf_attr
*a
, GLfloat
*out
, const GLubyte
*v
)
646 const GLfloat
*in
= (const GLfloat
*)v
;
655 static void extract_4chan_4f_rgba( const struct vf_attr
*a
, GLfloat
*out
,
658 GLchan
*c
= (GLchan
*)v
;
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]);
667 static void extract_4ub_4f_rgba( const struct vf_attr
*a
, GLfloat
*out
,
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]);
677 static void extract_4ub_4f_bgra( const struct vf_attr
*a
, GLfloat
*out
,
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]);
687 static void extract_4ub_4f_argb( const struct vf_attr
*a
, GLfloat
*out
,
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]);
697 static void extract_4ub_4f_abgr( const struct vf_attr
*a
, GLfloat
*out
,
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]);
707 static void extract_3ub_3f_rgb( const struct vf_attr
*a
, GLfloat
*out
,
711 out
[0] = UBYTE_TO_FLOAT(v
[0]);
712 out
[1] = UBYTE_TO_FLOAT(v
[1]);
713 out
[2] = UBYTE_TO_FLOAT(v
[2]);
717 static void extract_3ub_3f_bgr( const struct vf_attr
*a
, GLfloat
*out
,
721 out
[2] = UBYTE_TO_FLOAT(v
[0]);
722 out
[1] = UBYTE_TO_FLOAT(v
[1]);
723 out
[0] = UBYTE_TO_FLOAT(v
[2]);
727 static void extract_1ub_1f( const struct vf_attr
*a
, GLfloat
*out
, const GLubyte
*v
)
730 out
[0] = UBYTE_TO_FLOAT(v
[0]);
737 const struct vf_format_info vf_format_info
[EMIT_MAX
] =
741 { insert_1f_1
, insert_1f_1
, insert_1f_1
, insert_1f_1
},
746 { insert_2f_1
, insert_2f_2
, insert_2f_2
, insert_2f_2
},
747 2 * sizeof(GLfloat
) },
751 { insert_3f_1
, insert_3f_2
, insert_3f_3
, insert_3f_3
},
752 3 * sizeof(GLfloat
) },
756 { insert_4f_1
, insert_4f_2
, insert_4f_3
, insert_4f_4
},
757 4 * sizeof(GLfloat
) },
761 { insert_2f_viewport_1
, insert_2f_viewport_2
, insert_2f_viewport_2
,
762 insert_2f_viewport_2
},
763 2 * sizeof(GLfloat
) },
767 { insert_3f_viewport_1
, insert_3f_viewport_2
, insert_3f_viewport_3
,
768 insert_3f_viewport_3
},
769 3 * sizeof(GLfloat
) },
773 { insert_4f_viewport_1
, insert_4f_viewport_2
, insert_4f_viewport_3
,
774 insert_4f_viewport_4
},
775 4 * sizeof(GLfloat
) },
779 { insert_3f_xyw_err
, insert_3f_xyw_err
, insert_3f_xyw_err
,
781 3 * sizeof(GLfloat
) },
785 { insert_1ub_1f_1
, insert_1ub_1f_1
, insert_1ub_1f_1
, insert_1ub_1f_1
},
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
) },
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
) },
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
) },
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
) },
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
) },
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
) },
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
) },
832 { NULL
, NULL
, NULL
, NULL
},
840 /***********************************************************************
841 * Hardwired fastpaths for emitting whole vertices or groups of
844 #define EMIT5(NR, F0, F1, F2, F3, F4, NAME) \
845 static void NAME( struct vertex_fetch *vf, \
849 struct vf_attr *a = vf->attr; \
852 for (i = 0 ; i < count ; i++, v += vf->vertex_stride) { \
854 F0( &a[0], v + a[0].vertoffset, (GLfloat *)a[0].inputptr ); \
855 a[0].inputptr += a[0].inputstride; \
859 F1( &a[1], v + a[1].vertoffset, (GLfloat *)a[1].inputptr ); \
860 a[1].inputptr += a[1].inputstride; \
864 F2( &a[2], v + a[2].vertoffset, (GLfloat *)a[2].inputptr ); \
865 a[2].inputptr += a[2].inputstride; \
869 F3( &a[3], v + a[3].vertoffset, (GLfloat *)a[3].inputptr ); \
870 a[3].inputptr += a[3].inputstride; \
874 F4( &a[4], v + a[4].vertoffset, (GLfloat *)a[4].inputptr ); \
875 a[4].inputptr += a[4].inputstride; \
881 #define EMIT2(F0, F1, NAME) EMIT5(2, F0, F1, insert_null, \
882 insert_null, insert_null, NAME)
884 #define EMIT3(F0, F1, F2, NAME) EMIT5(3, F0, F1, F2, insert_null, \
887 #define EMIT4(F0, F1, F2, F3, NAME) EMIT5(4, F0, F1, F2, F3, \
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
)
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
)
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
)
904 /* Use the codegen paths to select one of a number of hardwired
907 void vf_generate_hardwired_emit( struct vertex_fetch
*vf
)
909 vf_emit_func func
= NULL
;
911 /* Does it fit a hardwired fastpath? Help! this is growing out of
914 switch (vf
->attr_count
) {
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
;
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
;
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
;
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
;
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
;
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
;
959 /***********************************************************************
960 * Generic (non-codegen) functions for whole vertices or groups of
964 void vf_generic_emit( struct vertex_fetch
*vf
,
968 struct vf_attr
*a
= vf
->attr
;
969 const GLuint attr_count
= vf
->attr_count
;
970 const GLuint stride
= vf
->vertex_stride
;
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
);