Path: blob/21.2-virgl/src/gallium/auxiliary/draw/draw_pt_util.c
4565 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627/*28* Authors:29* Keith Whitwell <[email protected]>30*/3132#include "draw/draw_context.h"33#include "draw/draw_private.h"34#include "draw/draw_pt.h"35#include "util/u_debug.h"3637void draw_pt_split_prim(unsigned prim, unsigned *first, unsigned *incr)38{39switch (prim) {40case PIPE_PRIM_POINTS:41*first = 1;42*incr = 1;43break;44case PIPE_PRIM_LINES:45*first = 2;46*incr = 2;47break;48case PIPE_PRIM_LINE_STRIP:49case PIPE_PRIM_LINE_LOOP:50*first = 2;51*incr = 1;52break;53case PIPE_PRIM_LINES_ADJACENCY:54*first = 4;55*incr = 4;56break;57case PIPE_PRIM_LINE_STRIP_ADJACENCY:58*first = 4;59*incr = 1;60break;61case PIPE_PRIM_TRIANGLES:62*first = 3;63*incr = 3;64break;65case PIPE_PRIM_TRIANGLES_ADJACENCY:66*first = 6;67*incr = 6;68break;69case PIPE_PRIM_TRIANGLE_STRIP:70case PIPE_PRIM_TRIANGLE_FAN:71case PIPE_PRIM_POLYGON:72*first = 3;73*incr = 1;74break;75case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:76*first = 6;77*incr = 2;78break;79case PIPE_PRIM_QUADS:80*first = 4;81*incr = 4;82break;83case PIPE_PRIM_QUAD_STRIP:84*first = 4;85*incr = 2;86break;87default:88assert(0);89*first = 0;90*incr = 1; /* set to one so that count % incr works */91break;92}93}9495unsigned draw_pt_trim_count(unsigned count, unsigned first, unsigned incr)96{97if (count < first)98return 0;99return count - (count - first) % incr;100}101102103