1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2007 VMware, Inc.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
16bf215546Sopenharmony_ci * of the Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci **************************************************************************/
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci /*
29bf215546Sopenharmony_ci  * Authors:
30bf215546Sopenharmony_ci  *   Keith Whitwell <keithw@vmware.com>
31bf215546Sopenharmony_ci  */
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#ifndef DRAW_PIPE_H
34bf215546Sopenharmony_ci#define DRAW_PIPE_H
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci#include "pipe/p_compiler.h"
37bf215546Sopenharmony_ci#include "draw_private.h"       /* for sizeof(vertex_header) */
38bf215546Sopenharmony_ci#include "draw_context.h"
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_ci/**
42bf215546Sopenharmony_ci * Basic info for a point/line/triangle primitive.
43bf215546Sopenharmony_ci */
44bf215546Sopenharmony_cistruct prim_header {
45bf215546Sopenharmony_ci   float det;                 /**< front/back face determinant */
46bf215546Sopenharmony_ci   ushort flags;
47bf215546Sopenharmony_ci   ushort pad;
48bf215546Sopenharmony_ci   struct vertex_header *v[3];  /**< 1 to 3 vertex pointers */
49bf215546Sopenharmony_ci};
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ci/**
54bf215546Sopenharmony_ci * Base class for all primitive drawing stages.
55bf215546Sopenharmony_ci */
56bf215546Sopenharmony_cistruct draw_stage
57bf215546Sopenharmony_ci{
58bf215546Sopenharmony_ci   struct draw_context *draw;   /**< parent context */
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ci   struct draw_stage *next;     /**< next stage in pipeline */
61bf215546Sopenharmony_ci   const char *name;            /**< for debugging  */
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_ci   struct vertex_header **tmp;  /**< temp vert storage, such as for clipping */
64bf215546Sopenharmony_ci   unsigned nr_tmps;
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ci   void (*point)( struct draw_stage *,
67bf215546Sopenharmony_ci		  struct prim_header * );
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ci   void (*line)( struct draw_stage *,
70bf215546Sopenharmony_ci		 struct prim_header * );
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_ci   void (*tri)( struct draw_stage *,
73bf215546Sopenharmony_ci		struct prim_header * );
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci   void (*flush)( struct draw_stage *,
76bf215546Sopenharmony_ci		  unsigned flags );
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_ci   void (*reset_stipple_counter)( struct draw_stage * );
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci   void (*destroy)( struct draw_stage * );
81bf215546Sopenharmony_ci};
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ciextern struct draw_stage *draw_unfilled_stage( struct draw_context *context );
85bf215546Sopenharmony_ciextern struct draw_stage *draw_twoside_stage( struct draw_context *context );
86bf215546Sopenharmony_ciextern struct draw_stage *draw_offset_stage( struct draw_context *context );
87bf215546Sopenharmony_ciextern struct draw_stage *draw_clip_stage( struct draw_context *context );
88bf215546Sopenharmony_ciextern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
89bf215546Sopenharmony_ciextern struct draw_stage *draw_cull_stage( struct draw_context *context );
90bf215546Sopenharmony_ciextern struct draw_stage *draw_user_cull_stage( struct draw_context *draw );
91bf215546Sopenharmony_ciextern struct draw_stage *draw_stipple_stage( struct draw_context *context );
92bf215546Sopenharmony_ciextern struct draw_stage *draw_wide_line_stage( struct draw_context *context );
93bf215546Sopenharmony_ciextern struct draw_stage *draw_wide_point_stage( struct draw_context *context );
94bf215546Sopenharmony_ciextern struct draw_stage *draw_validate_stage( struct draw_context *context );
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ciextern void draw_free_temp_verts( struct draw_stage *stage );
97bf215546Sopenharmony_ciextern boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr );
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ciextern void draw_reset_vertex_ids( struct draw_context *draw );
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_civoid draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header);
102bf215546Sopenharmony_civoid draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header);
103bf215546Sopenharmony_civoid draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header);
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_civoid draw_aapoint_prepare_outputs(struct draw_context *context,
106bf215546Sopenharmony_ci                                  struct draw_stage *stage);
107bf215546Sopenharmony_civoid draw_aaline_prepare_outputs(struct draw_context *context,
108bf215546Sopenharmony_ci                                 struct draw_stage *stage);
109bf215546Sopenharmony_civoid draw_unfilled_prepare_outputs(struct draw_context *context,
110bf215546Sopenharmony_ci                                   struct draw_stage *stage);
111bf215546Sopenharmony_ci
112bf215546Sopenharmony_ci/**
113bf215546Sopenharmony_ci * Get a writeable copy of a vertex.
114bf215546Sopenharmony_ci * \param stage  drawing stage info
115bf215546Sopenharmony_ci * \param vert  the vertex to copy (source)
116bf215546Sopenharmony_ci * \param idx  index into stage's tmp[] array to put the copy (dest)
117bf215546Sopenharmony_ci * \return  pointer to the copied vertex
118bf215546Sopenharmony_ci */
119bf215546Sopenharmony_cistatic inline struct vertex_header *
120bf215546Sopenharmony_cidup_vert( struct draw_stage *stage,
121bf215546Sopenharmony_ci	  const struct vertex_header *vert,
122bf215546Sopenharmony_ci	  unsigned idx )
123bf215546Sopenharmony_ci{
124bf215546Sopenharmony_ci   struct vertex_header *tmp = stage->tmp[idx];
125bf215546Sopenharmony_ci   const uint vsize = sizeof(struct vertex_header)
126bf215546Sopenharmony_ci      + draw_num_shader_outputs(stage->draw) * 4 * sizeof(float);
127bf215546Sopenharmony_ci   memcpy(tmp, vert, vsize);
128bf215546Sopenharmony_ci   tmp->vertex_id = UNDEFINED_VERTEX_ID;
129bf215546Sopenharmony_ci   return tmp;
130bf215546Sopenharmony_ci}
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci#endif
133