1bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell/************************************************************************** 2bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * 3bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. 4bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * All Rights Reserved. 5bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * 6bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 7bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * copy of this software and associated documentation files (the 8bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * "Software"), to deal in the Software without restriction, including 9bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 10bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 11bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to 12bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * the following conditions: 13bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * 14bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * The above copyright notice and this permission notice (including the 15bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * next paragraph) shall be included in all copies or substantial portions 16bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * of the Software. 17bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * 18bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * 26bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell **************************************************************************/ 27bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell 28bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell /* 29bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * Authors: 30bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell * Keith Whitwell <keith@tungstengraphics.com> 31bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell */ 32bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell 33bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell#include "draw/draw_context.h" 34bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell#include "draw/draw_private.h" 35bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell#include "draw/draw_pt.h" 362aaca1df9df6980ec88180c8866c8987b31db91aJosé Fonseca#include "util/u_debug.h" 37bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell 38bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwellvoid draw_pt_split_prim(unsigned prim, unsigned *first, unsigned *incr) 39bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell{ 40bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell switch (prim) { 41bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_POINTS: 42bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *first = 1; 43bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *incr = 1; 44bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell break; 45bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_LINES: 46bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *first = 2; 47bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *incr = 2; 48bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell break; 49bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_LINE_STRIP: 50bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_LINE_LOOP: 51bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *first = 2; 52bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *incr = 1; 53bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell break; 5489d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin case PIPE_PRIM_LINES_ADJACENCY: 5589d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin *first = 4; 56600cd858d446bc1698a9b28f714f3fd6145316fbChia-I Wu *incr = 4; 5789d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin break; 5889d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin case PIPE_PRIM_LINE_STRIP_ADJACENCY: 5989d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin *first = 4; 6089d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin *incr = 1; 6189d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin break; 62bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_TRIANGLES: 63bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *first = 3; 64bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *incr = 3; 65bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell break; 6689d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin case PIPE_PRIM_TRIANGLES_ADJACENCY: 6789d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin *first = 6; 68600cd858d446bc1698a9b28f714f3fd6145316fbChia-I Wu *incr = 6; 6989d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin break; 70bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_TRIANGLE_STRIP: 71bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_TRIANGLE_FAN: 72bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_POLYGON: 73bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *first = 3; 74bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *incr = 1; 75bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell break; 7689d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: 7789d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin *first = 6; 78600cd858d446bc1698a9b28f714f3fd6145316fbChia-I Wu *incr = 2; 7989d8577fb3036547ef0b47498cc8dc5c77f886e0Zack Rusin break; 80bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_QUADS: 81bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *first = 4; 82bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *incr = 4; 83bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell break; 84bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell case PIPE_PRIM_QUAD_STRIP: 85bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *first = 4; 86bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *incr = 2; 87bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell break; 88bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell default: 89bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell assert(0); 90bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *first = 0; 91bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell *incr = 1; /* set to one so that count % incr works */ 92bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell break; 93bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell } 94bbda45ec769120324f44febf00c6bb170f594f23Keith Whitwell} 9556213a64fe9e4270fd7886675b1e8224b2d88794Chia-I Wu 9656213a64fe9e4270fd7886675b1e8224b2d88794Chia-I Wuunsigned draw_pt_trim_count(unsigned count, unsigned first, unsigned incr) 9756213a64fe9e4270fd7886675b1e8224b2d88794Chia-I Wu{ 9856213a64fe9e4270fd7886675b1e8224b2d88794Chia-I Wu if (count < first) 9956213a64fe9e4270fd7886675b1e8224b2d88794Chia-I Wu return 0; 10056213a64fe9e4270fd7886675b1e8224b2d88794Chia-I Wu return count - (count - first) % incr; 10156213a64fe9e4270fd7886675b1e8224b2d88794Chia-I Wu} 102