Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5564 | serge | 1 | /* |
2 | * Copyright 2009 VMware, Inc. |
||
3 | * All Rights Reserved. |
||
4 | * |
||
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: |
||
11 | * |
||
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 |
||
14 | * Software. |
||
15 | * |
||
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. |
||
23 | */ |
||
24 | |||
25 | #ifndef U_INDICES_H |
||
26 | #define U_INDICES_H |
||
27 | |||
28 | #include "pipe/p_compiler.h" |
||
29 | |||
30 | #define PV_FIRST 0 |
||
31 | #define PV_LAST 1 |
||
32 | #define PV_COUNT 2 |
||
33 | |||
34 | /* primitive restart disable/enable flags */ |
||
35 | #define PR_DISABLE 0 |
||
36 | #define PR_ENABLE 1 |
||
37 | #define PR_COUNT 2 |
||
38 | /** |
||
39 | * Index translator function (for glDrawElements() case) |
||
40 | * |
||
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) |
||
46 | */ |
||
47 | typedef void (*u_translate_func)( const void *in, |
||
48 | unsigned start, |
||
49 | unsigned in_nr, |
||
50 | unsigned out_nr, |
||
51 | unsigned restart_index, |
||
52 | void *out ); |
||
53 | |||
54 | /** |
||
55 | * Index generator function (for glDrawArrays() case) |
||
56 | * |
||
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) |
||
61 | */ |
||
62 | typedef void (*u_generate_func)( unsigned start, |
||
63 | unsigned nr, |
||
64 | void *out ); |
||
65 | |||
66 | |||
67 | /* Return codes describe the translate/generate operation. Caller may |
||
68 | * be able to reuse translated indices under some circumstances. |
||
69 | */ |
||
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 |
||
76 | |||
77 | |||
78 | void u_index_init( void ); |
||
79 | |||
80 | int u_index_translator( unsigned hw_mask, |
||
81 | unsigned prim, |
||
82 | unsigned in_index_size, |
||
83 | unsigned nr, |
||
84 | unsigned in_pv, /* API */ |
||
85 | unsigned out_pv, /* hardware */ |
||
86 | unsigned prim_restart, |
||
87 | unsigned *out_prim, |
||
88 | unsigned *out_index_size, |
||
89 | unsigned *out_nr, |
||
90 | u_translate_func *out_translate ); |
||
91 | |||
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. |
||
96 | */ |
||
97 | int u_index_generator( unsigned hw_mask, |
||
98 | unsigned prim, |
||
99 | unsigned start, |
||
100 | unsigned nr, |
||
101 | unsigned in_pv, /* API */ |
||
102 | unsigned out_pv, /* hardware */ |
||
103 | unsigned *out_prim, |
||
104 | unsigned *out_index_size, |
||
105 | unsigned *out_nr, |
||
106 | u_generate_func *out_generate ); |
||
107 | |||
108 | |||
109 | void u_unfilled_init( void ); |
||
110 | |||
111 | int u_unfilled_translator( unsigned prim, |
||
112 | unsigned in_index_size, |
||
113 | unsigned nr, |
||
114 | unsigned unfilled_mode, |
||
115 | unsigned *out_prim, |
||
116 | unsigned *out_index_size, |
||
117 | unsigned *out_nr, |
||
118 | u_translate_func *out_translate ); |
||
119 | |||
120 | int u_unfilled_generator( unsigned prim, |
||
121 | unsigned start, |
||
122 | unsigned nr, |
||
123 | unsigned unfilled_mode, |
||
124 | unsigned *out_prim, |
||
125 | unsigned *out_index_size, |
||
126 | unsigned *out_nr, |
||
127 | u_generate_func *out_generate ); |
||
128 | |||
129 | |||
130 | |||
131 | |||
132 | #endif |