1 /**************************************************************************
3 Copyright (C) 2007 Dave Airlie
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Dave Airlie <airlied@linux.ie>
33 /* derived from r200 swtcl path */
37 #include "main/glheader.h"
38 #include "main/mtypes.h"
39 #include "main/colormac.h"
40 #include "main/enums.h"
41 #include "main/image.h"
42 #include "main/imports.h"
43 #include "main/light.h"
44 #include "main/macros.h"
46 #include "swrast/s_context.h"
47 #include "swrast/s_fog.h"
48 #include "swrast_setup/swrast_setup.h"
49 #include "math/m_translate.h"
51 #include "tnl/t_context.h"
52 #include "tnl/t_pipeline.h"
54 #include "r300_context.h"
55 #include "r300_swtcl.h"
56 #include "r300_state.h"
57 #include "r300_ioctl.h"
58 #include "r300_emit.h"
61 void r300EmitVertexAOS(r300ContextPtr rmesa
, GLuint vertex_size
, struct radeon_bo
*bo
, GLuint offset
);
62 void r300EmitVbufPrim(r300ContextPtr rmesa
, GLuint primitive
, GLuint vertex_nr
);
63 #define EMIT_ATTR( ATTR, STYLE ) \
65 rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].attrib = (ATTR); \
66 rmesa->radeon.swtcl.vertex_attrs[rmesa->radeon.swtcl.vertex_attr_count].format = (STYLE); \
67 rmesa->radeon.swtcl.vertex_attr_count++; \
70 #define EMIT_PAD( N ) \
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++; \
78 static void r300SetVertexFormat( GLcontext
*ctx
)
80 r300ContextPtr rmesa
= R300_CONTEXT( ctx
);
81 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
82 struct vertex_buffer
*VB
= &tnl
->vb
;
83 DECLARE_RENDERINPUTS(index_bitset
);
84 GLuint InputsRead
= 0, OutputsWritten
= 0;
88 GLint inputs
[VERT_ATTRIB_MAX
];
89 GLint tab
[VERT_ATTRIB_MAX
];
90 int swizzle
[VERT_ATTRIB_MAX
][4];
92 GLuint sz
, vap_fmt_1
= 0;
94 DECLARE_RENDERINPUTS(render_inputs_bitset
);
95 RENDERINPUTS_COPY(render_inputs_bitset
, tnl
->render_inputs_bitset
);
96 RENDERINPUTS_COPY( index_bitset
, tnl
->render_inputs_bitset
);
97 RENDERINPUTS_COPY(rmesa
->state
.render_inputs_bitset
, render_inputs_bitset
);
99 vte
= rmesa
->hw
.vte
.cmd
[1];
100 vte
&= ~(R300_VTX_XY_FMT
| R300_VTX_Z_FMT
| R300_VTX_W0_FMT
);
103 if ( VB
->NdcPtr
!= NULL
) {
104 VB
->AttribPtr
[VERT_ATTRIB_POS
] = VB
->NdcPtr
;
105 vte
|= R300_VTX_XY_FMT
| R300_VTX_Z_FMT
;
108 VB
->AttribPtr
[VERT_ATTRIB_POS
] = VB
->ClipPtr
;
109 vte
|= R300_VTX_W0_FMT
;
112 assert( VB
->AttribPtr
[VERT_ATTRIB_POS
] != NULL
);
113 rmesa
->radeon
.swtcl
.vertex_attr_count
= 0;
115 /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
116 * build up a hardware vertex.
118 if (RENDERINPUTS_TEST( index_bitset
, _TNL_ATTRIB_POS
)) {
119 sz
= VB
->AttribPtr
[VERT_ATTRIB_POS
]->size
;
120 InputsRead
|= 1 << VERT_ATTRIB_POS
;
121 OutputsWritten
|= 1 << VERT_RESULT_HPOS
;
122 EMIT_ATTR( _TNL_ATTRIB_POS
, EMIT_1F
+ sz
- 1 );
126 EMIT_PAD(4 * sizeof(float));
129 if (RENDERINPUTS_TEST( index_bitset
, _TNL_ATTRIB_POINTSIZE
)) {
130 EMIT_ATTR( _TNL_ATTRIB_POINTSIZE
, EMIT_1F
);
131 vap_fmt_0
|= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT
;
135 if (RENDERINPUTS_TEST(index_bitset
, _TNL_ATTRIB_COLOR0
)) {
136 sz
= VB
->AttribPtr
[VERT_ATTRIB_COLOR0
]->size
;
137 rmesa
->swtcl
.coloroffset
= offset
;
138 InputsRead
|= 1 << VERT_ATTRIB_COLOR0
;
139 OutputsWritten
|= 1 << VERT_RESULT_COL0
;
140 EMIT_ATTR( _TNL_ATTRIB_COLOR0
, EMIT_1F
+ sz
- 1 );
144 rmesa
->swtcl
.specoffset
= 0;
145 if (RENDERINPUTS_TEST( index_bitset
, _TNL_ATTRIB_COLOR1
)) {
146 sz
= VB
->AttribPtr
[VERT_ATTRIB_COLOR1
]->size
;
147 rmesa
->swtcl
.specoffset
= offset
;
148 EMIT_ATTR( _TNL_ATTRIB_COLOR1
, EMIT_1F
+ sz
- 1 );
149 InputsRead
|= 1 << VERT_ATTRIB_COLOR1
;
150 OutputsWritten
|= 1 << VERT_RESULT_COL1
;
153 if (RENDERINPUTS_TEST_RANGE( index_bitset
, _TNL_FIRST_TEX
, _TNL_LAST_TEX
)) {
156 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
157 if (RENDERINPUTS_TEST( index_bitset
, _TNL_ATTRIB_TEX(i
) )) {
158 sz
= VB
->TexCoordPtr
[i
]->size
;
159 InputsRead
|= 1 << (VERT_ATTRIB_TEX0
+ i
);
160 OutputsWritten
|= 1 << (VERT_RESULT_TEX0
+ i
);
161 EMIT_ATTR( _TNL_ATTRIB_TEX0
+i
, EMIT_1F
+ sz
- 1 );
162 vap_fmt_1
|= sz
<< (3 * i
);
167 for (i
= 0, nr
= 0; i
< VERT_ATTRIB_MAX
; i
++) {
168 if (InputsRead
& (1 << i
)) {
175 /* Fixed, apply to vir0 only */
176 if (InputsRead
& (1 << VERT_ATTRIB_POS
))
177 inputs
[VERT_ATTRIB_POS
] = 0;
178 if (InputsRead
& (1 << VERT_ATTRIB_COLOR0
))
179 inputs
[VERT_ATTRIB_COLOR0
] = 2;
180 if (InputsRead
& (1 << VERT_ATTRIB_COLOR1
))
181 inputs
[VERT_ATTRIB_COLOR1
] = 3;
182 for (i
= VERT_ATTRIB_TEX0
; i
<= VERT_ATTRIB_TEX7
; i
++)
183 if (InputsRead
& (1 << i
))
184 inputs
[i
] = 6 + (i
- VERT_ATTRIB_TEX0
);
186 for (i
= 0, nr
= 0; i
< VERT_ATTRIB_MAX
; i
++) {
187 if (InputsRead
& (1 << i
)) {
192 for (i
= 0; i
< nr
; i
++) {
195 swizzle
[i
][0] = SWIZZLE_ZERO
;
196 swizzle
[i
][1] = SWIZZLE_ZERO
;
197 swizzle
[i
][2] = SWIZZLE_ZERO
;
198 swizzle
[i
][3] = SWIZZLE_ONE
;
200 for (ci
= 0; ci
< VB
->AttribPtr
[tab
[i
]]->size
; ci
++) {
206 R300_STATECHANGE(rmesa
, vir
[0]);
207 ((drm_r300_cmd_header_t
*) rmesa
->hw
.vir
[0].cmd
)->packet0
.count
=
208 r300VAPInputRoute0(&rmesa
->hw
.vir
[0].cmd
[R300_VIR_CNTL_0
],
209 VB
->AttribPtr
, inputs
, tab
, nr
);
210 R300_STATECHANGE(rmesa
, vir
[1]);
211 ((drm_r300_cmd_header_t
*) rmesa
->hw
.vir
[1].cmd
)->packet0
.count
=
212 r300VAPInputRoute1(&rmesa
->hw
.vir
[1].cmd
[R300_VIR_CNTL_0
], swizzle
,
215 R300_STATECHANGE(rmesa
, vic
);
216 rmesa
->hw
.vic
.cmd
[R300_VIC_CNTL_0
] = r300VAPInputCntl0(ctx
, InputsRead
);
217 rmesa
->hw
.vic
.cmd
[R300_VIC_CNTL_1
] = r300VAPInputCntl1(ctx
, InputsRead
);
219 R300_STATECHANGE(rmesa
, vof
);
220 rmesa
->hw
.vof
.cmd
[R300_VOF_CNTL_0
] = r300VAPOutputCntl0(ctx
, OutputsWritten
);
221 rmesa
->hw
.vof
.cmd
[R300_VOF_CNTL_1
] = vap_fmt_1
;
223 rmesa
->radeon
.swtcl
.vertex_size
=
224 _tnl_install_attrs( ctx
,
225 rmesa
->radeon
.swtcl
.vertex_attrs
,
226 rmesa
->radeon
.swtcl
.vertex_attr_count
,
229 rmesa
->radeon
.swtcl
.vertex_size
/= 4;
231 RENDERINPUTS_COPY( rmesa
->tnl_index_bitset
, index_bitset
);
234 R300_STATECHANGE(rmesa
, vte
);
235 rmesa
->hw
.vte
.cmd
[1] = vte
;
236 rmesa
->hw
.vte
.cmd
[2] = rmesa
->radeon
.swtcl
.vertex_size
;
239 static GLuint reduced_prim
[] = {
252 static void r300RasterPrimitive( GLcontext
*ctx
, GLuint prim
);
253 static void r300RenderPrimitive( GLcontext
*ctx
, GLenum prim
);
254 //static void r300ResetLineStipple( GLcontext *ctx );
256 /***********************************************************************
257 * Emit primitives as inline vertices *
258 ***********************************************************************/
261 #define HAVE_POINTS 1
263 #define HAVE_LINE_STRIPS 1
264 #define HAVE_TRIANGLES 1
265 #define HAVE_TRI_STRIPS 1
266 #define HAVE_TRI_STRIP_1 0
267 #define HAVE_TRI_FANS 1
269 #define HAVE_QUAD_STRIPS 0
270 #define HAVE_POLYGONS 1
275 #define CTX_ARG r300ContextPtr rmesa
276 #define GET_VERTEX_DWORDS() rmesa->radeon.swtcl.vertex_size
277 #define ALLOC_VERTS( n, size ) rcommonAllocDmaLowVerts( &rmesa->radeon, n, size * 4 )
279 r300ContextPtr rmesa = R300_CONTEXT(ctx); \
280 const char *r300verts = (char *)rmesa->radeon.swtcl.verts;
281 #define VERT(x) (r300Vertex *)(r300verts + ((x) * vertsize * sizeof(int)))
282 #define VERTEX r300Vertex
283 #define DO_DEBUG_VERTS (1 && (RADEON_DEBUG & DEBUG_VERTS))
284 #define PRINT_VERTEX(x)
286 #define TAG(x) r300_##x
287 #include "tnl_dd/t_dd_triemit.h"
291 /***********************************************************************
292 * Macros for t_dd_tritmp.h to draw basic primitives *
293 ***********************************************************************/
295 #define QUAD( a, b, c, d ) r300_quad( rmesa, a, b, c, d )
296 #define TRI( a, b, c ) r300_triangle( rmesa, a, b, c )
297 #define LINE( a, b ) r300_line( rmesa, a, b )
298 #define POINT( a ) r300_point( rmesa, a )
300 /***********************************************************************
301 * Build render functions from dd templates *
302 ***********************************************************************/
304 #define R300_TWOSIDE_BIT 0x01
305 #define R300_UNFILLED_BIT 0x02
306 #define R300_MAX_TRIFUNC 0x04
309 tnl_points_func points
;
311 tnl_triangle_func triangle
;
313 } rast_tab
[R300_MAX_TRIFUNC
];
315 #define DO_FALLBACK 0
316 #define DO_UNFILLED (IND & R300_UNFILLED_BIT)
317 #define DO_TWOSIDE (IND & R300_TWOSIDE_BIT)
324 #define DO_FULL_QUAD 1
328 #define HAVE_BACK_COLORS 0
329 #define HAVE_HW_FLATSHADE 1
332 #define DEPTH_SCALE 1.0
333 #define UNFILLED_TRI unfilled_tri
334 #define UNFILLED_QUAD unfilled_quad
335 #define VERT_X(_v) _v->v.x
336 #define VERT_Y(_v) _v->v.y
337 #define VERT_Z(_v) _v->v.z
338 #define AREA_IS_CCW( a ) (a < 0)
339 #define GET_VERTEX(e) (rmesa->radeon.swtcl.verts + (e*rmesa->radeon.swtcl.vertex_size*sizeof(int)))
341 /* Only used to pull back colors into vertices (ie, we know color is
344 #define R300_COLOR( dst, src ) \
346 UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \
347 UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \
348 UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \
349 UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]); \
352 #define VERT_SET_RGBA( v, c ) if (coloroffset) R300_COLOR( v->ub4[coloroffset], c )
353 #define VERT_COPY_RGBA( v0, v1 ) if (coloroffset) v0->ui[coloroffset] = v1->ui[coloroffset]
354 #define VERT_SAVE_RGBA( idx ) if (coloroffset) color[idx] = v[idx]->ui[coloroffset]
355 #define VERT_RESTORE_RGBA( idx ) if (coloroffset) v[idx]->ui[coloroffset] = color[idx]
357 #define R300_SPEC( dst, src ) \
359 UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \
360 UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \
361 UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \
364 #define VERT_SET_SPEC( v, c ) if (specoffset) R300_SPEC( v->ub4[specoffset], c )
365 #define VERT_COPY_SPEC( v0, v1 ) if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset])
366 #define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset]
367 #define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
373 #define LOCAL_VARS(n) \
374 r300ContextPtr rmesa = R300_CONTEXT(ctx); \
375 GLuint color[n], spec[n]; \
376 GLuint coloroffset = rmesa->swtcl.coloroffset; \
377 GLuint specoffset = rmesa->swtcl.specoffset; \
378 (void) color; (void) spec; (void) coloroffset; (void) specoffset;
380 /***********************************************************************
381 * Helpers for rendering unfilled primitives *
382 ***********************************************************************/
384 #define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_prim[x] )
385 #define RENDER_PRIMITIVE rmesa->radeon.swtcl.render_primitive
388 #include "tnl_dd/t_dd_unfilled.h"
392 /***********************************************************************
393 * Generate GL render functions *
394 ***********************************************************************/
399 #include "tnl_dd/t_dd_tritmp.h"
401 #define IND (R300_TWOSIDE_BIT)
402 #define TAG(x) x##_twoside
403 #include "tnl_dd/t_dd_tritmp.h"
405 #define IND (R300_UNFILLED_BIT)
406 #define TAG(x) x##_unfilled
407 #include "tnl_dd/t_dd_tritmp.h"
409 #define IND (R300_TWOSIDE_BIT|R300_UNFILLED_BIT)
410 #define TAG(x) x##_twoside_unfilled
411 #include "tnl_dd/t_dd_tritmp.h"
415 static void init_rast_tab( void )
420 init_twoside_unfilled();
423 /**********************************************************************/
424 /* Render unclipped begin/end objects */
425 /**********************************************************************/
427 #define RENDER_POINTS( start, count ) \
428 for ( ; start < count ; start++) \
429 r300_point( rmesa, VERT(start) )
430 #define RENDER_LINE( v0, v1 ) \
431 r300_line( rmesa, VERT(v0), VERT(v1) )
432 #define RENDER_TRI( v0, v1, v2 ) \
433 r300_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
434 #define RENDER_QUAD( v0, v1, v2, v3 ) \
435 r300_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
436 #define INIT(x) do { \
437 r300RenderPrimitive( ctx, x ); \
441 r300ContextPtr rmesa = R300_CONTEXT(ctx); \
442 const GLuint vertsize = rmesa->radeon.swtcl.vertex_size; \
443 const char *r300verts = (char *)rmesa->radeon.swtcl.verts; \
444 const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
445 const GLboolean stipple = ctx->Line.StippleFlag; \
446 (void) elt; (void) stipple;
447 #define RESET_STIPPLE //if ( stipple ) r200ResetLineStipple( ctx );
448 #define RESET_OCCLUSION
449 #define PRESERVE_VB_DEFS
451 #define TAG(x) r300_##x##_verts
452 #include "tnl/t_vb_rendertmp.h"
455 #define TAG(x) r300_##x##_elts
456 #define ELT(x) elt[x]
457 #include "tnl/t_vb_rendertmp.h"
462 /**********************************************************************/
463 /* Choose render functions */
464 /**********************************************************************/
465 static void r300ChooseRenderState( GLcontext
*ctx
)
467 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
468 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
470 GLuint flags
= ctx
->_TriangleCaps
;
472 if (flags
& DD_TRI_LIGHT_TWOSIDE
) index
|= R300_TWOSIDE_BIT
;
473 if (flags
& DD_TRI_UNFILLED
) index
|= R300_UNFILLED_BIT
;
475 if (index
!= rmesa
->radeon
.swtcl
.RenderIndex
) {
476 tnl
->Driver
.Render
.Points
= rast_tab
[index
].points
;
477 tnl
->Driver
.Render
.Line
= rast_tab
[index
].line
;
478 tnl
->Driver
.Render
.ClippedLine
= rast_tab
[index
].line
;
479 tnl
->Driver
.Render
.Triangle
= rast_tab
[index
].triangle
;
480 tnl
->Driver
.Render
.Quad
= rast_tab
[index
].quad
;
483 tnl
->Driver
.Render
.PrimTabVerts
= r300_render_tab_verts
;
484 tnl
->Driver
.Render
.PrimTabElts
= r300_render_tab_elts
;
485 tnl
->Driver
.Render
.ClippedPolygon
= r300_fast_clipped_poly
;
487 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
488 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
489 tnl
->Driver
.Render
.ClippedPolygon
= _tnl_RenderClippedPolygon
;
492 rmesa
->radeon
.swtcl
.RenderIndex
= index
;
497 static void r300RenderStart(GLcontext
*ctx
)
499 r300ContextPtr rmesa
= R300_CONTEXT( ctx
);
500 // fprintf(stderr, "%s\n", __FUNCTION__);
502 r300ChooseRenderState(ctx
);
503 r300SetVertexFormat(ctx
);
505 r300ValidateBuffers(ctx
);
507 r300UpdateShaders(rmesa
);
508 r300UpdateShaderStates(rmesa
);
510 r300EmitCacheFlush(rmesa
);
511 if (rmesa
->radeon
.dma
.flush
!= NULL
) {
512 rmesa
->radeon
.dma
.flush(ctx
);
516 static void r300RenderFinish(GLcontext
*ctx
)
520 static void r300RasterPrimitive( GLcontext
*ctx
, GLuint hwprim
)
522 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
524 if (rmesa
->radeon
.swtcl
.hw_primitive
!= hwprim
) {
525 R300_NEWPRIM( rmesa
);
526 rmesa
->radeon
.swtcl
.hw_primitive
= hwprim
;
530 static void r300RenderPrimitive(GLcontext
*ctx
, GLenum prim
)
533 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
534 rmesa
->radeon
.swtcl
.render_primitive
= prim
;
536 if ((prim
== GL_TRIANGLES
) && (ctx
->_TriangleCaps
& DD_TRI_UNFILLED
))
539 r300RasterPrimitive( ctx
, reduced_prim
[prim
] );
540 // fprintf(stderr, "%s\n", __FUNCTION__);
544 static void r300ResetLineStipple(GLcontext
*ctx
)
550 void r300InitSwtcl(GLcontext
*ctx
)
552 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
553 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
554 static int firsttime
= 1;
561 tnl
->Driver
.Render
.Start
= r300RenderStart
;
562 tnl
->Driver
.Render
.Finish
= r300RenderFinish
;
563 tnl
->Driver
.Render
.PrimitiveNotify
= r300RenderPrimitive
;
564 tnl
->Driver
.Render
.ResetLineStipple
= r300ResetLineStipple
;
565 tnl
->Driver
.Render
.BuildVertices
= _tnl_build_vertices
;
566 tnl
->Driver
.Render
.CopyPV
= _tnl_copy_pv
;
567 tnl
->Driver
.Render
.Interp
= _tnl_interp
;
569 /* FIXME: what are these numbers? */
570 _tnl_init_vertices( ctx
, ctx
->Const
.MaxArrayLockSize
+ 12,
571 48 * sizeof(GLfloat
) );
573 rmesa
->radeon
.swtcl
.verts
= (GLubyte
*)tnl
->clipspace
.vertex_buf
;
574 rmesa
->radeon
.swtcl
.RenderIndex
= ~0;
575 rmesa
->radeon
.swtcl
.render_primitive
= GL_TRIANGLES
;
576 rmesa
->radeon
.swtcl
.hw_primitive
= 0;
578 _tnl_invalidate_vertex_state( ctx
, ~0 );
579 _tnl_invalidate_vertices( ctx
, ~0 );
580 RENDERINPUTS_ZERO( rmesa
->tnl_index_bitset
);
582 _tnl_need_projected_coords( ctx
, GL_FALSE
);
583 r300ChooseRenderState(ctx
);
585 _mesa_validate_all_lighting_tables( ctx
);
587 tnl
->Driver
.NotifyMaterialChange
=
588 _mesa_validate_all_lighting_tables
;
591 void r300DestroySwtcl(GLcontext
*ctx
)
595 void r300EmitVertexAOS(r300ContextPtr rmesa
, GLuint vertex_size
, struct radeon_bo
*bo
, GLuint offset
)
597 BATCH_LOCALS(&rmesa
->radeon
);
599 if (RADEON_DEBUG
& DEBUG_VERTS
)
600 fprintf(stderr
, "%s: vertex_size %d, offset 0x%x \n",
601 __FUNCTION__
, vertex_size
, offset
);
604 OUT_BATCH_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR
, 2);
606 OUT_BATCH(vertex_size
| (vertex_size
<< 8));
607 OUT_BATCH_RELOC(offset
, bo
, offset
, RADEON_GEM_DOMAIN_GTT
, 0, 0);
611 void r300EmitVbufPrim(r300ContextPtr rmesa
, GLuint primitive
, GLuint vertex_nr
)
613 BATCH_LOCALS(&rmesa
->radeon
);
616 type
= r300PrimitiveType(rmesa
, primitive
);
617 num_verts
= r300NumVerts(rmesa
, vertex_nr
, primitive
);
620 OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2
, 0);
621 OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST
| (num_verts
<< 16) | type
);
625 void r300_swtcl_flush(GLcontext
*ctx
, uint32_t current_offset
)
627 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
629 rcommonEnsureCmdBufSpace(&rmesa
->radeon
,
630 rmesa
->radeon
.hw
.max_state_size
+ (12*sizeof(int)),
632 radeonEmitState(&rmesa
->radeon
);
633 r300EmitVertexAOS(rmesa
,
634 rmesa
->radeon
.swtcl
.vertex_size
,
635 rmesa
->radeon
.dma
.current
,
638 r300EmitVbufPrim(rmesa
,
639 rmesa
->radeon
.swtcl
.hw_primitive
,
640 rmesa
->radeon
.swtcl
.numverts
);
641 r300EmitCacheFlush(rmesa
);