1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Keith Whitwell <keith@tungstengraphics.com>
36 #include "pipe/p_compiler.h"
38 typedef unsigned (*pt_elt_func
)( const void *elts
, unsigned idx
);
40 struct draw_pt_middle_end
;
43 /* We use the top couple of bits in the vertex fetch index to convey a
44 * little API information. This limits the number of vertices we can
45 * address to only 1 billion -- if that becomes a problem, these could
46 * be moved out & passed separately.
48 #define DRAW_PT_EDGEFLAG (1<<30)
49 #define DRAW_PT_RESET_STIPPLE (1<<31)
50 #define DRAW_PT_FLAG_MASK (3<<30)
54 #define PT_CLIPTEST 0x2
55 #define PT_PIPELINE 0x4
56 #define PT_MAX_MIDDLE 0x8
59 /* The "front end" - prepare sets of fetch, draw elements for the
62 * Currenly one version of this:
63 * - vcache - catchall implementation, decomposes to TRI/LINE/POINT prims
65 * - varray, varray_split
66 * - velement, velement_split
68 * Currenly only using the vcache version.
70 struct draw_pt_front_end
{
71 void (*prepare
)( struct draw_pt_front_end
*,
73 struct draw_pt_middle_end
*,
76 void (*run
)( struct draw_pt_front_end
*,
81 void (*finish
)( struct draw_pt_front_end
* );
82 void (*destroy
)( struct draw_pt_front_end
* );
86 /* The "middle end" - prepares actual hardware vertices for the
89 * Currently two versions of this:
90 * - fetch, vertex shade, cliptest, prim-pipeline
91 * - fetch, emit (ie passthrough)
93 struct draw_pt_middle_end
{
94 void (*prepare
)( struct draw_pt_middle_end
*,
98 void (*run
)( struct draw_pt_middle_end
*,
99 const unsigned *fetch_elts
,
100 unsigned fetch_count
,
101 const ushort
*draw_elts
,
102 unsigned draw_count
);
104 void (*finish
)( struct draw_pt_middle_end
* );
105 void (*destroy
)( struct draw_pt_middle_end
* );
109 /* The "back end" - supplied by the driver, defined in draw_vbuf.h.
112 struct vertex_header
;
117 pt_elt_func
draw_pt_elt_func( struct draw_context
*draw
);
118 const void *draw_pt_elt_ptr( struct draw_context
*draw
,
123 * Currently only the general-purpose vcache implementation, could add
124 * a special case for tiny vertex buffers.
126 struct draw_pt_front_end
*draw_pt_vcache( struct draw_context
*draw
);
130 * Currently one general-purpose case which can do all possibilities,
131 * at the slight expense of creating a vertex_header in some cases
134 * The special case fetch_emit code avoids pipeline vertices
135 * altogether and builds hardware vertices directly from API
138 struct draw_pt_middle_end
*draw_pt_fetch_emit( struct draw_context
*draw
);
139 struct draw_pt_middle_end
*draw_pt_fetch_pipeline_or_emit(struct draw_context
*draw
);
144 boolean
draw_pt_get_edgeflag( struct draw_context
*draw
,
148 /*******************************************************************************
153 void draw_pt_emit_prepare( struct pt_emit
*emit
,
156 void draw_pt_emit( struct pt_emit
*emit
,
157 const float (*vertex_data
)[4],
158 unsigned vertex_count
,
163 void draw_pt_emit_destroy( struct pt_emit
*emit
);
165 struct pt_emit
*draw_pt_emit_create( struct draw_context
*draw
);
168 /*******************************************************************************
173 void draw_pt_fetch_prepare( struct pt_fetch
*fetch
,
174 unsigned vertex_size
);
176 void draw_pt_fetch_run( struct pt_fetch
*fetch
,
177 const unsigned *elts
,
181 void draw_pt_fetch_destroy( struct pt_fetch
*fetch
);
183 struct pt_fetch
*draw_pt_fetch_create( struct draw_context
*draw
);
185 /*******************************************************************************
186 * Post-VS: cliptest, rhw, viewport
190 boolean
draw_pt_post_vs_run( struct pt_post_vs
*pvs
,
191 struct vertex_header
*pipeline_verts
,
195 void draw_pt_post_vs_prepare( struct pt_post_vs
*pvs
,
196 boolean bypass_clipping
,
197 boolean identity_viewport
,
200 struct pt_post_vs
*draw_pt_post_vs_create( struct draw_context
*draw
);
202 void draw_pt_post_vs_destroy( struct pt_post_vs
*pvs
);