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