13120894c6d33a26cda642246344e8945db200ac2Keith Whitwell/*
23120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * Copyright 2009 VMware, Inc.
33120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * All Rights Reserved.
43120894c6d33a26cda642246344e8945db200ac2Keith Whitwell *
53120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a
63120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * copy of this software and associated documentation files (the "Software"),
73120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * to deal in the Software without restriction, including without limitation
83120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * on the rights to use, copy, modify, merge, publish, distribute, sub
93120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * license, and/or sell copies of the Software, and to permit persons to whom
103120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * the Software is furnished to do so, subject to the following conditions:
113120894c6d33a26cda642246344e8945db200ac2Keith Whitwell *
123120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * The above copyright notice and this permission notice (including the next
133120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * paragraph) shall be included in all copies or substantial portions of the
143120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * Software.
153120894c6d33a26cda642246344e8945db200ac2Keith Whitwell *
163120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
173120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
193120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
203120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
213120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
223120894c6d33a26cda642246344e8945db200ac2Keith Whitwell * USE OR OTHER DEALINGS IN THE SOFTWARE.
233120894c6d33a26cda642246344e8945db200ac2Keith Whitwell */
243120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
253120894c6d33a26cda642246344e8945db200ac2Keith Whitwell#include "u_indices.h"
263120894c6d33a26cda642246344e8945db200ac2Keith Whitwell#include "u_indices_priv.h"
273120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
283120894c6d33a26cda642246344e8945db200ac2Keith Whitwellstatic void translate_memcpy_ushort( const void *in,
293120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                                     unsigned nr,
303120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                                     void *out )
313120894c6d33a26cda642246344e8945db200ac2Keith Whitwell{
323120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   memcpy(out, in, nr*sizeof(short));
333120894c6d33a26cda642246344e8945db200ac2Keith Whitwell}
343120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
353120894c6d33a26cda642246344e8945db200ac2Keith Whitwellstatic void translate_memcpy_uint( const void *in,
363120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                                   unsigned nr,
373120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                                   void *out )
383120894c6d33a26cda642246344e8945db200ac2Keith Whitwell{
393120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   memcpy(out, in, nr*sizeof(int));
403120894c6d33a26cda642246344e8945db200ac2Keith Whitwell}
413120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
423120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
433120894c6d33a26cda642246344e8945db200ac2Keith Whitwellint u_index_translator( unsigned hw_mask,
443120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        unsigned prim,
453120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        unsigned in_index_size,
463120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        unsigned nr,
473120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        unsigned in_pv,
483120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        unsigned out_pv,
493120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        unsigned *out_prim,
503120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        unsigned *out_index_size,
513120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        unsigned *out_nr,
523120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                        u_translate_func *out_translate )
533120894c6d33a26cda642246344e8945db200ac2Keith Whitwell{
543120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   unsigned in_idx;
553120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   unsigned out_idx;
563120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   int ret = U_TRANSLATE_NORMAL;
573120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
583120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   u_index_init();
593120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
603120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   in_idx = in_size_idx(in_index_size);
613120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   *out_index_size = (in_index_size == 4) ? 4 : 2;
623120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   out_idx = out_size_idx(*out_index_size);
633120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
643120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   if ((hw_mask & (1<<prim)) &&
653120894c6d33a26cda642246344e8945db200ac2Keith Whitwell       in_index_size == *out_index_size &&
663120894c6d33a26cda642246344e8945db200ac2Keith Whitwell       in_pv == out_pv)
673120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   {
683120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      if (in_index_size == 4)
693120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate_memcpy_uint;
703120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      else
713120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate_memcpy_ushort;
723120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
733120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      *out_prim = prim;
743120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      *out_nr = nr;
753120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
763120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      return U_TRANSLATE_MEMCPY;
773120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   }
783120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   else {
793120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      switch (prim) {
803120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_POINTS:
813120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
823120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_POINTS;
833120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr;
843120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
853120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
863120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_LINES:
873120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
883120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_LINES;
893120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr;
903120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
913120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
923120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_LINE_STRIP:
933120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
943120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_LINES;
953120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 1) * 2;
963120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
973120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
983120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_LINE_LOOP:
993120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
1003120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_LINES;
1013120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr * 2;
1023120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
1033120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1043120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_TRIANGLES:
1053120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
1063120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
1073120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr;
1083120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
1093120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1103120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_TRIANGLE_STRIP:
1113120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
1123120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
1133120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 2) * 3;
1143120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
1153120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1163120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_TRIANGLE_FAN:
1173120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
1183120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
1193120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 2) * 3;
1203120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
1213120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1223120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_QUADS:
1233120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
1243120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
1253120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr / 4) * 6;
1263120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
1273120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1283120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_QUAD_STRIP:
1293120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
1303120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
1313120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 2) * 3;
1323120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
1333120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1343120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_POLYGON:
1353120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
1363120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
1373120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 2) * 3;
1383120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         break;
1393120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1403120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      default:
1413120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         assert(0);
1423120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
1433120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_POINTS;
1443120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr;
1453120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_TRANSLATE_ERROR;
1463120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      }
1473120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   }
1483120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1493120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   return ret;
1503120894c6d33a26cda642246344e8945db200ac2Keith Whitwell}
1513120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1523120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1533120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1543120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1553120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1563120894c6d33a26cda642246344e8945db200ac2Keith Whitwellint u_index_generator( unsigned hw_mask,
1573120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       unsigned prim,
1583120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       unsigned start,
1593120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       unsigned nr,
1603120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       unsigned in_pv,
1613120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       unsigned out_pv,
1623120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       unsigned *out_prim,
1633120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       unsigned *out_index_size,
1643120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       unsigned *out_nr,
1653120894c6d33a26cda642246344e8945db200ac2Keith Whitwell                       u_generate_func *out_generate )
1663120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1673120894c6d33a26cda642246344e8945db200ac2Keith Whitwell{
1683120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   unsigned out_idx;
1693120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1703120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   u_index_init();
1713120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1723120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   *out_index_size = ((start + nr) > 0xfffe) ? 4 : 2;
1733120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   out_idx = out_size_idx(*out_index_size);
1743120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1753120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   if ((hw_mask & (1<<prim)) &&
1763120894c6d33a26cda642246344e8945db200ac2Keith Whitwell       (in_pv == out_pv)) {
1773120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1783120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      *out_generate = generate[out_idx][in_pv][out_pv][PIPE_PRIM_POINTS];
1793120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      *out_prim = prim;
1803120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      *out_nr = nr;
1813120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      return U_GENERATE_LINEAR;
1823120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   }
1833120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   else {
1843120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      switch (prim) {
1853120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_POINTS:
1863120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
1873120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_POINTS;
1883120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr;
1893120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
1903120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1913120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_LINES:
1923120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
1933120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_LINES;
1943120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr;
1953120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
1963120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
1973120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_LINE_STRIP:
1983120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
1993120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_LINES;
2003120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 1) * 2;
2013120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
2023120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
2033120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_LINE_LOOP:
2043120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
2053120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_LINES;
2063120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr * 2;
2073120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_ONE_OFF;
2083120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
2093120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_TRIANGLES:
2103120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
2113120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
2123120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr;
2133120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
2143120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
2153120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_TRIANGLE_STRIP:
2163120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
2173120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
2183120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 2) * 3;
2193120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
2203120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
2213120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_TRIANGLE_FAN:
2223120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
2233120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
2243120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 2) * 3;
2253120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
2263120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
2273120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_QUADS:
2283120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
2293120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
2303120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr / 4) * 6;
2313120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
2323120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
2333120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_QUAD_STRIP:
2343120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
2353120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
2363120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 2) * 3;
2373120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
2383120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
2393120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      case PIPE_PRIM_POLYGON:
2403120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][prim];
2413120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_TRIANGLES;
2423120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = (nr - 2) * 3;
2433120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_GENERATE_REUSABLE;
2443120894c6d33a26cda642246344e8945db200ac2Keith Whitwell
2453120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      default:
2463120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         assert(0);
247c9f8c400ab23ce86448d6b3f8e292e5d5a170a67Keith Whitwell         *out_generate = generate[out_idx][in_pv][out_pv][PIPE_PRIM_POINTS];
2483120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_prim = PIPE_PRIM_POINTS;
2493120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         *out_nr = nr;
2503120894c6d33a26cda642246344e8945db200ac2Keith Whitwell         return U_TRANSLATE_ERROR;
2513120894c6d33a26cda642246344e8945db200ac2Keith Whitwell      }
2523120894c6d33a26cda642246344e8945db200ac2Keith Whitwell   }
2533120894c6d33a26cda642246344e8945db200ac2Keith Whitwell}
254