draw: make pt run pipeline when need_pipeline is true, not just when clipped
[mesa.git] / src / gallium / auxiliary / draw / draw_pt.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Keith Whitwell <keith@tungstengraphics.com>
31 */
32
33 #ifndef DRAW_PT_H
34 #define DRAW_PT_H
35
36 #include "pipe/p_compiler.h"
37
38 typedef unsigned (*pt_elt_func)( const void *elts, unsigned idx );
39
40 struct draw_pt_middle_end;
41 struct draw_context;
42
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.
47 */
48 #define DRAW_PT_EDGEFLAG (1<<30)
49 #define DRAW_PT_RESET_STIPPLE (1<<31)
50 #define DRAW_PT_FLAG_MASK (3<<30)
51
52
53 /* The "front end" - prepare sets of fetch, draw elements for the
54 * middle end.
55 *
56 * Currenly one version of this:
57 * - vcache - catchall implementation, decomposes to TRI/LINE/POINT prims
58 * Later:
59 * - varray, varray_split
60 * - velement, velement_split
61 *
62 * Currenly only using the vcache version.
63 */
64 struct draw_pt_front_end {
65 void (*prepare)( struct draw_pt_front_end *,
66 unsigned prim,
67 struct draw_pt_middle_end *,
68 unsigned opt );
69
70 void (*run)( struct draw_pt_front_end *,
71 pt_elt_func elt_func,
72 const void *elt_ptr,
73 unsigned count );
74
75 void (*finish)( struct draw_pt_front_end * );
76 void (*destroy)( struct draw_pt_front_end * );
77 };
78
79
80 /* The "middle end" - prepares actual hardware vertices for the
81 * hardware backend.
82 *
83 * Currently two versions of this:
84 * - fetch, vertex shade, cliptest, prim-pipeline
85 * - fetch, emit (ie passthrough)
86 * Later:
87 * - fetch, vertex shade, cliptest, maybe-pipeline, maybe-emit
88 * - fetch, vertex shade, emit
89 *
90 * Currenly only using the passthrough version.
91 */
92 struct draw_pt_middle_end {
93 void (*prepare)( struct draw_pt_middle_end *,
94 unsigned prim,
95 unsigned opt );
96
97 void (*run)( struct draw_pt_middle_end *,
98 const unsigned *fetch_elts,
99 unsigned fetch_count,
100 const ushort *draw_elts,
101 unsigned draw_count );
102
103 void (*finish)( struct draw_pt_middle_end * );
104 void (*destroy)( struct draw_pt_middle_end * );
105 };
106
107
108 /* The "back end" - supplied by the driver, defined in draw_vbuf.h.
109 *
110 * Not sure whether to wrap the prim pipeline up as an alternate
111 * backend. Would be a win for everything except pure passthrough
112 * mode...
113 */
114 struct vbuf_render;
115
116
117 /* Helper functions.
118 */
119 pt_elt_func draw_pt_elt_func( struct draw_context *draw );
120 const void *draw_pt_elt_ptr( struct draw_context *draw,
121 unsigned start );
122
123 /* Implementations:
124 */
125 struct draw_pt_front_end *draw_pt_vcache( struct draw_context *draw );
126 struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw );
127 struct draw_pt_middle_end *draw_pt_fetch_pipeline( struct draw_context *draw );
128 struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *draw);
129
130
131 #endif