1 /* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c,v 1.5 2003/05/06 23:52:08 daenzer Exp $ */
3 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
5 The Weather Channel (TM) funded Tungsten Graphics to develop the
6 initial release of the Radeon 8500 driver under the XFree86 license.
7 This notice must be preserved.
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial
19 portions of the Software.
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
25 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 **************************************************************************/
33 * Keith Whitwell <keith@tungstengraphics.com>
44 #include "swrast/s_context.h"
45 #include "swrast/s_fog.h"
46 #include "swrast_setup/swrast_setup.h"
47 #include "math/m_translate.h"
49 #include "tnl/t_context.h"
50 #include "tnl/t_imm_exec.h"
51 #include "tnl/t_pipeline.h"
53 #include "r200_context.h"
54 #include "r200_ioctl.h"
55 #include "r200_state.h"
56 #include "r200_swtcl.h"
59 /***********************************************************************
60 * Build render functions from dd templates *
61 ***********************************************************************/
64 #define R200_XYZW_BIT 0x01
65 #define R200_RGBA_BIT 0x02
66 #define R200_SPEC_BIT 0x04
67 #define R200_TEX0_BIT 0x08
68 #define R200_TEX1_BIT 0x10
69 #define R200_PTEX_BIT 0x20
70 #define R200_MAX_SETUP 0x40
72 static void flush_last_swtcl_prim( r200ContextPtr rmesa
);
75 void (*emit
)( GLcontext
*, GLuint
, GLuint
, void *, GLuint
);
78 GLboolean (*check_tex_sizes
)( GLcontext
*ctx
);
80 GLuint vertex_stride_shift
;
82 } setup_tab
[R200_MAX_SETUP
];
85 static int se_vtx_fmt_0
[] = {
90 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
)),
95 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
) |
96 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_1_SHIFT
)),
101 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
) |
102 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_1_SHIFT
)),
107 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
) |
108 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_1_SHIFT
)),
113 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_0_SHIFT
) |
114 (R200_VTX_PK_RGBA
<< R200_VTX_COLOR_1_SHIFT
))
117 static int se_vtx_fmt_1
[] = {
121 ((2 << R200_VTX_TEX0_COMP_CNT_SHIFT
)),
122 ((2 << R200_VTX_TEX0_COMP_CNT_SHIFT
) |
123 (2 << R200_VTX_TEX1_COMP_CNT_SHIFT
)),
124 ((3 << R200_VTX_TEX0_COMP_CNT_SHIFT
) |
125 (3 << R200_VTX_TEX1_COMP_CNT_SHIFT
)),
128 #define TINY_VERTEX_FORMAT 1
129 #define NOTEX_VERTEX_FORMAT 2
130 #define TEX0_VERTEX_FORMAT 3
131 #define TEX1_VERTEX_FORMAT 4
132 #define PROJ_TEX1_VERTEX_FORMAT 5
133 #define TEX2_VERTEX_FORMAT 0
134 #define TEX3_VERTEX_FORMAT 0
135 #define PROJ_TEX3_VERTEX_FORMAT 0
137 #define DO_XYZW (IND & R200_XYZW_BIT)
138 #define DO_RGBA (IND & R200_RGBA_BIT)
139 #define DO_SPEC (IND & R200_SPEC_BIT)
140 #define DO_FOG (IND & R200_SPEC_BIT)
141 #define DO_TEX0 (IND & R200_TEX0_BIT)
142 #define DO_TEX1 (IND & R200_TEX1_BIT)
145 #define DO_PTEX (IND & R200_PTEX_BIT)
147 #define VERTEX r200Vertex
148 #define VERTEX_COLOR r200_color_t
149 #define GET_VIEWPORT_MAT() 0
150 #define GET_TEXSOURCE(n) n
151 #define GET_VERTEX_FORMAT() R200_CONTEXT(ctx)->swtcl.vertex_format
152 #define GET_VERTEX_STORE() R200_CONTEXT(ctx)->swtcl.verts
153 #define GET_VERTEX_STRIDE_SHIFT() R200_CONTEXT(ctx)->swtcl.vertex_stride_shift
154 #define GET_UBYTE_COLOR_STORE() &R200_CONTEXT(ctx)->UbyteColor
155 #define GET_UBYTE_SPEC_COLOR_STORE() &R200_CONTEXT(ctx)->UbyteSecondaryColor
157 #define HAVE_HW_VIEWPORT 1
158 #define HAVE_HW_DIVIDE (IND & ~(R200_XYZW_BIT|R200_RGBA_BIT))
159 #define HAVE_TINY_VERTICES 1
160 #define HAVE_RGBA_COLOR 1
161 #define HAVE_NOTEX_VERTICES 1
162 #define HAVE_TEX0_VERTICES 1
163 #define HAVE_TEX1_VERTICES 1
164 #define HAVE_TEX2_VERTICES 0
165 #define HAVE_TEX3_VERTICES 0
166 #define HAVE_PTEX_VERTICES 1
168 #define CHECK_HW_DIVIDE (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE| \
171 #define IMPORT_QUALIFIER
172 #define IMPORT_FLOAT_COLORS r200_import_float_colors
173 #define IMPORT_FLOAT_SPEC_COLORS r200_import_float_spec_colors
175 #define INTERP_VERTEX setup_tab[R200_CONTEXT(ctx)->swtcl.SetupIndex].interp
176 #define COPY_PV_VERTEX setup_tab[R200_CONTEXT(ctx)->swtcl.SetupIndex].copy_pv
179 /***********************************************************************
180 * Generate pv-copying and translation functions *
181 ***********************************************************************/
183 #define TAG(x) r200_##x
185 #include "tnl_dd/t_dd_vb.c"
189 /***********************************************************************
190 * Generate vertex emit and interp functions *
191 ***********************************************************************/
193 #define IND (R200_XYZW_BIT|R200_RGBA_BIT)
194 #define TAG(x) x##_wg
195 #include "tnl_dd/t_dd_vbtmp.h"
197 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_TEX0_BIT)
198 #define TAG(x) x##_wgt0
199 #include "tnl_dd/t_dd_vbtmp.h"
201 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_TEX0_BIT|R200_PTEX_BIT)
202 #define TAG(x) x##_wgpt0
203 #include "tnl_dd/t_dd_vbtmp.h"
205 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_TEX0_BIT|R200_TEX1_BIT)
206 #define TAG(x) x##_wgt0t1
207 #include "tnl_dd/t_dd_vbtmp.h"
209 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_TEX0_BIT|R200_TEX1_BIT|\
211 #define TAG(x) x##_wgpt0t1
212 #include "tnl_dd/t_dd_vbtmp.h"
214 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT)
215 #define TAG(x) x##_wgfs
216 #include "tnl_dd/t_dd_vbtmp.h"
218 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT|\
220 #define TAG(x) x##_wgfst0
221 #include "tnl_dd/t_dd_vbtmp.h"
223 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT|\
224 R200_TEX0_BIT|R200_PTEX_BIT)
225 #define TAG(x) x##_wgfspt0
226 #include "tnl_dd/t_dd_vbtmp.h"
228 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT|\
229 R200_TEX0_BIT|R200_TEX1_BIT)
230 #define TAG(x) x##_wgfst0t1
231 #include "tnl_dd/t_dd_vbtmp.h"
233 #define IND (R200_XYZW_BIT|R200_RGBA_BIT|R200_SPEC_BIT|\
234 R200_TEX0_BIT|R200_TEX1_BIT|R200_PTEX_BIT)
235 #define TAG(x) x##_wgfspt0t1
236 #include "tnl_dd/t_dd_vbtmp.h"
239 /***********************************************************************
241 ***********************************************************************/
243 static void init_setup_tab( void )
259 void r200PrintSetupFlags(char *msg
, GLuint flags
)
261 fprintf(stderr
, "%s(%x): %s%s%s%s%s%s\n",
264 (flags
& R200_XYZW_BIT
) ? " xyzw," : "",
265 (flags
& R200_RGBA_BIT
) ? " rgba," : "",
266 (flags
& R200_SPEC_BIT
) ? " spec/fog," : "",
267 (flags
& R200_TEX0_BIT
) ? " tex-0," : "",
268 (flags
& R200_TEX1_BIT
) ? " tex-1," : "",
269 (flags
& R200_PTEX_BIT
) ? " proj-tex," : "");
274 static void r200SetVertexFormat( GLcontext
*ctx
, GLuint ind
)
276 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
277 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
279 rmesa
->swtcl
.SetupIndex
= ind
;
281 if (ctx
->_TriangleCaps
& (DD_TRI_LIGHT_TWOSIDE
|DD_TRI_UNFILLED
)) {
282 tnl
->Driver
.Render
.Interp
= r200_interp_extras
;
283 tnl
->Driver
.Render
.CopyPV
= r200_copy_pv_extras
;
286 tnl
->Driver
.Render
.Interp
= setup_tab
[ind
].interp
;
287 tnl
->Driver
.Render
.CopyPV
= setup_tab
[ind
].copy_pv
;
290 if (setup_tab
[ind
].vertex_format
!= rmesa
->swtcl
.vertex_format
) {
293 i
= rmesa
->swtcl
.vertex_format
= setup_tab
[ind
].vertex_format
;
294 rmesa
->swtcl
.vertex_size
= setup_tab
[ind
].vertex_size
;
295 rmesa
->swtcl
.vertex_stride_shift
= setup_tab
[ind
].vertex_stride_shift
;
297 R200_STATECHANGE( rmesa
, vtx
);
298 rmesa
->hw
.vtx
.cmd
[VTX_VTXFMT_0
] = se_vtx_fmt_0
[i
];
299 rmesa
->hw
.vtx
.cmd
[VTX_VTXFMT_1
] = se_vtx_fmt_1
[i
];
303 GLuint vte
= rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
];
304 GLuint vap
= rmesa
->hw
.vap
.cmd
[VAP_SE_VAP_CNTL
];
307 /* HW perspective divide is a win, but tiny vertex formats are a
310 if (setup_tab
[ind
].vertex_format
== TINY_VERTEX_FORMAT
||
311 (ctx
->_TriangleCaps
& (DD_TRI_LIGHT_TWOSIDE
|DD_TRI_UNFILLED
))) {
313 vte
|= R200_VTX_XY_FMT
| R200_VTX_Z_FMT
;
314 vte
&= ~R200_VTX_W0_FMT
;
315 vap
|= R200_VAP_FORCE_W_TO_ONE
;
319 vte
&= ~(R200_VTX_XY_FMT
| R200_VTX_Z_FMT
);
320 vte
|= R200_VTX_W0_FMT
;
321 vap
&= ~R200_VAP_FORCE_W_TO_ONE
;
324 _tnl_need_projected_coords( ctx
, needproj
);
325 if (vte
!= rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
]) {
326 R200_STATECHANGE( rmesa
, vte
);
327 rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
] = vte
;
329 if (vap
!= rmesa
->hw
.vap
.cmd
[VAP_SE_VAP_CNTL
]) {
330 R200_STATECHANGE( rmesa
, vap
);
331 rmesa
->hw
.vap
.cmd
[VAP_SE_VAP_CNTL
] = vap
;
336 static void r200RenderStart( GLcontext
*ctx
)
338 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
340 if (!setup_tab
[rmesa
->swtcl
.SetupIndex
].check_tex_sizes(ctx
)) {
341 r200SetVertexFormat( ctx
, rmesa
->swtcl
.SetupIndex
| R200_PTEX_BIT
);
344 if (rmesa
->dma
.flush
!= 0 &&
345 rmesa
->dma
.flush
!= flush_last_swtcl_prim
)
346 rmesa
->dma
.flush( rmesa
);
350 void r200BuildVertices( GLcontext
*ctx
, GLuint start
, GLuint count
,
353 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
354 GLubyte
*v
= ((GLubyte
*)rmesa
->swtcl
.verts
+
355 (start
<< rmesa
->swtcl
.vertex_stride_shift
));
356 GLuint stride
= 1 << rmesa
->swtcl
.vertex_stride_shift
;
358 newinputs
|= rmesa
->swtcl
.SetupNewInputs
;
359 rmesa
->swtcl
.SetupNewInputs
= 0;
364 setup_tab
[rmesa
->swtcl
.SetupIndex
].emit( ctx
, start
, count
, v
, stride
);
368 void r200ChooseVertexState( GLcontext
*ctx
)
370 r200ContextPtr rmesa
= R200_CONTEXT( ctx
);
371 GLuint ind
= (R200_XYZW_BIT
| R200_RGBA_BIT
);
373 if (!rmesa
->TclFallback
|| rmesa
->Fallback
)
376 if (ctx
->Fog
.Enabled
|| (ctx
->_TriangleCaps
& DD_SEPARATE_SPECULAR
))
377 ind
|= R200_SPEC_BIT
;
379 if (ctx
->Texture
._EnabledUnits
& 0x2) /* unit 1 enabled */
380 ind
|= R200_TEX0_BIT
|R200_TEX1_BIT
;
381 else if (ctx
->Texture
._EnabledUnits
& 0x1) /* unit 1 enabled */
382 ind
|= R200_TEX0_BIT
;
384 r200SetVertexFormat( ctx
, ind
);
388 /* Flush vertices in the current dma region.
390 static void flush_last_swtcl_prim( r200ContextPtr rmesa
)
392 if (R200_DEBUG
& DEBUG_IOCTL
)
393 fprintf(stderr
, "%s\n", __FUNCTION__
);
395 rmesa
->dma
.flush
= 0;
397 if (rmesa
->dma
.current
.buf
) {
398 struct r200_dma_region
*current
= &rmesa
->dma
.current
;
399 GLuint current_offset
= (rmesa
->r200Screen
->gart_buffer_offset
+
400 current
->buf
->buf
->idx
* RADEON_BUFFER_SIZE
+
403 assert (!(rmesa
->swtcl
.hw_primitive
& R200_VF_PRIM_WALK_IND
));
405 assert (current
->start
+
406 rmesa
->swtcl
.numverts
* rmesa
->swtcl
.vertex_size
* 4 ==
409 if (rmesa
->dma
.current
.start
!= rmesa
->dma
.current
.ptr
) {
410 r200EmitVertexAOS( rmesa
,
411 rmesa
->swtcl
.vertex_size
,
414 r200EmitVbufPrim( rmesa
,
415 rmesa
->swtcl
.hw_primitive
,
416 rmesa
->swtcl
.numverts
);
419 rmesa
->swtcl
.numverts
= 0;
420 current
->start
= current
->ptr
;
425 /* Alloc space in the current dma region.
427 static __inline
void *r200AllocDmaLowVerts( r200ContextPtr rmesa
,
428 int nverts
, int vsize
)
430 GLuint bytes
= vsize
* nverts
;
432 if ( rmesa
->dma
.current
.ptr
+ bytes
> rmesa
->dma
.current
.end
)
433 r200RefillCurrentDmaRegion( rmesa
);
435 if (!rmesa
->dma
.flush
) {
436 rmesa
->glCtx
->Driver
.NeedFlush
|= FLUSH_STORED_VERTICES
;
437 rmesa
->dma
.flush
= flush_last_swtcl_prim
;
440 ASSERT( vsize
== rmesa
->swtcl
.vertex_size
* 4 );
441 ASSERT( rmesa
->dma
.flush
== flush_last_swtcl_prim
);
442 ASSERT( rmesa
->dma
.current
.start
+
443 rmesa
->swtcl
.numverts
* rmesa
->swtcl
.vertex_size
* 4 ==
444 rmesa
->dma
.current
.ptr
);
448 GLubyte
*head
= (GLubyte
*) (rmesa
->dma
.current
.address
+ rmesa
->dma
.current
.ptr
);
449 rmesa
->dma
.current
.ptr
+= bytes
;
450 rmesa
->swtcl
.numverts
+= nverts
;
459 void r200_emit_contiguous_verts( GLcontext
*ctx
, GLuint start
, GLuint count
)
461 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
462 GLuint vertex_size
= rmesa
->swtcl
.vertex_size
* 4;
463 CARD32
*dest
= r200AllocDmaLowVerts( rmesa
, count
-start
, vertex_size
);
464 setup_tab
[rmesa
->swtcl
.SetupIndex
].emit( ctx
, start
, count
, dest
,
470 void r200_emit_indexed_verts( GLcontext
*ctx
, GLuint start
, GLuint count
)
472 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
474 r200AllocDmaRegionVerts( rmesa
,
475 &rmesa
->swtcl
.indexed_verts
,
477 rmesa
->swtcl
.vertex_size
* 4,
480 setup_tab
[rmesa
->swtcl
.SetupIndex
].emit(
482 rmesa
->swtcl
.indexed_verts
.address
+ rmesa
->swtcl
.indexed_verts
.start
,
483 rmesa
->swtcl
.vertex_size
* 4 );
488 * Render unclipped vertex buffers by emitting vertices directly to
489 * dma buffers. Use strip/fan hardware primitives where possible.
490 * Try to simulate missing primitives with indexed vertices.
492 #define HAVE_POINTS 1
494 #define HAVE_LINE_STRIPS 1
495 #define HAVE_TRIANGLES 1
496 #define HAVE_TRI_STRIPS 1
497 #define HAVE_TRI_STRIP_1 0
498 #define HAVE_TRI_FANS 1
500 #define HAVE_QUAD_STRIPS 1
501 #define HAVE_POLYGONS 1
504 static const GLuint hw_prim
[GL_POLYGON
+1] = {
508 R200_VF_PRIM_LINE_STRIP
,
509 R200_VF_PRIM_TRIANGLES
,
510 R200_VF_PRIM_TRIANGLE_STRIP
,
511 R200_VF_PRIM_TRIANGLE_FAN
,
513 R200_VF_PRIM_QUAD_STRIP
,
517 static __inline
void r200DmaPrimitive( r200ContextPtr rmesa
, GLenum prim
)
519 R200_NEWPRIM( rmesa
);
520 rmesa
->swtcl
.hw_primitive
= hw_prim
[prim
];
521 assert(rmesa
->dma
.current
.ptr
== rmesa
->dma
.current
.start
);
524 static __inline
void r200EltPrimitive( r200ContextPtr rmesa
, GLenum prim
)
526 R200_NEWPRIM( rmesa
);
527 rmesa
->swtcl
.hw_primitive
= hw_prim
[prim
] | R200_VF_PRIM_WALK_IND
;
531 static void VERT_FALLBACK( GLcontext
*ctx
,
536 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
537 tnl
->Driver
.Render
.PrimitiveNotify( ctx
, flags
& PRIM_MODE_MASK
);
538 tnl
->Driver
.Render
.BuildVertices( ctx
, start
, count
, ~0 );
539 tnl
->Driver
.Render
.PrimTabVerts
[flags
&PRIM_MODE_MASK
]( ctx
, start
, count
, flags
);
540 R200_CONTEXT(ctx
)->swtcl
.SetupNewInputs
= VERT_BIT_CLIP
;
543 static void ELT_FALLBACK( GLcontext
*ctx
,
548 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
549 tnl
->Driver
.Render
.PrimitiveNotify( ctx
, flags
& PRIM_MODE_MASK
);
550 tnl
->Driver
.Render
.BuildVertices( ctx
, start
, count
, ~0 );
551 tnl
->Driver
.Render
.PrimTabElts
[flags
&PRIM_MODE_MASK
]( ctx
, start
, count
, flags
);
552 R200_CONTEXT(ctx
)->swtcl
.SetupNewInputs
= VERT_BIT_CLIP
;
556 #define LOCAL_VARS r200ContextPtr rmesa = R200_CONTEXT(ctx)
557 #define ELTS_VARS GLushort *dest
558 #define INIT( prim ) r200DmaPrimitive( rmesa, prim )
559 #define ELT_INIT(prim) r200EltPrimitive( rmesa, prim )
560 #define NEW_PRIMITIVE() R200_NEWPRIM( rmesa )
561 #define NEW_BUFFER() r200RefillCurrentDmaRegion( rmesa )
562 #define GET_CURRENT_VB_MAX_VERTS() \
563 (((int)rmesa->dma.current.end - (int)rmesa->dma.current.ptr) / (rmesa->swtcl.vertex_size*4))
564 #define GET_SUBSEQUENT_VB_MAX_VERTS() \
565 ((RADEON_BUFFER_SIZE) / (rmesa->swtcl.vertex_size*4))
567 #define GET_CURRENT_VB_MAX_ELTS() \
568 ((R200_CMD_BUF_SZ - (rmesa->store.cmd_used + 16)) / 2)
569 #define GET_SUBSEQUENT_VB_MAX_ELTS() \
570 ((R200_CMD_BUF_SZ - 1024) / 2)
574 /* How do you extend an existing primitive?
576 #define ALLOC_ELTS(nr) \
578 if (rmesa->dma.flush == r200FlushElts && \
579 rmesa->store.cmd_used + nr*2 < R200_CMD_BUF_SZ) { \
581 dest = (GLushort *)(rmesa->store.cmd_buf + \
582 rmesa->store.cmd_used); \
583 rmesa->store.cmd_used += nr*2; \
586 if (rmesa->dma.flush) { \
587 rmesa->dma.flush( rmesa ); \
590 r200EmitVertexAOS( rmesa, \
591 rmesa->swtcl.vertex_size, \
592 (rmesa->r200Screen->gart_buffer_offset + \
593 rmesa->swtcl.indexed_verts.buf->buf->idx * \
594 RADEON_BUFFER_SIZE + \
595 rmesa->swtcl.indexed_verts.start)); \
597 dest = r200AllocEltsOpenEnded( rmesa, \
598 rmesa->swtcl.hw_primitive, \
603 #define ALLOC_ELTS_NEW_PRIMITIVE(nr) ALLOC_ELTS( nr )
605 #ifdef MESA_BIG_ENDIAN
606 /* We could do without (most of) this ugliness if dest was always 32 bit word aligned... */
607 #define EMIT_ELT(offset, x) do { \
608 int off = offset + ( ( (GLuint)dest & 0x2 ) >> 1 ); \
609 GLushort *des = (GLushort *)( (GLuint)dest & ~0x2 ); \
610 (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); } while (0)
612 #define EMIT_ELT(offset, x) (dest)[offset] = (GLushort) (x)
614 #define EMIT_TWO_ELTS(offset, x, y) *(GLuint *)(dest+offset) = ((y)<<16)|(x);
615 #define INCR_ELTS( nr ) dest += nr
616 #define RELEASE_ELT_VERTS() \
617 r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, __FUNCTION__ )
618 #define EMIT_VERTS( ctx, j, nr ) \
619 r200_emit_contiguous_verts(ctx, j, (j)+(nr))
620 #define EMIT_INDEXED_VERTS( ctx, start, count ) \
621 r200_emit_indexed_verts( ctx, start, count )
624 #define TAG(x) r200_dma_##x
625 #include "tnl_dd/t_dd_dmatmp.h"
628 /**********************************************************************/
629 /* Render pipeline stage */
630 /**********************************************************************/
633 static GLboolean
r200_run_render( GLcontext
*ctx
,
634 struct gl_pipeline_stage
*stage
)
636 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
637 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
638 struct vertex_buffer
*VB
= &tnl
->vb
;
639 GLuint i
, length
, flags
= 0;
640 render_func
*tab
= TAG(render_tab_verts
);
642 if (rmesa
->swtcl
.indexed_verts
.buf
&& (!VB
->Elts
|| stage
->changed_inputs
))
647 if ((R200_DEBUG
& DEBUG_VERTS
) || /* No debug */
648 VB
->ClipOrMask
|| /* No clipping */
649 rmesa
->swtcl
.RenderIndex
!= 0 || /* No per-vertex manipulations */
650 ctx
->Line
.StippleFlag
) /* No stipple -- fix me? */
654 tab
= TAG(render_tab_elts
);
655 if (!rmesa
->swtcl
.indexed_verts
.buf
)
656 if (!TAG(emit_elt_verts
)(ctx
, 0, VB
->Count
))
657 return GL_TRUE
; /* too many vertices */
660 tnl
->Driver
.Render
.Start( ctx
);
662 for (i
= 0 ; !(flags
& PRIM_LAST
) ; i
+= length
)
664 flags
= VB
->Primitive
[i
];
665 length
= VB
->PrimitiveLength
[i
];
667 if (R200_DEBUG
& DEBUG_PRIMS
)
668 fprintf(stderr
, "r200_render.c: prim %s %d..%d\n",
669 _mesa_lookup_enum_by_nr(flags
& PRIM_MODE_MASK
),
673 tab
[flags
& PRIM_MODE_MASK
]( ctx
, i
, i
+ length
, flags
);
676 tnl
->Driver
.Render
.Finish( ctx
);
678 return GL_FALSE
; /* finished the pipe */
683 static void r200_check_render( GLcontext
*ctx
,
684 struct gl_pipeline_stage
*stage
)
686 GLuint inputs
= VERT_BIT_POS
| VERT_BIT_CLIP
| VERT_BIT_COLOR0
;
688 if (ctx
->RenderMode
== GL_RENDER
) {
689 if (ctx
->_TriangleCaps
& DD_SEPARATE_SPECULAR
)
690 inputs
|= VERT_BIT_COLOR1
;
692 if (ctx
->Texture
.Unit
[0]._ReallyEnabled
)
693 inputs
|= VERT_BIT_TEX0
;
695 if (ctx
->Texture
.Unit
[1]._ReallyEnabled
)
696 inputs
|= VERT_BIT_TEX1
;
698 if (ctx
->Fog
.Enabled
)
699 inputs
|= VERT_BIT_FOG
;
702 stage
->inputs
= inputs
;
706 static void dtr( struct gl_pipeline_stage
*stage
)
712 const struct gl_pipeline_stage _r200_render_stage
=
715 (_DD_NEW_SEPARATE_SPECULAR
|
718 _NEW_RENDERMODE
), /* re-check (new inputs) */
719 0, /* re-run (always runs) */
720 GL_TRUE
, /* active */
721 0, 0, /* inputs (set in check_render), outputs */
722 0, 0, /* changed_inputs, private */
723 dtr
, /* destructor */
724 r200_check_render
, /* check - initially set to alloc data */
725 r200_run_render
/* run */
730 /**************************************************************************/
733 static const GLuint reduced_hw_prim
[GL_POLYGON
+1] = {
738 R200_VF_PRIM_TRIANGLES
,
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
746 static void r200RasterPrimitive( GLcontext
*ctx
, GLuint hwprim
);
747 static void r200RenderPrimitive( GLcontext
*ctx
, GLenum prim
);
748 static void r200ResetLineStipple( GLcontext
*ctx
);
753 #undef HAVE_QUAD_STRIPS
754 #define HAVE_QUAD_STRIPS 0
756 /***********************************************************************
757 * Emit primitives as inline vertices *
758 ***********************************************************************/
761 #define CTX_ARG r200ContextPtr rmesa
762 #define CTX_ARG2 rmesa
763 #define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size
764 #define ALLOC_VERTS( n, size ) r200AllocDmaLowVerts( rmesa, n, size * 4 )
766 r200ContextPtr rmesa = R200_CONTEXT(ctx); \
767 const GLuint shift = rmesa->swtcl.vertex_stride_shift; \
768 const char *r200verts = (char *)rmesa->swtcl.verts;
769 #define VERT(x) (r200Vertex *)(r200verts + (x << shift))
770 #define VERTEX r200Vertex
771 #define DO_DEBUG_VERTS (1 && (R200_DEBUG & DEBUG_VERTS))
772 #define PRINT_VERTEX(v) r200_print_vertex(rmesa->glCtx, v)
774 #define TAG(x) r200_##x
775 #include "tnl_dd/t_dd_triemit.h"
778 /***********************************************************************
779 * Macros for t_dd_tritmp.h to draw basic primitives *
780 ***********************************************************************/
782 #define QUAD( a, b, c, d ) r200_quad( rmesa, a, b, c, d )
783 #define TRI( a, b, c ) r200_triangle( rmesa, a, b, c )
784 #define LINE( a, b ) r200_line( rmesa, a, b )
785 #define POINT( a ) r200_point( rmesa, a )
787 /***********************************************************************
788 * Build render functions from dd templates *
789 ***********************************************************************/
791 #define R200_TWOSIDE_BIT 0x01
792 #define R200_UNFILLED_BIT 0x02
793 #define R200_MAX_TRIFUNC 0x04
799 triangle_func triangle
;
801 } rast_tab
[R200_MAX_TRIFUNC
];
804 #define DO_FALLBACK 0
805 #define DO_UNFILLED (IND & R200_UNFILLED_BIT)
806 #define DO_TWOSIDE (IND & R200_TWOSIDE_BIT)
813 #define DO_FULL_QUAD 1
818 #define HAVE_BACK_COLORS 0
819 #define HAVE_HW_FLATSHADE 1
822 #define DEPTH_SCALE 1.0
823 #define UNFILLED_TRI unfilled_tri
824 #define UNFILLED_QUAD unfilled_quad
825 #define VERT_X(_v) _v->v.x
826 #define VERT_Y(_v) _v->v.y
827 #define VERT_Z(_v) _v->v.z
828 #define AREA_IS_CCW( a ) (a < 0)
829 #define GET_VERTEX(e) (rmesa->swtcl.verts + (e<<rmesa->swtcl.vertex_stride_shift))
831 #define VERT_SET_RGBA( v, c ) v->ui[coloroffset] = LE32_TO_CPU(*(GLuint *)c)
832 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
833 #define VERT_SAVE_RGBA( idx ) color[idx] = CPU_TO_LE32(v[idx]->ui[coloroffset])
834 #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = LE32_TO_CPU(color[idx])
836 #define VERT_SET_SPEC( v0, c ) if (havespec) { \
837 v0->v.specular.red = (c)[0]; \
838 v0->v.specular.green = (c)[1]; \
839 v0->v.specular.blue = (c)[2]; }
840 #define VERT_COPY_SPEC( v0, v1 ) if (havespec) { \
841 v0->v.specular.red = v1->v.specular.red; \
842 v0->v.specular.green = v1->v.specular.green; \
843 v0->v.specular.blue = v1->v.specular.blue; }
844 #define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = CPU_TO_LE32(v[idx]->ui[5])
845 #define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = LE32_TO_CPU(spec[idx])
851 #define LOCAL_VARS(n) \
852 r200ContextPtr rmesa = R200_CONTEXT(ctx); \
853 GLuint color[n], spec[n]; \
854 GLuint coloroffset = (rmesa->swtcl.vertex_size == 4 ? 3 : 4); \
855 GLboolean havespec = (rmesa->swtcl.vertex_size > 4); \
856 (void) color; (void) spec; (void) coloroffset; (void) havespec;
858 /***********************************************************************
859 * Helpers for rendering unfilled primitives *
860 ***********************************************************************/
862 #define RASTERIZE(x) r200RasterPrimitive( ctx, reduced_hw_prim[x] )
863 #define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
866 #include "tnl_dd/t_dd_unfilled.h"
870 /***********************************************************************
871 * Generate GL render functions *
872 ***********************************************************************/
877 #include "tnl_dd/t_dd_tritmp.h"
879 #define IND (R200_TWOSIDE_BIT)
880 #define TAG(x) x##_twoside
881 #include "tnl_dd/t_dd_tritmp.h"
883 #define IND (R200_UNFILLED_BIT)
884 #define TAG(x) x##_unfilled
885 #include "tnl_dd/t_dd_tritmp.h"
887 #define IND (R200_TWOSIDE_BIT|R200_UNFILLED_BIT)
888 #define TAG(x) x##_twoside_unfilled
889 #include "tnl_dd/t_dd_tritmp.h"
892 static void init_rast_tab( void )
897 init_twoside_unfilled();
900 /**********************************************************************/
901 /* Render unclipped begin/end objects */
902 /**********************************************************************/
904 #define VERT(x) (r200Vertex *)(r200verts + (x << shift))
905 #define RENDER_POINTS( start, count ) \
906 for ( ; start < count ; start++) \
907 r200_point( rmesa, VERT(start) )
908 #define RENDER_LINE( v0, v1 ) \
909 r200_line( rmesa, VERT(v0), VERT(v1) )
910 #define RENDER_TRI( v0, v1, v2 ) \
911 r200_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
912 #define RENDER_QUAD( v0, v1, v2, v3 ) \
913 r200_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
914 #define INIT(x) do { \
915 r200RenderPrimitive( ctx, x ); \
919 r200ContextPtr rmesa = R200_CONTEXT(ctx); \
920 const GLuint shift = rmesa->swtcl.vertex_stride_shift; \
921 const char *r200verts = (char *)rmesa->swtcl.verts; \
922 const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
923 const GLboolean stipple = ctx->Line.StippleFlag; \
924 (void) elt; (void) stipple;
925 #define RESET_STIPPLE if ( stipple ) r200ResetLineStipple( ctx );
926 #define RESET_OCCLUSION
927 #define PRESERVE_VB_DEFS
929 #define TAG(x) r200_##x##_verts
930 #include "tnl/t_vb_rendertmp.h"
933 #define TAG(x) r200_##x##_elts
934 #define ELT(x) elt[x]
935 #include "tnl/t_vb_rendertmp.h"
939 /**********************************************************************/
940 /* Choose render functions */
941 /**********************************************************************/
943 void r200ChooseRenderState( GLcontext
*ctx
)
945 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
946 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
948 GLuint flags
= ctx
->_TriangleCaps
;
950 if (!rmesa
->TclFallback
|| rmesa
->Fallback
)
953 if (flags
& DD_TRI_LIGHT_TWOSIDE
) index
|= R200_TWOSIDE_BIT
;
954 if (flags
& DD_TRI_UNFILLED
) index
|= R200_UNFILLED_BIT
;
956 if (index
!= rmesa
->swtcl
.RenderIndex
) {
957 tnl
->Driver
.Render
.Points
= rast_tab
[index
].points
;
958 tnl
->Driver
.Render
.Line
= rast_tab
[index
].line
;
959 tnl
->Driver
.Render
.ClippedLine
= rast_tab
[index
].line
;
960 tnl
->Driver
.Render
.Triangle
= rast_tab
[index
].triangle
;
961 tnl
->Driver
.Render
.Quad
= rast_tab
[index
].quad
;
964 tnl
->Driver
.Render
.PrimTabVerts
= r200_render_tab_verts
;
965 tnl
->Driver
.Render
.PrimTabElts
= r200_render_tab_elts
;
966 tnl
->Driver
.Render
.ClippedPolygon
= r200_fast_clipped_poly
;
968 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
969 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
970 tnl
->Driver
.Render
.ClippedPolygon
= _tnl_RenderClippedPolygon
;
973 rmesa
->swtcl
.RenderIndex
= index
;
978 /**********************************************************************/
979 /* High level hooks for t_vb_render.c */
980 /**********************************************************************/
983 static void r200RasterPrimitive( GLcontext
*ctx
, GLuint hwprim
)
985 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
987 if (rmesa
->swtcl
.hw_primitive
!= hwprim
) {
988 R200_NEWPRIM( rmesa
);
989 rmesa
->swtcl
.hw_primitive
= hwprim
;
993 static void r200RenderPrimitive( GLcontext
*ctx
, GLenum prim
)
995 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
996 rmesa
->swtcl
.render_primitive
= prim
;
997 if (prim
< GL_TRIANGLES
|| !(ctx
->_TriangleCaps
& DD_TRI_UNFILLED
))
998 r200RasterPrimitive( ctx
, reduced_hw_prim
[prim
] );
1001 static void r200RenderFinish( GLcontext
*ctx
)
1005 static void r200ResetLineStipple( GLcontext
*ctx
)
1007 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1008 R200_STATECHANGE( rmesa
, lin
);
1012 /**********************************************************************/
1013 /* Transition to/from hardware rasterization. */
1014 /**********************************************************************/
1016 static const char * const fallbackStrings
[] = {
1018 "glDrawBuffer(GL_FRONT_AND_BACK)",
1019 "glEnable(GL_STENCIL) without hw stencil buffer",
1020 "glRenderMode(selection or feedback)",
1022 "glBlendFunc(mode != ADD)",
1024 "Mixing GL_CLAMP_TO_BORDER and GL_CLAMP (or GL_MIRROR_CLAMP_ATI)"
1028 static const char *getFallbackString(GLuint bit
)
1035 return fallbackStrings
[i
];
1039 void r200Fallback( GLcontext
*ctx
, GLuint bit
, GLboolean mode
)
1041 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1042 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
1043 GLuint oldfallback
= rmesa
->Fallback
;
1046 rmesa
->Fallback
|= bit
;
1047 if (oldfallback
== 0) {
1048 R200_FIREVERTICES( rmesa
);
1049 TCL_FALLBACK( ctx
, R200_TCL_FALLBACK_RASTER
, GL_TRUE
);
1050 _swsetup_Wakeup( ctx
);
1051 _tnl_need_projected_coords( ctx
, GL_TRUE
);
1052 rmesa
->swtcl
.RenderIndex
= ~0;
1053 if (R200_DEBUG
& DEBUG_FALLBACKS
) {
1054 fprintf(stderr
, "R200 begin rasterization fallback: 0x%x %s\n",
1055 bit
, getFallbackString(bit
));
1060 rmesa
->Fallback
&= ~bit
;
1061 if (oldfallback
== bit
) {
1062 _swrast_flush( ctx
);
1063 tnl
->Driver
.Render
.Start
= r200RenderStart
;
1064 tnl
->Driver
.Render
.PrimitiveNotify
= r200RenderPrimitive
;
1065 tnl
->Driver
.Render
.Finish
= r200RenderFinish
;
1066 tnl
->Driver
.Render
.BuildVertices
= r200BuildVertices
;
1067 tnl
->Driver
.Render
.ResetLineStipple
= r200ResetLineStipple
;
1068 TCL_FALLBACK( ctx
, R200_TCL_FALLBACK_RASTER
, GL_FALSE
);
1069 if (rmesa
->TclFallback
) {
1070 /* These are already done if rmesa->TclFallback goes to
1071 * zero above. But not if it doesn't (R200_NO_TCL for
1074 r200ChooseVertexState( ctx
);
1075 r200ChooseRenderState( ctx
);
1077 if (R200_DEBUG
& DEBUG_FALLBACKS
) {
1078 fprintf(stderr
, "R200 end rasterization fallback: 0x%x %s\n",
1079 bit
, getFallbackString(bit
));
1088 /* Cope with depth operations by drawing individual pixels as points???
1091 r200PointsBitmap( GLcontext
*ctx
, GLint px
, GLint py
,
1092 GLsizei width
, GLsizei height
,
1093 const struct gl_pixelstore_attrib
*unpack
,
1094 const GLubyte
*bitmap
)
1096 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1097 const GLfloat
*rc
= ctx
->Current
.RasterColor
;
1106 TCL_FALLBACK( ctx
, R200_TCL_FALLBACK_BITMAP
, 1 );
1108 /* Choose tiny vertex format
1110 r200SetVertexFormat( ctx
, R200_XYZW_BIT
| R200_RGBA_BIT
);
1112 /* Ready for point primitives:
1114 r200RenderPrimitive( ctx
, GL_POINTS
);
1116 /* Turn off the hw viewport transformation:
1118 R200_STATECHANGE( rmesa
, vte
);
1119 orig_vte
= rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
];
1120 rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
] &= ~(R200_VPORT_X_SCALE_ENA
|
1121 R200_VPORT_Y_SCALE_ENA
|
1122 R200_VPORT_Z_SCALE_ENA
|
1123 R200_VPORT_X_OFFSET_ENA
|
1124 R200_VPORT_Y_OFFSET_ENA
|
1125 R200_VPORT_Z_OFFSET_ENA
);
1127 /* Turn off other stuff: Stipple?, texture?, blending?, etc.
1131 /* Populate the vertex
1133 * Incorporate FOG into RGBA
1135 if (ctx
->Fog
.Enabled
) {
1136 const GLfloat
*fc
= ctx
->Fog
.Color
;
1140 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
1141 f
= _swrast_z_to_fogfactor(ctx
, ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0]);
1143 f
= _swrast_z_to_fogfactor(ctx
, ctx
->Current
.RasterDistance
);
1145 color
[0] = f
* rc
[0] + (1.F
- f
) * fc
[0];
1146 color
[1] = f
* rc
[1] + (1.F
- f
) * fc
[1];
1147 color
[2] = f
* rc
[2] + (1.F
- f
) * fc
[2];
1150 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.red
, color
[0]);
1151 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.green
, color
[1]);
1152 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.blue
, color
[2]);
1153 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.alpha
, color
[3]);
1156 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.red
, rc
[0]);
1157 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.green
, rc
[1]);
1158 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.blue
, rc
[2]);
1159 UNCLAMPED_FLOAT_TO_CHAN(vert
.tv
.color
.alpha
, rc
[3]);
1163 vert
.tv
.z
= ctx
->Current
.RasterPos
[2];
1166 /* Update window height
1168 LOCK_HARDWARE( rmesa
);
1169 UNLOCK_HARDWARE( rmesa
);
1170 h
= rmesa
->dri
.drawable
->h
+ rmesa
->dri
.drawable
->y
;
1171 px
+= rmesa
->dri
.drawable
->x
;
1173 /* Clipping handled by existing mechansims in r200_ioctl.c?
1175 for (row
=0; row
<height
; row
++) {
1176 const GLubyte
*src
= (const GLubyte
*)
1177 _mesa_image_address( unpack
, bitmap
, width
, height
,
1178 GL_COLOR_INDEX
, GL_BITMAP
, 0, row
, 0 );
1180 if (unpack
->LsbFirst
) {
1182 GLubyte mask
= 1U << (unpack
->SkipPixels
& 0x7);
1183 for (col
=0; col
<width
; col
++) {
1186 vert
.tv
.y
= h
- (py
+row
) - 1;
1187 r200_point( rmesa
, &vert
);
1190 mask
= ((mask
<< 1) & 0xff) | (mask
>> 7);
1193 /* get ready for next row */
1199 GLubyte mask
= 128U >> (unpack
->SkipPixels
& 0x7);
1200 for (col
=0; col
<width
; col
++) {
1203 vert
.tv
.y
= h
- (py
+row
) - 1;
1204 r200_point( rmesa
, &vert
);
1207 mask
= ((mask
<< 7) & 0xff) | (mask
>> 1);
1209 /* get ready for next row */
1215 /* Fire outstanding vertices, restore state
1217 R200_STATECHANGE( rmesa
, vte
);
1218 rmesa
->hw
.vte
.cmd
[VTE_SE_VTE_CNTL
] = orig_vte
;
1222 TCL_FALLBACK( ctx
, R200_TCL_FALLBACK_BITMAP
, 0 );
1224 /* Need to restore vertexformat?
1226 if (rmesa
->TclFallback
)
1227 r200ChooseVertexState( ctx
);
1231 void r200FlushVertices( GLcontext
*ctx
, GLuint flags
)
1233 _tnl_flush_vertices( ctx
, flags
);
1235 if (flags
& FLUSH_STORED_VERTICES
)
1236 R200_NEWPRIM( R200_CONTEXT( ctx
) );
1239 /**********************************************************************/
1240 /* Initialization. */
1241 /**********************************************************************/
1243 void r200InitSwtcl( GLcontext
*ctx
)
1245 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
1246 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1247 GLuint size
= TNL_CONTEXT(ctx
)->vb
.Size
;
1248 static int firsttime
= 1;
1256 tnl
->Driver
.Render
.Start
= r200RenderStart
;
1257 tnl
->Driver
.Render
.Finish
= r200RenderFinish
;
1258 tnl
->Driver
.Render
.PrimitiveNotify
= r200RenderPrimitive
;
1259 tnl
->Driver
.Render
.ResetLineStipple
= r200ResetLineStipple
;
1260 tnl
->Driver
.Render
.BuildVertices
= r200BuildVertices
;
1262 rmesa
->swtcl
.verts
= (GLubyte
*)ALIGN_MALLOC( size
* 16 * 4, 32 );
1263 rmesa
->swtcl
.RenderIndex
= ~0;
1264 rmesa
->swtcl
.render_primitive
= GL_TRIANGLES
;
1265 rmesa
->swtcl
.hw_primitive
= 0;
1269 void r200DestroySwtcl( GLcontext
*ctx
)
1271 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
1273 if (rmesa
->swtcl
.indexed_verts
.buf
)
1274 r200ReleaseDmaRegion( rmesa
, &rmesa
->swtcl
.indexed_verts
, __FUNCTION__
);
1276 if (rmesa
->swtcl
.verts
) {
1277 ALIGN_FREE(rmesa
->swtcl
.verts
);
1278 rmesa
->swtcl
.verts
= 0;
1281 if (rmesa
->UbyteSecondaryColor
.Ptr
) {
1282 ALIGN_FREE(rmesa
->UbyteSecondaryColor
.Ptr
);
1283 rmesa
->UbyteSecondaryColor
.Ptr
= 0;
1286 if (rmesa
->UbyteColor
.Ptr
) {
1287 ALIGN_FREE(rmesa
->UbyteColor
.Ptr
);
1288 rmesa
->UbyteColor
.Ptr
= 0;