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 * TUNGSTEN GRAPHICS 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
34typedef void (*u_translate_func)( const void *in,
35                                  unsigned nr,
36                                  void *out );
37
38typedef void (*u_generate_func)( unsigned nr,
39                                 void *out );
40
41
42/* Return codes describe the translate/generate operation.  Caller may
43 * be able to reuse translated indices under some circumstances.
44 */
45#define U_TRANSLATE_ERROR  -1
46#define U_TRANSLATE_NORMAL  1
47#define U_TRANSLATE_MEMCPY  2
48#define U_GENERATE_LINEAR   3
49#define U_GENERATE_REUSABLE 4
50#define U_GENERATE_ONE_OFF  5
51
52
53void u_index_init( void );
54
55int u_index_translator( unsigned hw_mask,
56                        unsigned prim,
57                        unsigned in_index_size,
58                        unsigned nr,
59                        unsigned in_pv,   /* API */
60                        unsigned out_pv,  /* hardware */
61                        unsigned *out_prim,
62                        unsigned *out_index_size,
63                        unsigned *out_nr,
64                        u_translate_func *out_translate );
65
66/* Note that even when generating it is necessary to know what the
67 * API's PV is, as the indices generated will depend on whether it is
68 * the same as hardware or not, and in the case of triangle strips,
69 * whether it is first or last.
70 */
71int u_index_generator( unsigned hw_mask,
72                       unsigned prim,
73                       unsigned start,
74                       unsigned nr,
75                       unsigned in_pv,   /* API */
76                       unsigned out_pv,  /* hardware */
77                       unsigned *out_prim,
78                       unsigned *out_index_size,
79                       unsigned *out_nr,
80                       u_generate_func *out_generate );
81
82
83void u_unfilled_init( void );
84
85int u_unfilled_translator( unsigned prim,
86                           unsigned in_index_size,
87                           unsigned nr,
88                           unsigned unfilled_mode,
89                           unsigned *out_prim,
90                           unsigned *out_index_size,
91                           unsigned *out_nr,
92                           u_translate_func *out_translate );
93
94int u_unfilled_generator( unsigned prim,
95                          unsigned start,
96                          unsigned nr,
97                          unsigned unfilled_mode,
98                          unsigned *out_prim,
99                          unsigned *out_index_size,
100                          unsigned *out_nr,
101                          u_generate_func *out_generate );
102
103
104
105
106#endif
107