2 /**************************************************************************
4 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
6 The Weather Channel (TM) funded Tungsten Graphics to develop the
7 initial release of the Radeon 8500 driver under the XFree86 license.
8 This notice must be preserved.
10 Permission is hereby granted, free of charge, to any person obtaining
11 a copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sublicense, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial
20 portions of the Software.
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
26 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
34 * Keith Whitwell <keith@tungstengraphics.com>
45 #include "swrast/s_context.h"
46 #include "swrast/s_fog.h"
47 #include "swrast_setup/swrast_setup.h"
48 #include "math/m_translate.h"
50 #include "tnl/t_context.h"
51 #include "tnl/t_imm_exec.h"
52 #include "tnl/t_pipeline.h"
54 #include "r200_context.h"
55 #include "r200_ioctl.h"
56 #include "r200_state.h"
57 #include "r200_swtcl.h"
60 /***********************************************************************
61 * Build render functions from dd templates *
62 ***********************************************************************/
65 #define R200_XYZW_BIT 0x01
66 #define R200_RGBA_BIT 0x02
67 #define R200_SPEC_BIT 0x04
68 #define R200_TEX0_BIT 0x08
69 #define R200_TEX1_BIT 0x10
70 #define R200_PTEX_BIT 0x20
71 #define R200_MAX_SETUP 0x40
73 static void flush_last_swtcl_prim( r200ContextPtr rmesa
);
76 void (*emit
)( GLcontext
*, GLuint
, GLuint
, void *, GLuint
);
79 GLboolean (*check_tex_sizes
)( GLcontext
*ctx
);
81 GLuint vertex_stride_shift
;
83 } setup_tab
[R200_MAX_SETUP
];
86 static int se_vtx_fmt_0
[] = {
91 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
)),
96 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
) |
97 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_1_SHIFT
)),
102 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
) |
103 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_1_SHIFT
)),
108 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
) |
109 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_1_SHIFT
)),
114 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
) |
115 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_1_SHIFT
))
118 static int se_vtx_fmt_1
[] = {
122 ((2 << R200_VTX_TEX0_COMP_CNT_SHIFT
)),
123 ((2 << R200_VTX_TEX0_COMP_CNT_SHIFT
) |
124 (2 << R200_VTX_TEX1_COMP_CNT_SHIFT
)),
125 ((3 << R200_VTX_TEX0_COMP_CNT_SHIFT
) |
126 (3 << R200_VTX_TEX1_COMP_CNT_SHIFT
)),
129 #define TINY_VERTEX_FORMAT 1
130 #define NOTEX_VERTEX_FORMAT 2
131 #define TEX0_VERTEX_FORMAT 3
132 #define TEX1_VERTEX_FORMAT 4
133 #define PROJ_TEX1_VERTEX_FORMAT 5
134 #define TEX2_VERTEX_FORMAT 0
135 #define TEX3_VERTEX_FORMAT 0
136 #define PROJ_TEX3_VERTEX_FORMAT 0
138 #define DO_XYZW (IND & R200_XYZW_BIT)
139 #define DO_RGBA (IND & R200_RGBA_BIT)
140 #define DO_SPEC (IND & R200_SPEC_BIT)
141 #define DO_FOG (IND & R200_SPEC_BIT)
142 #define DO_TEX0 (IND & R200_TEX0_BIT)
143 #define DO_TEX1 (IND & R200_TEX1_BIT)
146 #define DO_PTEX (IND & R200_PTEX_BIT)
148 #define VERTEX r200Vertex
149 #define VERTEX_COLOR r200_color_t
150 #define GET_VIEWPORT_MAT() 0
151 #define GET_TEXSOURCE(n) n
152 #define GET_VERTEX_FORMAT() R200_CONTEXT(ctx)->swtcl.vertex_format
153 #define GET_VERTEX_STORE() R200_CONTEXT(ctx)->swtcl.verts
154 #define GET_VERTEX_STRIDE_SHIFT() R200_CONTEXT(ctx)->swtcl.vertex_stride_shift
155 #define GET_UBYTE_COLOR_STORE() &R200_CONTEXT(ctx)->UbyteColor
156 #define GET_UBYTE_SPEC_COLOR_STORE() &R200_CONTEXT(ctx)->UbyteSecondaryColor
158 #define HAVE_HW_VIEWPORT 1
159 #define HAVE_HW_DIVIDE (IND & ~(R200_XYZW_BIT|R200_RGBA_BIT))
160 #define HAVE_TINY_VERTICES 1
161 #define HAVE_RGBA_COLOR 1
162 #define HAVE_NOTEX_VERTICES 1
163 #define HAVE_TEX0_VERTICES 1
164 #define HAVE_TEX1_VERTICES 1
165 #define HAVE_TEX2_VERTICES 0
166 #define HAVE_TEX3_VERTICES 0
167 #define HAVE_PTEX_VERTICES 1
169 #define CHECK_HW_DIVIDE (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE| \
172 #define IMPORT_QUALIFIER
173 #define IMPORT_FLOAT_COLORS r200_import_float_colors
174 #define IMPORT_FLOAT_SPEC_COLORS r200_import_float_spec_colors
176 #define INTERP_VERTEX setup_tab[R200_CONTEXT(ctx)->swtcl.SetupIndex].interp
177 #define COPY_PV_VERTEX setup_tab[R200_CONTEXT(ctx)->swtcl.SetupIndex].copy_pv
180 /***********************************************************************
181 * Generate pv-copying and translation functions *
182 ***********************************************************************/
184 #define TAG(x) r200_##x
186 #include "tnl_dd/t_dd_vb.c"
190 /***********************************************************************
191 * Generate vertex emit and interp functions *
192 ***********************************************************************/
194 #define IND (R200_XYZW_BIT|R200_RGBA_BIT)
195 #define TAG(x) x##_wg
196 #include "tnl_dd/t_dd_vbtmp.h"
198 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_TEX0_BIT)
199 #define TAG(x) x##_wgt0
200 #include "tnl_dd/t_dd_vbtmp.h"
202 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_TEX0_BIT|R200_PTEX_BIT)
203 #define TAG(x) x##_wgpt0
204 #include "tnl_dd/t_dd_vbtmp.h"
206 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_TEX0_BIT|R200_TEX1_BIT)
207 #define TAG(x) x##_wgt0t1
208 #include "tnl_dd/t_dd_vbtmp.h"
210 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_TEX0_BIT|R200_TEX1_BIT|\
212 #define TAG(x) x##_wgpt0t1
213 #include "tnl_dd/t_dd_vbtmp.h"
215 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT)
216 #define TAG(x) x##_wgfs
217 #include "tnl_dd/t_dd_vbtmp.h"
219 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT|\
221 #define TAG(x) x##_wgfst0
222 #include "tnl_dd/t_dd_vbtmp.h"
224 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT|\
225 R200_TEX0_BIT|R200_PTEX_BIT)
226 #define TAG(x) x##_wgfspt0
227 #include "tnl_dd/t_dd_vbtmp.h"
229 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT|\
230 R200_TEX0_BIT|R200_TEX1_BIT)
231 #define TAG(x) x##_wgfst0t1
232 #include "tnl_dd/t_dd_vbtmp.h"
234 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT|\
235 R200_TEX0_BIT|R200_TEX1_BIT|R200_PTEX_BIT)
236 #define TAG(x) x##_wgfspt0t1
237 #include "tnl_dd/t_dd_vbtmp.h"
240 /***********************************************************************
242 ***********************************************************************/
244 static void init_setup_tab( void )
260 void r200PrintSetupFlags(char *msg
, GLuint flags
)
262 fprintf(stderr
, "%s(%x): %s%s%s%s%s%s\n",
265 (flags
& R200_XYZW_BIT
) ? " xyzw," : "",
266 (flags
& R200_RGBA_BIT
) ? " rgba," : "",
267 (flags
& R200_SPEC_BIT
) ? " spec/fog," : "",
268 (flags
& R200_TEX0_BIT
) ? " tex-0," : "",
269 (flags
& R200_TEX1_BIT
) ? " tex-1," : "",
270 (flags
& R200_PTEX_BIT
) ? " proj-tex," : "");
275 static void r200SetVertexFormat( GLcontext
*ctx
, GLuint ind
)
277 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
278 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
280 rmesa
->swtcl
.SetupIndex
= ind
;
282 if (ctx
->_TriangleCaps
& (DD_TRI_LIGHT_TWOSIDE
|DD_TRI_UNFILLED
)) {
283 tnl
->Driver
.Render
.Interp
= r200_interp_extras
;
284 tnl
->Driver
.Render
.CopyPV
= r200_copy_pv_extras
;
287 tnl
->Driver
.Render
.Interp
= setup_tab
[ind
].interp
;
288 tnl
->Driver
.Render
.CopyPV
= setup_tab
[ind
].copy_pv
;
291 if (setup_tab
[ind
].vertex_format
!= rmesa
->swtcl
.vertex_format
) {
294 i
= rmesa
->swtcl
.vertex_format
= setup_tab
[ind
].vertex_format
;
295 rmesa
->swtcl
.vertex_size
= setup_tab
[ind
].vertex_size
;
296 rmesa
->swtcl
.vertex_stride_shift
= setup_tab
[ind
].vertex_stride_shift
;
298 R200_STATECHANGE( rmesa
, vtx
);
299 rmesa
->hw
.vtx
.cmd
[VTX_VTXFMT_0
] = se_vtx_fmt_0
[i
];
300 rmesa
->hw
.vtx
.cmd
[VTX_VTXFMT_1
] = se_vtx_fmt_1
[i
];
304 GLuint vte
= rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
];
305 GLuint vap
= rmesa
->hw
.vap
.cmd
[VAP_SE_VAP_CNTL
];
308 /* HW perspective divide is a win, but tiny vertex formats are a
311 if (setup_tab
[ind
].vertex_format
== TINY_VERTEX_FORMAT
||
312 (ctx
->_TriangleCaps
& (DD_TRI_LIGHT_TWOSIDE
|DD_TRI_UNFILLED
))) {
314 vte
|= R200_VTX_XY_FMT
| R200_VTX_Z_FMT
;
315 vte
&= ~R200_VTX_W0_FMT
;
316 vap
|= R200_VAP_FORCE_W_TO_ONE
;
320 vte
&= ~(R200_VTX_XY_FMT
| R200_VTX_Z_FMT
);
321 vte
|= R200_VTX_W0_FMT
;
322 vap
&= ~R200_VAP_FORCE_W_TO_ONE
;
325 _tnl_need_projected_coords( ctx
, needproj
);
326 if (vte
!= rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
]) {
327 R200_STATECHANGE( rmesa
, vte
);
328 rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
] = vte
;
330 if (vap
!= rmesa
->hw
.vap
.cmd
[VAP_SE_VAP_CNTL
]) {
331 R200_STATECHANGE( rmesa
, vap
);
332 rmesa
->hw
.vap
.cmd
[VAP_SE_VAP_CNTL
] = vap
;
337 static void r200RenderStart( GLcontext
*ctx
)
339 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
341 if (!setup_tab
[rmesa
->swtcl
.SetupIndex
].check_tex_sizes(ctx
)) {
342 r200SetVertexFormat( ctx
, rmesa
->swtcl
.SetupIndex
| R200_PTEX_BIT
);
345 if (rmesa
->dma
.flush
!= 0 &&
346 rmesa
->dma
.flush
!= flush_last_swtcl_prim
)
347 rmesa
->dma
.flush( rmesa
);
351 void r200BuildVertices( GLcontext
*ctx
, GLuint start
, GLuint count
,
354 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
355 GLubyte
*v
= ((GLubyte
*)rmesa
->swtcl
.verts
+
356 (start
<< rmesa
->swtcl
.vertex_stride_shift
));
357 GLuint stride
= 1 << rmesa
->swtcl
.vertex_stride_shift
;
359 newinputs
|= rmesa
->swtcl
.SetupNewInputs
;
360 rmesa
->swtcl
.SetupNewInputs
= 0;
365 setup_tab
[rmesa
->swtcl
.SetupIndex
].emit( ctx
, start
, count
, v
, stride
);
369 void r200ChooseVertexState( GLcontext
*ctx
)
371 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
372 GLuint ind
= (R200_XYZW_BIT
| R200_RGBA_BIT
);
374 if (!rmesa
->TclFallback
|| rmesa
->Fallback
)
377 if (ctx
->Fog
.Enabled
|| (ctx
->_TriangleCaps
& DD_SEPARATE_SPECULAR
))
378 ind
|= R200_SPEC_BIT
;
380 if (ctx
->Texture
._EnabledUnits
& 0x2) /* unit 1 enabled */
381 ind
|= R200_TEX0_BIT
|R200_TEX1_BIT
;
382 else if (ctx
->Texture
._EnabledUnits
& 0x1) /* unit 1 enabled */
383 ind
|= R200_TEX0_BIT
;
385 r200SetVertexFormat( ctx
, ind
);
389 /* Flush vertices in the current dma region.
391 static void flush_last_swtcl_prim( r200ContextPtr rmesa
)
393 if (R200_DEBUG
& DEBUG_IOCTL
)
394 fprintf(stderr
, "%s\n", __FUNCTION__
);
396 rmesa
->dma
.flush
= 0;
398 if (rmesa
->dma
.current
.buf
) {
399 struct r200_dma_region
*current
= &rmesa
->dma
.current
;
400 GLuint current_offset
= (rmesa
->r200Screen
->agp_buffer_offset
+
401 current
->buf
->buf
->idx
* RADEON_BUFFER_SIZE
+
404 assert (!(rmesa
->swtcl
.hw_primitive
& R200_VF_PRIM_WALK_IND
));
406 assert (current
->start
+
407 rmesa
->swtcl
.numverts
* rmesa
->swtcl
.vertex_size
* 4 ==
410 if (rmesa
->dma
.current
.start
!= rmesa
->dma
.current
.ptr
) {
411 r200EmitVertexAOS( rmesa
,
412 rmesa
->swtcl
.vertex_size
,
415 r200EmitVbufPrim( rmesa
,
416 rmesa
->swtcl
.hw_primitive
,
417 rmesa
->swtcl
.numverts
);
420 rmesa
->swtcl
.numverts
= 0;
421 current
->start
= current
->ptr
;
426 /* Alloc space in the current dma region.
428 static __inline
void *r200AllocDmaLowVerts( r200ContextPtr rmesa
,
429 int nverts
, int vsize
)
431 GLuint bytes
= vsize
* nverts
;
433 if ( rmesa
->dma
.current
.ptr
+ bytes
> rmesa
->dma
.current
.end
)
434 r200RefillCurrentDmaRegion( rmesa
);
436 if (!rmesa
->dma
.flush
) {
437 rmesa
->glCtx
->Driver
.NeedFlush
|= FLUSH_STORED_VERTICES
;
438 rmesa
->dma
.flush
= flush_last_swtcl_prim
;
441 ASSERT( vsize
== rmesa
->swtcl
.vertex_size
* 4 );
442 ASSERT( rmesa
->dma
.flush
== flush_last_swtcl_prim
);
443 ASSERT( rmesa
->dma
.current
.start
+
444 rmesa
->swtcl
.numverts
* rmesa
->swtcl
.vertex_size
* 4 ==
445 rmesa
->dma
.current
.ptr
);
449 char *head
= rmesa
->dma
.current
.address
+ rmesa
->dma
.current
.ptr
;
450 rmesa
->dma
.current
.ptr
+= bytes
;
451 rmesa
->swtcl
.numverts
+= nverts
;
460 void r200_emit_contiguous_verts( GLcontext
*ctx
, GLuint start
, GLuint count
)
462 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
463 GLuint vertex_size
= rmesa
->swtcl
.vertex_size
* 4;
464 CARD32
*dest
= r200AllocDmaLowVerts( rmesa
, count
-start
, vertex_size
);
465 setup_tab
[rmesa
->swtcl
.SetupIndex
].emit( ctx
, start
, count
, dest
,
471 void r200_emit_indexed_verts( GLcontext
*ctx
, GLuint start
, GLuint count
)
473 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
475 r200AllocDmaRegionVerts( rmesa
,
476 &rmesa
->swtcl
.indexed_verts
,
478 rmesa
->swtcl
.vertex_size
* 4,
481 setup_tab
[rmesa
->swtcl
.SetupIndex
].emit(
483 rmesa
->swtcl
.indexed_verts
.address
+ rmesa
->swtcl
.indexed_verts
.start
,
484 rmesa
->swtcl
.vertex_size
* 4 );
489 * Render unclipped vertex buffers by emitting vertices directly to
490 * dma buffers. Use strip/fan hardware primitives where possible.
491 * Try to simulate missing primitives with indexed vertices.
493 #define HAVE_POINTS 1
495 #define HAVE_LINE_STRIPS 1
496 #define HAVE_TRIANGLES 1
497 #define HAVE_TRI_STRIPS 1
498 #define HAVE_TRI_STRIP_1 0
499 #define HAVE_TRI_FANS 1
501 #define HAVE_QUAD_STRIPS 1
502 #define HAVE_POLYGONS 1
505 static const GLuint hw_prim
[GL_POLYGON
+1] = {
509 R200_VF_PRIM_LINE_STRIP
,
510 R200_VF_PRIM_TRIANGLES
,
511 R200_VF_PRIM_TRIANGLE_STRIP
,
512 R200_VF_PRIM_TRIANGLE_FAN
,
514 R200_VF_PRIM_QUAD_STRIP
,
518 static __inline
void r200DmaPrimitive( r200ContextPtr rmesa
, GLenum prim
)
520 R200_NEWPRIM( rmesa
);
521 rmesa
->swtcl
.hw_primitive
= hw_prim
[prim
];
522 assert(rmesa
->dma
.current
.ptr
== rmesa
->dma
.current
.start
);
525 static __inline
void r200EltPrimitive( r200ContextPtr rmesa
, GLenum prim
)
527 R200_NEWPRIM( rmesa
);
528 rmesa
->swtcl
.hw_primitive
= hw_prim
[prim
] | R200_VF_PRIM_WALK_IND
;
532 static void VERT_FALLBACK( GLcontext
*ctx
,
537 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
538 tnl
->Driver
.Render
.PrimitiveNotify( ctx
, flags
& PRIM_MODE_MASK
);
539 tnl
->Driver
.Render
.BuildVertices( ctx
, start
, count
, ~0 );
540 tnl
->Driver
.Render
.PrimTabVerts
[flags
&PRIM_MODE_MASK
]( ctx
, start
, count
, flags
);
541 R200_CONTEXT(ctx
)->swtcl
.SetupNewInputs
= VERT_BIT_CLIP
;
544 static void ELT_FALLBACK( GLcontext
*ctx
,
549 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
550 tnl
->Driver
.Render
.PrimitiveNotify( ctx
, flags
& PRIM_MODE_MASK
);
551 tnl
->Driver
.Render
.BuildVertices( ctx
, start
, count
, ~0 );
552 tnl
->Driver
.Render
.PrimTabElts
[flags
&PRIM_MODE_MASK
]( ctx
, start
, count
, flags
);
553 R200_CONTEXT(ctx
)->swtcl
.SetupNewInputs
= VERT_BIT_CLIP
;
557 #define LOCAL_VARS r200ContextPtr rmesa = R200_CONTEXT(ctx)
558 #define ELTS_VARS GLushort *dest
559 #define INIT( prim ) r200DmaPrimitive( rmesa, prim )
560 #define ELT_INIT(prim) r200EltPrimitive( rmesa, prim )
561 #define NEW_PRIMITIVE() R200_NEWPRIM( rmesa )
562 #define NEW_BUFFER() r200RefillCurrentDmaRegion( rmesa )
563 #define GET_CURRENT_VB_MAX_VERTS() \
564 (((int)rmesa->dma.current.end - (int)rmesa->dma.current.ptr) / (rmesa->swtcl.vertex_size*4))
565 #define GET_SUBSEQUENT_VB_MAX_VERTS() \
566 ((RADEON_BUFFER_SIZE) / (rmesa->swtcl.vertex_size*4))
568 #define GET_CURRENT_VB_MAX_ELTS() \
569 ((R200_CMD_BUF_SZ - (rmesa->store.cmd_used + 16)) / 2)
570 #define GET_SUBSEQUENT_VB_MAX_ELTS() \
571 ((R200_CMD_BUF_SZ - 1024) / 2)
575 /* How do you extend an existing primitive?
577 #define ALLOC_ELTS(nr) \
579 if (rmesa->dma.flush == r200FlushElts && \
580 rmesa->store.cmd_used + nr*2 < R200_CMD_BUF_SZ) { \
582 dest = (GLushort *)(rmesa->store.cmd_buf + \
583 rmesa->store.cmd_used); \
584 rmesa->store.cmd_used += nr*2; \
587 if (rmesa->dma.flush) { \
588 rmesa->dma.flush( rmesa ); \
591 r200EmitVertexAOS( rmesa, \
592 rmesa->swtcl.vertex_size, \
593 (rmesa->r200Screen->agp_buffer_offset + \
594 rmesa->swtcl.indexed_verts.buf->buf->idx * \
595 RADEON_BUFFER_SIZE + \
596 rmesa->swtcl.indexed_verts.start)); \
598 dest = r200AllocEltsOpenEnded( rmesa, \
599 rmesa->swtcl.hw_primitive, \
604 #define ALLOC_ELTS_NEW_PRIMITIVE(nr) ALLOC_ELTS( nr )
606 #ifdef MESA_BIG_ENDIAN
607 /* We could do without (most of) this ugliness if dest was always 32 bit word aligned... */
608 #define EMIT_ELT(offset, x) do { \
609 int off = offset + ( ( (GLuint)dest & 0x2 ) >> 1 ); \
610 GLushort *des = (GLushort *)( (GLuint)dest & ~0x2 ); \
611 (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); } while (0)
613 #define EMIT_ELT(offset, x) (dest)[offset] = (GLushort) (x)
615 #define EMIT_TWO_ELTS(offset, x, y) *(GLuint *)(dest+offset) = ((y)<<16)|(x);
616 #define INCR_ELTS( nr ) dest += nr
617 #define RELEASE_ELT_VERTS() \
618 r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, __FUNCTION__ )
619 #define EMIT_VERTS( ctx, j, nr ) \
620 r200_emit_contiguous_verts(ctx, j, (j)+(nr))
621 #define EMIT_INDEXED_VERTS( ctx, start, count ) \
622 r200_emit_indexed_verts( ctx, start, count )
625 #define TAG(x) r200_dma_##x
626 #include "tnl_dd/t_dd_dmatmp.h"
629 /**********************************************************************/
630 /* Render pipeline stage */
631 /**********************************************************************/
634 static GLboolean
r200_run_render( GLcontext
*ctx
,
635 struct gl_pipeline_stage
*stage
)
637 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
638 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
639 struct vertex_buffer
*VB
= &tnl
->vb
;
640 GLuint i
, length
, flags
= 0;
641 render_func
*tab
= TAG(render_tab_verts
);
643 if (rmesa
->swtcl
.indexed_verts
.buf
&& (!VB
->Elts
|| stage
->changed_inputs
))
648 if ((R200_DEBUG
& DEBUG_VERTS
) || /* No debug */
649 VB
->ClipOrMask
|| /* No clipping */
650 rmesa
->swtcl
.RenderIndex
!= 0 || /* No per-vertex manipulations */
651 ctx
->Line
.StippleFlag
) /* No stipple -- fix me? */
655 tab
= TAG(render_tab_elts
);
656 if (!rmesa
->swtcl
.indexed_verts
.buf
)
657 if (!TAG(emit_elt_verts
)(ctx
, 0, VB
->Count
))
658 return GL_TRUE
; /* too many vertices */
661 tnl
->Driver
.Render
.Start( ctx
);
663 for (i
= 0 ; !(flags
& PRIM_LAST
) ; i
+= length
)
665 flags
= VB
->Primitive
[i
];
666 length
= VB
->PrimitiveLength
[i
];
668 if (R200_DEBUG
& DEBUG_PRIMS
)
669 fprintf(stderr
, "r200_render.c: prim %s %d..%d\n",
670 _mesa_lookup_enum_by_nr(flags
& PRIM_MODE_MASK
),
674 tab
[flags
& PRIM_MODE_MASK
]( ctx
, i
, i
+ length
, flags
);
677 tnl
->Driver
.Render
.Finish( ctx
);
679 return GL_FALSE
; /* finished the pipe */
684 static void r200_check_render( GLcontext
*ctx
,
685 struct gl_pipeline_stage
*stage
)
687 GLuint inputs
= VERT_BIT_POS
| VERT_BIT_CLIP
| VERT_BIT_COLOR0
;
689 if (ctx
->RenderMode
== GL_RENDER
) {
690 if (ctx
->_TriangleCaps
& DD_SEPARATE_SPECULAR
)
691 inputs
|= VERT_BIT_COLOR1
;
693 if (ctx
->Texture
.Unit
[0]._ReallyEnabled
)
694 inputs
|= VERT_BIT_TEX0
;
696 if (ctx
->Texture
.Unit
[1]._ReallyEnabled
)
697 inputs
|= VERT_BIT_TEX1
;
699 if (ctx
->Fog
.Enabled
)
700 inputs
|= VERT_BIT_FOG
;
703 stage
->inputs
= inputs
;
707 static void dtr( struct gl_pipeline_stage
*stage
)
713 const struct gl_pipeline_stage _r200_render_stage
=
716 (_DD_NEW_SEPARATE_SPECULAR
|
719 _NEW_RENDERMODE
), /* re-check (new inputs) */
720 0, /* re-run (always runs) */
721 GL_TRUE
, /* active */
722 0, 0, /* inputs (set in check_render), outputs */
723 0, 0, /* changed_inputs, private */
724 dtr
, /* destructor */
725 r200_check_render
, /* check - initially set to alloc data */
726 r200_run_render
/* run */
731 /**************************************************************************/
734 static const GLuint reduced_hw_prim
[GL_POLYGON
+1] = {
739 R200_VF_PRIM_TRIANGLES
,
740 R200_VF_PRIM_TRIANGLES
,
741 R200_VF_PRIM_TRIANGLES
,
742 R200_VF_PRIM_TRIANGLES
,
743 R200_VF_PRIM_TRIANGLES
,
744 R200_VF_PRIM_TRIANGLES
747 static void r200RasterPrimitive( GLcontext
*ctx
, GLuint hwprim
);
748 static void r200RenderPrimitive( GLcontext
*ctx
, GLenum prim
);
749 static void r200ResetLineStipple( GLcontext
*ctx
);
754 #undef HAVE_QUAD_STRIPS
755 #define HAVE_QUAD_STRIPS 0
757 /***********************************************************************
758 * Emit primitives as inline vertices *
759 ***********************************************************************/
762 #define CTX_ARG r200ContextPtr rmesa
763 #define CTX_ARG2 rmesa
764 #define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size
765 #define ALLOC_VERTS( n, size ) r200AllocDmaLowVerts( rmesa, n, size * 4 )
767 r200ContextPtr rmesa = R200_CONTEXT(ctx); \
768 const GLuint shift = rmesa->swtcl.vertex_stride_shift; \
769 const char *r200verts = (char *)rmesa->swtcl.verts;
770 #define VERT(x) (r200Vertex *)(r200verts + (x << shift))
771 #define VERTEX r200Vertex
772 #define DO_DEBUG_VERTS (1 && (R200_DEBUG & DEBUG_VERTS))
773 #define PRINT_VERTEX(v) r200_print_vertex(rmesa->glCtx, v)
775 #define TAG(x) r200_##x
776 #include "tnl_dd/t_dd_triemit.h"
779 /***********************************************************************
780 * Macros for t_dd_tritmp.h to draw basic primitives *
781 ***********************************************************************/
783 #define QUAD( a, b, c, d ) r200_quad( rmesa, a, b, c, d )
784 #define TRI( a, b, c ) r200_triangle( rmesa, a, b, c )
785 #define LINE( a, b ) r200_line( rmesa, a, b )
786 #define POINT( a ) r200_point( rmesa, a )
788 /***********************************************************************
789 * Build render functions from dd templates *
790 ***********************************************************************/
792 #define R200_TWOSIDE_BIT 0x01
793 #define R200_UNFILLED_BIT 0x02
794 #define R200_MAX_TRIFUNC 0x04
800 triangle_func triangle
;
802 } rast_tab
[R200_MAX_TRIFUNC
];
805 #define DO_FALLBACK 0
806 #define DO_UNFILLED (IND & R200_UNFILLED_BIT)
807 #define DO_TWOSIDE (IND & R200_TWOSIDE_BIT)
814 #define DO_FULL_QUAD 1
819 #define HAVE_BACK_COLORS 0
820 #define HAVE_HW_FLATSHADE 1
823 #define DEPTH_SCALE 1.0
824 #define UNFILLED_TRI unfilled_tri
825 #define UNFILLED_QUAD unfilled_quad
826 #define VERT_X(_v) _v->v.x
827 #define VERT_Y(_v) _v->v.y
828 #define VERT_Z(_v) _v->v.z
829 #define AREA_IS_CCW( a ) (a < 0)
830 #define GET_VERTEX(e) (rmesa->swtcl.verts + (e<<rmesa->swtcl.vertex_stride_shift))
832 #define VERT_SET_RGBA( v, c ) v->ui[coloroffset] = LE32_TO_CPU(*(GLuint *)c)
833 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
834 #define VERT_SAVE_RGBA( idx ) color[idx] = CPU_TO_LE32(v[idx]->ui[coloroffset])
835 #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = LE32_TO_CPU(color[idx])
837 #define VERT_SET_SPEC( v0, c ) if (havespec) { \
838 v0->v.specular.red = (c)[0]; \
839 v0->v.specular.green = (c)[1]; \
840 v0->v.specular.blue = (c)[2]; }
841 #define VERT_COPY_SPEC( v0, v1 ) if (havespec) { \
842 v0->v.specular.red = v1->v.specular.red; \
843 v0->v.specular.green = v1->v.specular.green; \
844 v0->v.specular.blue = v1->v.specular.blue; }
845 #define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = CPU_TO_LE32(v[idx]->ui[5])
846 #define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = LE32_TO_CPU(spec[idx])
852 #define LOCAL_VARS(n) \
853 r200ContextPtr rmesa = R200_CONTEXT(ctx); \
854 GLuint color[n], spec[n]; \
855 GLuint coloroffset = (rmesa->swtcl.vertex_size == 4 ? 3 : 4); \
856 GLboolean havespec = (rmesa->swtcl.vertex_size > 4); \
857 (void) color; (void) spec; (void) coloroffset; (void) havespec;
859 /***********************************************************************
860 * Helpers for rendering unfilled primitives *
861 ***********************************************************************/
863 #define RASTERIZE(x) r200RasterPrimitive( ctx, reduced_hw_prim[x] )
864 #define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
867 #include "tnl_dd/t_dd_unfilled.h"
871 /***********************************************************************
872 * Generate GL render functions *
873 ***********************************************************************/
878 #include "tnl_dd/t_dd_tritmp.h"
880 #define IND (R200_TWOSIDE_BIT)
881 #define TAG(x) x##_twoside
882 #include "tnl_dd/t_dd_tritmp.h"
884 #define IND (R200_UNFILLED_BIT)
885 #define TAG(x) x##_unfilled
886 #include "tnl_dd/t_dd_tritmp.h"
888 #define IND (R200_TWOSIDE_BIT|R200_UNFILLED_BIT)
889 #define TAG(x) x##_twoside_unfilled
890 #include "tnl_dd/t_dd_tritmp.h"
893 static void init_rast_tab( void )
898 init_twoside_unfilled();
901 /**********************************************************************/
902 /* Render unclipped begin/end objects */
903 /**********************************************************************/
905 #define VERT(x) (r200Vertex *)(r200verts + (x << shift))
906 #define RENDER_POINTS( start, count ) \
907 for ( ; start < count ; start++) \
908 r200_point( rmesa, VERT(start) )
909 #define RENDER_LINE( v0, v1 ) \
910 r200_line( rmesa, VERT(v0), VERT(v1) )
911 #define RENDER_TRI( v0, v1, v2 ) \
912 r200_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
913 #define RENDER_QUAD( v0, v1, v2, v3 ) \
914 r200_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
915 #define INIT(x) do { \
916 r200RenderPrimitive( ctx, x ); \
920 r200ContextPtr rmesa = R200_CONTEXT(ctx); \
921 const GLuint shift = rmesa->swtcl.vertex_stride_shift; \
922 const char *r200verts = (char *)rmesa->swtcl.verts; \
923 const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
924 const GLboolean stipple = ctx->Line.StippleFlag; \
925 (void) elt; (void) stipple;
926 #define RESET_STIPPLE if ( stipple ) r200ResetLineStipple( ctx );
927 #define RESET_OCCLUSION
928 #define PRESERVE_VB_DEFS
930 #define TAG(x) r200_##x##_verts
931 #include "tnl/t_vb_rendertmp.h"
934 #define TAG(x) r200_##x##_elts
935 #define ELT(x) elt[x]
936 #include "tnl/t_vb_rendertmp.h"
940 /**********************************************************************/
941 /* Choose render functions */
942 /**********************************************************************/
944 void r200ChooseRenderState( GLcontext
*ctx
)
946 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
947 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
949 GLuint flags
= ctx
->_TriangleCaps
;
951 if (!rmesa
->TclFallback
|| rmesa
->Fallback
)
954 if (flags
& DD_TRI_LIGHT_TWOSIDE
) index
|= R200_TWOSIDE_BIT
;
955 if (flags
& DD_TRI_UNFILLED
) index
|= R200_UNFILLED_BIT
;
957 if (index
!= rmesa
->swtcl
.RenderIndex
) {
958 tnl
->Driver
.Render
.Points
= rast_tab
[index
].points
;
959 tnl
->Driver
.Render
.Line
= rast_tab
[index
].line
;
960 tnl
->Driver
.Render
.ClippedLine
= rast_tab
[index
].line
;
961 tnl
->Driver
.Render
.Triangle
= rast_tab
[index
].triangle
;
962 tnl
->Driver
.Render
.Quad
= rast_tab
[index
].quad
;
965 tnl
->Driver
.Render
.PrimTabVerts
= r200_render_tab_verts
;
966 tnl
->Driver
.Render
.PrimTabElts
= r200_render_tab_elts
;
967 tnl
->Driver
.Render
.ClippedPolygon
= r200_fast_clipped_poly
;
969 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
970 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
971 tnl
->Driver
.Render
.ClippedPolygon
= _tnl_RenderClippedPolygon
;
974 rmesa
->swtcl
.RenderIndex
= index
;
979 /**********************************************************************/
980 /* High level hooks for t_vb_render.c */
981 /**********************************************************************/
984 static void r200RasterPrimitive( GLcontext
*ctx
, GLuint hwprim
)
986 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
988 if (rmesa
->swtcl
.hw_primitive
!= hwprim
) {
989 R200_NEWPRIM( rmesa
);
990 rmesa
->swtcl
.hw_primitive
= hwprim
;
994 static void r200RenderPrimitive( GLcontext
*ctx
, GLenum prim
)
996 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
997 rmesa
->swtcl
.render_primitive
= prim
;
998 if (prim
< GL_TRIANGLES
|| !(ctx
->_TriangleCaps
& DD_TRI_UNFILLED
))
999 r200RasterPrimitive( ctx
, reduced_hw_prim
[prim
] );
1002 static void r200RenderFinish( GLcontext
*ctx
)
1006 static void r200ResetLineStipple( GLcontext
*ctx
)
1008 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1009 R200_STATECHANGE( rmesa
, lin
);
1013 /**********************************************************************/
1014 /* Transition to/from hardware rasterization. */
1015 /**********************************************************************/
1017 static const char * const fallbackStrings
[] = {
1019 "glDrawBuffer(GL_FRONT_AND_BACK)",
1020 "glEnable(GL_STENCIL) without hw stencil buffer",
1021 "glRenderMode(selection or feedback)",
1023 "glBlendFunc(mode != ADD)",
1025 "Mixing GL_CLAMP_TO_BORDER and GL_CLAMP (or GL_MIRROR_CLAMP_ATI)"
1029 static const char *getFallbackString(GLuint bit
)
1036 return fallbackStrings
[i
];
1040 void r200Fallback( GLcontext
*ctx
, GLuint bit
, GLboolean mode
)
1042 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1043 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
1044 GLuint oldfallback
= rmesa
->Fallback
;
1047 rmesa
->Fallback
|= bit
;
1048 if (oldfallback
== 0) {
1049 R200_FIREVERTICES( rmesa
);
1050 TCL_FALLBACK( ctx
, R200_TCL_FALLBACK_RASTER
, GL_TRUE
);
1051 _swsetup_Wakeup( ctx
);
1052 _tnl_need_projected_coords( ctx
, GL_TRUE
);
1053 rmesa
->swtcl
.RenderIndex
= ~0;
1054 if (R200_DEBUG
& DEBUG_FALLBACKS
) {
1055 fprintf(stderr
, "R200 begin rasterization fallback: 0x%x %s\n",
1056 bit
, getFallbackString(bit
));
1061 rmesa
->Fallback
&= ~bit
;
1062 if (oldfallback
== bit
) {
1063 _swrast_flush( ctx
);
1064 tnl
->Driver
.Render
.Start
= r200RenderStart
;
1065 tnl
->Driver
.Render
.PrimitiveNotify
= r200RenderPrimitive
;
1066 tnl
->Driver
.Render
.Finish
= r200RenderFinish
;
1067 tnl
->Driver
.Render
.BuildVertices
= r200BuildVertices
;
1068 tnl
->Driver
.Render
.ResetLineStipple
= r200ResetLineStipple
;
1069 TCL_FALLBACK( ctx
, R200_TCL_FALLBACK_RASTER
, GL_FALSE
);
1070 if (rmesa
->TclFallback
) {
1071 /* These are already done if rmesa->TclFallback goes to
1072 * zero above. But not if it doesn't (R200_NO_TCL for
1075 r200ChooseVertexState( ctx
);
1076 r200ChooseRenderState( ctx
);
1078 if (R200_DEBUG
& DEBUG_FALLBACKS
) {
1079 fprintf(stderr
, "R200 end rasterization fallback: 0x%x %s\n",
1080 bit
, getFallbackString(bit
));
1089 /* Cope with depth operations by drawing individual pixels as points???
1092 r200PointsBitmap( GLcontext
*ctx
, GLint px
, GLint py
,
1093 GLsizei width
, GLsizei height
,
1094 const struct gl_pixelstore_attrib
*unpack
,
1095 const GLubyte
*bitmap
)
1097 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1098 const GLfloat
*rc
= ctx
->Current
.RasterColor
;
1107 TCL_FALLBACK( ctx
, R200_TCL_FALLBACK_BITMAP
, 1 );
1109 /* Choose tiny vertex format
1111 r200SetVertexFormat( ctx
, R200_XYZW_BIT
| R200_RGBA_BIT
);
1113 /* Ready for point primitives:
1115 r200RenderPrimitive( ctx
, GL_POINTS
);
1117 /* Turn off the hw viewport transformation:
1119 R200_STATECHANGE( rmesa
, vte
);
1120 orig_vte
= rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
];
1121 rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
] &= ~(R200_VPORT_X_SCALE_ENA
|
1122 R200_VPORT_Y_SCALE_ENA
|
1123 R200_VPORT_Z_SCALE_ENA
|
1124 R200_VPORT_X_OFFSET_ENA
|
1125 R200_VPORT_Y_OFFSET_ENA
|
1126 R200_VPORT_Z_OFFSET_ENA
);
1128 /* Turn off other stuff: Stipple?, texture?, blending?, etc.
1132 /* Populate the vertex
1134 * Incorporate FOG into RGBA
1136 if (ctx
->Fog
.Enabled
) {
1137 const GLfloat
*fc
= ctx
->Fog
.Color
;
1141 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
1142 f
= _swrast_z_to_fogfactor(ctx
, ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0]);
1144 f
= _swrast_z_to_fogfactor(ctx
, ctx
->Current
.RasterDistance
);
1146 color
[0] = f
* rc
[0] + (1.F
- f
) * fc
[0];
1147 color
[1] = f
* rc
[1] + (1.F
- f
) * fc
[1];
1148 color
[2] = f
* rc
[2] + (1.F
- f
) * fc
[2];
1151 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.red
, color
[0]);
1152 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.green
, color
[1]);
1153 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.blue
, color
[2]);
1154 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.alpha
, color
[3]);
1157 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.red
, rc
[0]);
1158 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.green
, rc
[1]);
1159 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.blue
, rc
[2]);
1160 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.alpha
, rc
[3]);
1164 vert
.tv
.z
= ctx
->Current
.RasterPos
[2];
1167 /* Update window height
1169 LOCK_HARDWARE( rmesa
);
1170 UNLOCK_HARDWARE( rmesa
);
1171 h
= rmesa
->dri
.drawable
->h
+ rmesa
->dri
.drawable
->y
;
1172 px
+= rmesa
->dri
.drawable
->x
;
1174 /* Clipping handled by existing mechansims in r200_ioctl.c?
1176 for (row
=0; row
<height
; row
++) {
1177 const GLubyte
*src
= (const GLubyte
*)
1178 _mesa_image_address( unpack
, bitmap
, width
, height
,
1179 GL_COLOR_INDEX
, GL_BITMAP
, 0, row
, 0 );
1181 if (unpack
->LsbFirst
) {
1183 GLubyte mask
= 1U << (unpack
->SkipPixels
& 0x7);
1184 for (col
=0; col
<width
; col
++) {
1187 vert
.tv
.y
= h
- (py
+row
) - 1;
1188 r200_point( rmesa
, &vert
);
1191 mask
= ((mask
<< 1) & 0xff) | (mask
>> 7);
1194 /* get ready for next row */
1200 GLubyte mask
= 128U >> (unpack
->SkipPixels
& 0x7);
1201 for (col
=0; col
<width
; col
++) {
1204 vert
.tv
.y
= h
- (py
+row
) - 1;
1205 r200_point( rmesa
, &vert
);
1208 mask
= ((mask
<< 7) & 0xff) | (mask
>> 1);
1210 /* get ready for next row */
1216 /* Fire outstanding vertices, restore state
1218 R200_STATECHANGE( rmesa
, vte
);
1219 rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
] = orig_vte
;
1223 TCL_FALLBACK( ctx
, R200_TCL_FALLBACK_BITMAP
, 0 );
1225 /* Need to restore vertexformat?
1227 if (rmesa
->TclFallback
)
1228 r200ChooseVertexState( ctx
);
1232 void r200FlushVertices( GLcontext
*ctx
, GLuint flags
)
1234 _tnl_flush_vertices( ctx
, flags
);
1236 if (flags
& FLUSH_STORED_VERTICES
)
1237 R200_NEWPRIM( R200_CONTEXT( ctx
) );
1240 /**********************************************************************/
1241 /* Initialization. */
1242 /**********************************************************************/
1244 void r200InitSwtcl( GLcontext
*ctx
)
1246 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
1247 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1248 GLuint size
= TNL_CONTEXT(ctx
)->vb
.Size
;
1249 static int firsttime
= 1;
1257 tnl
->Driver
.Render
.Start
= r200RenderStart
;
1258 tnl
->Driver
.Render
.Finish
= r200RenderFinish
;
1259 tnl
->Driver
.Render
.PrimitiveNotify
= r200RenderPrimitive
;
1260 tnl
->Driver
.Render
.ResetLineStipple
= r200ResetLineStipple
;
1261 tnl
->Driver
.Render
.BuildVertices
= r200BuildVertices
;
1263 rmesa
->swtcl
.verts
= (GLubyte
*)ALIGN_MALLOC( size
* 16 * 4, 32 );
1264 rmesa
->swtcl
.RenderIndex
= ~0;
1265 rmesa
->swtcl
.render_primitive
= GL_TRIANGLES
;
1266 rmesa
->swtcl
.hw_primitive
= 0;
1270 void r200DestroySwtcl( GLcontext
*ctx
)
1272 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1274 if (rmesa
->swtcl
.indexed_verts
.buf
)
1275 r200ReleaseDmaRegion( rmesa
, &rmesa
->swtcl
.indexed_verts
, __FUNCTION__
);
1277 if (rmesa
->swtcl
.verts
) {
1278 ALIGN_FREE(rmesa
->swtcl
.verts
);
1279 rmesa
->swtcl
.verts
= 0;
1282 if (rmesa
->UbyteSecondaryColor
.Ptr
) {
1283 ALIGN_FREE(rmesa
->UbyteSecondaryColor
.Ptr
);
1284 rmesa
->UbyteSecondaryColor
.Ptr
= 0;
1287 if (rmesa
->UbyteColor
.Ptr
) {
1288 ALIGN_FREE(rmesa
->UbyteColor
.Ptr
);
1289 rmesa
->UbyteColor
.Ptr
= 0;