Make gallium compile in win32.
[mesa.git] / src / mesa / pipe / softpipe / sp_context.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 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
29 */
30
31 #ifndef SP_CONTEXT_H
32 #define SP_CONTEXT_H
33
34 #include "pipe/p_context.h"
35 #include "pipe/p_defines.h"
36
37 #include "pipe/draw/draw_vertex.h"
38
39 #include "sp_quad.h"
40
41
42 struct softpipe_winsys;
43 struct draw_context;
44 struct draw_stage;
45 struct softpipe_tile_cache;
46
47
48 #define SP_NEW_VIEWPORT 0x1
49 #define SP_NEW_RASTERIZER 0x2
50 #define SP_NEW_FS 0x4
51 #define SP_NEW_BLEND 0x8
52 #define SP_NEW_CLIP 0x10
53 #define SP_NEW_SCISSOR 0x20
54 #define SP_NEW_STIPPLE 0x40
55 #define SP_NEW_FRAMEBUFFER 0x80
56 #define SP_NEW_ALPHA_TEST 0x100
57 #define SP_NEW_DEPTH_STENCIL 0x200
58 #define SP_NEW_SAMPLER 0x400
59 #define SP_NEW_TEXTURE 0x800
60 #define SP_NEW_VERTEX 0x1000
61 #define SP_NEW_VS 0x2000
62 #define SP_NEW_CONSTANTS 0x4000
63
64 struct sp_vertex_shader_state {
65 struct pipe_shader_state *state;
66 void *draw_data;
67 };
68
69 struct softpipe_context {
70 struct pipe_context pipe; /**< base class */
71 struct softpipe_winsys *winsys; /**< window system interface */
72
73
74 /* The most recent drawing state as set by the driver:
75 */
76 const struct pipe_alpha_test_state *alpha_test;
77 const struct pipe_blend_state *blend;
78 const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
79 const struct pipe_depth_stencil_state *depth_stencil;
80 const struct pipe_rasterizer_state *rasterizer;
81 const struct sp_fragment_shader_state *fs;
82 const struct sp_vertex_shader_state *vs;
83
84 struct pipe_blend_color blend_color;
85 struct pipe_clear_color_state clear_color;
86 struct pipe_clip_state clip;
87 struct pipe_constant_buffer constants[2];
88 struct pipe_feedback_state feedback;
89 struct pipe_framebuffer_state framebuffer;
90 struct pipe_poly_stipple poly_stipple;
91 struct pipe_scissor_state scissor;
92 struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
93 struct pipe_viewport_state viewport;
94 struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
95 struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
96 uint sampler_units[PIPE_MAX_SAMPLERS];
97 unsigned dirty;
98
99 /*
100 * Active queries
101 */
102 struct pipe_query_object *queries[PIPE_QUERY_TYPES];
103
104 /*
105 * Mapped vertex buffers
106 */
107 ubyte *mapped_vbuffer[PIPE_ATTRIB_MAX];
108
109 /** Mapped constant buffers */
110 void *mapped_constants[PIPE_SHADER_TYPES];
111
112 /** Vertex format */
113 struct vertex_info vertex_info;
114 unsigned attr_mask;
115 unsigned nr_frag_attrs; /**< number of active fragment attribs */
116 boolean need_z; /**< produce quad/fragment Z values? */
117 boolean need_w; /**< produce quad/fragment W values? */
118 int psize_slot;
119
120 /** Feedback buffers */
121 struct pipe_feedback_buffer feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS];
122
123 #if 0
124 /* Stipple derived state:
125 */
126 ubyte stipple_masks[16][16];
127 #endif
128
129 /** Derived from scissor and surface bounds: */
130 struct pipe_scissor_state cliprect;
131
132 unsigned line_stipple_counter;
133
134 /** Software quad rendering pipeline */
135 struct {
136 struct quad_stage *polygon_stipple;
137 struct quad_stage *shade;
138 struct quad_stage *alpha_test;
139 struct quad_stage *stencil_test;
140 struct quad_stage *depth_test;
141 struct quad_stage *occlusion;
142 struct quad_stage *coverage;
143 struct quad_stage *bufloop;
144 struct quad_stage *blend;
145 struct quad_stage *colormask;
146 struct quad_stage *output;
147
148 struct quad_stage *first; /**< points to one of the above stages */
149 } quad;
150
151 /** The primitive drawing context */
152 struct draw_context *draw;
153 struct draw_stage *setup;
154 struct draw_stage *vbuf;
155
156 struct pipe_surface *cbuf; /**< current color buffer (one of cbufs) */
157
158 struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];
159 struct softpipe_tile_cache *zbuf_cache;
160 /** Stencil buffer cache, for stencil separate from Z */
161 struct softpipe_tile_cache *sbuf_cache_sep;
162 /** This either points to zbuf_cache or sbuf_cache_sep */
163 struct softpipe_tile_cache *sbuf_cache;
164
165 struct softpipe_tile_cache *tex_cache[PIPE_MAX_SAMPLERS];
166
167 int use_sse : 1;
168 int dump_fs : 1;
169 };
170
171
172
173
174 static INLINE struct softpipe_context *
175 softpipe_context( struct pipe_context *pipe )
176 {
177 return (struct softpipe_context *)pipe;
178 }
179
180
181 #endif /* SP_CONTEXT_H */