f2749b34bbb4ad4a63a998f0f671946df9da7637
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"
37 #include "draw_private.h" /* for sizeof(vertex_header) */
42 * Base class for all primitive drawing stages.
46 struct draw_context
*draw
; /**< parent context */
48 struct draw_stage
*next
; /**< next stage in pipeline */
50 struct vertex_header
**tmp
; /**< temp vert storage, such as for clipping */
53 void (*point
)( struct draw_stage
*,
54 struct prim_header
* );
56 void (*line
)( struct draw_stage
*,
57 struct prim_header
* );
59 void (*tri
)( struct draw_stage
*,
60 struct prim_header
* );
62 void (*flush
)( struct draw_stage
*,
65 void (*reset_stipple_counter
)( struct draw_stage
* );
67 void (*destroy
)( struct draw_stage
* );
71 extern struct draw_stage
*draw_unfilled_stage( struct draw_context
*context
);
72 extern struct draw_stage
*draw_twoside_stage( struct draw_context
*context
);
73 extern struct draw_stage
*draw_offset_stage( struct draw_context
*context
);
74 extern struct draw_stage
*draw_clip_stage( struct draw_context
*context
);
75 extern struct draw_stage
*draw_flatshade_stage( struct draw_context
*context
);
76 extern struct draw_stage
*draw_cull_stage( struct draw_context
*context
);
77 extern struct draw_stage
*draw_stipple_stage( struct draw_context
*context
);
78 extern struct draw_stage
*draw_wide_line_stage( struct draw_context
*context
);
79 extern struct draw_stage
*draw_wide_point_stage( struct draw_context
*context
);
80 extern struct draw_stage
*draw_validate_stage( struct draw_context
*context
);
83 extern void draw_free_temp_verts( struct draw_stage
*stage
);
84 extern void draw_alloc_temp_verts( struct draw_stage
*stage
, unsigned nr
);
86 extern void draw_reset_vertex_ids( struct draw_context
*draw
);
91 * Get a writeable copy of a vertex.
92 * \param stage drawing stage info
93 * \param vert the vertex to copy (source)
94 * \param idx index into stage's tmp[] array to put the copy (dest)
95 * \return pointer to the copied vertex
97 static INLINE
struct vertex_header
*
98 dup_vert( struct draw_stage
*stage
,
99 const struct vertex_header
*vert
,
102 struct vertex_header
*tmp
= stage
->tmp
[idx
];
103 const uint vsize
= sizeof(struct vertex_header
)
104 + stage
->draw
->num_vs_outputs
* 4 * sizeof(float);
105 memcpy(tmp
, vert
, vsize
);
106 tmp
->vertex_id
= UNDEFINED_VERTEX_ID
;