2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
27 * Render unclipped vertex buffers by emitting vertices directly to
28 * dma buffers. Use strip/fan hardware acceleration where possible.
36 #include "tnl/t_context.h"
38 #include "via_context.h"
40 #include "via_state.h"
41 #include "via_ioctl.h"
44 * Render unclipped vertex buffers by emitting vertices directly to
45 * dma buffers. Use strip/fan hardware primitives where possible.
46 * Try to simulate missing primitives with indexed vertices.
50 #define HAVE_LINE_STRIPS 1
51 #define HAVE_LINE_LOOP 1
52 #define HAVE_TRIANGLES 1
53 #define HAVE_TRI_STRIPS 1
54 #define HAVE_TRI_STRIP_1 0
55 #define HAVE_TRI_FANS 1
56 #define HAVE_POLYGONS 1
58 #define HAVE_QUAD_STRIPS 0
62 #define LOCAL_VARS struct via_context *vmesa = VIA_CONTEXT(ctx)
63 #define INIT(prim) do { \
64 viaRasterPrimitive(ctx, prim, prim); \
66 #define GET_CURRENT_VB_MAX_VERTS() \
67 ((VIA_DMA_BUF_SZ - (512 + (int)vmesa->dmaLow)) / (vmesa->vertexSize * 4))
68 #define GET_SUBSEQUENT_VB_MAX_VERTS() \
69 (VIA_DMA_BUF_SZ - 512) / (vmesa->vertexSize * 4)
71 #define ALLOC_VERTS( nr ) \
72 viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4)
74 #define EMIT_VERTS(ctx, j, nr, buf) \
75 _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf )
77 #define FLUSH() VIA_FINISH_PRIM( vmesa )
79 #define TAG(x) via_fast##x
80 #include "tnl_dd/t_dd_dmatmp.h"
85 /**********************************************************************/
86 /* Fast Render pipeline stage */
87 /**********************************************************************/
88 static GLboolean
via_run_fastrender(GLcontext
*ctx
,
89 struct tnl_pipeline_stage
*stage
)
91 struct via_context
*vmesa
= VIA_CONTEXT(ctx
);
92 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
93 struct vertex_buffer
*VB
= &tnl
->vb
;
97 tnl
->Driver
.Render
.Start(ctx
);
100 vmesa
->renderIndex
!= 0 ||
101 !via_fastvalidate_render( ctx
, VB
)) {
102 tnl
->Driver
.Render
.Finish(ctx
);
106 tnl
->clipspace
.new_inputs
|= VERT_BIT_POS
;
108 for (i
= 0; i
< VB
->PrimitiveCount
; ++i
) {
109 GLuint mode
= VB
->Primitive
[i
].mode
;
110 GLuint start
= VB
->Primitive
[i
].start
;
111 GLuint length
= VB
->Primitive
[i
].count
;
113 via_fastrender_tab_verts
[mode
& PRIM_MODE_MASK
](ctx
, start
, start
+length
, mode
);
116 tnl
->Driver
.Render
.Finish(ctx
);
118 return GL_FALSE
; /* finished the pipe */
122 static void via_check_fastrender(GLcontext
*ctx
,
123 struct tnl_pipeline_stage
*stage
)
125 stage
->inputs
= TNL_CONTEXT(ctx
)->render_inputs
;
129 static void fastdtr(struct tnl_pipeline_stage
*stage
)
135 const struct tnl_pipeline_stage _via_fastrender_stage
=
138 (_DD_NEW_SEPARATE_SPECULAR
|
141 _NEW_RENDERMODE
), /* re-check (new inputs) */
142 0, /* re-run (always runs) */
143 GL_TRUE
, /* active */
144 0, 0, /* inputs (set in check_render), outputs */
145 0, 0, /* changed_inputs, private */
146 fastdtr
, /* destructor */
147 via_check_fastrender
, /* check - initially set to alloc data */
148 via_run_fastrender
/* run */