Initial work for glClear(), clear color state.
[mesa.git] / src / mesa / pipe / p_state.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 #ifndef PIPE_STATE_H
29 #define PIPE_STATE_H
30
31 #include "mtypes.h"
32 #include "vf/vf.h"
33
34 #define WINDING_NONE 0
35 #define WINDING_CW 1
36 #define WINDING_CCW 2
37 #define WINDING_BOTH (WINDING_CW | WINDING_CCW)
38
39 #define FILL_POINT 1
40 #define FILL_LINE 2
41 #define FILL_TRI 3
42
43 struct pipe_setup_state {
44 GLuint flatshade:1;
45 GLuint light_twoside:1;
46
47 GLuint front_winding:2;
48
49 GLuint cull_mode:2;
50
51 GLuint fill_cw:2;
52 GLuint fill_ccw:2;
53
54 GLuint offset_cw:1;
55 GLuint offset_ccw:1;
56
57 GLuint scissor:1;
58 GLuint poly_stipple:1;
59
60 GLuint pad:18;
61
62 GLfloat offset_units;
63 GLfloat offset_scale;
64 };
65
66 struct pipe_poly_stipple {
67 GLuint stipple[32];
68 };
69
70
71 struct pipe_viewport {
72 GLfloat scale[4];
73 GLfloat translate[4];
74 };
75
76 struct pipe_scissor_rect {
77 GLshort minx;
78 GLshort miny;
79 GLshort maxx;
80 GLshort maxy;
81 };
82
83
84 #define PIPE_MAX_CLIP_PLANES 6
85
86 struct pipe_clip_state {
87 GLfloat ucp[PIPE_MAX_CLIP_PLANES][4];
88 GLuint nr;
89 };
90
91 struct pipe_fs_state {
92 struct gl_fragment_program *fp;
93 };
94
95 #define PIPE_MAX_CONSTANT 32
96
97 struct pipe_constant_buffer {
98 GLfloat constant[PIPE_MAX_CONSTANT][4];
99 GLuint nr_constants;
100 };
101
102
103 struct pipe_depth_state
104 {
105 GLuint enabled:1; /**< depth test enabled? */
106 GLuint writemask:1; /**< allow depth buffer writes? */
107 GLuint func:3; /**< depth test func (PIPE_FUNC_x) */
108 GLfloat clear; /**< Clear value in [0,1] (XXX correct place?) */
109 };
110
111 struct pipe_alpha_test_state {
112 GLuint enable:1;
113 GLuint func:3; /**< PIPE_FUNC_x */
114 GLfloat ref; /**< reference value */
115 };
116
117 struct pipe_blend_state {
118 GLuint blend_enable:1;
119
120 GLuint rgb_func:3;
121 GLuint rgb_src_factor:5;
122 GLuint rgb_dst_factor:5;
123
124 GLuint alpha_func:3;
125 GLuint alpha_src_factor:5;
126 GLuint alpha_dst_factor:5;
127
128 GLuint logicop_enable:1;
129 GLuint logicop_func:4;
130 };
131
132 struct pipe_blend_color {
133 GLfloat color[4];
134 };
135
136 struct pipe_clear_color_state
137 {
138 GLfloat color[4];
139 };
140
141 struct pipe_line_state
142 {
143 GLuint smooth:1;
144 GLuint stipple:1;
145 GLushort stipple_pattern;
146 GLint stipple_factor;
147 GLfloat width;
148 };
149
150 struct pipe_point_state
151 {
152 GLuint smooth:1;
153 GLfloat size;
154 GLfloat min_size, max_size;
155 GLfloat attenuation[3];
156 };
157
158 struct pipe_polygon_state {
159 GLuint cull_mode:2; /**< PIPE_POLYGON_CULL_x */
160 GLuint front_winding:1; /**< PIPE_POLYGON_FRONT_CCW,CW */
161 GLuint front_mode:2; /**< PIPE_POLYGON_MODE_x */
162 GLuint back_mode:2; /**< PIPE_POLYGON_MODE_x */
163 GLuint stipple:1; /**< enable */
164 GLuint smooth:1; /**< enable */
165 /* XXX Polygon offset? */
166 };
167
168 struct pipe_stencil_state {
169 GLuint front_enabled:1;
170 GLuint front_func:3; /**< PIPE_FUNC_x */
171 GLuint front_fail_op:3; /**< PIPE_STENCIL_OP_x */
172 GLuint front_zpass_op:3; /**< PIPE_STENCIL_OP_x */
173 GLuint front_zfail_op:3; /**< PIPE_STENCIL_OP_x */
174 GLuint back_enabled:1;
175 GLuint back_func:3;
176 GLuint back_fail_op:3;
177 GLuint back_zpass_op:3;
178 GLuint back_zfail_op:3;
179 GLubyte ref_value[2]; /**< [0] = front, [1] = back */
180 GLubyte value_mask[2];
181 GLubyte write_mask[2];
182 GLubyte clear_value;
183 };
184
185
186 /* This will change for hardware pipes...
187 */
188 struct pipe_surface
189 {
190 GLuint width, height;
191 GLubyte *ptr;
192 GLint stride;
193 GLuint cpp;
194 GLuint format;
195 };
196
197
198 struct pipe_framebuffer_state
199 {
200 GLuint num_cbufs; /**< Number of color bufs to draw to */
201 struct pipe_surface *cbufs[4]; /**< OpenGL can write to as many as
202 4 color buffers at once */
203 struct pipe_surface *zbuf; /**< Z buffer */
204 struct pipe_surface *sbuf; /**< Stencil buffer */
205 struct pipe_surface *abuf; /**< Accum buffer */
206 };
207
208
209 /**
210 * Texture sampler state.
211 */
212 struct pipe_sampler_state
213 {
214 GLuint wrap_s:3; /**< PIPE_TEX_WRAP_x */
215 GLuint wrap_t:3; /**< PIPE_TEX_WRAP_x */
216 GLuint wrap_r:3; /**< PIPE_TEX_WRAP_x */
217 GLuint min_filter:3; /**< PIPE_TEX_FILTER_x */
218 GLuint mag_filter:1; /**< PIPE_TEX_FILTER_LINEAR or _NEAREST */
219 GLfloat min_lod;
220 GLfloat max_lod;
221 GLfloat lod_bias;
222 #if 0 /* need these? */
223 GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
224 GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
225 #endif
226 GLfloat max_anisotropy;
227 GLuint compare:1; /**< shadow/depth compare enabled? */
228 GLenum compare_mode:1; /**< PIPE_TEX_COMPARE_x */
229 GLenum compare_func:3; /**< PIPE_FUNC_x */
230 GLfloat shadow_ambient; /**< shadow test fail color/intensity */
231 };
232
233 #endif