more r500 vs r300 kickin
[mesa.git] / src / mesa / drivers / dri / ffb / ffb_vbtmp.h
1 /* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vbtmp.h,v 1.1 2002/02/22 21:32:59 dawes Exp $ */
2
3 static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end)
4 {
5 ffbContextPtr fmesa = FFB_CONTEXT(ctx);
6 #if defined(VB_DEBUG) || (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
7 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
8 #endif
9 #if (IND & (FFB_VB_RGBA_BIT))
10 GLfloat (*col0)[4];
11 GLuint col0_stride;
12 #if (IND & (FFB_VB_TWOSIDE_BIT))
13 GLfloat (*col1)[4];
14 GLuint col1_stride;
15 #endif
16 #endif
17 #if (IND & FFB_VB_XYZ_BIT)
18 GLfloat (*proj)[4] = VB->NdcPtr->data;
19 GLuint proj_stride = VB->NdcPtr->stride;
20 const GLubyte *mask = VB->ClipMask;
21 #endif
22 ffb_vertex *v = &fmesa->verts[start];
23 int i;
24
25 #ifdef VB_DEBUG
26 fprintf(stderr, "FFB: ffb_emit ["
27 #if (IND & (FFB_VB_XYZ_BIT))
28 " XYZ"
29 #endif
30 #if (IND & (FFB_VB_RGBA_BIT))
31 " RGBA"
32 #endif
33 #if (IND & (FFB_VB_TWOSIDE_BIT))
34 " TWOSIDE"
35 #endif
36 "] start(%d) end(%d) import(%d)\n",
37 start, end,
38 VB->importable_data);
39 #endif
40
41 #if (IND & (FFB_VB_RGBA_BIT))
42 col0 = VB->ColorPtr[0]->data;
43 col0_stride = VB->ColorPtr[0]->stride;
44 #if (IND & (FFB_VB_TWOSIDE_BIT))
45 col1 = VB->ColorPtr[1]->data;
46 col1_stride = VB->ColorPtr[1]->stride;
47 #endif
48 #endif
49
50 {
51 if (start) {
52 #if (IND & (FFB_VB_XYZ_BIT))
53 proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
54 #endif
55 #if (IND & (FFB_VB_RGBA_BIT))
56 col0 = (GLfloat (*)[4])((GLubyte *)col0 + start * col0_stride);
57 #if (IND & (FFB_VB_TWOSIDE_BIT))
58 col1 = (GLfloat (*)[4])((GLubyte *)col1 + start * col1_stride);
59 #endif
60 #endif
61 }
62 for (i = start; i < end; i++, v++) {
63 #if (IND & (FFB_VB_XYZ_BIT))
64 if (mask[i] == 0) {
65 v->x = proj[0][0];
66 v->y = proj[0][1];
67 v->z = proj[0][2];
68 }
69 proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
70 #endif
71 #if (IND & (FFB_VB_RGBA_BIT))
72 v->color[0].alpha = CLAMP(col0[0][3], 0.0f, 1.0f);
73 v->color[0].red = CLAMP(col0[0][0], 0.0f, 1.0f);
74 v->color[0].green = CLAMP(col0[0][1], 0.0f, 1.0f);
75 v->color[0].blue = CLAMP(col0[0][2], 0.0f, 1.0f);
76 col0 = (GLfloat (*)[4])((GLubyte *)col0 + col0_stride);
77 #if (IND & (FFB_VB_TWOSIDE_BIT))
78 v->color[1].alpha = CLAMP(col1[0][3], 0.0f, 1.0f);
79 v->color[1].red = CLAMP(col1[0][0], 0.0f, 1.0f);
80 v->color[1].green = CLAMP(col1[0][1], 0.0f, 1.0f);
81 v->color[1].blue = CLAMP(col1[0][2], 0.0f, 1.0f);
82 col1 = (GLfloat (*)[4])((GLubyte *)col1 + col1_stride);
83 #endif
84 #endif
85 }
86 }
87 }
88
89 static void TAG(interp)(GLcontext *ctx, GLfloat t,
90 GLuint edst, GLuint eout, GLuint ein,
91 GLboolean force_boundary)
92 {
93 #if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
94 ffbContextPtr fmesa = FFB_CONTEXT(ctx);
95 #endif
96 #if (IND & (FFB_VB_XYZ_BIT))
97 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
98 const GLfloat *dstclip = VB->ClipPtr->data[edst];
99 GLfloat oow = 1.0 / dstclip[3];
100 #endif
101 #if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
102 ffb_vertex *dst = &fmesa->verts[edst];
103 #endif
104 #if (IND & (FFB_VB_RGBA_BIT))
105 ffb_vertex *in = &fmesa->verts[eout];
106 ffb_vertex *out = &fmesa->verts[ein];
107 #endif
108
109 #ifdef VB_DEBUG
110 fprintf(stderr, "FFB: ffb_interp ["
111 #if (IND & (FFB_VB_XYZ_BIT))
112 " XYZ"
113 #endif
114 #if (IND & (FFB_VB_RGBA_BIT))
115 " RGBA"
116 #endif
117 #if (IND & (FFB_VB_TWOSIDE_BIT))
118 " TWOSIDE"
119 #endif
120 "] edst(%d) eout(%d) ein(%d)\n",
121 edst, eout, ein);
122 #endif
123
124 #if (IND & (FFB_VB_XYZ_BIT))
125 dst->x = dstclip[0] * oow;
126 dst->y = dstclip[1] * oow;
127 dst->z = dstclip[2] * oow;
128 #endif
129
130 #if (IND & (FFB_VB_RGBA_BIT))
131 INTERP_F(t, dst->color[0].alpha, out->color[0].alpha, in->color[0].alpha);
132 INTERP_F(t, dst->color[0].red, out->color[0].red, in->color[0].red);
133 INTERP_F(t, dst->color[0].green, out->color[0].green, in->color[0].green);
134 INTERP_F(t, dst->color[0].blue, out->color[0].blue, in->color[0].blue);
135 #if (IND & (FFB_VB_TWOSIDE_BIT))
136 INTERP_F(t, dst->color[1].alpha, out->color[1].alpha, in->color[1].alpha);
137 INTERP_F(t, dst->color[1].red, out->color[1].red, in->color[1].red);
138 INTERP_F(t, dst->color[1].green, out->color[1].green, in->color[1].green);
139 INTERP_F(t, dst->color[1].blue, out->color[1].blue, in->color[1].blue);
140 #endif
141 #endif
142 }
143
144 static void TAG(init)(void)
145 {
146 setup_tab[IND].emit = TAG(emit);
147 setup_tab[IND].interp = TAG(interp);
148 }
149
150 #undef IND
151 #undef TAG