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 **************************************************************************/
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
42 #include "pipe/p_state.h"
46 * Vertex attribute emit modes
49 EMIT_OMIT
, /**< don't emit the attribute */
51 EMIT_1F_PSIZE
, /**< insert constant point size */
55 EMIT_4UB
/**< XXX may need variations for RGBA vs BGRA, etc */
60 * Attribute interpolation mode
63 INTERP_NONE
, /**< never interpolate vertex header info */
64 INTERP_POS
, /**< special case for frag position */
72 * Information about hardware/rasterization vertex layout.
77 uint hwfmt
[4]; /**< hardware format info for this format */
78 uint size
; /**< total vertex size in dwords */
80 /* Keep this small and at the end of the struct to allow quick
81 * memcmp() comparisons.
84 ubyte interp_mode
:4; /**< INTERP_x */
85 ubyte emit
:4; /**< EMIT_x */
86 ubyte src_index
; /**< map to post-xform attribs */
87 } attrib
[PIPE_MAX_SHADER_INPUTS
];
91 draw_vinfo_size( const struct vertex_info
*a
)
93 return ((const char *)&a
->attrib
[a
->num_attribs
] -
98 draw_vinfo_compare( const struct vertex_info
*a
,
99 const struct vertex_info
*b
)
101 unsigned sizea
= draw_vinfo_size( a
);
102 return memcmp( a
, b
, sizea
);
106 draw_vinfo_copy( struct vertex_info
*dst
,
107 const struct vertex_info
*src
)
109 unsigned size
= draw_vinfo_size( src
);
110 memcpy( dst
, src
, size
);
116 * Add another attribute to the given vertex_info object.
117 * \param src_index indicates which post-transformed vertex attrib slot
118 * corresponds to this attribute.
119 * \return slot in which the attribute was added
122 draw_emit_vertex_attr(struct vertex_info
*vinfo
,
123 enum attrib_emit emit
,
124 enum interp_mode interp
, /* only used by softpipe??? */
127 const uint n
= vinfo
->num_attribs
;
128 assert(n
< PIPE_MAX_SHADER_INPUTS
);
129 vinfo
->attrib
[n
].emit
= emit
;
130 vinfo
->attrib
[n
].interp_mode
= interp
;
131 vinfo
->attrib
[n
].src_index
= src_index
;
132 vinfo
->num_attribs
++;
137 extern void draw_compute_vertex_size(struct vertex_info
*vinfo
);
139 void draw_dump_emitted_vertex(const struct vertex_info
*vinfo
,
140 const uint8_t *data
);
143 static INLINE
unsigned draw_translate_vinfo_format(unsigned format
)
148 return PIPE_FORMAT_R32_FLOAT
;
150 return PIPE_FORMAT_R32G32_FLOAT
;
152 return PIPE_FORMAT_R32G32B32_FLOAT
;
154 return PIPE_FORMAT_R32G32B32A32_FLOAT
;
156 return PIPE_FORMAT_R8G8B8A8_UNORM
;
158 return PIPE_FORMAT_NONE
;
163 #endif /* DRAW_VERTEX_H */