2 * Intel i810 DRI driver for Mesa 3.5
4 * Copyright (C) 1999-2000 Keith Whitwell All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL KEITH WHITWELL BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Keith Whitwell <keith@tungstengraphics.com>
30 * Render unclipped vertex buffers by emitting vertices directly to
31 * dma buffers. Use strip/fan hardware acceleration where possible.
40 #include "tnl/t_context.h"
42 #include "i810screen.h"
45 #include "i810context.h"
47 #include "i810state.h"
49 #include "i810ioctl.h"
52 * Render unclipped vertex buffers by emitting vertices directly to
53 * dma buffers. Use strip/fan hardware primitives where possible.
54 * Try to simulate missing primitives with indexed vertices.
58 #define HAVE_LINE_STRIPS 1
59 #define HAVE_TRIANGLES 1
60 #define HAVE_TRI_STRIPS 1
61 #define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */
62 #define HAVE_TRI_FANS 1
63 #define HAVE_POLYGONS 1
65 #define HAVE_QUAD_STRIPS 0
70 static GLuint hw_prim
[GL_POLYGON
+1] = {
83 static const GLenum reduced_prim
[GL_POLYGON
+1] = {
99 #define LOCAL_VARS i810ContextPtr imesa = I810_CONTEXT(ctx)
100 #define INIT( prim ) do { \
101 I810_STATECHANGE(imesa, 0); \
102 i810RasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] ); \
104 #define GET_CURRENT_VB_MAX_VERTS() \
105 (((int)imesa->vertex_high - (int)imesa->vertex_low) / (imesa->vertex_size*4))
106 #define GET_SUBSEQUENT_VB_MAX_VERTS() \
107 (I810_DMA_BUF_SZ-4) / (imesa->vertex_size * 4)
109 #define ALLOC_VERTS( nr ) \
110 i810AllocDmaLow( imesa, (nr) * imesa->vertex_size * 4)
111 #define EMIT_VERTS( ctx, j, nr, buf ) \
112 i810_emit_contiguous_verts(ctx, j, (j)+(nr), buf)
114 #define FLUSH() I810_FIREVERTICES( imesa )
117 #define TAG(x) i810_##x
118 #include "tnl_dd/t_dd_dmatmp.h"
121 /**********************************************************************/
122 /* Render pipeline stage */
123 /**********************************************************************/
126 static GLboolean
i810_run_render( GLcontext
*ctx
,
127 struct tnl_pipeline_stage
*stage
)
129 i810ContextPtr imesa
= I810_CONTEXT(ctx
);
130 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
131 struct vertex_buffer
*VB
= &tnl
->vb
;
134 /* Don't handle clipping or indexed vertices.
136 if (imesa
->RenderIndex
!= 0 ||
137 !i810_validate_render( ctx
, VB
)) {
141 imesa
->SetupNewInputs
= VERT_BIT_POS
;
143 tnl
->Driver
.Render
.Start( ctx
);
145 for (i
= 0 ; i
< VB
->PrimitiveCount
; i
++)
147 GLuint prim
= VB
->Primitive
[i
].mode
;
148 GLuint start
= VB
->Primitive
[i
].start
;
149 GLuint length
= VB
->Primitive
[i
].count
;
154 i810_render_tab_verts
[prim
& PRIM_MODE_MASK
]( ctx
, start
, start
+ length
,
158 tnl
->Driver
.Render
.Finish( ctx
);
160 return GL_FALSE
; /* finished the pipe */
164 static void i810_check_render( GLcontext
*ctx
,
165 struct tnl_pipeline_stage
*stage
)
167 stage
->inputs
= TNL_CONTEXT(ctx
)->render_inputs
;
171 static void dtr( struct tnl_pipeline_stage
*stage
)
177 const struct tnl_pipeline_stage _i810_render_stage
=
180 (_DD_NEW_SEPARATE_SPECULAR
|
183 _NEW_RENDERMODE
), /* re-check (new inputs) */
184 0, /* re-run (always runs) */
185 GL_TRUE
, /* active */
186 0, 0, /* inputs (set in check_render), outputs */
187 0, 0, /* changed_inputs, private */
188 dtr
, /* destructor */
189 i810_check_render
, /* check - initially set to alloc data */
190 i810_run_render
/* run */