73a19ad38af4a04f9fbdf2adc272362b8b7b3770
2 * Mesa 3-D graphics library
5 * Copyright (C) 1999 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Keith Whitwell <keithw@valinux.com>
32 #include "tnl/t_context.h"
34 #include "ss_triangle.h"
35 #include "ss_context.h"
37 #define SS_RGBA_BIT 0x1
38 #define SS_OFFSET_BIT 0x2
39 #define SS_TWOSIDE_BIT 0x4
40 #define SS_UNFILLED_BIT 0x8
41 #define SS_MAX_TRIFUNC 0x10
43 static triangle_func tri_tab
[SS_MAX_TRIFUNC
];
44 static quad_func quad_tab
[SS_MAX_TRIFUNC
];
47 #define SS_COLOR(a,b) COPY_4UBV(a,b)
48 #define SS_SPEC(a,b) COPY_4UBV(a,b)
49 #define SS_IND(a,b) (a = b)
53 #include "ss_tritmp.h"
55 #define IND (SS_OFFSET_BIT)
56 #define TAG(x) x##_offset
57 #include "ss_tritmp.h"
59 #define IND (SS_TWOSIDE_BIT)
60 #define TAG(x) x##_twoside
61 #include "ss_tritmp.h"
63 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
64 #define TAG(x) x##_offset_twoside
65 #include "ss_tritmp.h"
67 #define IND (SS_UNFILLED_BIT)
68 #define TAG(x) x##_unfilled
69 #include "ss_tritmp.h"
71 #define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
72 #define TAG(x) x##_offset_unfilled
73 #include "ss_tritmp.h"
75 #define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
76 #define TAG(x) x##_twoside_unfilled
77 #include "ss_tritmp.h"
79 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
80 #define TAG(x) x##_offset_twoside_unfilled
81 #include "ss_tritmp.h"
83 #define IND (0|SS_RGBA_BIT)
84 #define TAG(x) x##_rgba
85 #include "ss_tritmp.h"
87 #define IND (SS_OFFSET_BIT|SS_RGBA_BIT)
88 #define TAG(x) x##_offset_rgba
89 #include "ss_tritmp.h"
91 #define IND (SS_TWOSIDE_BIT|SS_RGBA_BIT)
92 #define TAG(x) x##_twoside_rgba
93 #include "ss_tritmp.h"
95 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT)
96 #define TAG(x) x##_offset_twoside_rgba
97 #include "ss_tritmp.h"
99 #define IND (SS_UNFILLED_BIT|SS_RGBA_BIT)
100 #define TAG(x) x##_unfilled_rgba
101 #include "ss_tritmp.h"
103 #define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
104 #define TAG(x) x##_offset_unfilled_rgba
105 #include "ss_tritmp.h"
107 #define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
108 #define TAG(x) x##_twoside_unfilled_rgba
109 #include "ss_tritmp.h"
111 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
112 #define TAG(x) x##_offset_twoside_unfilled_rgba
113 #include "ss_tritmp.h"
116 void _swsetup_trifuncs_init( GLcontext
*ctx
)
123 init_offset_twoside();
125 init_offset_unfilled();
126 init_twoside_unfilled();
127 init_offset_twoside_unfilled();
132 init_offset_twoside_rgba();
133 init_unfilled_rgba();
134 init_offset_unfilled_rgba();
135 init_twoside_unfilled_rgba();
136 init_offset_twoside_unfilled_rgba();
140 static void swsetup_points( GLcontext
*ctx
, GLuint first
, GLuint last
)
142 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
143 SWvertex
*verts
= SWSETUP_CONTEXT(ctx
)->verts
;
147 for(i
=first
;i
<last
;i
++)
148 if(VB
->ClipMask
[VB
->Elts
[i
]]==0)
149 _swrast_Point( ctx
, &verts
[VB
->Elts
[i
]] );
151 for(i
=first
;i
<last
;i
++)
152 if(VB
->ClipMask
[i
]==0)
153 _swrast_Point( ctx
, &verts
[i
] );
157 static void swsetup_line( GLcontext
*ctx
, GLuint v0
, GLuint v1
)
159 SWvertex
*verts
= SWSETUP_CONTEXT(ctx
)->verts
;
160 _swrast_Line( ctx
, &verts
[v0
], &verts
[v1
] );
165 void _swsetup_choose_trifuncs( GLcontext
*ctx
)
167 SScontext
*swsetup
= SWSETUP_CONTEXT(ctx
);
170 if (ctx
->Polygon
._OffsetAny
)
171 ind
|= SS_OFFSET_BIT
;
173 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
174 ind
|= SS_TWOSIDE_BIT
;
176 if (ctx
->_TriangleCaps
& DD_TRI_UNFILLED
)
177 ind
|= SS_UNFILLED_BIT
;
179 if (ctx
->Visual
.RGBAflag
)
182 swsetup
->Triangle
= tri_tab
[ind
];
183 swsetup
->Quad
= quad_tab
[ind
];
184 swsetup
->Line
= swsetup_line
;
185 swsetup
->Points
= swsetup_points
;