Merge branch 'mesa_7_7_branch'
[mesa.git] / src / mesa / drivers / dri / ffb / ffb_points.c
1 /*
2 *
3 * GLX Hardware Device Driver for Sun Creator/Creator3D
4 * Copyright (C) 2000, 2001 David S. Miller
5 *
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 *
25 * David S. Miller <davem@redhat.com>
26 */
27
28 #include "main/mtypes.h"
29 #include "ffb_dd.h"
30 #include "ffb_context.h"
31 #include "ffb_vb.h"
32 #include "ffb_points.h"
33
34
35 #undef FFB_POINT_TRACE
36
37 #define FFB_POINT_AA_BIT 0x01
38
39 static ffb_point_func ffb_point_tab[0x08];
40
41 #define IND (0)
42 #define TAG(x) x
43 #include "ffb_pointtmp.h"
44
45 #define IND (FFB_POINT_AA_BIT)
46 #define TAG(x) x##_aa
47 #include "ffb_pointtmp.h"
48
49 void ffbDDPointfuncInit(void)
50 {
51 init();
52 init_aa();
53 }
54
55 static void ffb_dd_points( GLcontext *ctx, GLuint first, GLuint last )
56 {
57 struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
58 ffbContextPtr fmesa = FFB_CONTEXT(ctx);
59 ffb_vertex *fverts = fmesa->verts;
60 int i;
61
62 if (VB->Elts == 0) {
63 for ( i = first ; i < last ; i++ ) {
64 if ( VB->ClipMask[i] == 0 ) {
65 fmesa->draw_point( ctx, &fverts[i] );
66 }
67 }
68 } else {
69 for ( i = first ; i < last ; i++ ) {
70 GLuint e = VB->Elts[i];
71 if ( VB->ClipMask[e] == 0 ) {
72 fmesa->draw_point( ctx, &fverts[e] );
73 }
74 }
75 }
76 }
77
78 void ffbChoosePointState(GLcontext *ctx)
79 {
80 ffbContextPtr fmesa = FFB_CONTEXT(ctx);
81 TNLcontext *tnl = TNL_CONTEXT(ctx);
82 GLuint flags = ctx->_TriangleCaps;
83 GLuint ind = 0;
84
85 tnl->Driver.Render.Points = ffb_dd_points;
86
87 if (flags & DD_POINT_SMOOTH)
88 ind |= FFB_POINT_AA_BIT;
89
90 fmesa->draw_point = ffb_point_tab[ind];
91 }