1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Keith Whitwell <keith@tungstengraphics.com>
33 #include "util/u_memory.h"
34 #include "draw/draw_private.h"
35 #include "draw/draw_pipe.h"
40 draw_pipe_passthrough_point(struct draw_stage
*stage
, struct prim_header
*header
)
42 stage
->next
->point(stage
->next
, header
);
46 draw_pipe_passthrough_line(struct draw_stage
*stage
, struct prim_header
*header
)
48 stage
->next
->line(stage
->next
, header
);
52 draw_pipe_passthrough_tri(struct draw_stage
*stage
, struct prim_header
*header
)
54 stage
->next
->tri(stage
->next
, header
);
61 /* This is only used for temporary verts.
63 #define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
67 * Allocate space for temporary post-transform vertices, such as for clipping.
69 boolean
draw_alloc_temp_verts( struct draw_stage
*stage
, unsigned nr
)
79 ubyte
*store
= (ubyte
*) MALLOC( MAX_VERTEX_SIZE
* nr
);
84 stage
->tmp
= (struct vertex_header
**) MALLOC( sizeof(struct vertex_header
*) * nr
);
85 if (stage
->tmp
== NULL
) {
90 for (i
= 0; i
< nr
; i
++)
91 stage
->tmp
[i
] = (struct vertex_header
*)(store
+ i
* MAX_VERTEX_SIZE
);
98 void draw_free_temp_verts( struct draw_stage
*stage
)
101 FREE( stage
->tmp
[0] );
108 /* Reset vertex ids. This is basically a type of flush.
110 * Called only from draw_pipe_vbuf.c
112 void draw_reset_vertex_ids(struct draw_context
*draw
)
114 struct draw_stage
*stage
= draw
->pipeline
.first
;
119 for (i
= 0; i
< stage
->nr_tmps
; i
++)
120 stage
->tmp
[i
]->vertex_id
= UNDEFINED_VERTEX_ID
;
125 if (draw
->pipeline
.verts
)
128 char *verts
= draw
->pipeline
.verts
;
129 unsigned stride
= draw
->pipeline
.vertex_stride
;
131 for (i
= 0; i
< draw
->pipeline
.vertex_count
; i
++) {
132 ((struct vertex_header
*)verts
)->vertex_id
= UNDEFINED_VERTEX_ID
;