2 * Copyright 2009 VMware, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "pipe/p_compiler.h"
29 #include "pipe/p_defines.h"
31 /* First/last provoking vertex */
36 /* primitive restart disable/enable flags */
43 * Index translator function (for glDrawElements() case)
45 * \param in the input index buffer
46 * \param start the index of the first vertex (pipe_draw_info::start)
47 * \param nr the number of vertices (pipe_draw_info::count)
48 * \param out output buffer big enough for nr vertices (of
49 * @out_index_size bytes each)
51 typedef void (*u_translate_func
)( const void *in
,
55 unsigned restart_index
,
59 * Index generator function (for glDrawArrays() case)
61 * \param start the index of the first vertex (pipe_draw_info::start)
62 * \param nr the number of vertices (pipe_draw_info::count)
63 * \param out output buffer big enough for nr vertices (of
64 * @out_index_size bytes each)
66 typedef void (*u_generate_func
)( unsigned start
,
71 /* Return codes describe the translate/generate operation. Caller may
72 * be able to reuse translated indices under some circumstances.
75 U_TRANSLATE_ERROR
= -1,
76 U_TRANSLATE_NORMAL
= 1,
77 U_TRANSLATE_MEMCPY
= 2,
78 U_GENERATE_LINEAR
= 3,
79 U_GENERATE_REUSABLE
= 4,
80 U_GENERATE_ONE_OFF
= 5,
83 void u_index_init( void );
87 * For indexed drawing, this function determines what kind of primitive
88 * transformation is needed (if any) for handling:
89 * - unsupported primitive types (such as PIPE_PRIM_POLYGON)
90 * - changing the provoking vertex
92 * - index size (1 byte, 2 byte or 4 byte indexes)
95 u_index_translator(unsigned hw_mask
,
96 enum pipe_prim_type prim
,
97 unsigned in_index_size
,
99 unsigned in_pv
, /* API */
100 unsigned out_pv
, /* hardware */
101 unsigned prim_restart
,
102 enum pipe_prim_type
*out_prim
,
103 unsigned *out_index_size
,
105 u_translate_func
*out_translate
);
109 * For non-indexed drawing, this function determines what kind of primitive
110 * transformation is needed (see above).
112 * Note that even when generating it is necessary to know what the
113 * API's PV is, as the indices generated will depend on whether it is
114 * the same as hardware or not, and in the case of triangle strips,
115 * whether it is first or last.
118 u_index_generator(unsigned hw_mask
,
119 enum pipe_prim_type prim
,
122 unsigned in_pv
, /* API */
123 unsigned out_pv
, /* hardware */
124 enum pipe_prim_type
*out_prim
,
125 unsigned *out_index_size
,
127 u_generate_func
*out_generate
);
130 void u_unfilled_init( void );
133 * If the driver can't handle "unfilled" primitives (i.e. drawing triangle
134 * primitives as 3 lines or 3 points) this function can be used to translate
135 * an indexed primitive into a new indexed primitive to draw as lines or
139 u_unfilled_translator(enum pipe_prim_type prim
,
140 unsigned in_index_size
,
142 unsigned unfilled_mode
,
143 enum pipe_prim_type
*out_prim
,
144 unsigned *out_index_size
,
146 u_translate_func
*out_translate
);
149 * As above, but for non-indexed (array) primitives.
152 u_unfilled_generator(enum pipe_prim_type prim
,
155 unsigned unfilled_mode
,
156 enum pipe_prim_type
*out_prim
,
157 unsigned *out_index_size
,
159 u_generate_func
*out_generate
);