14a49301eSmrg/************************************************************************** 24a49301eSmrg * 3af69d88dSmrg * Copyright 2007 VMware, Inc. 44a49301eSmrg * All Rights Reserved. 54a49301eSmrg * 64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a 74a49301eSmrg * copy of this software and associated documentation files (the 84a49301eSmrg * "Software"), to deal in the Software without restriction, including 94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish, 104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to 114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to 124a49301eSmrg * the following conditions: 134a49301eSmrg * 144a49301eSmrg * The above copyright notice and this permission notice (including the 154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions 164a49301eSmrg * of the Software. 174a49301eSmrg * 184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 254a49301eSmrg * 264a49301eSmrg **************************************************************************/ 274a49301eSmrg 284a49301eSmrg /* 294a49301eSmrg * Authors: 30af69d88dSmrg * Keith Whitwell <keithw@vmware.com> 314a49301eSmrg */ 324a49301eSmrg 334a49301eSmrg#ifndef DRAW_PIPE_H 344a49301eSmrg#define DRAW_PIPE_H 354a49301eSmrg 364a49301eSmrg#include "pipe/p_compiler.h" 374a49301eSmrg#include "draw_private.h" /* for sizeof(vertex_header) */ 38af69d88dSmrg#include "draw_context.h" 394a49301eSmrg 404a49301eSmrg 414a49301eSmrg/** 424a49301eSmrg * Basic info for a point/line/triangle primitive. 434a49301eSmrg */ 444a49301eSmrgstruct prim_header { 454a49301eSmrg float det; /**< front/back face determinant */ 464a49301eSmrg ushort flags; 474a49301eSmrg ushort pad; 484a49301eSmrg struct vertex_header *v[3]; /**< 1 to 3 vertex pointers */ 494a49301eSmrg}; 504a49301eSmrg 514a49301eSmrg 524a49301eSmrg 534a49301eSmrg/** 544a49301eSmrg * Base class for all primitive drawing stages. 554a49301eSmrg */ 564a49301eSmrgstruct draw_stage 574a49301eSmrg{ 584a49301eSmrg struct draw_context *draw; /**< parent context */ 594a49301eSmrg 604a49301eSmrg struct draw_stage *next; /**< next stage in pipeline */ 614a49301eSmrg const char *name; /**< for debugging */ 624a49301eSmrg 634a49301eSmrg struct vertex_header **tmp; /**< temp vert storage, such as for clipping */ 644a49301eSmrg unsigned nr_tmps; 654a49301eSmrg 664a49301eSmrg void (*point)( struct draw_stage *, 674a49301eSmrg struct prim_header * ); 684a49301eSmrg 694a49301eSmrg void (*line)( struct draw_stage *, 704a49301eSmrg struct prim_header * ); 714a49301eSmrg 724a49301eSmrg void (*tri)( struct draw_stage *, 734a49301eSmrg struct prim_header * ); 744a49301eSmrg 754a49301eSmrg void (*flush)( struct draw_stage *, 764a49301eSmrg unsigned flags ); 774a49301eSmrg 784a49301eSmrg void (*reset_stipple_counter)( struct draw_stage * ); 794a49301eSmrg 804a49301eSmrg void (*destroy)( struct draw_stage * ); 814a49301eSmrg}; 824a49301eSmrg 834a49301eSmrg 844a49301eSmrgextern struct draw_stage *draw_unfilled_stage( struct draw_context *context ); 854a49301eSmrgextern struct draw_stage *draw_twoside_stage( struct draw_context *context ); 864a49301eSmrgextern struct draw_stage *draw_offset_stage( struct draw_context *context ); 874a49301eSmrgextern struct draw_stage *draw_clip_stage( struct draw_context *context ); 884a49301eSmrgextern struct draw_stage *draw_flatshade_stage( struct draw_context *context ); 894a49301eSmrgextern struct draw_stage *draw_cull_stage( struct draw_context *context ); 907ec681f3Smrgextern struct draw_stage *draw_user_cull_stage( struct draw_context *draw ); 914a49301eSmrgextern struct draw_stage *draw_stipple_stage( struct draw_context *context ); 924a49301eSmrgextern struct draw_stage *draw_wide_line_stage( struct draw_context *context ); 934a49301eSmrgextern struct draw_stage *draw_wide_point_stage( struct draw_context *context ); 944a49301eSmrgextern struct draw_stage *draw_validate_stage( struct draw_context *context ); 954a49301eSmrg 964a49301eSmrgextern void draw_free_temp_verts( struct draw_stage *stage ); 974a49301eSmrgextern boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr ); 984a49301eSmrg 994a49301eSmrgextern void draw_reset_vertex_ids( struct draw_context *draw ); 1004a49301eSmrg 1014a49301eSmrgvoid draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header); 1024a49301eSmrgvoid draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header); 1034a49301eSmrgvoid draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header); 1044a49301eSmrg 105af69d88dSmrgvoid draw_aapoint_prepare_outputs(struct draw_context *context, 106af69d88dSmrg struct draw_stage *stage); 107af69d88dSmrgvoid draw_aaline_prepare_outputs(struct draw_context *context, 108af69d88dSmrg struct draw_stage *stage); 109af69d88dSmrgvoid draw_unfilled_prepare_outputs(struct draw_context *context, 110af69d88dSmrg struct draw_stage *stage); 1114a49301eSmrg 1124a49301eSmrg/** 1134a49301eSmrg * Get a writeable copy of a vertex. 1144a49301eSmrg * \param stage drawing stage info 1154a49301eSmrg * \param vert the vertex to copy (source) 1164a49301eSmrg * \param idx index into stage's tmp[] array to put the copy (dest) 1174a49301eSmrg * \return pointer to the copied vertex 1184a49301eSmrg */ 11901e04c3fSmrgstatic inline struct vertex_header * 1204a49301eSmrgdup_vert( struct draw_stage *stage, 1214a49301eSmrg const struct vertex_header *vert, 1224a49301eSmrg unsigned idx ) 1234a49301eSmrg{ 1244a49301eSmrg struct vertex_header *tmp = stage->tmp[idx]; 1254a49301eSmrg const uint vsize = sizeof(struct vertex_header) 126af69d88dSmrg + draw_num_shader_outputs(stage->draw) * 4 * sizeof(float); 1274a49301eSmrg memcpy(tmp, vert, vsize); 1284a49301eSmrg tmp->vertex_id = UNDEFINED_VERTEX_ID; 1294a49301eSmrg return tmp; 1304a49301eSmrg} 1314a49301eSmrg 1324a49301eSmrg#endif 133