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