Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4358 | Serge | 1 | /* |
2 | Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. |
||
3 | |||
4 | The Weather Channel (TM) funded Tungsten Graphics to develop the |
||
5 | initial release of the Radeon 8500 driver under the XFree86 license. |
||
6 | This notice must be preserved. |
||
7 | |||
8 | Permission is hereby granted, free of charge, to any person obtaining |
||
9 | a copy of this software and associated documentation files (the |
||
10 | "Software"), to deal in the Software without restriction, including |
||
11 | without limitation the rights to use, copy, modify, merge, publish, |
||
12 | distribute, sublicense, and/or sell copies of the Software, and to |
||
13 | permit persons to whom the Software is furnished to do so, subject to |
||
14 | the following conditions: |
||
15 | |||
16 | The above copyright notice and this permission notice (including the |
||
17 | next paragraph) shall be included in all copies or substantial |
||
18 | portions of the Software. |
||
19 | |||
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||
22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||
23 | IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE |
||
24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
||
25 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
||
26 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
27 | |||
28 | **************************************************************************/ |
||
29 | |||
30 | /* |
||
31 | * Authors: |
||
32 | * Keith Whitwell |
||
33 | */ |
||
34 | |||
35 | #include "main/glheader.h" |
||
36 | #include "main/mtypes.h" |
||
37 | #include "main/colormac.h" |
||
38 | #include "main/enums.h" |
||
39 | #include "main/image.h" |
||
40 | #include "main/imports.h" |
||
41 | #include "main/macros.h" |
||
42 | #include "main/simple_list.h" |
||
43 | |||
44 | #include "swrast/s_context.h" |
||
45 | #include "swrast/s_fog.h" |
||
46 | #include "swrast_setup/swrast_setup.h" |
||
47 | #include "tnl/tnl.h" |
||
48 | #include "tnl/t_context.h" |
||
49 | #include "tnl/t_pipeline.h" |
||
50 | |||
51 | #include "r200_context.h" |
||
52 | #include "r200_ioctl.h" |
||
53 | #include "r200_state.h" |
||
54 | #include "r200_swtcl.h" |
||
55 | #include "r200_tcl.h" |
||
56 | |||
57 | |||
58 | /*********************************************************************** |
||
59 | * Initialization |
||
60 | ***********************************************************************/ |
||
61 | |||
62 | #define EMIT_ATTR( ATTR, STYLE, F0 ) \ |
||
63 | do { \ |
||
64 | rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = (ATTR); \ |
||
65 | rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = (STYLE); \ |
||
66 | rmesa->radeon.swtcl.vertex_attr_count++; \ |
||
67 | fmt_0 |= F0; \ |
||
68 | } while (0) |
||
69 | |||
70 | #define EMIT_PAD( N ) \ |
||
71 | do { \ |
||
72 | rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = 0; \ |
||
73 | rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = EMIT_PAD; \ |
||
74 | rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].offset = (N); \ |
||
75 | rmesa->radeon.swtcl.vertex_attr_count++; \ |
||
76 | } while (0) |
||
77 | |||
78 | static void r200SetVertexFormat( struct gl_context *ctx ) |
||
79 | { |
||
80 | r200ContextPtr rmesa = R200_CONTEXT( ctx ); |
||
81 | TNLcontext *tnl = TNL_CONTEXT(ctx); |
||
82 | struct vertex_buffer *VB = &tnl->vb; |
||
83 | GLbitfield64 index_bitset = tnl->render_inputs_bitset; |
||
84 | int fmt_0 = 0; |
||
85 | int fmt_1 = 0; |
||
86 | int offset = 0; |
||
87 | |||
88 | /* Important: |
||
89 | */ |
||
90 | if ( VB->NdcPtr != NULL ) { |
||
91 | VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; |
||
92 | } |
||
93 | else { |
||
94 | VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr; |
||
95 | } |
||
96 | |||
97 | assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL ); |
||
98 | rmesa->radeon.swtcl.vertex_attr_count = 0; |
||
99 | |||
100 | /* EMIT_ATTR's must be in order as they tell t_vertex.c how to |
||
101 | * build up a hardware vertex. |
||
102 | */ |
||
103 | if ( !rmesa->swtcl.needproj || |
||
104 | (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)) ) { |
||
105 | /* need w coord for projected textures */ |
||
106 | EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F, R200_VTX_XY | R200_VTX_Z0 | R200_VTX_W0 ); |
||
107 | offset = 4; |
||
108 | } |
||
109 | else { |
||
110 | EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F, R200_VTX_XY | R200_VTX_Z0 ); |
||
111 | offset = 3; |
||
112 | } |
||
113 | |||
114 | if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE)) { |
||
115 | EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, R200_VTX_POINT_SIZE ); |
||
116 | offset += 1; |
||
117 | } |
||
118 | |||
119 | rmesa->swtcl.coloroffset = offset; |
||
120 | #if MESA_LITTLE_ENDIAN |
||
121 | EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) ); |
||
122 | #else |
||
123 | EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) ); |
||
124 | #endif |
||
125 | offset += 1; |
||
126 | |||
127 | rmesa->swtcl.specoffset = 0; |
||
128 | if (index_bitset & |
||
129 | (BITFIELD64_BIT(_TNL_ATTRIB_COLOR1) | BITFIELD64_BIT(_TNL_ATTRIB_FOG))) { |
||
130 | |||
131 | #if MESA_LITTLE_ENDIAN |
||
132 | if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR1)) { |
||
133 | rmesa->swtcl.specoffset = offset; |
||
134 | EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) ); |
||
135 | } |
||
136 | else { |
||
137 | EMIT_PAD( 3 ); |
||
138 | } |
||
139 | |||
140 | if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) { |
||
141 | EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) ); |
||
142 | } |
||
143 | else { |
||
144 | EMIT_PAD( 1 ); |
||
145 | } |
||
146 | #else |
||
147 | if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) { |
||
148 | EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) ); |
||
149 | } |
||
150 | else { |
||
151 | EMIT_PAD( 1 ); |
||
152 | } |
||
153 | |||
154 | if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR1)) { |
||
155 | rmesa->swtcl.specoffset = offset; |
||
156 | EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) ); |
||
157 | } |
||
158 | else { |
||
159 | EMIT_PAD( 3 ); |
||
160 | } |
||
161 | #endif |
||
162 | } |
||
163 | |||
164 | if (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)) { |
||
165 | int i; |
||
166 | |||
167 | for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { |
||
168 | if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_TEX(i))) { |
||
169 | GLuint sz = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size; |
||
170 | |||
171 | fmt_1 |= sz << (3 * i); |
||
172 | EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1, 0 ); |
||
173 | } |
||
174 | } |
||
175 | } |
||
176 | |||
177 | if ( (rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] & R200_FOG_USE_MASK) |
||
178 | != R200_FOG_USE_SPEC_ALPHA ) { |
||
179 | R200_STATECHANGE( rmesa, ctx ); |
||
180 | rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK; |
||
181 | rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_SPEC_ALPHA; |
||
182 | } |
||
183 | |||
184 | if (rmesa->radeon.tnl_index_bitset != index_bitset || |
||
185 | (rmesa->hw.vtx.cmd[VTX_VTXFMT_0] != fmt_0) || |
||
186 | (rmesa->hw.vtx.cmd[VTX_VTXFMT_1] != fmt_1) ) { |
||
187 | R200_NEWPRIM(rmesa); |
||
188 | R200_STATECHANGE( rmesa, vtx ); |
||
189 | rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = fmt_0; |
||
190 | rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = fmt_1; |
||
191 | |||
192 | rmesa->radeon.swtcl.vertex_size = |
||
193 | _tnl_install_attrs( ctx, |
||
194 | rmesa->radeon.swtcl.vertex_attrs, |
||
195 | rmesa->radeon.swtcl.vertex_attr_count, |
||
196 | NULL, 0 ); |
||
197 | rmesa->radeon.swtcl.vertex_size /= 4; |
||
198 | rmesa->radeon.tnl_index_bitset = index_bitset; |
||
199 | } |
||
200 | } |
||
201 | |||
202 | static void r200_predict_emit_size( r200ContextPtr rmesa ) |
||
203 | { |
||
204 | if (RADEON_DEBUG & RADEON_VERTS) |
||
205 | fprintf(stderr, "%s\n", __func__); |
||
206 | const int vertex_array_size = 7; |
||
207 | const int prim_size = 3; |
||
208 | if (!rmesa->radeon.swtcl.emit_prediction) { |
||
209 | const int state_size = radeonCountStateEmitSize(&rmesa->radeon); |
||
210 | if (rcommonEnsureCmdBufSpace(&rmesa->radeon, |
||
211 | state_size + |
||
212 | vertex_array_size + prim_size, |
||
213 | __FUNCTION__)) |
||
214 | rmesa->radeon.swtcl.emit_prediction = radeonCountStateEmitSize(&rmesa->radeon); |
||
215 | else |
||
216 | rmesa->radeon.swtcl.emit_prediction = state_size; |
||
217 | rmesa->radeon.swtcl.emit_prediction += vertex_array_size + prim_size |
||
218 | + rmesa->radeon.cmdbuf.cs->cdw; |
||
219 | } |
||
220 | } |
||
221 | |||
222 | |||
223 | static void r200RenderStart( struct gl_context *ctx ) |
||
224 | { |
||
225 | r200SetVertexFormat( ctx ); |
||
226 | if (RADEON_DEBUG & RADEON_VERTS) |
||
227 | fprintf(stderr, "%s\n", __func__); |
||
228 | } |
||
229 | |||
230 | |||
231 | /** |
||
232 | * Set vertex state for SW TCL. The primary purpose of this function is to |
||
233 | * determine in advance whether or not the hardware can / should do the |
||
234 | * projection divide or Mesa should do it. |
||
235 | */ |
||
236 | void r200ChooseVertexState( struct gl_context *ctx ) |
||
237 | { |
||
238 | r200ContextPtr rmesa = R200_CONTEXT( ctx ); |
||
239 | TNLcontext *tnl = TNL_CONTEXT(ctx); |
||
240 | GLuint vte; |
||
241 | GLuint vap; |
||
242 | GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL || |
||
243 | ctx->Polygon.BackMode != GL_FILL); |
||
244 | GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide; |
||
245 | |||
246 | /* We must ensure that we don't do _tnl_need_projected_coords while in a |
||
247 | * rasterization fallback. As this function will be called again when we |
||
248 | * leave a rasterization fallback, we can just skip it for now. |
||
249 | */ |
||
250 | if (rmesa->radeon.Fallback != 0) |
||
251 | return; |
||
252 | |||
253 | vte = rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL]; |
||
254 | vap = rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL]; |
||
255 | |||
256 | /* HW perspective divide is a win, but tiny vertex formats are a |
||
257 | * bigger one. |
||
258 | */ |
||
259 | if ((0 == (tnl->render_inputs_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX))) |
||
260 | || twosided |
||
261 | || unfilled) { |
||
262 | rmesa->swtcl.needproj = GL_TRUE; |
||
263 | vte |= R200_VTX_XY_FMT | R200_VTX_Z_FMT; |
||
264 | vte &= ~R200_VTX_W0_FMT; |
||
265 | if (tnl->render_inputs_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)) { |
||
266 | vap &= ~R200_VAP_FORCE_W_TO_ONE; |
||
267 | } |
||
268 | else { |
||
269 | vap |= R200_VAP_FORCE_W_TO_ONE; |
||
270 | } |
||
271 | } |
||
272 | else { |
||
273 | rmesa->swtcl.needproj = GL_FALSE; |
||
274 | vte &= ~(R200_VTX_XY_FMT | R200_VTX_Z_FMT); |
||
275 | vte |= R200_VTX_W0_FMT; |
||
276 | vap &= ~R200_VAP_FORCE_W_TO_ONE; |
||
277 | } |
||
278 | |||
279 | _tnl_need_projected_coords( ctx, rmesa->swtcl.needproj ); |
||
280 | |||
281 | if (vte != rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL]) { |
||
282 | R200_STATECHANGE( rmesa, vte ); |
||
283 | rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] = vte; |
||
284 | } |
||
285 | |||
286 | if (vap != rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL]) { |
||
287 | R200_STATECHANGE( rmesa, vap ); |
||
288 | rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] = vap; |
||
289 | } |
||
290 | } |
||
291 | |||
292 | void r200_swtcl_flush(struct gl_context *ctx, uint32_t current_offset) |
||
293 | { |
||
294 | r200ContextPtr rmesa = R200_CONTEXT(ctx); |
||
295 | if (RADEON_DEBUG & RADEON_VERTS) |
||
296 | fprintf(stderr, "%s\n", __func__); |
||
297 | |||
298 | |||
299 | radeonEmitState(&rmesa->radeon); |
||
300 | r200EmitVertexAOS( rmesa, |
||
301 | rmesa->radeon.swtcl.vertex_size, |
||
302 | rmesa->radeon.swtcl.bo, |
||
303 | current_offset); |
||
304 | |||
305 | |||
306 | r200EmitVbufPrim( rmesa, |
||
307 | rmesa->radeon.swtcl.hw_primitive, |
||
308 | rmesa->radeon.swtcl.numverts); |
||
309 | if ( rmesa->radeon.swtcl.emit_prediction < rmesa->radeon.cmdbuf.cs->cdw ) |
||
310 | WARN_ONCE("Rendering was %d commands larger than predicted size." |
||
311 | " We might overflow command buffer.\n", |
||
312 | rmesa->radeon.cmdbuf.cs->cdw - rmesa->radeon.swtcl.emit_prediction ); |
||
313 | |||
314 | rmesa->radeon.swtcl.emit_prediction = 0; |
||
315 | |||
316 | } |
||
317 | |||
318 | /**************************************************************************/ |
||
319 | |||
320 | |||
321 | static INLINE GLuint reduced_hw_prim( struct gl_context *ctx, GLuint prim) |
||
322 | { |
||
323 | switch (prim) { |
||
324 | case GL_POINTS: |
||
325 | return ((!ctx->Point.SmoothFlag) ? |
||
326 | R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS); |
||
327 | case GL_LINES: |
||
328 | /* fallthrough */ |
||
329 | case GL_LINE_LOOP: |
||
330 | /* fallthrough */ |
||
331 | case GL_LINE_STRIP: |
||
332 | return R200_VF_PRIM_LINES; |
||
333 | default: |
||
334 | /* all others reduced to triangles */ |
||
335 | return R200_VF_PRIM_TRIANGLES; |
||
336 | } |
||
337 | } |
||
338 | |||
339 | |||
340 | static void r200RasterPrimitive( struct gl_context *ctx, GLuint hwprim ); |
||
341 | static void r200RenderPrimitive( struct gl_context *ctx, GLenum prim ); |
||
342 | static void r200ResetLineStipple( struct gl_context *ctx ); |
||
343 | |||
344 | /*********************************************************************** |
||
345 | * Emit primitives as inline vertices * |
||
346 | ***********************************************************************/ |
||
347 | |||
348 | #define HAVE_POINTS 1 |
||
349 | #define HAVE_LINES 1 |
||
350 | #define HAVE_LINE_STRIPS 1 |
||
351 | #define HAVE_TRIANGLES 1 |
||
352 | #define HAVE_TRI_STRIPS 1 |
||
353 | #define HAVE_TRI_STRIP_1 0 |
||
354 | #define HAVE_TRI_FANS 1 |
||
355 | #define HAVE_QUADS 0 |
||
356 | #define HAVE_QUAD_STRIPS 0 |
||
357 | #define HAVE_POLYGONS 1 |
||
358 | #define HAVE_ELTS 0 |
||
359 | |||
360 | static void* r200_alloc_verts( r200ContextPtr rmesa, GLuint n, GLuint size) |
||
361 | { |
||
362 | void *rv; |
||
363 | do { |
||
364 | r200_predict_emit_size( rmesa ); |
||
365 | rv = rcommonAllocDmaLowVerts( &rmesa->radeon, n, size * 4 ); |
||
366 | } while(!rv); |
||
367 | return rv; |
||
368 | } |
||
369 | |||
370 | #undef LOCAL_VARS |
||
371 | #undef ALLOC_VERTS |
||
372 | #define CTX_ARG r200ContextPtr rmesa |
||
373 | #define GET_VERTEX_DWORDS() rmesa->radeon.swtcl.vertex_size |
||
374 | #define ALLOC_VERTS( n, size ) r200_alloc_verts(rmesa, n, size) |
||
375 | #define LOCAL_VARS \ |
||
376 | r200ContextPtr rmesa = R200_CONTEXT(ctx); \ |
||
377 | const char *r200verts = (char *)rmesa->radeon.swtcl.verts; |
||
378 | #define VERT(x) (radeonVertex *)(r200verts + ((x) * vertsize * sizeof(int))) |
||
379 | #define VERTEX radeonVertex |
||
380 | #define DO_DEBUG_VERTS (1 && (R200_DEBUG & RADEON_VERTS)) |
||
381 | |||
382 | #undef TAG |
||
383 | #define TAG(x) r200_##x |
||
384 | #include "tnl_dd/t_dd_triemit.h" |
||
385 | |||
386 | |||
387 | /*********************************************************************** |
||
388 | * Macros for t_dd_tritmp.h to draw basic primitives * |
||
389 | ***********************************************************************/ |
||
390 | |||
391 | #define QUAD( a, b, c, d ) r200_quad( rmesa, a, b, c, d ) |
||
392 | #define TRI( a, b, c ) r200_triangle( rmesa, a, b, c ) |
||
393 | #define LINE( a, b ) r200_line( rmesa, a, b ) |
||
394 | #define POINT( a ) r200_point( rmesa, a ) |
||
395 | |||
396 | /*********************************************************************** |
||
397 | * Build render functions from dd templates * |
||
398 | ***********************************************************************/ |
||
399 | |||
400 | #define R200_TWOSIDE_BIT 0x01 |
||
401 | #define R200_UNFILLED_BIT 0x02 |
||
402 | #define R200_MAX_TRIFUNC 0x04 |
||
403 | |||
404 | |||
405 | static struct { |
||
406 | tnl_points_func points; |
||
407 | tnl_line_func line; |
||
408 | tnl_triangle_func triangle; |
||
409 | tnl_quad_func quad; |
||
410 | } rast_tab[R200_MAX_TRIFUNC]; |
||
411 | |||
412 | |||
413 | #define DO_FALLBACK 0 |
||
414 | #define DO_UNFILLED (IND & R200_UNFILLED_BIT) |
||
415 | #define DO_TWOSIDE (IND & R200_TWOSIDE_BIT) |
||
416 | #define DO_FLAT 0 |
||
417 | #define DO_OFFSET 0 |
||
418 | #define DO_TRI 1 |
||
419 | #define DO_QUAD 1 |
||
420 | #define DO_LINE 1 |
||
421 | #define DO_POINTS 1 |
||
422 | #define DO_FULL_QUAD 1 |
||
423 | |||
424 | #define HAVE_SPEC 1 |
||
425 | #define HAVE_BACK_COLORS 0 |
||
426 | #define HAVE_HW_FLATSHADE 1 |
||
427 | #define TAB rast_tab |
||
428 | |||
429 | #define DEPTH_SCALE 1.0 |
||
430 | #define UNFILLED_TRI unfilled_tri |
||
431 | #define UNFILLED_QUAD unfilled_quad |
||
432 | #define VERT_X(_v) _v->v.x |
||
433 | #define VERT_Y(_v) _v->v.y |
||
434 | #define VERT_Z(_v) _v->v.z |
||
435 | #define AREA_IS_CCW( a ) (a < 0) |
||
436 | #define GET_VERTEX(e) (rmesa->radeon.swtcl.verts + (e*rmesa->radeon.swtcl.vertex_size*sizeof(int))) |
||
437 | |||
438 | #define VERT_SET_RGBA( v, c ) \ |
||
439 | do { \ |
||
440 | radeon_color_t *color = (radeon_color_t *)&((v)->ui[coloroffset]); \ |
||
441 | UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ |
||
442 | UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ |
||
443 | UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ |
||
444 | UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ |
||
445 | } while (0) |
||
446 | |||
447 | #define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] |
||
448 | |||
449 | #define VERT_SET_SPEC( v, c ) \ |
||
450 | do { \ |
||
451 | if (specoffset) { \ |
||
452 | radeon_color_t *spec = (radeon_color_t *)&((v)->ui[specoffset]); \ |
||
453 | UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \ |
||
454 | UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \ |
||
455 | UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \ |
||
456 | } \ |
||
457 | } while (0) |
||
458 | #define VERT_COPY_SPEC( v0, v1 ) \ |
||
459 | do { \ |
||
460 | if (specoffset) { \ |
||
461 | radeon_color_t *spec0 = (radeon_color_t *)&((v0)->ui[specoffset]); \ |
||
462 | radeon_color_t *spec1 = (radeon_color_t *)&((v1)->ui[specoffset]); \ |
||
463 | spec0->red = spec1->red; \ |
||
464 | spec0->green = spec1->green; \ |
||
465 | spec0->blue = spec1->blue; \ |
||
466 | } \ |
||
467 | } while (0) |
||
468 | |||
469 | /* These don't need LE32_TO_CPU() as they used to save and restore |
||
470 | * colors which are already in the correct format. |
||
471 | */ |
||
472 | #define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] |
||
473 | #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] |
||
474 | #define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset] |
||
475 | #define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx] |
||
476 | |||
477 | #undef LOCAL_VARS |
||
478 | #undef TAG |
||
479 | #undef INIT |
||
480 | |||
481 | #define LOCAL_VARS(n) \ |
||
482 | r200ContextPtr rmesa = R200_CONTEXT(ctx); \ |
||
483 | GLuint color[n] = {0}, spec[n] = {0}; \ |
||
484 | GLuint coloroffset = rmesa->swtcl.coloroffset; \ |
||
485 | GLuint specoffset = rmesa->swtcl.specoffset; \ |
||
486 | (void) color; (void) spec; (void) coloroffset; (void) specoffset; |
||
487 | |||
488 | /*********************************************************************** |
||
489 | * Helpers for rendering unfilled primitives * |
||
490 | ***********************************************************************/ |
||
491 | |||
492 | #define RASTERIZE(x) r200RasterPrimitive( ctx, reduced_hw_prim(ctx, x) ) |
||
493 | #define RENDER_PRIMITIVE rmesa->radeon.swtcl.render_primitive |
||
494 | #undef TAG |
||
495 | #define TAG(x) x |
||
496 | #include "tnl_dd/t_dd_unfilled.h" |
||
497 | #undef IND |
||
498 | |||
499 | |||
500 | /*********************************************************************** |
||
501 | * Generate GL render functions * |
||
502 | ***********************************************************************/ |
||
503 | |||
504 | |||
505 | #define IND (0) |
||
506 | #define TAG(x) x |
||
507 | #include "tnl_dd/t_dd_tritmp.h" |
||
508 | |||
509 | #define IND (R200_TWOSIDE_BIT) |
||
510 | #define TAG(x) x##_twoside |
||
511 | #include "tnl_dd/t_dd_tritmp.h" |
||
512 | |||
513 | #define IND (R200_UNFILLED_BIT) |
||
514 | #define TAG(x) x##_unfilled |
||
515 | #include "tnl_dd/t_dd_tritmp.h" |
||
516 | |||
517 | #define IND (R200_TWOSIDE_BIT|R200_UNFILLED_BIT) |
||
518 | #define TAG(x) x##_twoside_unfilled |
||
519 | #include "tnl_dd/t_dd_tritmp.h" |
||
520 | |||
521 | |||
522 | static void init_rast_tab( void ) |
||
523 | { |
||
524 | init(); |
||
525 | init_twoside(); |
||
526 | init_unfilled(); |
||
527 | init_twoside_unfilled(); |
||
528 | } |
||
529 | |||
530 | /**********************************************************************/ |
||
531 | /* Render unclipped begin/end objects */ |
||
532 | /**********************************************************************/ |
||
533 | |||
534 | #define RENDER_POINTS( start, count ) \ |
||
535 | for ( ; start < count ; start++) \ |
||
536 | r200_point( rmesa, VERT(start) ) |
||
537 | #define RENDER_LINE( v0, v1 ) \ |
||
538 | r200_line( rmesa, VERT(v0), VERT(v1) ) |
||
539 | #define RENDER_TRI( v0, v1, v2 ) \ |
||
540 | r200_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) ) |
||
541 | #define RENDER_QUAD( v0, v1, v2, v3 ) \ |
||
542 | r200_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) |
||
543 | #define INIT(x) do { \ |
||
544 | r200RenderPrimitive( ctx, x ); \ |
||
545 | } while (0) |
||
546 | #undef LOCAL_VARS |
||
547 | #define LOCAL_VARS \ |
||
548 | r200ContextPtr rmesa = R200_CONTEXT(ctx); \ |
||
549 | const GLuint vertsize = rmesa->radeon.swtcl.vertex_size; \ |
||
550 | const char *r200verts = (char *)rmesa->radeon.swtcl.verts; \ |
||
551 | const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ |
||
552 | const GLboolean stipple = ctx->Line.StippleFlag; \ |
||
553 | (void) elt; (void) stipple; |
||
554 | #define RESET_STIPPLE if ( stipple ) r200ResetLineStipple( ctx ); |
||
555 | #define RESET_OCCLUSION |
||
556 | #define PRESERVE_VB_DEFS |
||
557 | #define ELT(x) (x) |
||
558 | #define TAG(x) r200_##x##_verts |
||
559 | #include "tnl/t_vb_rendertmp.h" |
||
560 | #undef ELT |
||
561 | #undef TAG |
||
562 | #define TAG(x) r200_##x##_elts |
||
563 | #define ELT(x) elt[x] |
||
564 | #include "tnl/t_vb_rendertmp.h" |
||
565 | |||
566 | |||
567 | |||
568 | /**********************************************************************/ |
||
569 | /* Choose render functions */ |
||
570 | /**********************************************************************/ |
||
571 | |||
572 | void r200ChooseRenderState( struct gl_context *ctx ) |
||
573 | { |
||
574 | TNLcontext *tnl = TNL_CONTEXT(ctx); |
||
575 | r200ContextPtr rmesa = R200_CONTEXT(ctx); |
||
576 | GLuint index = 0; |
||
577 | GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL || |
||
578 | ctx->Polygon.BackMode != GL_FILL); |
||
579 | GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide; |
||
580 | |||
581 | if (!rmesa->radeon.TclFallback || rmesa->radeon.Fallback) |
||
582 | return; |
||
583 | |||
584 | if (twosided) |
||
585 | index |= R200_TWOSIDE_BIT; |
||
586 | if (unfilled) |
||
587 | index |= R200_UNFILLED_BIT; |
||
588 | |||
589 | if (index != rmesa->radeon.swtcl.RenderIndex) { |
||
590 | tnl->Driver.Render.Points = rast_tab[index].points; |
||
591 | tnl->Driver.Render.Line = rast_tab[index].line; |
||
592 | tnl->Driver.Render.ClippedLine = rast_tab[index].line; |
||
593 | tnl->Driver.Render.Triangle = rast_tab[index].triangle; |
||
594 | tnl->Driver.Render.Quad = rast_tab[index].quad; |
||
595 | |||
596 | if (index == 0) { |
||
597 | tnl->Driver.Render.PrimTabVerts = r200_render_tab_verts; |
||
598 | tnl->Driver.Render.PrimTabElts = r200_render_tab_elts; |
||
599 | tnl->Driver.Render.ClippedPolygon = r200_fast_clipped_poly; |
||
600 | } else { |
||
601 | tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; |
||
602 | tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; |
||
603 | tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; |
||
604 | } |
||
605 | |||
606 | rmesa->radeon.swtcl.RenderIndex = index; |
||
607 | } |
||
608 | } |
||
609 | |||
610 | |||
611 | /**********************************************************************/ |
||
612 | /* High level hooks for t_vb_render.c */ |
||
613 | /**********************************************************************/ |
||
614 | |||
615 | |||
616 | static void r200RasterPrimitive( struct gl_context *ctx, GLuint hwprim ) |
||
617 | { |
||
618 | r200ContextPtr rmesa = R200_CONTEXT(ctx); |
||
619 | |||
620 | radeon_prepare_render(&rmesa->radeon); |
||
621 | if (rmesa->radeon.NewGLState) |
||
622 | r200ValidateState( ctx ); |
||
623 | |||
624 | |||
625 | if (rmesa->radeon.swtcl.hw_primitive != hwprim) { |
||
626 | /* need to disable perspective-correct texturing for point sprites */ |
||
627 | if ((hwprim & 0xf) == R200_VF_PRIM_POINT_SPRITES && ctx->Point.PointSprite) { |
||
628 | if (rmesa->hw.set.cmd[SET_RE_CNTL] & R200_PERSPECTIVE_ENABLE) { |
||
629 | R200_STATECHANGE( rmesa, set ); |
||
630 | rmesa->hw.set.cmd[SET_RE_CNTL] &= ~R200_PERSPECTIVE_ENABLE; |
||
631 | } |
||
632 | } |
||
633 | else if (!(rmesa->hw.set.cmd[SET_RE_CNTL] & R200_PERSPECTIVE_ENABLE)) { |
||
634 | R200_STATECHANGE( rmesa, set ); |
||
635 | rmesa->hw.set.cmd[SET_RE_CNTL] |= R200_PERSPECTIVE_ENABLE; |
||
636 | } |
||
637 | R200_NEWPRIM( rmesa ); |
||
638 | rmesa->radeon.swtcl.hw_primitive = hwprim; |
||
639 | } |
||
640 | } |
||
641 | |||
642 | static void r200RenderPrimitive( struct gl_context *ctx, GLenum prim ) |
||
643 | { |
||
644 | r200ContextPtr rmesa = R200_CONTEXT(ctx); |
||
645 | GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL || |
||
646 | ctx->Polygon.BackMode != GL_FILL); |
||
647 | |||
648 | rmesa->radeon.swtcl.render_primitive = prim; |
||
649 | if (prim < GL_TRIANGLES || !unfilled) |
||
650 | r200RasterPrimitive( ctx, reduced_hw_prim(ctx, prim) ); |
||
651 | } |
||
652 | |||
653 | static void r200RenderFinish( struct gl_context *ctx ) |
||
654 | { |
||
655 | } |
||
656 | |||
657 | static void r200ResetLineStipple( struct gl_context *ctx ) |
||
658 | { |
||
659 | r200ContextPtr rmesa = R200_CONTEXT(ctx); |
||
660 | R200_STATECHANGE( rmesa, lin ); |
||
661 | } |
||
662 | |||
663 | |||
664 | /**********************************************************************/ |
||
665 | /* Transition to/from hardware rasterization. */ |
||
666 | /**********************************************************************/ |
||
667 | |||
668 | static const char * const fallbackStrings[] = { |
||
669 | "Texture mode", |
||
670 | "glDrawBuffer(GL_FRONT_AND_BACK)", |
||
671 | "glEnable(GL_STENCIL) without hw stencil buffer", |
||
672 | "glRenderMode(selection or feedback)", |
||
673 | "R200_NO_RAST", |
||
674 | "Mixing GL_CLAMP_TO_BORDER and GL_CLAMP (or GL_MIRROR_CLAMP_ATI)" |
||
675 | }; |
||
676 | |||
677 | |||
678 | static const char *getFallbackString(GLuint bit) |
||
679 | { |
||
680 | int i = 0; |
||
681 | while (bit > 1) { |
||
682 | i++; |
||
683 | bit >>= 1; |
||
684 | } |
||
685 | return fallbackStrings[i]; |
||
686 | } |
||
687 | |||
688 | |||
689 | void r200Fallback( struct gl_context *ctx, GLuint bit, GLboolean mode ) |
||
690 | { |
||
691 | r200ContextPtr rmesa = R200_CONTEXT(ctx); |
||
692 | TNLcontext *tnl = TNL_CONTEXT(ctx); |
||
693 | GLuint oldfallback = rmesa->radeon.Fallback; |
||
694 | |||
695 | if (mode) { |
||
696 | rmesa->radeon.Fallback |= bit; |
||
697 | if (oldfallback == 0) { |
||
698 | radeon_firevertices(&rmesa->radeon); |
||
699 | TCL_FALLBACK( ctx, R200_TCL_FALLBACK_RASTER, GL_TRUE ); |
||
700 | _swsetup_Wakeup( ctx ); |
||
701 | rmesa->radeon.swtcl.RenderIndex = ~0; |
||
702 | if (R200_DEBUG & RADEON_FALLBACKS) { |
||
703 | fprintf(stderr, "R200 begin rasterization fallback: 0x%x %s\n", |
||
704 | bit, getFallbackString(bit)); |
||
705 | } |
||
706 | } |
||
707 | } |
||
708 | else { |
||
709 | rmesa->radeon.Fallback &= ~bit; |
||
710 | if (oldfallback == bit) { |
||
711 | |||
712 | _swrast_flush( ctx ); |
||
713 | tnl->Driver.Render.Start = r200RenderStart; |
||
714 | tnl->Driver.Render.PrimitiveNotify = r200RenderPrimitive; |
||
715 | tnl->Driver.Render.Finish = r200RenderFinish; |
||
716 | |||
717 | tnl->Driver.Render.BuildVertices = _tnl_build_vertices; |
||
718 | tnl->Driver.Render.CopyPV = _tnl_copy_pv; |
||
719 | tnl->Driver.Render.Interp = _tnl_interp; |
||
720 | |||
721 | tnl->Driver.Render.ResetLineStipple = r200ResetLineStipple; |
||
722 | TCL_FALLBACK( ctx, R200_TCL_FALLBACK_RASTER, GL_FALSE ); |
||
723 | if (rmesa->radeon.TclFallback) { |
||
724 | /* These are already done if rmesa->radeon.TclFallback goes to |
||
725 | * zero above. But not if it doesn't (R200_NO_TCL for |
||
726 | * example?) |
||
727 | */ |
||
728 | _tnl_invalidate_vertex_state( ctx, ~0 ); |
||
729 | _tnl_invalidate_vertices( ctx, ~0 ); |
||
730 | rmesa->radeon.tnl_index_bitset = 0; |
||
731 | r200ChooseVertexState( ctx ); |
||
732 | r200ChooseRenderState( ctx ); |
||
733 | } |
||
734 | if (R200_DEBUG & RADEON_FALLBACKS) { |
||
735 | fprintf(stderr, "R200 end rasterization fallback: 0x%x %s\n", |
||
736 | bit, getFallbackString(bit)); |
||
737 | } |
||
738 | } |
||
739 | } |
||
740 | } |
||
741 | |||
742 | |||
743 | |||
744 | |||
745 | /** |
||
746 | * Cope with depth operations by drawing individual pixels as points. |
||
747 | * |
||
748 | * \todo |
||
749 | * The way the vertex state is set in this routine is hokey. It seems to |
||
750 | * work, but it's very hackish. This whole routine is pretty hackish. If |
||
751 | * the bitmap is small enough, it seems like it would be faster to copy it |
||
752 | * to AGP memory and use it as a non-power-of-two texture (i.e., |
||
753 | * NV_texture_rectangle). |
||
754 | */ |
||
755 | void |
||
756 | r200PointsBitmap( struct gl_context *ctx, GLint px, GLint py, |
||
757 | GLsizei width, GLsizei height, |
||
758 | const struct gl_pixelstore_attrib *unpack, |
||
759 | const GLubyte *bitmap ) |
||
760 | { |
||
761 | r200ContextPtr rmesa = R200_CONTEXT(ctx); |
||
762 | const GLfloat *rc = ctx->Current.RasterColor; |
||
763 | GLint row, col; |
||
764 | radeonVertex vert; |
||
765 | GLuint orig_vte; |
||
766 | GLuint h; |
||
767 | |||
768 | |||
769 | /* Turn off tcl. |
||
770 | */ |
||
771 | TCL_FALLBACK( ctx, R200_TCL_FALLBACK_BITMAP, 1 ); |
||
772 | |||
773 | /* Choose tiny vertex format |
||
774 | */ |
||
775 | { |
||
776 | const GLuint fmt_0 = R200_VTX_XY | R200_VTX_Z0 | R200_VTX_W0 |
||
777 | | (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT); |
||
778 | const GLuint fmt_1 = 0; |
||
779 | GLuint vte = rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL]; |
||
780 | GLuint vap = rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL]; |
||
781 | |||
782 | vte &= ~(R200_VTX_XY_FMT | R200_VTX_Z_FMT); |
||
783 | vte |= R200_VTX_W0_FMT; |
||
784 | vap &= ~R200_VAP_FORCE_W_TO_ONE; |
||
785 | |||
786 | rmesa->radeon.swtcl.vertex_size = 5; |
||
787 | |||
788 | if ( (rmesa->hw.vtx.cmd[VTX_VTXFMT_0] != fmt_0) |
||
789 | || (rmesa->hw.vtx.cmd[VTX_VTXFMT_1] != fmt_1) ) { |
||
790 | R200_NEWPRIM(rmesa); |
||
791 | R200_STATECHANGE( rmesa, vtx ); |
||
792 | rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = fmt_0; |
||
793 | rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = fmt_1; |
||
794 | } |
||
795 | |||
796 | if (vte != rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL]) { |
||
797 | R200_STATECHANGE( rmesa, vte ); |
||
798 | rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] = vte; |
||
799 | } |
||
800 | |||
801 | if (vap != rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL]) { |
||
802 | R200_STATECHANGE( rmesa, vap ); |
||
803 | rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] = vap; |
||
804 | } |
||
805 | } |
||
806 | |||
807 | /* Ready for point primitives: |
||
808 | */ |
||
809 | r200RenderPrimitive( ctx, GL_POINTS ); |
||
810 | |||
811 | /* Turn off the hw viewport transformation: |
||
812 | */ |
||
813 | R200_STATECHANGE( rmesa, vte ); |
||
814 | orig_vte = rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL]; |
||
815 | rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] &= ~(R200_VPORT_X_SCALE_ENA | |
||
816 | R200_VPORT_Y_SCALE_ENA | |
||
817 | R200_VPORT_Z_SCALE_ENA | |
||
818 | R200_VPORT_X_OFFSET_ENA | |
||
819 | R200_VPORT_Y_OFFSET_ENA | |
||
820 | R200_VPORT_Z_OFFSET_ENA); |
||
821 | |||
822 | /* Turn off other stuff: Stipple?, texture?, blending?, etc. |
||
823 | */ |
||
824 | |||
825 | |||
826 | /* Populate the vertex |
||
827 | * |
||
828 | * Incorporate FOG into RGBA |
||
829 | */ |
||
830 | if (ctx->Fog.Enabled) { |
||
831 | const GLfloat *fc = ctx->Fog.Color; |
||
832 | GLfloat color[4]; |
||
833 | GLfloat f; |
||
834 | |||
835 | if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) |
||
836 | f = _swrast_z_to_fogfactor(ctx, ctx->Current.Attrib[VERT_ATTRIB_FOG][0]); |
||
837 | else |
||
838 | f = _swrast_z_to_fogfactor(ctx, ctx->Current.RasterDistance); |
||
839 | |||
840 | color[0] = f * rc[0] + (1.F - f) * fc[0]; |
||
841 | color[1] = f * rc[1] + (1.F - f) * fc[1]; |
||
842 | color[2] = f * rc[2] + (1.F - f) * fc[2]; |
||
843 | color[3] = rc[3]; |
||
844 | |||
845 | UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.red, color[0]); |
||
846 | UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.green, color[1]); |
||
847 | UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.blue, color[2]); |
||
848 | UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.alpha, color[3]); |
||
849 | } |
||
850 | else { |
||
851 | UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.red, rc[0]); |
||
852 | UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.green, rc[1]); |
||
853 | UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.blue, rc[2]); |
||
854 | UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.alpha, rc[3]); |
||
855 | } |
||
856 | |||
857 | |||
858 | vert.tv.z = ctx->Current.RasterPos[2]; |
||
859 | |||
860 | |||
861 | /* Update window height |
||
862 | */ |
||
863 | h = radeon_get_drawable(&rmesa->radeon)->h; |
||
864 | |||
865 | /* Clipping handled by existing mechansims in r200_ioctl.c? |
||
866 | */ |
||
867 | for (row=0; row |
||
868 | const GLubyte *src = (const GLubyte *) |
||
869 | _mesa_image_address2d(unpack, bitmap, width, height, |
||
870 | GL_COLOR_INDEX, GL_BITMAP, row, 0 ); |
||
871 | |||
872 | if (unpack->LsbFirst) { |
||
873 | /* Lsb first */ |
||
874 | GLubyte mask = 1U << (unpack->SkipPixels & 0x7); |
||
875 | for (col=0; col |
||
876 | if (*src & mask) { |
||
877 | vert.tv.x = px+col; |
||
878 | vert.tv.y = h - (py+row) - 1; |
||
879 | r200_point( rmesa, &vert ); |
||
880 | } |
||
881 | src += (mask >> 7); |
||
882 | mask = ((mask << 1) & 0xff) | (mask >> 7); |
||
883 | } |
||
884 | |||
885 | /* get ready for next row */ |
||
886 | if (mask != 1) |
||
887 | src++; |
||
888 | } |
||
889 | else { |
||
890 | /* Msb first */ |
||
891 | GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); |
||
892 | for (col=0; col |
||
893 | if (*src & mask) { |
||
894 | vert.tv.x = px+col; |
||
895 | vert.tv.y = h - (py+row) - 1; |
||
896 | r200_point( rmesa, &vert ); |
||
897 | } |
||
898 | src += mask & 1; |
||
899 | mask = ((mask << 7) & 0xff) | (mask >> 1); |
||
900 | } |
||
901 | /* get ready for next row */ |
||
902 | if (mask != 128) |
||
903 | src++; |
||
904 | } |
||
905 | } |
||
906 | |||
907 | /* Fire outstanding vertices, restore state |
||
908 | */ |
||
909 | R200_STATECHANGE( rmesa, vte ); |
||
910 | rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] = orig_vte; |
||
911 | |||
912 | /* Unfallback |
||
913 | */ |
||
914 | TCL_FALLBACK( ctx, R200_TCL_FALLBACK_BITMAP, 0 ); |
||
915 | |||
916 | /* Need to restore vertexformat? |
||
917 | */ |
||
918 | if (rmesa->radeon.TclFallback) |
||
919 | r200ChooseVertexState( ctx ); |
||
920 | } |
||
921 | |||
922 | |||
923 | |||
924 | /**********************************************************************/ |
||
925 | /* Initialization. */ |
||
926 | /**********************************************************************/ |
||
927 | |||
928 | void r200InitSwtcl( struct gl_context *ctx ) |
||
929 | { |
||
930 | TNLcontext *tnl = TNL_CONTEXT(ctx); |
||
931 | r200ContextPtr rmesa = R200_CONTEXT(ctx); |
||
932 | static int firsttime = 1; |
||
933 | |||
934 | if (firsttime) { |
||
935 | init_rast_tab(); |
||
936 | firsttime = 0; |
||
937 | } |
||
938 | rmesa->radeon.swtcl.emit_prediction = 0; |
||
939 | |||
940 | tnl->Driver.Render.Start = r200RenderStart; |
||
941 | tnl->Driver.Render.Finish = r200RenderFinish; |
||
942 | tnl->Driver.Render.PrimitiveNotify = r200RenderPrimitive; |
||
943 | tnl->Driver.Render.ResetLineStipple = r200ResetLineStipple; |
||
944 | tnl->Driver.Render.BuildVertices = _tnl_build_vertices; |
||
945 | tnl->Driver.Render.CopyPV = _tnl_copy_pv; |
||
946 | tnl->Driver.Render.Interp = _tnl_interp; |
||
947 | |||
948 | /* FIXME: what are these numbers? */ |
||
949 | _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, |
||
950 | 36 * sizeof(GLfloat) ); |
||
951 | |||
952 | rmesa->radeon.swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf; |
||
953 | rmesa->radeon.swtcl.RenderIndex = ~0; |
||
954 | rmesa->radeon.swtcl.render_primitive = GL_TRIANGLES; |
||
955 | rmesa->radeon.swtcl.hw_primitive = 0; |
||
956 | }><>><>><>><>>>>>><>>><>><>><>><>><>><> |
||
957 |