draw: associate rhw divide with clipping not viewport flag
[mesa.git] / src / gallium / auxiliary / draw / draw_vertex.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 * Post-transform vertex format info. The vertex_info struct is used by
30 * the draw_vbuf code to emit hardware-specific vertex layouts into hw
31 * vertex buffers.
32 *
33 * Author:
34 * Brian Paul
35 */
36
37
38 #ifndef DRAW_VERTEX_H
39 #define DRAW_VERTEX_H
40
41
42 #include "pipe/p_state.h"
43
44
45 /**
46 * Vertex attribute emit modes
47 */
48 enum attrib_emit {
49 EMIT_OMIT, /**< don't emit the attribute */
50 EMIT_ALL, /**< emit whole post-xform vertex, w/ header */
51 EMIT_HEADER, /**< emit vertex_header struct (XXX temp?) */
52 EMIT_1F,
53 EMIT_1F_PSIZE, /**< insert constant point size */
54 EMIT_2F,
55 EMIT_3F,
56 EMIT_4F,
57 EMIT_4UB /**< XXX may need variations for RGBA vs BGRA, etc */
58 };
59
60
61 /**
62 * Attribute interpolation mode
63 */
64 enum interp_mode {
65 INTERP_NONE, /**< never interpolate vertex header info */
66 INTERP_POS, /**< special case for frag position */
67 INTERP_CONSTANT,
68 INTERP_LINEAR,
69 INTERP_PERSPECTIVE
70 };
71
72
73 /**
74 * Information about hardware/rasterization vertex layout.
75 */
76 struct vertex_info
77 {
78 uint num_attribs;
79 uint hwfmt[4]; /**< hardware format info for this format */
80 enum interp_mode interp_mode[PIPE_MAX_SHADER_INPUTS];
81 enum attrib_emit emit[PIPE_MAX_SHADER_INPUTS]; /**< EMIT_x */
82 uint src_index[PIPE_MAX_SHADER_INPUTS]; /**< map to post-xform attribs */
83 uint size; /**< total vertex size in dwords */
84 };
85
86
87
88 /**
89 * Add another attribute to the given vertex_info object.
90 * \param src_index indicates which post-transformed vertex attrib slot
91 * corresponds to this attribute.
92 * \return slot in which the attribute was added
93 */
94 static INLINE uint
95 draw_emit_vertex_attr(struct vertex_info *vinfo,
96 enum attrib_emit emit, enum interp_mode interp,
97 uint src_index)
98 {
99 const uint n = vinfo->num_attribs;
100 assert(n < PIPE_MAX_SHADER_INPUTS);
101 vinfo->emit[n] = emit;
102 vinfo->interp_mode[n] = interp;
103 vinfo->src_index[n] = src_index;
104 vinfo->num_attribs++;
105 return n;
106 }
107
108
109 extern void draw_compute_vertex_size(struct vertex_info *vinfo);
110
111
112 #endif /* DRAW_VERTEX_H */