Merge branch 'gallium-0.1' into gallium-0.2
[mesa.git] / src / gallium / drivers / 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 "draw/draw_vertex.h"
38
39 #include "sp_quad.h"
40
41
42 /**
43 * This is a temporary variable for testing draw-stage polygon stipple.
44 * If zero, do stipple in sp_quad_stipple.c
45 */
46 #define USE_DRAW_STAGE_PSTIPPLE 1
47
48
49 struct softpipe_winsys;
50 struct softpipe_vbuf_render;
51 struct draw_context;
52 struct draw_stage;
53 struct softpipe_tile_cache;
54 struct sp_fragment_shader;
55 struct sp_vertex_shader;
56
57
58 struct softpipe_context {
59 struct pipe_context pipe; /**< base class */
60
61 /* The most recent drawing state as set by the driver:
62 */
63 const struct pipe_blend_state *blend;
64 const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
65 const struct pipe_depth_stencil_alpha_state *depth_stencil;
66 const struct pipe_rasterizer_state *rasterizer;
67 const struct sp_fragment_shader *fs;
68 const struct sp_vertex_shader *vs;
69
70 struct pipe_blend_color blend_color;
71 struct pipe_clip_state clip;
72 struct pipe_constant_buffer constants[PIPE_SHADER_TYPES];
73 struct pipe_framebuffer_state framebuffer;
74 struct pipe_poly_stipple poly_stipple;
75 struct pipe_scissor_state scissor;
76 struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
77 struct pipe_viewport_state viewport;
78 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
79 struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
80 unsigned dirty;
81
82 unsigned num_samplers;
83 unsigned num_textures;
84 unsigned num_vertex_elements;
85 unsigned num_vertex_buffers;
86
87 boolean no_rast;
88
89 /* Counter for occlusion queries. Note this supports overlapping
90 * queries.
91 */
92 uint64 occlusion_count;
93
94 /*
95 * Mapped vertex buffers
96 */
97 ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS];
98
99 /** Mapped constant buffers */
100 void *mapped_constants[PIPE_SHADER_TYPES];
101
102 /** Vertex format */
103 struct vertex_info vertex_info;
104 struct vertex_info vertex_info_vbuf;
105
106 int psize_slot;
107
108 unsigned reduced_api_prim; /**< PIPE_PRIM_POINTS, _LINES or _TRIANGLES */
109
110 #if 0
111 /* Stipple derived state:
112 */
113 ubyte stipple_masks[16][16];
114 #endif
115
116 /** Derived from scissor and surface bounds: */
117 struct pipe_scissor_state cliprect;
118
119 unsigned line_stipple_counter;
120
121 /** Software quad rendering pipeline */
122 struct {
123 struct quad_stage *polygon_stipple;
124 struct quad_stage *earlyz;
125 struct quad_stage *shade;
126 struct quad_stage *alpha_test;
127 struct quad_stage *stencil_test;
128 struct quad_stage *depth_test;
129 struct quad_stage *occlusion;
130 struct quad_stage *coverage;
131 struct quad_stage *blend;
132 struct quad_stage *colormask;
133 struct quad_stage *output;
134
135 struct quad_stage *first; /**< points to one of the above stages */
136 } quad;
137
138 /** The primitive drawing context */
139 struct draw_context *draw;
140 struct draw_stage *setup;
141 struct draw_stage *vbuf;
142 struct softpipe_vbuf_render *vbuf_render;
143
144 struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];
145 struct softpipe_tile_cache *zsbuf_cache;
146
147 struct softpipe_tile_cache *tex_cache[PIPE_MAX_SAMPLERS];
148
149 int use_sse : 1;
150 int dump_fs : 1;
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 */