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"
34 /* primitive restart disable/enable flags */
39 * Index translator function (for glDrawElements() case)
41 * \param in the input index buffer
42 * \param start the index of the first vertex (pipe_draw_info::start)
43 * \param nr the number of vertices (pipe_draw_info::count)
44 * \param out output buffer big enough or nr vertices (of
45 * @out_index_size bytes each)
47 typedef void (*u_translate_func
)( const void *in
,
51 unsigned restart_index
,
55 * Index generator function (for glDrawArrays() case)
57 * \param start the index of the first vertex (pipe_draw_info::start)
58 * \param nr the number of vertices (pipe_draw_info::count)
59 * \param out output buffer big enough or nr vertices (of
60 * @out_index_size bytes each)
62 typedef void (*u_generate_func
)( unsigned start
,
67 /* Return codes describe the translate/generate operation. Caller may
68 * be able to reuse translated indices under some circumstances.
70 #define U_TRANSLATE_ERROR -1
71 #define U_TRANSLATE_NORMAL 1
72 #define U_TRANSLATE_MEMCPY 2
73 #define U_GENERATE_LINEAR 3
74 #define U_GENERATE_REUSABLE 4
75 #define U_GENERATE_ONE_OFF 5
78 void u_index_init( void );
80 int u_index_translator( unsigned hw_mask
,
82 unsigned in_index_size
,
84 unsigned in_pv
, /* API */
85 unsigned out_pv
, /* hardware */
86 unsigned prim_restart
,
88 unsigned *out_index_size
,
90 u_translate_func
*out_translate
);
92 /* Note that even when generating it is necessary to know what the
93 * API's PV is, as the indices generated will depend on whether it is
94 * the same as hardware or not, and in the case of triangle strips,
95 * whether it is first or last.
97 int u_index_generator( unsigned hw_mask
,
101 unsigned in_pv
, /* API */
102 unsigned out_pv
, /* hardware */
104 unsigned *out_index_size
,
106 u_generate_func
*out_generate
);
109 void u_unfilled_init( void );
111 int u_unfilled_translator( unsigned prim
,
112 unsigned in_index_size
,
114 unsigned unfilled_mode
,
116 unsigned *out_index_size
,
118 u_translate_func
*out_translate
);
120 int u_unfilled_generator( unsigned prim
,
123 unsigned unfilled_mode
,
125 unsigned *out_index_size
,
127 u_generate_func
*out_generate
);