1 /**************************************************************************
3 Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
4 VA Linux Systems Inc., Fremont, California.
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 on the rights to use, copy, modify, merge, publish, distribute, sub
12 license, and/or sell copies of the Software, and to permit persons to whom
13 the Software is furnished to do so, subject to the following conditions:
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
31 * Keith Whitwell <keith@tungstengraphics.com>
37 * Render unclipped vertex buffers by emitting vertices directly to
38 * dma buffers. Use strip/fan hardware primitives where possible.
39 * Simulate missing primitives with indexed vertices.
41 #include "main/glheader.h"
42 #include "main/context.h"
43 #include "main/macros.h"
44 #include "main/imports.h"
45 #include "main/mtypes.h"
47 #include "tnl/t_context.h"
49 #include "mgacontext.h"
57 #define HAVE_LINE_STRIPS 0
58 #define HAVE_TRIANGLES 1
59 #define HAVE_TRI_STRIPS 1
60 #define HAVE_TRI_STRIP_1 0
61 #define HAVE_TRI_FANS 1
62 #define HAVE_POLYGONS 0
64 #define HAVE_QUAD_STRIPS 0
66 #define HAVE_ELTS 0 /* for now */
68 static void mgaDmaPrimitive( GLcontext
*ctx
, GLenum prim
)
70 mgaContextPtr mmesa
= MGA_CONTEXT(ctx
);
75 hwprim
= MGA_WA_TRIANGLES
;
77 case GL_TRIANGLE_STRIP
:
78 if (mmesa
->vertex_size
== 8)
79 hwprim
= MGA_WA_TRISTRIP_T0
;
81 hwprim
= MGA_WA_TRISTRIP_T0T1
;
84 if (mmesa
->vertex_size
== 8)
85 hwprim
= MGA_WA_TRIFAN_T0
;
87 hwprim
= MGA_WA_TRIFAN_T0T1
;
93 mgaRasterPrimitive( ctx
, GL_TRIANGLES
, hwprim
);
97 #define LOCAL_VARS mgaContextPtr mmesa = MGA_CONTEXT(ctx)
98 #define INIT( prim ) do { \
99 if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
100 FLUSH_BATCH(mmesa); \
101 mgaDmaPrimitive( ctx, prim ); \
103 #define FLUSH() FLUSH_BATCH( mmesa )
104 #define GET_CURRENT_VB_MAX_VERTS() \
106 #define GET_SUBSEQUENT_VB_MAX_VERTS() \
107 MGA_BUFFER_SIZE / (mmesa->vertex_size * 4)
110 #define ALLOC_VERTS( nr ) \
111 mgaAllocDmaLow( mmesa, (nr) * mmesa->vertex_size * 4)
112 #define EMIT_VERTS( ctx, j, nr, buf ) \
113 mga_emit_contiguous_verts(ctx, j, (j)+(nr), buf)
116 #define TAG(x) mga_##x
117 #include "tnl_dd/t_dd_dmatmp.h"
121 /**********************************************************************/
122 /* Render pipeline stage */
123 /**********************************************************************/
126 static GLboolean
mga_run_render( GLcontext
*ctx
,
127 struct tnl_pipeline_stage
*stage
)
129 mgaContextPtr mmesa
= MGA_CONTEXT(ctx
);
130 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
131 struct vertex_buffer
*VB
= &tnl
->vb
;
134 /* Don't handle clipping or indexed vertices or vertex manipulations.
136 if (mmesa
->RenderIndex
!= 0 ||
137 !mga_validate_render( ctx
, VB
)) {
141 tnl
->Driver
.Render
.Start( ctx
);
142 mmesa
->SetupNewInputs
= ~0;
144 for (i
= 0 ; i
< VB
->PrimitiveCount
; i
++)
146 GLuint prim
= _tnl_translate_prim(&VB
->Primitive
[i
]);
147 GLuint start
= VB
->Primitive
[i
].start
;
148 GLuint length
= VB
->Primitive
[i
].count
;
153 mga_render_tab_verts
[prim
& PRIM_MODE_MASK
]( ctx
, start
, start
+ length
,
157 tnl
->Driver
.Render
.Finish( ctx
);
159 return GL_FALSE
; /* finished the pipe */
163 const struct tnl_pipeline_stage _mga_render_stage
=
170 mga_run_render
/* run */