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
;
42 struct draw_prim_info
;
43 struct draw_vertex_info
;
47 #define PT_CLIPTEST 0x2
48 #define PT_PIPELINE 0x4
49 #define PT_MAX_MIDDLE 0x8
52 /* The "front end" - prepare sets of fetch, draw elements for the
55 * Currenly one version of this:
56 * - vcache - catchall implementation, decomposes to TRI/LINE/POINT prims
58 * - varray, varray_split
59 * - velement, velement_split
61 * Currenly only using the vcache version.
63 struct draw_pt_front_end
{
64 void (*prepare
)( struct draw_pt_front_end
*,
66 struct draw_pt_middle_end
*,
69 void (*run
)( struct draw_pt_front_end
*,
75 void (*finish
)( struct draw_pt_front_end
* );
76 void (*destroy
)( struct draw_pt_front_end
* );
80 /* The "middle end" - prepares actual hardware vertices for the
83 * Currently two versions of this:
84 * - fetch, vertex shade, cliptest, prim-pipeline
85 * - fetch, emit (ie passthrough)
87 struct draw_pt_middle_end
{
88 void (*prepare
)( struct draw_pt_middle_end
*,
91 unsigned *max_vertices
);
93 void (*run
)( struct draw_pt_middle_end
*,
94 const unsigned *fetch_elts
,
96 const ushort
*draw_elts
,
97 unsigned draw_count
);
99 void (*run_linear
)(struct draw_pt_middle_end
*,
103 /* Transform all vertices in a linear range and then draw them with
104 * the supplied element list. May fail and return FALSE.
106 boolean (*run_linear_elts
)( struct draw_pt_middle_end
*,
107 unsigned fetch_start
,
108 unsigned fetch_count
,
109 const ushort
*draw_elts
,
110 unsigned draw_count
);
112 int (*get_max_vertex_count
)( struct draw_pt_middle_end
* );
114 void (*finish
)( struct draw_pt_middle_end
* );
115 void (*destroy
)( struct draw_pt_middle_end
* );
119 /* The "back end" - supplied by the driver, defined in draw_vbuf.h.
122 struct vertex_header
;
127 pt_elt_func
draw_pt_elt_func( struct draw_context
*draw
);
128 const void *draw_pt_elt_ptr( struct draw_context
*draw
,
133 * Currently only the general-purpose vcache implementation, could add
134 * a special case for tiny vertex buffers.
136 struct draw_pt_front_end
*draw_pt_vcache( struct draw_context
*draw
);
137 struct draw_pt_front_end
*draw_pt_varray(struct draw_context
*draw
);
142 * Currently one general-purpose case which can do all possibilities,
143 * at the slight expense of creating a vertex_header in some cases
146 * The special case fetch_emit code avoids pipeline vertices
147 * altogether and builds hardware vertices directly from API
150 struct draw_pt_middle_end
*draw_pt_fetch_emit( struct draw_context
*draw
);
151 struct draw_pt_middle_end
*draw_pt_middle_fse( struct draw_context
*draw
);
152 struct draw_pt_middle_end
*draw_pt_fetch_pipeline_or_emit(struct draw_context
*draw
);
153 struct draw_pt_middle_end
*draw_pt_fetch_pipeline_or_emit_llvm(struct draw_context
*draw
);
157 /*******************************************************************************
162 void draw_pt_emit_prepare( struct pt_emit
*emit
,
164 unsigned *max_vertices
);
166 void draw_pt_emit( struct pt_emit
*emit
,
167 const struct draw_vertex_info
*vert_info
,
168 const struct draw_prim_info
*prim_info
);
170 void draw_pt_emit_linear( struct pt_emit
*emit
,
171 const struct draw_vertex_info
*vert_info
,
172 const struct draw_prim_info
*prim_info
);
174 void draw_pt_emit_destroy( struct pt_emit
*emit
);
176 struct pt_emit
*draw_pt_emit_create( struct draw_context
*draw
);
178 /*******************************************************************************
179 * HW stream output emit:
183 void draw_pt_so_emit_prepare( struct pt_so_emit
*emit
);
185 void draw_pt_so_emit( struct pt_so_emit
*emit
,
186 const struct draw_vertex_info
*vert_info
,
187 const struct draw_prim_info
*prim_info
);
189 void draw_pt_so_emit_destroy( struct pt_so_emit
*emit
);
191 struct pt_so_emit
*draw_pt_so_emit_create( struct draw_context
*draw
);
193 /*******************************************************************************
198 void draw_pt_fetch_prepare( struct pt_fetch
*fetch
,
199 unsigned vertex_input_count
,
200 unsigned vertex_size
,
201 unsigned instance_id_index
);
203 void draw_pt_fetch_run( struct pt_fetch
*fetch
,
204 const unsigned *elts
,
208 void draw_pt_fetch_run_linear( struct pt_fetch
*fetch
,
213 void draw_pt_fetch_destroy( struct pt_fetch
*fetch
);
215 struct pt_fetch
*draw_pt_fetch_create( struct draw_context
*draw
);
217 /*******************************************************************************
218 * Post-VS: cliptest, rhw, viewport
222 boolean
draw_pt_post_vs_run( struct pt_post_vs
*pvs
,
223 struct draw_vertex_info
*info
);
225 void draw_pt_post_vs_prepare( struct pt_post_vs
*pvs
,
226 boolean bypass_clipping
,
227 boolean bypass_viewport
,
229 boolean need_edgeflags
);
231 struct pt_post_vs
*draw_pt_post_vs_create( struct draw_context
*draw
);
233 void draw_pt_post_vs_destroy( struct pt_post_vs
*pvs
);
236 /*******************************************************************************
239 void draw_pt_split_prim(unsigned prim
, unsigned *first
, unsigned *incr
);