}
}
-/* XXX move to u_prim.h */
-static unsigned
-prim_count(unsigned prim, unsigned num_verts)
-{
- unsigned num_prims;
-
- u_trim_pipe_prim(prim, &num_verts);
-
- switch (prim) {
- case PIPE_PRIM_POINTS:
- num_prims = num_verts;
- break;
- case PIPE_PRIM_LINES:
- num_prims = num_verts / 2;
- break;
- case PIPE_PRIM_LINE_LOOP:
- num_prims = num_verts;
- break;
- case PIPE_PRIM_LINE_STRIP:
- num_prims = num_verts - 1;
- break;
- case PIPE_PRIM_TRIANGLES:
- num_prims = num_verts / 3;
- break;
- case PIPE_PRIM_TRIANGLE_STRIP:
- case PIPE_PRIM_TRIANGLE_FAN:
- num_prims = num_verts - 2;
- break;
- case PIPE_PRIM_QUADS:
- num_prims = (num_verts / 4) * 2;
- break;
- case PIPE_PRIM_QUAD_STRIP:
- num_prims = (num_verts / 2 - 1) * 2;
- break;
- case PIPE_PRIM_POLYGON:
- num_prims = num_verts - 2;
- break;
- case PIPE_PRIM_LINES_ADJACENCY:
- num_prims = num_verts / 4;
- break;
- case PIPE_PRIM_LINE_STRIP_ADJACENCY:
- num_prims = num_verts - 3;
- break;
- case PIPE_PRIM_TRIANGLES_ADJACENCY:
- /* u_trim_pipe_prim is wrong? */
- num_verts += 1;
-
- num_prims = num_verts / 6;
- break;
- case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
- /* u_trim_pipe_prim is wrong? */
- if (num_verts >= 6)
- num_verts -= (num_verts % 2);
- else
- num_verts = 0;
-
- num_prims = (num_verts / 2 - 2);
- break;
- default:
- assert(!"unknown pipe prim");
- num_prims = 0;
- break;
- }
-
- return num_prims;
-}
-
/**
* Emit context states and 3DPRIMITIVE.
*/
const int num_verts = u_vertices_per_prim(u_reduced_prim(info->mode));
const int max_emit =
(p->state.so_max_vertices - p->state.so_num_vertices) / num_verts;
- const int generated = prim_count(info->mode, info->count);
+ const int generated = u_reduced_prims_for_vertices(info->mode, info->count);
const int emitted = MIN2(generated, max_emit);
p->state.so_num_vertices += emitted * num_verts;