1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 **********************************************************/
29 #include "pipe/p_compiler.h"
30 #include "pipe/p_defines.h"
31 #include "indices/u_indices.h"
32 #include "svga_hw_reg.h"
33 #include "svga3d_shaderdefs.h"
38 /* Should include polygon?
40 static const unsigned svga_hw_prims =
41 ((1 << PIPE_PRIM_POINTS) |
42 (1 << PIPE_PRIM_LINES) |
43 (1 << PIPE_PRIM_LINE_STRIP) |
44 (1 << PIPE_PRIM_TRIANGLES) |
45 (1 << PIPE_PRIM_TRIANGLE_STRIP) |
46 (1 << PIPE_PRIM_TRIANGLE_FAN));
49 static INLINE unsigned svga_translate_prim(unsigned mode,
54 case PIPE_PRIM_POINTS:
56 return SVGA3D_PRIMITIVE_POINTLIST;
59 *out_count = count / 2;
60 return SVGA3D_PRIMITIVE_LINELIST;
62 case PIPE_PRIM_LINE_STRIP:
63 *out_count = count - 1;
64 return SVGA3D_PRIMITIVE_LINESTRIP;
66 case PIPE_PRIM_TRIANGLES:
67 *out_count = count / 3;
68 return SVGA3D_PRIMITIVE_TRIANGLELIST;
70 case PIPE_PRIM_TRIANGLE_STRIP:
71 *out_count = count - 2;
72 return SVGA3D_PRIMITIVE_TRIANGLESTRIP;
74 case PIPE_PRIM_TRIANGLE_FAN:
75 *out_count = count - 2;
76 return SVGA3D_PRIMITIVE_TRIANGLEFAN;
87 u_generate_func generate;
90 /* If non-null, this buffer is filled by calling
91 * generate(nr, map(buffer))
93 struct pipe_buffer *buffer;
99 struct svga_winsys_context *swc;
101 SVGA3dVertexDecl vdecl[SVGA3D_INPUTREG_MAX];
102 struct pipe_buffer *vdecl_vb[SVGA3D_INPUTREG_MAX];
103 unsigned vdecl_count;
105 SVGA3dPrimitiveRange prim[QSZ];
106 struct pipe_buffer *prim_ib[QSZ];
108 unsigned min_index[QSZ];
109 unsigned max_index[QSZ];
112 #define IDX_CACHE_MAX 8
115 struct svga_context *svga;
116 struct u_upload_mgr *upload_ib;
118 /* Flatshade information:
122 unsigned api_fillmode;
124 /* Cache the results of running a particular generate func on each
127 struct index_cache index_cache[PIPE_PRIM_MAX][IDX_CACHE_MAX];
129 /* Try to build the maximal draw command packet before emitting:
136 /***********************************************************************
140 svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
141 const SVGA3dPrimitiveRange *range,
144 struct pipe_buffer *ib );
147 svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
148 struct pipe_buffer *indexBuffer,