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 **************************************************************************/
29 * Private data structures, etc for the draw module.
35 * Keith Whitwell <keith@tungstengraphics.com>
40 #ifndef DRAW_PRIVATE_H
41 #define DRAW_PRIVATE_H
44 #include "pipe/p_state.h"
45 #include "pipe/p_defines.h"
47 #include "tgsi/exec/tgsi_exec.h"
48 #include "tgsi/util/tgsi_scan.h"
53 struct gallivm_cpu_engine
;
54 struct draw_vertex_shader
;
62 * Carry some useful information around with the vertices in the prim pipe.
64 struct vertex_header
{
68 unsigned vertex_id
:16;
72 /* This will probably become float (*data)[4] soon:
77 /* NOTE: It should match vertex_id size above */
78 #define UNDEFINED_VERTEX_ID 0xffff
82 * Private context for the drawing module.
86 /** Drawing/primitive pipeline stages */
88 struct draw_stage
*first
; /**< one of the following */
90 struct draw_stage
*validate
;
92 /* stages (in logical order) */
93 struct draw_stage
*flatshade
;
94 struct draw_stage
*clip
;
95 struct draw_stage
*cull
;
96 struct draw_stage
*twoside
;
97 struct draw_stage
*offset
;
98 struct draw_stage
*unfilled
;
99 struct draw_stage
*stipple
;
100 struct draw_stage
*aapoint
;
101 struct draw_stage
*aaline
;
102 struct draw_stage
*pstipple
;
103 struct draw_stage
*wide_line
;
104 struct draw_stage
*wide_point
;
105 struct draw_stage
*rasterize
;
107 float wide_point_threshold
; /**< convert pnts to tris if larger than this */
108 float wide_line_threshold
; /**< convert lines to tris if wider than this */
109 boolean line_stipple
; /**< do line stipple? */
110 boolean point_sprite
; /**< convert points to quads for sprites? */
112 /* Temporary storage while the pipeline is being run:
115 unsigned vertex_stride
;
116 unsigned vertex_count
;
120 struct vbuf_render
*render
;
122 /* Support prototype passthrough path:
126 struct draw_pt_middle_end
*fetch_emit
;
127 struct draw_pt_middle_end
*general
;
131 struct draw_pt_front_end
*vcache
;
132 struct draw_pt_front_end
*varray
;
135 struct pipe_vertex_buffer vertex_buffer
[PIPE_MAX_ATTRIBS
];
136 unsigned nr_vertex_buffers
;
138 struct pipe_vertex_element vertex_element
[PIPE_MAX_ATTRIBS
];
139 unsigned nr_vertex_elements
;
141 /* user-space vertex data, buffers */
143 const unsigned *edgeflag
;
145 /** vertex element/index buffer (ex: glDrawElements) */
147 /** bytes per index (0, 1, 2 or 4) */
151 const void *vbuffer
[PIPE_MAX_ATTRIBS
];
153 /** constant buffer (for vertex shader) */
154 const void *constants
;
160 boolean bypass_clipping
;
163 boolean flushing
; /**< debugging/sanity */
164 boolean suspend_flushing
; /**< internally set */
165 boolean bypass_clipping
; /**< set if either api or driver bypass_clipping true */
167 /* pipe state that we need: */
168 const struct pipe_rasterizer_state
*rasterizer
;
169 struct pipe_viewport_state viewport
;
171 struct draw_vertex_shader
*vertex_shader
;
173 boolean identity_viewport
;
175 uint num_vs_outputs
; /**< convenience, from vertex_shader */
178 /* Clip derived state:
183 /* If a prim stage introduces new vertex attributes, they'll be stored here
191 unsigned reduced_prim
;
193 /** TGSI program interpreter runtime state */
194 struct tgsi_exec_machine machine
;
196 /* This (and the tgsi_exec_machine struct) probably need to be moved somewhere private.
198 struct gallivm_cpu_engine
*engine
;
199 void *driver_private
;
208 /*******************************************************************************
209 * Vertex processing (was passthrough) code:
211 boolean
draw_pt_init( struct draw_context
*draw
);
212 void draw_pt_destroy( struct draw_context
*draw
);
213 void draw_pt_reset_vertex_ids( struct draw_context
*draw
);
216 /*******************************************************************************
217 * Primitive processing (pipeline) code:
220 boolean
draw_pipeline_init( struct draw_context
*draw
);
221 void draw_pipeline_destroy( struct draw_context
*draw
);
227 /* We use the top few bits in the elts[] parameter to convey a little
228 * API information. This limits the number of vertices we can address
229 * to only 4096 -- if that becomes a problem, we can switch to 32-bit
232 * These flags expected at first vertex of lines & triangles when
233 * unfilled and/or line stipple modes are operational.
235 #define DRAW_PIPE_EDGE_FLAG_0 (0x1<<12)
236 #define DRAW_PIPE_EDGE_FLAG_1 (0x2<<12)
237 #define DRAW_PIPE_EDGE_FLAG_2 (0x4<<12)
238 #define DRAW_PIPE_EDGE_FLAG_ALL (0x7<<12)
239 #define DRAW_PIPE_RESET_STIPPLE (0x8<<12)
240 #define DRAW_PIPE_FLAG_MASK (0xf<<12)
242 void draw_pipeline_run( struct draw_context
*draw
,
244 struct vertex_header
*vertices
,
245 unsigned vertex_count
,
252 void draw_pipeline_flush( struct draw_context
*draw
,
257 /*******************************************************************************
261 #define DRAW_FLUSH_STATE_CHANGE 0x8
262 #define DRAW_FLUSH_BACKEND 0x10
265 void draw_do_flush( struct draw_context
*draw
, unsigned flags
);
270 #endif /* DRAW_PRIVATE_H */