ac0c6f0a8b3ce5bf25cb6c3dedeb1a32c690d66f
1 /* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vbtmp.h,v 1.1 2002/02/22 21:32:59 dawes Exp $ */
3 static void TAG(emit
)(GLcontext
*ctx
, GLuint start
, GLuint end
)
5 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
6 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
7 #if (IND & (FFB_VB_RGBA_BIT))
10 #if (IND & (FFB_VB_TWOSIDE_BIT))
15 #if (IND & FFB_VB_XYZ_BIT)
16 GLfloat (*proj
)[4] = VB
->NdcPtr
->data
;
17 GLuint proj_stride
= VB
->NdcPtr
->stride
;
18 const GLubyte
*mask
= VB
->ClipMask
;
20 ffb_vertex
*v
= &fmesa
->verts
[start
];
24 fprintf(stderr
, "FFB: ffb_emit ["
25 #if (IND & (FFB_VB_XYZ_BIT))
28 #if (IND & (FFB_VB_RGBA_BIT))
31 #if (IND & (FFB_VB_TWOSIDE_BIT))
34 "] start(%d) end(%d) import(%d)\n",
39 #if (IND & (FFB_VB_RGBA_BIT))
40 if (VB
->ColorPtr
[0]->Type
!= GL_FLOAT
)
41 ffbImportColors(fmesa
, ctx
, 0);
42 #if (IND & (FFB_VB_TWOSIDE_BIT))
43 if (VB
->ColorPtr
[1]->Type
!= GL_FLOAT
)
44 ffbImportColors(fmesa
, ctx
, 1);
46 col0
= (GLfloat (*)[4]) VB
->ColorPtr
[0]->Ptr
;
47 col0_stride
= VB
->ColorPtr
[0]->StrideB
;
48 #if (IND & (FFB_VB_TWOSIDE_BIT))
49 col1
= (GLfloat (*)[4]) VB
->ColorPtr
[1]->Ptr
;
50 col1_stride
= VB
->ColorPtr
[1]->StrideB
;
54 if (VB
->importable_data
) {
56 #if (IND & (FFB_VB_XYZ_BIT))
57 proj
= (GLfloat (*)[4])((GLubyte
*)proj
+ start
* proj_stride
);
59 #if (IND & (FFB_VB_RGBA_BIT))
60 col0
= (GLfloat (*)[4])((GLubyte
*)col0
+ start
* col0_stride
);
61 #if (IND & (FFB_VB_TWOSIDE_BIT))
62 col1
= (GLfloat (*)[4])((GLubyte
*)col1
+ start
* col1_stride
);
66 for (i
= start
; i
< end
; i
++, v
++) {
67 #if (IND & (FFB_VB_XYZ_BIT))
73 proj
= (GLfloat (*)[4])((GLubyte
*)proj
+ proj_stride
);
75 #if (IND & (FFB_VB_RGBA_BIT))
76 v
->color
[0].alpha
= CLAMP(col0
[0][3], 0.0f
, 1.0f
);
77 v
->color
[0].red
= CLAMP(col0
[0][0], 0.0f
, 1.0f
);
78 v
->color
[0].green
= CLAMP(col0
[0][1], 0.0f
, 1.0f
);
79 v
->color
[0].blue
= CLAMP(col0
[0][2], 0.0f
, 1.0f
);
80 col0
= (GLfloat (*)[4])((GLubyte
*)col0
+ col0_stride
);
81 #if (IND & (FFB_VB_TWOSIDE_BIT))
82 v
->color
[1].alpha
= CLAMP(col1
[0][3], 0.0f
, 1.0f
);
83 v
->color
[1].red
= CLAMP(col1
[0][0], 0.0f
, 1.0f
);
84 v
->color
[1].green
= CLAMP(col1
[0][1], 0.0f
, 1.0f
);
85 v
->color
[1].blue
= CLAMP(col1
[0][2], 0.0f
, 1.0f
);
86 col1
= (GLfloat (*)[4])((GLubyte
*)col1
+ col1_stride
);
91 for (i
= start
; i
< end
; i
++, v
++) {
92 #if (IND & (FFB_VB_XYZ_BIT))
99 #if (IND & (FFB_VB_RGBA_BIT))
100 v
->color
[0].alpha
= CLAMP(col0
[i
][3], 0.0f
, 1.0f
);
101 v
->color
[0].red
= CLAMP(col0
[i
][0], 0.0f
, 1.0f
);
102 v
->color
[0].green
= CLAMP(col0
[i
][1], 0.0f
, 1.0f
);
103 v
->color
[0].blue
= CLAMP(col0
[i
][2], 0.0f
, 1.0f
);
104 #if (IND & (FFB_VB_TWOSIDE_BIT))
105 v
->color
[1].alpha
= CLAMP(col1
[i
][3], 0.0f
, 1.0f
);
106 v
->color
[1].red
= CLAMP(col1
[i
][0], 0.0f
, 1.0f
);
107 v
->color
[1].green
= CLAMP(col1
[i
][1], 0.0f
, 1.0f
);
108 v
->color
[1].blue
= CLAMP(col1
[i
][2], 0.0f
, 1.0f
);
115 static void TAG(interp
)(GLcontext
*ctx
, GLfloat t
,
116 GLuint edst
, GLuint eout
, GLuint ein
,
117 GLboolean force_boundary
)
119 #if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
120 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
122 #if (IND & (FFB_VB_XYZ_BIT))
123 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
124 const GLfloat
*dstclip
= VB
->ClipPtr
->data
[edst
];
125 GLfloat oow
= 1.0 / dstclip
[3];
127 #if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
128 ffb_vertex
*dst
= &fmesa
->verts
[edst
];
130 #if (IND & (FFB_VB_RGBA_BIT))
131 ffb_vertex
*in
= &fmesa
->verts
[eout
];
132 ffb_vertex
*out
= &fmesa
->verts
[ein
];
136 fprintf(stderr
, "FFB: ffb_interp ["
137 #if (IND & (FFB_VB_XYZ_BIT))
140 #if (IND & (FFB_VB_RGBA_BIT))
143 #if (IND & (FFB_VB_TWOSIDE_BIT))
146 "] edst(%d) eout(%d) ein(%d)\n",
150 #if (IND & (FFB_VB_XYZ_BIT))
151 dst
->x
= dstclip
[0] * oow
;
152 dst
->y
= dstclip
[1] * oow
;
153 dst
->z
= dstclip
[2] * oow
;
156 #if (IND & (FFB_VB_RGBA_BIT))
157 INTERP_F(t
, dst
->color
[0].alpha
, out
->color
[0].alpha
, in
->color
[0].alpha
);
158 INTERP_F(t
, dst
->color
[0].red
, out
->color
[0].red
, in
->color
[0].red
);
159 INTERP_F(t
, dst
->color
[0].green
, out
->color
[0].green
, in
->color
[0].green
);
160 INTERP_F(t
, dst
->color
[0].blue
, out
->color
[0].blue
, in
->color
[0].blue
);
161 #if (IND & (FFB_VB_TWOSIDE_BIT))
162 INTERP_F(t
, dst
->color
[1].alpha
, out
->color
[1].alpha
, in
->color
[1].alpha
);
163 INTERP_F(t
, dst
->color
[1].red
, out
->color
[1].red
, in
->color
[1].red
);
164 INTERP_F(t
, dst
->color
[1].green
, out
->color
[1].green
, in
->color
[1].green
);
165 INTERP_F(t
, dst
->color
[1].blue
, out
->color
[1].blue
, in
->color
[1].blue
);
170 static void TAG(init
)(void)
172 setup_tab
[IND
].emit
= TAG(emit
);
173 setup_tab
[IND
].interp
= TAG(interp
);