• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2007 VMware, Inc.
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 VMWARE 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 <keithw@vmware.com>
31   */
32 
33 #ifndef DRAW_PIPE_H
34 #define DRAW_PIPE_H
35 
36 #include "pipe/p_compiler.h"
37 #include "draw_private.h"       /* for sizeof(vertex_header) */
38 #include "draw_context.h"
39 
40 
41 /**
42  * Basic info for a point/line/triangle primitive.
43  */
44 struct prim_header {
45    float det;                 /**< front/back face determinant */
46    ushort flags;
47    ushort pad;
48    struct vertex_header *v[3];  /**< 1 to 3 vertex pointers */
49 };
50 
51 
52 
53 /**
54  * Base class for all primitive drawing stages.
55  */
56 struct draw_stage
57 {
58    struct draw_context *draw;   /**< parent context */
59 
60    struct draw_stage *next;     /**< next stage in pipeline */
61    const char *name;            /**< for debugging  */
62 
63    struct vertex_header **tmp;  /**< temp vert storage, such as for clipping */
64    unsigned nr_tmps;
65 
66    void (*point)( struct draw_stage *,
67 		  struct prim_header * );
68 
69    void (*line)( struct draw_stage *,
70 		 struct prim_header * );
71 
72    void (*tri)( struct draw_stage *,
73 		struct prim_header * );
74 
75    void (*flush)( struct draw_stage *,
76 		  unsigned flags );
77 
78    void (*reset_stipple_counter)( struct draw_stage * );
79 
80    void (*destroy)( struct draw_stage * );
81 };
82 
83 
84 extern struct draw_stage *draw_unfilled_stage( struct draw_context *context );
85 extern struct draw_stage *draw_twoside_stage( struct draw_context *context );
86 extern struct draw_stage *draw_offset_stage( struct draw_context *context );
87 extern struct draw_stage *draw_clip_stage( struct draw_context *context );
88 extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
89 extern struct draw_stage *draw_cull_stage( struct draw_context *context );
90 extern struct draw_stage *draw_user_cull_stage( struct draw_context *draw );
91 extern struct draw_stage *draw_stipple_stage( struct draw_context *context );
92 extern struct draw_stage *draw_wide_line_stage( struct draw_context *context );
93 extern struct draw_stage *draw_wide_point_stage( struct draw_context *context );
94 extern struct draw_stage *draw_validate_stage( struct draw_context *context );
95 
96 extern void draw_free_temp_verts( struct draw_stage *stage );
97 extern boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr );
98 
99 extern void draw_reset_vertex_ids( struct draw_context *draw );
100 
101 void draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header);
102 void draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header);
103 void draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header);
104 
105 void draw_aapoint_prepare_outputs(struct draw_context *context,
106                                   struct draw_stage *stage);
107 void draw_aaline_prepare_outputs(struct draw_context *context,
108                                  struct draw_stage *stage);
109 void draw_unfilled_prepare_outputs(struct draw_context *context,
110                                    struct draw_stage *stage);
111 
112 /**
113  * Get a writeable copy of a vertex.
114  * \param stage  drawing stage info
115  * \param vert  the vertex to copy (source)
116  * \param idx  index into stage's tmp[] array to put the copy (dest)
117  * \return  pointer to the copied vertex
118  */
119 static inline struct vertex_header *
dup_vert(struct draw_stage * stage,const struct vertex_header * vert,unsigned idx)120 dup_vert( struct draw_stage *stage,
121 	  const struct vertex_header *vert,
122 	  unsigned idx )
123 {
124    struct vertex_header *tmp = stage->tmp[idx];
125    const uint vsize = sizeof(struct vertex_header)
126       + draw_num_shader_outputs(stage->draw) * 4 * sizeof(float);
127    memcpy(tmp, vert, vsize);
128    tmp->vertex_id = UNDEFINED_VERTEX_ID;
129    return tmp;
130 }
131 
132 #endif
133