draw_pt.h revision edfa8201a50c47376b7aa0c05d7851e3e1353bde
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
38typedef unsigned (*pt_elt_func)( const void *elts, unsigned idx );
39
40struct draw_pt_middle_end;
41struct draw_context;
42
43/* The "front end" - prepare sets of fetch, draw elements for the
44 * middle end.
45 *
46 * Currenly one version of this:
47 *    - vcache - catchall implementation, decomposes to TRI/LINE/POINT prims
48 * Later:
49 *    - varray, varray_split
50 *    - velement, velement_split
51 *
52 * Currenly only using the vcache version.
53 */
54struct draw_pt_front_end {
55   void (*prepare)( struct draw_pt_front_end *,
56                    struct draw_pt_middle_end * );
57
58   void (*run)( struct draw_pt_front_end *,
59                unsigned prim,
60                pt_elt_func elt_func,
61                const void *elt_ptr,
62                unsigned count );
63
64   void (*finish)( struct draw_pt_front_end * );
65   void (*destroy)( struct draw_pt_front_end * );
66};
67
68
69/* The "middle end" - prepares actual hardware vertices for the
70 * hardware backend.
71 *
72 * Currently two versions of this:
73 *     - fetch, vertex shade, cliptest, prim-pipeline
74 *     - fetch, emit (ie passthrough)
75 * Later:
76 *     - fetch, vertex shade, cliptest, maybe-pipeline, maybe-emit
77 *     - fetch, vertex shade, emit
78 *
79 * Currenly only using the passthrough version.
80 */
81struct draw_pt_middle_end {
82   void (*prepare)( struct draw_pt_middle_end * );
83
84   void (*run)( struct draw_pt_middle_end *,
85                unsigned prim,
86                const unsigned *fetch_elts,
87                unsigned fetch_count,
88                const ushort *draw_elts,
89                unsigned draw_count );
90
91   void (*finish)( struct draw_pt_middle_end * );
92   void (*destroy)( struct draw_pt_middle_end * );
93};
94
95
96/* The "back end" - supplied by the driver, defined in draw_vbuf.h.
97 *
98 * Not sure whether to wrap the prim pipeline up as an alternate
99 * backend.  Would be a win for everything except pure passthrough
100 * mode...
101 */
102struct vbuf_render;
103
104
105/* Helper functions.
106 */
107pt_elt_func draw_pt_elt_func( struct draw_context *draw );
108const void *draw_pt_elt_ptr( struct draw_context *draw,
109                             unsigned start );
110
111/* Implementations:
112 */
113struct draw_pt_front_end *draw_pt_vcache( struct draw_context *draw );
114struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw );
115
116
117
118#endif
119