1e64d31b9Smaya/* File automatically generated by u_unfilled_gen.py */
2e64d31b9Smaya
3e64d31b9Smaya/*
4e64d31b9Smaya * Copyright 2009 VMware, Inc.
5e64d31b9Smaya * All Rights Reserved.
6e64d31b9Smaya *
7e64d31b9Smaya * Permission is hereby granted, free of charge, to any person obtaining a
8e64d31b9Smaya * copy of this software and associated documentation files (the "Software"),
9e64d31b9Smaya * to deal in the Software without restriction, including without limitation
10e64d31b9Smaya * on the rights to use, copy, modify, merge, publish, distribute, sub
11e64d31b9Smaya * license, and/or sell copies of the Software, and to permit persons to whom
12e64d31b9Smaya * the Software is furnished to do so, subject to the following conditions:
13e64d31b9Smaya *
14e64d31b9Smaya * The above copyright notice and this permission notice (including the next
15e64d31b9Smaya * paragraph) shall be included in all copies or substantial portions of the
16e64d31b9Smaya * Software.
17e64d31b9Smaya *
18e64d31b9Smaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19e64d31b9Smaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20e64d31b9Smaya * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
21e64d31b9Smaya * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22e64d31b9Smaya * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23e64d31b9Smaya * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24e64d31b9Smaya * USE OR OTHER DEALINGS IN THE SOFTWARE.
25e64d31b9Smaya */
26e64d31b9Smaya
27e64d31b9Smaya
28e64d31b9Smaya
29e64d31b9Smaya/**
30e64d31b9Smaya * @file
31e64d31b9Smaya * Functions to translate and generate index lists
32e64d31b9Smaya */
33e64d31b9Smaya
34e64d31b9Smaya#include "indices/u_indices.h"
35e64d31b9Smaya#include "indices/u_indices_priv.h"
36e64d31b9Smaya#include "pipe/p_compiler.h"
37e64d31b9Smaya#include "util/u_debug.h"
38e64d31b9Smaya#include "pipe/p_defines.h"
39e64d31b9Smaya#include "util/u_memory.h"
40e64d31b9Smaya
41e64d31b9Smaya
42e64d31b9Smayastatic unsigned out_size_idx( unsigned index_size )
43e64d31b9Smaya{
44e64d31b9Smaya   switch (index_size) {
45e64d31b9Smaya   case 4: return OUT_UINT;
46e64d31b9Smaya   case 2: return OUT_USHORT;
47e64d31b9Smaya   default: assert(0); return OUT_USHORT;
48e64d31b9Smaya   }
49e64d31b9Smaya}
50e64d31b9Smaya
51e64d31b9Smayastatic unsigned in_size_idx( unsigned index_size )
52e64d31b9Smaya{
53e64d31b9Smaya   switch (index_size) {
54e64d31b9Smaya   case 4: return IN_UINT;
55e64d31b9Smaya   case 2: return IN_USHORT;
56e64d31b9Smaya   case 1: return IN_UBYTE;
57e64d31b9Smaya   default: assert(0); return IN_UBYTE;
58e64d31b9Smaya   }
59e64d31b9Smaya}
60e64d31b9Smaya
61e64d31b9Smaya
62e64d31b9Smayastatic u_generate_func generate_line[OUT_COUNT][PRIM_COUNT];
63e64d31b9Smayastatic u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT];
64e64d31b9Smaya
65e64d31b9Smaya
66e64d31b9Smayastatic void generate_tris_ushort(
67e64d31b9Smaya    unsigned start,
68e64d31b9Smaya    unsigned out_nr,
69e64d31b9Smaya    void *_out )
70e64d31b9Smaya{
71e64d31b9Smaya  ushort *out = (ushort*)_out;
72e64d31b9Smaya  unsigned i, j;
73e64d31b9Smaya  (void)j;
74e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=3) {
75e64d31b9Smaya      (out+j)[0] = (ushort)(i);
76e64d31b9Smaya      (out+j)[1] = (ushort)(i+1);
77e64d31b9Smaya      (out+j+2)[0] = (ushort)(i+1);
78e64d31b9Smaya      (out+j+2)[1] = (ushort)(i+2);
79e64d31b9Smaya      (out+j+4)[0] = (ushort)(i+2);
80e64d31b9Smaya      (out+j+4)[1] = (ushort)(i);
81e64d31b9Smaya   }
82e64d31b9Smaya}
83e64d31b9Smayastatic void generate_tristrip_ushort(
84e64d31b9Smaya    unsigned start,
85e64d31b9Smaya    unsigned out_nr,
86e64d31b9Smaya    void *_out )
87e64d31b9Smaya{
88e64d31b9Smaya  ushort *out = (ushort*)_out;
89e64d31b9Smaya  unsigned i, j;
90e64d31b9Smaya  (void)j;
91e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
92e64d31b9Smaya      (out+j)[0] = (ushort)(i);
93e64d31b9Smaya      (out+j)[1] = (ushort)(i+1/*+(i&1)*/);
94e64d31b9Smaya      (out+j+2)[0] = (ushort)(i+1/*+(i&1)*/);
95e64d31b9Smaya      (out+j+2)[1] = (ushort)(i+2/*-(i&1)*/);
96e64d31b9Smaya      (out+j+4)[0] = (ushort)(i+2/*-(i&1)*/);
97e64d31b9Smaya      (out+j+4)[1] = (ushort)(i);
98e64d31b9Smaya   }
99e64d31b9Smaya}
100e64d31b9Smayastatic void generate_trifan_ushort(
101e64d31b9Smaya    unsigned start,
102e64d31b9Smaya    unsigned out_nr,
103e64d31b9Smaya    void *_out )
104e64d31b9Smaya{
105e64d31b9Smaya  ushort *out = (ushort*)_out;
106e64d31b9Smaya  unsigned i, j;
107e64d31b9Smaya  (void)j;
108e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
109e64d31b9Smaya      (out+j)[0] = (ushort)(0);
110e64d31b9Smaya      (out+j)[1] = (ushort)(i+1);
111e64d31b9Smaya      (out+j+2)[0] = (ushort)(i+1);
112e64d31b9Smaya      (out+j+2)[1] = (ushort)(i+2);
113e64d31b9Smaya      (out+j+4)[0] = (ushort)(i+2);
114e64d31b9Smaya      (out+j+4)[1] = (ushort)(0);
115e64d31b9Smaya   }
116e64d31b9Smaya}
117e64d31b9Smayastatic void generate_quads_ushort(
118e64d31b9Smaya    unsigned start,
119e64d31b9Smaya    unsigned out_nr,
120e64d31b9Smaya    void *_out )
121e64d31b9Smaya{
122e64d31b9Smaya  ushort *out = (ushort*)_out;
123e64d31b9Smaya  unsigned i, j;
124e64d31b9Smaya  (void)j;
125e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=4) {
126e64d31b9Smaya      (out+j)[0] = (ushort)(i+0);
127e64d31b9Smaya      (out+j)[1] = (ushort)(i+1);
128e64d31b9Smaya      (out+j+2)[0] = (ushort)(i+1);
129e64d31b9Smaya      (out+j+2)[1] = (ushort)(i+2);
130e64d31b9Smaya      (out+j+4)[0] = (ushort)(i+2);
131e64d31b9Smaya      (out+j+4)[1] = (ushort)(i+3);
132e64d31b9Smaya      (out+j+6)[0] = (ushort)(i+3);
133e64d31b9Smaya      (out+j+6)[1] = (ushort)(i+0);
134e64d31b9Smaya   }
135e64d31b9Smaya}
136e64d31b9Smayastatic void generate_quadstrip_ushort(
137e64d31b9Smaya    unsigned start,
138e64d31b9Smaya    unsigned out_nr,
139e64d31b9Smaya    void *_out )
140e64d31b9Smaya{
141e64d31b9Smaya  ushort *out = (ushort*)_out;
142e64d31b9Smaya  unsigned i, j;
143e64d31b9Smaya  (void)j;
144e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=2) {
145e64d31b9Smaya      (out+j)[0] = (ushort)(i+2);
146e64d31b9Smaya      (out+j)[1] = (ushort)(i+0);
147e64d31b9Smaya      (out+j+2)[0] = (ushort)(i+0);
148e64d31b9Smaya      (out+j+2)[1] = (ushort)(i+1);
149e64d31b9Smaya      (out+j+4)[0] = (ushort)(i+1);
150e64d31b9Smaya      (out+j+4)[1] = (ushort)(i+3);
151e64d31b9Smaya      (out+j+6)[0] = (ushort)(i+3);
152e64d31b9Smaya      (out+j+6)[1] = (ushort)(i+2);
153e64d31b9Smaya   }
154e64d31b9Smaya}
155e64d31b9Smayastatic void generate_polygon_ushort(
156e64d31b9Smaya    unsigned start,
157e64d31b9Smaya    unsigned out_nr,
158e64d31b9Smaya    void *_out )
159e64d31b9Smaya{
160e64d31b9Smaya  ushort *out = (ushort*)_out;
161e64d31b9Smaya  unsigned i, j;
162e64d31b9Smaya  (void)j;
163e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=2, i++) {
164e64d31b9Smaya      (out+j)[0] = (ushort)(i);
165e64d31b9Smaya      (out+j)[1] = (ushort)((i+1)%(out_nr/2));
166e64d31b9Smaya   }
167e64d31b9Smaya}
168e64d31b9Smayastatic void generate_trisadj_ushort(
169e64d31b9Smaya    unsigned start,
170e64d31b9Smaya    unsigned out_nr,
171e64d31b9Smaya    void *_out )
172e64d31b9Smaya{
173e64d31b9Smaya  ushort *out = (ushort*)_out;
174e64d31b9Smaya  unsigned i, j;
175e64d31b9Smaya  (void)j;
176e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=6) {
177e64d31b9Smaya      (out+j)[0] = (ushort)(i);
178e64d31b9Smaya      (out+j)[1] = (ushort)(i+2);
179e64d31b9Smaya      (out+j+2)[0] = (ushort)(i+2);
180e64d31b9Smaya      (out+j+2)[1] = (ushort)(i+4);
181e64d31b9Smaya      (out+j+4)[0] = (ushort)(i+4);
182e64d31b9Smaya      (out+j+4)[1] = (ushort)(i);
183e64d31b9Smaya   }
184e64d31b9Smaya}
185e64d31b9Smayastatic void generate_tristripadj_ushort(
186e64d31b9Smaya    unsigned start,
187e64d31b9Smaya    unsigned out_nr,
188e64d31b9Smaya    void *_out )
189e64d31b9Smaya{
190e64d31b9Smaya  ushort *out = (ushort*)_out;
191e64d31b9Smaya  unsigned i, j;
192e64d31b9Smaya  (void)j;
193e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=2) {
194e64d31b9Smaya      (out+j)[0] = (ushort)(i);
195e64d31b9Smaya      (out+j)[1] = (ushort)(i+2);
196e64d31b9Smaya      (out+j+2)[0] = (ushort)(i+2);
197e64d31b9Smaya      (out+j+2)[1] = (ushort)(i+4);
198e64d31b9Smaya      (out+j+4)[0] = (ushort)(i+4);
199e64d31b9Smaya      (out+j+4)[1] = (ushort)(i);
200e64d31b9Smaya   }
201e64d31b9Smaya}
202e64d31b9Smayastatic void generate_tris_uint(
203e64d31b9Smaya    unsigned start,
204e64d31b9Smaya    unsigned out_nr,
205e64d31b9Smaya    void *_out )
206e64d31b9Smaya{
207e64d31b9Smaya  uint *out = (uint*)_out;
208e64d31b9Smaya  unsigned i, j;
209e64d31b9Smaya  (void)j;
210e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=3) {
211e64d31b9Smaya      (out+j)[0] = (uint)(i);
212e64d31b9Smaya      (out+j)[1] = (uint)(i+1);
213e64d31b9Smaya      (out+j+2)[0] = (uint)(i+1);
214e64d31b9Smaya      (out+j+2)[1] = (uint)(i+2);
215e64d31b9Smaya      (out+j+4)[0] = (uint)(i+2);
216e64d31b9Smaya      (out+j+4)[1] = (uint)(i);
217e64d31b9Smaya   }
218e64d31b9Smaya}
219e64d31b9Smayastatic void generate_tristrip_uint(
220e64d31b9Smaya    unsigned start,
221e64d31b9Smaya    unsigned out_nr,
222e64d31b9Smaya    void *_out )
223e64d31b9Smaya{
224e64d31b9Smaya  uint *out = (uint*)_out;
225e64d31b9Smaya  unsigned i, j;
226e64d31b9Smaya  (void)j;
227e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
228e64d31b9Smaya      (out+j)[0] = (uint)(i);
229e64d31b9Smaya      (out+j)[1] = (uint)(i+1/*+(i&1)*/);
230e64d31b9Smaya      (out+j+2)[0] = (uint)(i+1/*+(i&1)*/);
231e64d31b9Smaya      (out+j+2)[1] = (uint)(i+2/*-(i&1)*/);
232e64d31b9Smaya      (out+j+4)[0] = (uint)(i+2/*-(i&1)*/);
233e64d31b9Smaya      (out+j+4)[1] = (uint)(i);
234e64d31b9Smaya   }
235e64d31b9Smaya}
236e64d31b9Smayastatic void generate_trifan_uint(
237e64d31b9Smaya    unsigned start,
238e64d31b9Smaya    unsigned out_nr,
239e64d31b9Smaya    void *_out )
240e64d31b9Smaya{
241e64d31b9Smaya  uint *out = (uint*)_out;
242e64d31b9Smaya  unsigned i, j;
243e64d31b9Smaya  (void)j;
244e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
245e64d31b9Smaya      (out+j)[0] = (uint)(0);
246e64d31b9Smaya      (out+j)[1] = (uint)(i+1);
247e64d31b9Smaya      (out+j+2)[0] = (uint)(i+1);
248e64d31b9Smaya      (out+j+2)[1] = (uint)(i+2);
249e64d31b9Smaya      (out+j+4)[0] = (uint)(i+2);
250e64d31b9Smaya      (out+j+4)[1] = (uint)(0);
251e64d31b9Smaya   }
252e64d31b9Smaya}
253e64d31b9Smayastatic void generate_quads_uint(
254e64d31b9Smaya    unsigned start,
255e64d31b9Smaya    unsigned out_nr,
256e64d31b9Smaya    void *_out )
257e64d31b9Smaya{
258e64d31b9Smaya  uint *out = (uint*)_out;
259e64d31b9Smaya  unsigned i, j;
260e64d31b9Smaya  (void)j;
261e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=4) {
262e64d31b9Smaya      (out+j)[0] = (uint)(i+0);
263e64d31b9Smaya      (out+j)[1] = (uint)(i+1);
264e64d31b9Smaya      (out+j+2)[0] = (uint)(i+1);
265e64d31b9Smaya      (out+j+2)[1] = (uint)(i+2);
266e64d31b9Smaya      (out+j+4)[0] = (uint)(i+2);
267e64d31b9Smaya      (out+j+4)[1] = (uint)(i+3);
268e64d31b9Smaya      (out+j+6)[0] = (uint)(i+3);
269e64d31b9Smaya      (out+j+6)[1] = (uint)(i+0);
270e64d31b9Smaya   }
271e64d31b9Smaya}
272e64d31b9Smayastatic void generate_quadstrip_uint(
273e64d31b9Smaya    unsigned start,
274e64d31b9Smaya    unsigned out_nr,
275e64d31b9Smaya    void *_out )
276e64d31b9Smaya{
277e64d31b9Smaya  uint *out = (uint*)_out;
278e64d31b9Smaya  unsigned i, j;
279e64d31b9Smaya  (void)j;
280e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=2) {
281e64d31b9Smaya      (out+j)[0] = (uint)(i+2);
282e64d31b9Smaya      (out+j)[1] = (uint)(i+0);
283e64d31b9Smaya      (out+j+2)[0] = (uint)(i+0);
284e64d31b9Smaya      (out+j+2)[1] = (uint)(i+1);
285e64d31b9Smaya      (out+j+4)[0] = (uint)(i+1);
286e64d31b9Smaya      (out+j+4)[1] = (uint)(i+3);
287e64d31b9Smaya      (out+j+6)[0] = (uint)(i+3);
288e64d31b9Smaya      (out+j+6)[1] = (uint)(i+2);
289e64d31b9Smaya   }
290e64d31b9Smaya}
291e64d31b9Smayastatic void generate_polygon_uint(
292e64d31b9Smaya    unsigned start,
293e64d31b9Smaya    unsigned out_nr,
294e64d31b9Smaya    void *_out )
295e64d31b9Smaya{
296e64d31b9Smaya  uint *out = (uint*)_out;
297e64d31b9Smaya  unsigned i, j;
298e64d31b9Smaya  (void)j;
299e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=2, i++) {
300e64d31b9Smaya      (out+j)[0] = (uint)(i);
301e64d31b9Smaya      (out+j)[1] = (uint)((i+1)%(out_nr/2));
302e64d31b9Smaya   }
303e64d31b9Smaya}
304e64d31b9Smayastatic void generate_trisadj_uint(
305e64d31b9Smaya    unsigned start,
306e64d31b9Smaya    unsigned out_nr,
307e64d31b9Smaya    void *_out )
308e64d31b9Smaya{
309e64d31b9Smaya  uint *out = (uint*)_out;
310e64d31b9Smaya  unsigned i, j;
311e64d31b9Smaya  (void)j;
312e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=6) {
313e64d31b9Smaya      (out+j)[0] = (uint)(i);
314e64d31b9Smaya      (out+j)[1] = (uint)(i+2);
315e64d31b9Smaya      (out+j+2)[0] = (uint)(i+2);
316e64d31b9Smaya      (out+j+2)[1] = (uint)(i+4);
317e64d31b9Smaya      (out+j+4)[0] = (uint)(i+4);
318e64d31b9Smaya      (out+j+4)[1] = (uint)(i);
319e64d31b9Smaya   }
320e64d31b9Smaya}
321e64d31b9Smayastatic void generate_tristripadj_uint(
322e64d31b9Smaya    unsigned start,
323e64d31b9Smaya    unsigned out_nr,
324e64d31b9Smaya    void *_out )
325e64d31b9Smaya{
326e64d31b9Smaya  uint *out = (uint*)_out;
327e64d31b9Smaya  unsigned i, j;
328e64d31b9Smaya  (void)j;
329e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=2) {
330e64d31b9Smaya      (out+j)[0] = (uint)(i);
331e64d31b9Smaya      (out+j)[1] = (uint)(i+2);
332e64d31b9Smaya      (out+j+2)[0] = (uint)(i+2);
333e64d31b9Smaya      (out+j+2)[1] = (uint)(i+4);
334e64d31b9Smaya      (out+j+4)[0] = (uint)(i+4);
335e64d31b9Smaya      (out+j+4)[1] = (uint)(i);
336e64d31b9Smaya   }
337e64d31b9Smaya}
338e64d31b9Smayastatic void translate_tris_ubyte2ushort(
339e64d31b9Smaya    const void * _in,
340e64d31b9Smaya    unsigned start,
341e64d31b9Smaya    unsigned in_nr,
342e64d31b9Smaya    unsigned out_nr,
343e64d31b9Smaya    unsigned restart_index,
344e64d31b9Smaya    void *_out )
345e64d31b9Smaya{
346e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
347e64d31b9Smaya  ushort *out = (ushort*)_out;
348e64d31b9Smaya  unsigned i, j;
349e64d31b9Smaya  (void)j;
350e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=3) {
351e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
352e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
353e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
354e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
355e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
356e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
357e64d31b9Smaya   }
358e64d31b9Smaya}
359e64d31b9Smayastatic void translate_tristrip_ubyte2ushort(
360e64d31b9Smaya    const void * _in,
361e64d31b9Smaya    unsigned start,
362e64d31b9Smaya    unsigned in_nr,
363e64d31b9Smaya    unsigned out_nr,
364e64d31b9Smaya    unsigned restart_index,
365e64d31b9Smaya    void *_out )
366e64d31b9Smaya{
367e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
368e64d31b9Smaya  ushort *out = (ushort*)_out;
369e64d31b9Smaya  unsigned i, j;
370e64d31b9Smaya  (void)j;
371e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
372e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
373e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
374e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
375e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
376e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
377e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
378e64d31b9Smaya   }
379e64d31b9Smaya}
380e64d31b9Smayastatic void translate_trifan_ubyte2ushort(
381e64d31b9Smaya    const void * _in,
382e64d31b9Smaya    unsigned start,
383e64d31b9Smaya    unsigned in_nr,
384e64d31b9Smaya    unsigned out_nr,
385e64d31b9Smaya    unsigned restart_index,
386e64d31b9Smaya    void *_out )
387e64d31b9Smaya{
388e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
389e64d31b9Smaya  ushort *out = (ushort*)_out;
390e64d31b9Smaya  unsigned i, j;
391e64d31b9Smaya  (void)j;
392e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
393e64d31b9Smaya      (out+j)[0] = (ushort)in[0];
394e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
395e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
396e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
397e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
398e64d31b9Smaya      (out+j+4)[1] = (ushort)in[0];
399e64d31b9Smaya   }
400e64d31b9Smaya}
401e64d31b9Smayastatic void translate_quads_ubyte2ushort(
402e64d31b9Smaya    const void * _in,
403e64d31b9Smaya    unsigned start,
404e64d31b9Smaya    unsigned in_nr,
405e64d31b9Smaya    unsigned out_nr,
406e64d31b9Smaya    unsigned restart_index,
407e64d31b9Smaya    void *_out )
408e64d31b9Smaya{
409e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
410e64d31b9Smaya  ushort *out = (ushort*)_out;
411e64d31b9Smaya  unsigned i, j;
412e64d31b9Smaya  (void)j;
413e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=4) {
414e64d31b9Smaya      (out+j)[0] = (ushort)in[i+0];
415e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
416e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
417e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
418e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
419e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i+3];
420e64d31b9Smaya      (out+j+6)[0] = (ushort)in[i+3];
421e64d31b9Smaya      (out+j+6)[1] = (ushort)in[i+0];
422e64d31b9Smaya   }
423e64d31b9Smaya}
424e64d31b9Smayastatic void translate_quadstrip_ubyte2ushort(
425e64d31b9Smaya    const void * _in,
426e64d31b9Smaya    unsigned start,
427e64d31b9Smaya    unsigned in_nr,
428e64d31b9Smaya    unsigned out_nr,
429e64d31b9Smaya    unsigned restart_index,
430e64d31b9Smaya    void *_out )
431e64d31b9Smaya{
432e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
433e64d31b9Smaya  ushort *out = (ushort*)_out;
434e64d31b9Smaya  unsigned i, j;
435e64d31b9Smaya  (void)j;
436e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=2) {
437e64d31b9Smaya      (out+j)[0] = (ushort)in[i+2];
438e64d31b9Smaya      (out+j)[1] = (ushort)in[i+0];
439e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+0];
440e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+1];
441e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+1];
442e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i+3];
443e64d31b9Smaya      (out+j+6)[0] = (ushort)in[i+3];
444e64d31b9Smaya      (out+j+6)[1] = (ushort)in[i+2];
445e64d31b9Smaya   }
446e64d31b9Smaya}
447e64d31b9Smayastatic void translate_polygon_ubyte2ushort(
448e64d31b9Smaya    const void * _in,
449e64d31b9Smaya    unsigned start,
450e64d31b9Smaya    unsigned in_nr,
451e64d31b9Smaya    unsigned out_nr,
452e64d31b9Smaya    unsigned restart_index,
453e64d31b9Smaya    void *_out )
454e64d31b9Smaya{
455e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
456e64d31b9Smaya  ushort *out = (ushort*)_out;
457e64d31b9Smaya  unsigned i, j;
458e64d31b9Smaya  (void)j;
459e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=2, i++) {
460e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
461e64d31b9Smaya      (out+j)[1] = (ushort)in[(i+1)%(out_nr/2)];
462e64d31b9Smaya   }
463e64d31b9Smaya}
464e64d31b9Smayastatic void translate_trisadj_ubyte2ushort(
465e64d31b9Smaya    const void * _in,
466e64d31b9Smaya    unsigned start,
467e64d31b9Smaya    unsigned in_nr,
468e64d31b9Smaya    unsigned out_nr,
469e64d31b9Smaya    unsigned restart_index,
470e64d31b9Smaya    void *_out )
471e64d31b9Smaya{
472e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
473e64d31b9Smaya  ushort *out = (ushort*)_out;
474e64d31b9Smaya  unsigned i, j;
475e64d31b9Smaya  (void)j;
476e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=6) {
477e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
478e64d31b9Smaya      (out+j)[1] = (ushort)in[i+2];
479e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+2];
480e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+4];
481e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+4];
482e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
483e64d31b9Smaya   }
484e64d31b9Smaya}
485e64d31b9Smayastatic void translate_tristripadj_ubyte2ushort(
486e64d31b9Smaya    const void * _in,
487e64d31b9Smaya    unsigned start,
488e64d31b9Smaya    unsigned in_nr,
489e64d31b9Smaya    unsigned out_nr,
490e64d31b9Smaya    unsigned restart_index,
491e64d31b9Smaya    void *_out )
492e64d31b9Smaya{
493e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
494e64d31b9Smaya  ushort *out = (ushort*)_out;
495e64d31b9Smaya  unsigned i, j;
496e64d31b9Smaya  (void)j;
497e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=2) {
498e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
499e64d31b9Smaya      (out+j)[1] = (ushort)in[i+2];
500e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+2];
501e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+4];
502e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+4];
503e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
504e64d31b9Smaya   }
505e64d31b9Smaya}
506e64d31b9Smayastatic void translate_tris_ubyte2uint(
507e64d31b9Smaya    const void * _in,
508e64d31b9Smaya    unsigned start,
509e64d31b9Smaya    unsigned in_nr,
510e64d31b9Smaya    unsigned out_nr,
511e64d31b9Smaya    unsigned restart_index,
512e64d31b9Smaya    void *_out )
513e64d31b9Smaya{
514e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
515e64d31b9Smaya  uint *out = (uint*)_out;
516e64d31b9Smaya  unsigned i, j;
517e64d31b9Smaya  (void)j;
518e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=3) {
519e64d31b9Smaya      (out+j)[0] = (uint)in[i];
520e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
521e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
522e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
523e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
524e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
525e64d31b9Smaya   }
526e64d31b9Smaya}
527e64d31b9Smayastatic void translate_tristrip_ubyte2uint(
528e64d31b9Smaya    const void * _in,
529e64d31b9Smaya    unsigned start,
530e64d31b9Smaya    unsigned in_nr,
531e64d31b9Smaya    unsigned out_nr,
532e64d31b9Smaya    unsigned restart_index,
533e64d31b9Smaya    void *_out )
534e64d31b9Smaya{
535e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
536e64d31b9Smaya  uint *out = (uint*)_out;
537e64d31b9Smaya  unsigned i, j;
538e64d31b9Smaya  (void)j;
539e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
540e64d31b9Smaya      (out+j)[0] = (uint)in[i];
541e64d31b9Smaya      (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
542e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
543e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
544e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
545e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
546e64d31b9Smaya   }
547e64d31b9Smaya}
548e64d31b9Smayastatic void translate_trifan_ubyte2uint(
549e64d31b9Smaya    const void * _in,
550e64d31b9Smaya    unsigned start,
551e64d31b9Smaya    unsigned in_nr,
552e64d31b9Smaya    unsigned out_nr,
553e64d31b9Smaya    unsigned restart_index,
554e64d31b9Smaya    void *_out )
555e64d31b9Smaya{
556e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
557e64d31b9Smaya  uint *out = (uint*)_out;
558e64d31b9Smaya  unsigned i, j;
559e64d31b9Smaya  (void)j;
560e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
561e64d31b9Smaya      (out+j)[0] = (uint)in[0];
562e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
563e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
564e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
565e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
566e64d31b9Smaya      (out+j+4)[1] = (uint)in[0];
567e64d31b9Smaya   }
568e64d31b9Smaya}
569e64d31b9Smayastatic void translate_quads_ubyte2uint(
570e64d31b9Smaya    const void * _in,
571e64d31b9Smaya    unsigned start,
572e64d31b9Smaya    unsigned in_nr,
573e64d31b9Smaya    unsigned out_nr,
574e64d31b9Smaya    unsigned restart_index,
575e64d31b9Smaya    void *_out )
576e64d31b9Smaya{
577e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
578e64d31b9Smaya  uint *out = (uint*)_out;
579e64d31b9Smaya  unsigned i, j;
580e64d31b9Smaya  (void)j;
581e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=4) {
582e64d31b9Smaya      (out+j)[0] = (uint)in[i+0];
583e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
584e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
585e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
586e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
587e64d31b9Smaya      (out+j+4)[1] = (uint)in[i+3];
588e64d31b9Smaya      (out+j+6)[0] = (uint)in[i+3];
589e64d31b9Smaya      (out+j+6)[1] = (uint)in[i+0];
590e64d31b9Smaya   }
591e64d31b9Smaya}
592e64d31b9Smayastatic void translate_quadstrip_ubyte2uint(
593e64d31b9Smaya    const void * _in,
594e64d31b9Smaya    unsigned start,
595e64d31b9Smaya    unsigned in_nr,
596e64d31b9Smaya    unsigned out_nr,
597e64d31b9Smaya    unsigned restart_index,
598e64d31b9Smaya    void *_out )
599e64d31b9Smaya{
600e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
601e64d31b9Smaya  uint *out = (uint*)_out;
602e64d31b9Smaya  unsigned i, j;
603e64d31b9Smaya  (void)j;
604e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=2) {
605e64d31b9Smaya      (out+j)[0] = (uint)in[i+2];
606e64d31b9Smaya      (out+j)[1] = (uint)in[i+0];
607e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+0];
608e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+1];
609e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+1];
610e64d31b9Smaya      (out+j+4)[1] = (uint)in[i+3];
611e64d31b9Smaya      (out+j+6)[0] = (uint)in[i+3];
612e64d31b9Smaya      (out+j+6)[1] = (uint)in[i+2];
613e64d31b9Smaya   }
614e64d31b9Smaya}
615e64d31b9Smayastatic void translate_polygon_ubyte2uint(
616e64d31b9Smaya    const void * _in,
617e64d31b9Smaya    unsigned start,
618e64d31b9Smaya    unsigned in_nr,
619e64d31b9Smaya    unsigned out_nr,
620e64d31b9Smaya    unsigned restart_index,
621e64d31b9Smaya    void *_out )
622e64d31b9Smaya{
623e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
624e64d31b9Smaya  uint *out = (uint*)_out;
625e64d31b9Smaya  unsigned i, j;
626e64d31b9Smaya  (void)j;
627e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=2, i++) {
628e64d31b9Smaya      (out+j)[0] = (uint)in[i];
629e64d31b9Smaya      (out+j)[1] = (uint)in[(i+1)%(out_nr/2)];
630e64d31b9Smaya   }
631e64d31b9Smaya}
632e64d31b9Smayastatic void translate_trisadj_ubyte2uint(
633e64d31b9Smaya    const void * _in,
634e64d31b9Smaya    unsigned start,
635e64d31b9Smaya    unsigned in_nr,
636e64d31b9Smaya    unsigned out_nr,
637e64d31b9Smaya    unsigned restart_index,
638e64d31b9Smaya    void *_out )
639e64d31b9Smaya{
640e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
641e64d31b9Smaya  uint *out = (uint*)_out;
642e64d31b9Smaya  unsigned i, j;
643e64d31b9Smaya  (void)j;
644e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=6) {
645e64d31b9Smaya      (out+j)[0] = (uint)in[i];
646e64d31b9Smaya      (out+j)[1] = (uint)in[i+2];
647e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+2];
648e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+4];
649e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+4];
650e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
651e64d31b9Smaya   }
652e64d31b9Smaya}
653e64d31b9Smayastatic void translate_tristripadj_ubyte2uint(
654e64d31b9Smaya    const void * _in,
655e64d31b9Smaya    unsigned start,
656e64d31b9Smaya    unsigned in_nr,
657e64d31b9Smaya    unsigned out_nr,
658e64d31b9Smaya    unsigned restart_index,
659e64d31b9Smaya    void *_out )
660e64d31b9Smaya{
661e64d31b9Smaya  const ubyte*in = (const ubyte*)_in;
662e64d31b9Smaya  uint *out = (uint*)_out;
663e64d31b9Smaya  unsigned i, j;
664e64d31b9Smaya  (void)j;
665e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=2) {
666e64d31b9Smaya      (out+j)[0] = (uint)in[i];
667e64d31b9Smaya      (out+j)[1] = (uint)in[i+2];
668e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+2];
669e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+4];
670e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+4];
671e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
672e64d31b9Smaya   }
673e64d31b9Smaya}
674e64d31b9Smayastatic void translate_tris_ushort2ushort(
675e64d31b9Smaya    const void * _in,
676e64d31b9Smaya    unsigned start,
677e64d31b9Smaya    unsigned in_nr,
678e64d31b9Smaya    unsigned out_nr,
679e64d31b9Smaya    unsigned restart_index,
680e64d31b9Smaya    void *_out )
681e64d31b9Smaya{
682e64d31b9Smaya  const ushort*in = (const ushort*)_in;
683e64d31b9Smaya  ushort *out = (ushort*)_out;
684e64d31b9Smaya  unsigned i, j;
685e64d31b9Smaya  (void)j;
686e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=3) {
687e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
688e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
689e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
690e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
691e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
692e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
693e64d31b9Smaya   }
694e64d31b9Smaya}
695e64d31b9Smayastatic void translate_tristrip_ushort2ushort(
696e64d31b9Smaya    const void * _in,
697e64d31b9Smaya    unsigned start,
698e64d31b9Smaya    unsigned in_nr,
699e64d31b9Smaya    unsigned out_nr,
700e64d31b9Smaya    unsigned restart_index,
701e64d31b9Smaya    void *_out )
702e64d31b9Smaya{
703e64d31b9Smaya  const ushort*in = (const ushort*)_in;
704e64d31b9Smaya  ushort *out = (ushort*)_out;
705e64d31b9Smaya  unsigned i, j;
706e64d31b9Smaya  (void)j;
707e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
708e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
709e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
710e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
711e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
712e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
713e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
714e64d31b9Smaya   }
715e64d31b9Smaya}
716e64d31b9Smayastatic void translate_trifan_ushort2ushort(
717e64d31b9Smaya    const void * _in,
718e64d31b9Smaya    unsigned start,
719e64d31b9Smaya    unsigned in_nr,
720e64d31b9Smaya    unsigned out_nr,
721e64d31b9Smaya    unsigned restart_index,
722e64d31b9Smaya    void *_out )
723e64d31b9Smaya{
724e64d31b9Smaya  const ushort*in = (const ushort*)_in;
725e64d31b9Smaya  ushort *out = (ushort*)_out;
726e64d31b9Smaya  unsigned i, j;
727e64d31b9Smaya  (void)j;
728e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
729e64d31b9Smaya      (out+j)[0] = (ushort)in[0];
730e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
731e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
732e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
733e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
734e64d31b9Smaya      (out+j+4)[1] = (ushort)in[0];
735e64d31b9Smaya   }
736e64d31b9Smaya}
737e64d31b9Smayastatic void translate_quads_ushort2ushort(
738e64d31b9Smaya    const void * _in,
739e64d31b9Smaya    unsigned start,
740e64d31b9Smaya    unsigned in_nr,
741e64d31b9Smaya    unsigned out_nr,
742e64d31b9Smaya    unsigned restart_index,
743e64d31b9Smaya    void *_out )
744e64d31b9Smaya{
745e64d31b9Smaya  const ushort*in = (const ushort*)_in;
746e64d31b9Smaya  ushort *out = (ushort*)_out;
747e64d31b9Smaya  unsigned i, j;
748e64d31b9Smaya  (void)j;
749e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=4) {
750e64d31b9Smaya      (out+j)[0] = (ushort)in[i+0];
751e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
752e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
753e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
754e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
755e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i+3];
756e64d31b9Smaya      (out+j+6)[0] = (ushort)in[i+3];
757e64d31b9Smaya      (out+j+6)[1] = (ushort)in[i+0];
758e64d31b9Smaya   }
759e64d31b9Smaya}
760e64d31b9Smayastatic void translate_quadstrip_ushort2ushort(
761e64d31b9Smaya    const void * _in,
762e64d31b9Smaya    unsigned start,
763e64d31b9Smaya    unsigned in_nr,
764e64d31b9Smaya    unsigned out_nr,
765e64d31b9Smaya    unsigned restart_index,
766e64d31b9Smaya    void *_out )
767e64d31b9Smaya{
768e64d31b9Smaya  const ushort*in = (const ushort*)_in;
769e64d31b9Smaya  ushort *out = (ushort*)_out;
770e64d31b9Smaya  unsigned i, j;
771e64d31b9Smaya  (void)j;
772e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=2) {
773e64d31b9Smaya      (out+j)[0] = (ushort)in[i+2];
774e64d31b9Smaya      (out+j)[1] = (ushort)in[i+0];
775e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+0];
776e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+1];
777e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+1];
778e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i+3];
779e64d31b9Smaya      (out+j+6)[0] = (ushort)in[i+3];
780e64d31b9Smaya      (out+j+6)[1] = (ushort)in[i+2];
781e64d31b9Smaya   }
782e64d31b9Smaya}
783e64d31b9Smayastatic void translate_polygon_ushort2ushort(
784e64d31b9Smaya    const void * _in,
785e64d31b9Smaya    unsigned start,
786e64d31b9Smaya    unsigned in_nr,
787e64d31b9Smaya    unsigned out_nr,
788e64d31b9Smaya    unsigned restart_index,
789e64d31b9Smaya    void *_out )
790e64d31b9Smaya{
791e64d31b9Smaya  const ushort*in = (const ushort*)_in;
792e64d31b9Smaya  ushort *out = (ushort*)_out;
793e64d31b9Smaya  unsigned i, j;
794e64d31b9Smaya  (void)j;
795e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=2, i++) {
796e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
797e64d31b9Smaya      (out+j)[1] = (ushort)in[(i+1)%(out_nr/2)];
798e64d31b9Smaya   }
799e64d31b9Smaya}
800e64d31b9Smayastatic void translate_trisadj_ushort2ushort(
801e64d31b9Smaya    const void * _in,
802e64d31b9Smaya    unsigned start,
803e64d31b9Smaya    unsigned in_nr,
804e64d31b9Smaya    unsigned out_nr,
805e64d31b9Smaya    unsigned restart_index,
806e64d31b9Smaya    void *_out )
807e64d31b9Smaya{
808e64d31b9Smaya  const ushort*in = (const ushort*)_in;
809e64d31b9Smaya  ushort *out = (ushort*)_out;
810e64d31b9Smaya  unsigned i, j;
811e64d31b9Smaya  (void)j;
812e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=6) {
813e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
814e64d31b9Smaya      (out+j)[1] = (ushort)in[i+2];
815e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+2];
816e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+4];
817e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+4];
818e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
819e64d31b9Smaya   }
820e64d31b9Smaya}
821e64d31b9Smayastatic void translate_tristripadj_ushort2ushort(
822e64d31b9Smaya    const void * _in,
823e64d31b9Smaya    unsigned start,
824e64d31b9Smaya    unsigned in_nr,
825e64d31b9Smaya    unsigned out_nr,
826e64d31b9Smaya    unsigned restart_index,
827e64d31b9Smaya    void *_out )
828e64d31b9Smaya{
829e64d31b9Smaya  const ushort*in = (const ushort*)_in;
830e64d31b9Smaya  ushort *out = (ushort*)_out;
831e64d31b9Smaya  unsigned i, j;
832e64d31b9Smaya  (void)j;
833e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=2) {
834e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
835e64d31b9Smaya      (out+j)[1] = (ushort)in[i+2];
836e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+2];
837e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+4];
838e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+4];
839e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
840e64d31b9Smaya   }
841e64d31b9Smaya}
842e64d31b9Smayastatic void translate_tris_ushort2uint(
843e64d31b9Smaya    const void * _in,
844e64d31b9Smaya    unsigned start,
845e64d31b9Smaya    unsigned in_nr,
846e64d31b9Smaya    unsigned out_nr,
847e64d31b9Smaya    unsigned restart_index,
848e64d31b9Smaya    void *_out )
849e64d31b9Smaya{
850e64d31b9Smaya  const ushort*in = (const ushort*)_in;
851e64d31b9Smaya  uint *out = (uint*)_out;
852e64d31b9Smaya  unsigned i, j;
853e64d31b9Smaya  (void)j;
854e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=3) {
855e64d31b9Smaya      (out+j)[0] = (uint)in[i];
856e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
857e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
858e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
859e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
860e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
861e64d31b9Smaya   }
862e64d31b9Smaya}
863e64d31b9Smayastatic void translate_tristrip_ushort2uint(
864e64d31b9Smaya    const void * _in,
865e64d31b9Smaya    unsigned start,
866e64d31b9Smaya    unsigned in_nr,
867e64d31b9Smaya    unsigned out_nr,
868e64d31b9Smaya    unsigned restart_index,
869e64d31b9Smaya    void *_out )
870e64d31b9Smaya{
871e64d31b9Smaya  const ushort*in = (const ushort*)_in;
872e64d31b9Smaya  uint *out = (uint*)_out;
873e64d31b9Smaya  unsigned i, j;
874e64d31b9Smaya  (void)j;
875e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
876e64d31b9Smaya      (out+j)[0] = (uint)in[i];
877e64d31b9Smaya      (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
878e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
879e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
880e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
881e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
882e64d31b9Smaya   }
883e64d31b9Smaya}
884e64d31b9Smayastatic void translate_trifan_ushort2uint(
885e64d31b9Smaya    const void * _in,
886e64d31b9Smaya    unsigned start,
887e64d31b9Smaya    unsigned in_nr,
888e64d31b9Smaya    unsigned out_nr,
889e64d31b9Smaya    unsigned restart_index,
890e64d31b9Smaya    void *_out )
891e64d31b9Smaya{
892e64d31b9Smaya  const ushort*in = (const ushort*)_in;
893e64d31b9Smaya  uint *out = (uint*)_out;
894e64d31b9Smaya  unsigned i, j;
895e64d31b9Smaya  (void)j;
896e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
897e64d31b9Smaya      (out+j)[0] = (uint)in[0];
898e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
899e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
900e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
901e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
902e64d31b9Smaya      (out+j+4)[1] = (uint)in[0];
903e64d31b9Smaya   }
904e64d31b9Smaya}
905e64d31b9Smayastatic void translate_quads_ushort2uint(
906e64d31b9Smaya    const void * _in,
907e64d31b9Smaya    unsigned start,
908e64d31b9Smaya    unsigned in_nr,
909e64d31b9Smaya    unsigned out_nr,
910e64d31b9Smaya    unsigned restart_index,
911e64d31b9Smaya    void *_out )
912e64d31b9Smaya{
913e64d31b9Smaya  const ushort*in = (const ushort*)_in;
914e64d31b9Smaya  uint *out = (uint*)_out;
915e64d31b9Smaya  unsigned i, j;
916e64d31b9Smaya  (void)j;
917e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=4) {
918e64d31b9Smaya      (out+j)[0] = (uint)in[i+0];
919e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
920e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
921e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
922e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
923e64d31b9Smaya      (out+j+4)[1] = (uint)in[i+3];
924e64d31b9Smaya      (out+j+6)[0] = (uint)in[i+3];
925e64d31b9Smaya      (out+j+6)[1] = (uint)in[i+0];
926e64d31b9Smaya   }
927e64d31b9Smaya}
928e64d31b9Smayastatic void translate_quadstrip_ushort2uint(
929e64d31b9Smaya    const void * _in,
930e64d31b9Smaya    unsigned start,
931e64d31b9Smaya    unsigned in_nr,
932e64d31b9Smaya    unsigned out_nr,
933e64d31b9Smaya    unsigned restart_index,
934e64d31b9Smaya    void *_out )
935e64d31b9Smaya{
936e64d31b9Smaya  const ushort*in = (const ushort*)_in;
937e64d31b9Smaya  uint *out = (uint*)_out;
938e64d31b9Smaya  unsigned i, j;
939e64d31b9Smaya  (void)j;
940e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=2) {
941e64d31b9Smaya      (out+j)[0] = (uint)in[i+2];
942e64d31b9Smaya      (out+j)[1] = (uint)in[i+0];
943e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+0];
944e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+1];
945e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+1];
946e64d31b9Smaya      (out+j+4)[1] = (uint)in[i+3];
947e64d31b9Smaya      (out+j+6)[0] = (uint)in[i+3];
948e64d31b9Smaya      (out+j+6)[1] = (uint)in[i+2];
949e64d31b9Smaya   }
950e64d31b9Smaya}
951e64d31b9Smayastatic void translate_polygon_ushort2uint(
952e64d31b9Smaya    const void * _in,
953e64d31b9Smaya    unsigned start,
954e64d31b9Smaya    unsigned in_nr,
955e64d31b9Smaya    unsigned out_nr,
956e64d31b9Smaya    unsigned restart_index,
957e64d31b9Smaya    void *_out )
958e64d31b9Smaya{
959e64d31b9Smaya  const ushort*in = (const ushort*)_in;
960e64d31b9Smaya  uint *out = (uint*)_out;
961e64d31b9Smaya  unsigned i, j;
962e64d31b9Smaya  (void)j;
963e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=2, i++) {
964e64d31b9Smaya      (out+j)[0] = (uint)in[i];
965e64d31b9Smaya      (out+j)[1] = (uint)in[(i+1)%(out_nr/2)];
966e64d31b9Smaya   }
967e64d31b9Smaya}
968e64d31b9Smayastatic void translate_trisadj_ushort2uint(
969e64d31b9Smaya    const void * _in,
970e64d31b9Smaya    unsigned start,
971e64d31b9Smaya    unsigned in_nr,
972e64d31b9Smaya    unsigned out_nr,
973e64d31b9Smaya    unsigned restart_index,
974e64d31b9Smaya    void *_out )
975e64d31b9Smaya{
976e64d31b9Smaya  const ushort*in = (const ushort*)_in;
977e64d31b9Smaya  uint *out = (uint*)_out;
978e64d31b9Smaya  unsigned i, j;
979e64d31b9Smaya  (void)j;
980e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=6) {
981e64d31b9Smaya      (out+j)[0] = (uint)in[i];
982e64d31b9Smaya      (out+j)[1] = (uint)in[i+2];
983e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+2];
984e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+4];
985e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+4];
986e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
987e64d31b9Smaya   }
988e64d31b9Smaya}
989e64d31b9Smayastatic void translate_tristripadj_ushort2uint(
990e64d31b9Smaya    const void * _in,
991e64d31b9Smaya    unsigned start,
992e64d31b9Smaya    unsigned in_nr,
993e64d31b9Smaya    unsigned out_nr,
994e64d31b9Smaya    unsigned restart_index,
995e64d31b9Smaya    void *_out )
996e64d31b9Smaya{
997e64d31b9Smaya  const ushort*in = (const ushort*)_in;
998e64d31b9Smaya  uint *out = (uint*)_out;
999e64d31b9Smaya  unsigned i, j;
1000e64d31b9Smaya  (void)j;
1001e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=2) {
1002e64d31b9Smaya      (out+j)[0] = (uint)in[i];
1003e64d31b9Smaya      (out+j)[1] = (uint)in[i+2];
1004e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+2];
1005e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+4];
1006e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+4];
1007e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
1008e64d31b9Smaya   }
1009e64d31b9Smaya}
1010e64d31b9Smayastatic void translate_tris_uint2ushort(
1011e64d31b9Smaya    const void * _in,
1012e64d31b9Smaya    unsigned start,
1013e64d31b9Smaya    unsigned in_nr,
1014e64d31b9Smaya    unsigned out_nr,
1015e64d31b9Smaya    unsigned restart_index,
1016e64d31b9Smaya    void *_out )
1017e64d31b9Smaya{
1018e64d31b9Smaya  const uint*in = (const uint*)_in;
1019e64d31b9Smaya  ushort *out = (ushort*)_out;
1020e64d31b9Smaya  unsigned i, j;
1021e64d31b9Smaya  (void)j;
1022e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=3) {
1023e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
1024e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
1025e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
1026e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
1027e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
1028e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
1029e64d31b9Smaya   }
1030e64d31b9Smaya}
1031e64d31b9Smayastatic void translate_tristrip_uint2ushort(
1032e64d31b9Smaya    const void * _in,
1033e64d31b9Smaya    unsigned start,
1034e64d31b9Smaya    unsigned in_nr,
1035e64d31b9Smaya    unsigned out_nr,
1036e64d31b9Smaya    unsigned restart_index,
1037e64d31b9Smaya    void *_out )
1038e64d31b9Smaya{
1039e64d31b9Smaya  const uint*in = (const uint*)_in;
1040e64d31b9Smaya  ushort *out = (ushort*)_out;
1041e64d31b9Smaya  unsigned i, j;
1042e64d31b9Smaya  (void)j;
1043e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
1044e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
1045e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1/*+(i&1)*/];
1046e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/];
1047e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/];
1048e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/];
1049e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
1050e64d31b9Smaya   }
1051e64d31b9Smaya}
1052e64d31b9Smayastatic void translate_trifan_uint2ushort(
1053e64d31b9Smaya    const void * _in,
1054e64d31b9Smaya    unsigned start,
1055e64d31b9Smaya    unsigned in_nr,
1056e64d31b9Smaya    unsigned out_nr,
1057e64d31b9Smaya    unsigned restart_index,
1058e64d31b9Smaya    void *_out )
1059e64d31b9Smaya{
1060e64d31b9Smaya  const uint*in = (const uint*)_in;
1061e64d31b9Smaya  ushort *out = (ushort*)_out;
1062e64d31b9Smaya  unsigned i, j;
1063e64d31b9Smaya  (void)j;
1064e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
1065e64d31b9Smaya      (out+j)[0] = (ushort)in[0];
1066e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
1067e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
1068e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
1069e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
1070e64d31b9Smaya      (out+j+4)[1] = (ushort)in[0];
1071e64d31b9Smaya   }
1072e64d31b9Smaya}
1073e64d31b9Smayastatic void translate_quads_uint2ushort(
1074e64d31b9Smaya    const void * _in,
1075e64d31b9Smaya    unsigned start,
1076e64d31b9Smaya    unsigned in_nr,
1077e64d31b9Smaya    unsigned out_nr,
1078e64d31b9Smaya    unsigned restart_index,
1079e64d31b9Smaya    void *_out )
1080e64d31b9Smaya{
1081e64d31b9Smaya  const uint*in = (const uint*)_in;
1082e64d31b9Smaya  ushort *out = (ushort*)_out;
1083e64d31b9Smaya  unsigned i, j;
1084e64d31b9Smaya  (void)j;
1085e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=4) {
1086e64d31b9Smaya      (out+j)[0] = (ushort)in[i+0];
1087e64d31b9Smaya      (out+j)[1] = (ushort)in[i+1];
1088e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+1];
1089e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+2];
1090e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+2];
1091e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i+3];
1092e64d31b9Smaya      (out+j+6)[0] = (ushort)in[i+3];
1093e64d31b9Smaya      (out+j+6)[1] = (ushort)in[i+0];
1094e64d31b9Smaya   }
1095e64d31b9Smaya}
1096e64d31b9Smayastatic void translate_quadstrip_uint2ushort(
1097e64d31b9Smaya    const void * _in,
1098e64d31b9Smaya    unsigned start,
1099e64d31b9Smaya    unsigned in_nr,
1100e64d31b9Smaya    unsigned out_nr,
1101e64d31b9Smaya    unsigned restart_index,
1102e64d31b9Smaya    void *_out )
1103e64d31b9Smaya{
1104e64d31b9Smaya  const uint*in = (const uint*)_in;
1105e64d31b9Smaya  ushort *out = (ushort*)_out;
1106e64d31b9Smaya  unsigned i, j;
1107e64d31b9Smaya  (void)j;
1108e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=2) {
1109e64d31b9Smaya      (out+j)[0] = (ushort)in[i+2];
1110e64d31b9Smaya      (out+j)[1] = (ushort)in[i+0];
1111e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+0];
1112e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+1];
1113e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+1];
1114e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i+3];
1115e64d31b9Smaya      (out+j+6)[0] = (ushort)in[i+3];
1116e64d31b9Smaya      (out+j+6)[1] = (ushort)in[i+2];
1117e64d31b9Smaya   }
1118e64d31b9Smaya}
1119e64d31b9Smayastatic void translate_polygon_uint2ushort(
1120e64d31b9Smaya    const void * _in,
1121e64d31b9Smaya    unsigned start,
1122e64d31b9Smaya    unsigned in_nr,
1123e64d31b9Smaya    unsigned out_nr,
1124e64d31b9Smaya    unsigned restart_index,
1125e64d31b9Smaya    void *_out )
1126e64d31b9Smaya{
1127e64d31b9Smaya  const uint*in = (const uint*)_in;
1128e64d31b9Smaya  ushort *out = (ushort*)_out;
1129e64d31b9Smaya  unsigned i, j;
1130e64d31b9Smaya  (void)j;
1131e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=2, i++) {
1132e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
1133e64d31b9Smaya      (out+j)[1] = (ushort)in[(i+1)%(out_nr/2)];
1134e64d31b9Smaya   }
1135e64d31b9Smaya}
1136e64d31b9Smayastatic void translate_trisadj_uint2ushort(
1137e64d31b9Smaya    const void * _in,
1138e64d31b9Smaya    unsigned start,
1139e64d31b9Smaya    unsigned in_nr,
1140e64d31b9Smaya    unsigned out_nr,
1141e64d31b9Smaya    unsigned restart_index,
1142e64d31b9Smaya    void *_out )
1143e64d31b9Smaya{
1144e64d31b9Smaya  const uint*in = (const uint*)_in;
1145e64d31b9Smaya  ushort *out = (ushort*)_out;
1146e64d31b9Smaya  unsigned i, j;
1147e64d31b9Smaya  (void)j;
1148e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=6) {
1149e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
1150e64d31b9Smaya      (out+j)[1] = (ushort)in[i+2];
1151e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+2];
1152e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+4];
1153e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+4];
1154e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
1155e64d31b9Smaya   }
1156e64d31b9Smaya}
1157e64d31b9Smayastatic void translate_tristripadj_uint2ushort(
1158e64d31b9Smaya    const void * _in,
1159e64d31b9Smaya    unsigned start,
1160e64d31b9Smaya    unsigned in_nr,
1161e64d31b9Smaya    unsigned out_nr,
1162e64d31b9Smaya    unsigned restart_index,
1163e64d31b9Smaya    void *_out )
1164e64d31b9Smaya{
1165e64d31b9Smaya  const uint*in = (const uint*)_in;
1166e64d31b9Smaya  ushort *out = (ushort*)_out;
1167e64d31b9Smaya  unsigned i, j;
1168e64d31b9Smaya  (void)j;
1169e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=2) {
1170e64d31b9Smaya      (out+j)[0] = (ushort)in[i];
1171e64d31b9Smaya      (out+j)[1] = (ushort)in[i+2];
1172e64d31b9Smaya      (out+j+2)[0] = (ushort)in[i+2];
1173e64d31b9Smaya      (out+j+2)[1] = (ushort)in[i+4];
1174e64d31b9Smaya      (out+j+4)[0] = (ushort)in[i+4];
1175e64d31b9Smaya      (out+j+4)[1] = (ushort)in[i];
1176e64d31b9Smaya   }
1177e64d31b9Smaya}
1178e64d31b9Smayastatic void translate_tris_uint2uint(
1179e64d31b9Smaya    const void * _in,
1180e64d31b9Smaya    unsigned start,
1181e64d31b9Smaya    unsigned in_nr,
1182e64d31b9Smaya    unsigned out_nr,
1183e64d31b9Smaya    unsigned restart_index,
1184e64d31b9Smaya    void *_out )
1185e64d31b9Smaya{
1186e64d31b9Smaya  const uint*in = (const uint*)_in;
1187e64d31b9Smaya  uint *out = (uint*)_out;
1188e64d31b9Smaya  unsigned i, j;
1189e64d31b9Smaya  (void)j;
1190e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=3) {
1191e64d31b9Smaya      (out+j)[0] = (uint)in[i];
1192e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
1193e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
1194e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
1195e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
1196e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
1197e64d31b9Smaya   }
1198e64d31b9Smaya}
1199e64d31b9Smayastatic void translate_tristrip_uint2uint(
1200e64d31b9Smaya    const void * _in,
1201e64d31b9Smaya    unsigned start,
1202e64d31b9Smaya    unsigned in_nr,
1203e64d31b9Smaya    unsigned out_nr,
1204e64d31b9Smaya    unsigned restart_index,
1205e64d31b9Smaya    void *_out )
1206e64d31b9Smaya{
1207e64d31b9Smaya  const uint*in = (const uint*)_in;
1208e64d31b9Smaya  uint *out = (uint*)_out;
1209e64d31b9Smaya  unsigned i, j;
1210e64d31b9Smaya  (void)j;
1211e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
1212e64d31b9Smaya      (out+j)[0] = (uint)in[i];
1213e64d31b9Smaya      (out+j)[1] = (uint)in[i+1/*+(i&1)*/];
1214e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/];
1215e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/];
1216e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/];
1217e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
1218e64d31b9Smaya   }
1219e64d31b9Smaya}
1220e64d31b9Smayastatic void translate_trifan_uint2uint(
1221e64d31b9Smaya    const void * _in,
1222e64d31b9Smaya    unsigned start,
1223e64d31b9Smaya    unsigned in_nr,
1224e64d31b9Smaya    unsigned out_nr,
1225e64d31b9Smaya    unsigned restart_index,
1226e64d31b9Smaya    void *_out )
1227e64d31b9Smaya{
1228e64d31b9Smaya  const uint*in = (const uint*)_in;
1229e64d31b9Smaya  uint *out = (uint*)_out;
1230e64d31b9Smaya  unsigned i, j;
1231e64d31b9Smaya  (void)j;
1232e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i++) {
1233e64d31b9Smaya      (out+j)[0] = (uint)in[0];
1234e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
1235e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
1236e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
1237e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
1238e64d31b9Smaya      (out+j+4)[1] = (uint)in[0];
1239e64d31b9Smaya   }
1240e64d31b9Smaya}
1241e64d31b9Smayastatic void translate_quads_uint2uint(
1242e64d31b9Smaya    const void * _in,
1243e64d31b9Smaya    unsigned start,
1244e64d31b9Smaya    unsigned in_nr,
1245e64d31b9Smaya    unsigned out_nr,
1246e64d31b9Smaya    unsigned restart_index,
1247e64d31b9Smaya    void *_out )
1248e64d31b9Smaya{
1249e64d31b9Smaya  const uint*in = (const uint*)_in;
1250e64d31b9Smaya  uint *out = (uint*)_out;
1251e64d31b9Smaya  unsigned i, j;
1252e64d31b9Smaya  (void)j;
1253e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=4) {
1254e64d31b9Smaya      (out+j)[0] = (uint)in[i+0];
1255e64d31b9Smaya      (out+j)[1] = (uint)in[i+1];
1256e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+1];
1257e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+2];
1258e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+2];
1259e64d31b9Smaya      (out+j+4)[1] = (uint)in[i+3];
1260e64d31b9Smaya      (out+j+6)[0] = (uint)in[i+3];
1261e64d31b9Smaya      (out+j+6)[1] = (uint)in[i+0];
1262e64d31b9Smaya   }
1263e64d31b9Smaya}
1264e64d31b9Smayastatic void translate_quadstrip_uint2uint(
1265e64d31b9Smaya    const void * _in,
1266e64d31b9Smaya    unsigned start,
1267e64d31b9Smaya    unsigned in_nr,
1268e64d31b9Smaya    unsigned out_nr,
1269e64d31b9Smaya    unsigned restart_index,
1270e64d31b9Smaya    void *_out )
1271e64d31b9Smaya{
1272e64d31b9Smaya  const uint*in = (const uint*)_in;
1273e64d31b9Smaya  uint *out = (uint*)_out;
1274e64d31b9Smaya  unsigned i, j;
1275e64d31b9Smaya  (void)j;
1276e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=8, i+=2) {
1277e64d31b9Smaya      (out+j)[0] = (uint)in[i+2];
1278e64d31b9Smaya      (out+j)[1] = (uint)in[i+0];
1279e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+0];
1280e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+1];
1281e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+1];
1282e64d31b9Smaya      (out+j+4)[1] = (uint)in[i+3];
1283e64d31b9Smaya      (out+j+6)[0] = (uint)in[i+3];
1284e64d31b9Smaya      (out+j+6)[1] = (uint)in[i+2];
1285e64d31b9Smaya   }
1286e64d31b9Smaya}
1287e64d31b9Smayastatic void translate_polygon_uint2uint(
1288e64d31b9Smaya    const void * _in,
1289e64d31b9Smaya    unsigned start,
1290e64d31b9Smaya    unsigned in_nr,
1291e64d31b9Smaya    unsigned out_nr,
1292e64d31b9Smaya    unsigned restart_index,
1293e64d31b9Smaya    void *_out )
1294e64d31b9Smaya{
1295e64d31b9Smaya  const uint*in = (const uint*)_in;
1296e64d31b9Smaya  uint *out = (uint*)_out;
1297e64d31b9Smaya  unsigned i, j;
1298e64d31b9Smaya  (void)j;
1299e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=2, i++) {
1300e64d31b9Smaya      (out+j)[0] = (uint)in[i];
1301e64d31b9Smaya      (out+j)[1] = (uint)in[(i+1)%(out_nr/2)];
1302e64d31b9Smaya   }
1303e64d31b9Smaya}
1304e64d31b9Smayastatic void translate_trisadj_uint2uint(
1305e64d31b9Smaya    const void * _in,
1306e64d31b9Smaya    unsigned start,
1307e64d31b9Smaya    unsigned in_nr,
1308e64d31b9Smaya    unsigned out_nr,
1309e64d31b9Smaya    unsigned restart_index,
1310e64d31b9Smaya    void *_out )
1311e64d31b9Smaya{
1312e64d31b9Smaya  const uint*in = (const uint*)_in;
1313e64d31b9Smaya  uint *out = (uint*)_out;
1314e64d31b9Smaya  unsigned i, j;
1315e64d31b9Smaya  (void)j;
1316e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=6) {
1317e64d31b9Smaya      (out+j)[0] = (uint)in[i];
1318e64d31b9Smaya      (out+j)[1] = (uint)in[i+2];
1319e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+2];
1320e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+4];
1321e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+4];
1322e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
1323e64d31b9Smaya   }
1324e64d31b9Smaya}
1325e64d31b9Smayastatic void translate_tristripadj_uint2uint(
1326e64d31b9Smaya    const void * _in,
1327e64d31b9Smaya    unsigned start,
1328e64d31b9Smaya    unsigned in_nr,
1329e64d31b9Smaya    unsigned out_nr,
1330e64d31b9Smaya    unsigned restart_index,
1331e64d31b9Smaya    void *_out )
1332e64d31b9Smaya{
1333e64d31b9Smaya  const uint*in = (const uint*)_in;
1334e64d31b9Smaya  uint *out = (uint*)_out;
1335e64d31b9Smaya  unsigned i, j;
1336e64d31b9Smaya  (void)j;
1337e64d31b9Smaya  for (i = start, j = 0; j < out_nr; j+=6, i+=2) {
1338e64d31b9Smaya      (out+j)[0] = (uint)in[i];
1339e64d31b9Smaya      (out+j)[1] = (uint)in[i+2];
1340e64d31b9Smaya      (out+j+2)[0] = (uint)in[i+2];
1341e64d31b9Smaya      (out+j+2)[1] = (uint)in[i+4];
1342e64d31b9Smaya      (out+j+4)[0] = (uint)in[i+4];
1343e64d31b9Smaya      (out+j+4)[1] = (uint)in[i];
1344e64d31b9Smaya   }
1345e64d31b9Smaya}
1346e64d31b9Smayavoid u_unfilled_init( void )
1347e64d31b9Smaya{
1348e64d31b9Smaya  static int firsttime = 1;
1349e64d31b9Smaya  if (!firsttime) return;
1350e64d31b9Smaya  firsttime = 0;
1351e64d31b9Smayagenerate_line[OUT_USHORT][PIPE_PRIM_TRIANGLES] = generate_tris_ushort;
1352e64d31b9Smayagenerate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort;
1353e64d31b9Smayagenerate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort;
1354e64d31b9Smayagenerate_line[OUT_USHORT][PIPE_PRIM_QUADS] = generate_quads_ushort;
1355e64d31b9Smayagenerate_line[OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort;
1356e64d31b9Smayagenerate_line[OUT_USHORT][PIPE_PRIM_POLYGON] = generate_polygon_ushort;
1357e64d31b9Smayagenerate_line[OUT_USHORT][PIPE_PRIM_TRIANGLES_ADJACENCY] = generate_trisadj_ushort;
1358e64d31b9Smayagenerate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = generate_tristripadj_ushort;
1359e64d31b9Smayagenerate_line[OUT_UINT][PIPE_PRIM_TRIANGLES] = generate_tris_uint;
1360e64d31b9Smayagenerate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint;
1361e64d31b9Smayagenerate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint;
1362e64d31b9Smayagenerate_line[OUT_UINT][PIPE_PRIM_QUADS] = generate_quads_uint;
1363e64d31b9Smayagenerate_line[OUT_UINT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint;
1364e64d31b9Smayagenerate_line[OUT_UINT][PIPE_PRIM_POLYGON] = generate_polygon_uint;
1365e64d31b9Smayagenerate_line[OUT_UINT][PIPE_PRIM_TRIANGLES_ADJACENCY] = generate_trisadj_uint;
1366e64d31b9Smayagenerate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = generate_tristripadj_uint;
1367e64d31b9Smayatranslate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort;
1368e64d31b9Smayatranslate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort;
1369e64d31b9Smayatranslate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort;
1370e64d31b9Smayatranslate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort;
1371e64d31b9Smayatranslate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort;
1372e64d31b9Smayatranslate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort;
1373e64d31b9Smayatranslate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLES_ADJACENCY] = translate_trisadj_ubyte2ushort;
1374e64d31b9Smayatranslate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = translate_tristripadj_ubyte2ushort;
1375e64d31b9Smayatranslate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint;
1376e64d31b9Smayatranslate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint;
1377e64d31b9Smayatranslate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint;
1378e64d31b9Smayatranslate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint;
1379e64d31b9Smayatranslate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint;
1380e64d31b9Smayatranslate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint;
1381e64d31b9Smayatranslate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLES_ADJACENCY] = translate_trisadj_ubyte2uint;
1382e64d31b9Smayatranslate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = translate_tristripadj_ubyte2uint;
1383e64d31b9Smayatranslate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort;
1384e64d31b9Smayatranslate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort;
1385e64d31b9Smayatranslate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort;
1386e64d31b9Smayatranslate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort;
1387e64d31b9Smayatranslate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort;
1388e64d31b9Smayatranslate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort;
1389e64d31b9Smayatranslate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLES_ADJACENCY] = translate_trisadj_ushort2ushort;
1390e64d31b9Smayatranslate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = translate_tristripadj_ushort2ushort;
1391e64d31b9Smayatranslate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint;
1392e64d31b9Smayatranslate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint;
1393e64d31b9Smayatranslate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint;
1394e64d31b9Smayatranslate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ushort2uint;
1395e64d31b9Smayatranslate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint;
1396e64d31b9Smayatranslate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint;
1397e64d31b9Smayatranslate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLES_ADJACENCY] = translate_trisadj_ushort2uint;
1398e64d31b9Smayatranslate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = translate_tristripadj_ushort2uint;
1399e64d31b9Smayatranslate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort;
1400e64d31b9Smayatranslate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort;
1401e64d31b9Smayatranslate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort;
1402e64d31b9Smayatranslate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_uint2ushort;
1403e64d31b9Smayatranslate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort;
1404e64d31b9Smayatranslate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort;
1405e64d31b9Smayatranslate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLES_ADJACENCY] = translate_trisadj_uint2ushort;
1406e64d31b9Smayatranslate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = translate_tristripadj_uint2ushort;
1407e64d31b9Smayatranslate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint;
1408e64d31b9Smayatranslate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint;
1409e64d31b9Smayatranslate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint;
1410e64d31b9Smayatranslate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_uint2uint;
1411e64d31b9Smayatranslate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint;
1412e64d31b9Smayatranslate_line[IN_UINT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint;
1413e64d31b9Smayatranslate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLES_ADJACENCY] = translate_trisadj_uint2uint;
1414e64d31b9Smayatranslate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY] = translate_tristripadj_uint2uint;
1415e64d31b9Smaya}
1416e64d31b9Smaya#include "indices/u_unfilled_indices.c"
1417