Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4358 | Serge | 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 |
||
29 | */ |
||
30 | |||
31 | #ifndef SP_CONTEXT_H |
||
32 | #define SP_CONTEXT_H |
||
33 | |||
34 | #include "pipe/p_context.h" |
||
35 | #include "util/u_blitter.h" |
||
36 | |||
37 | #include "draw/draw_vertex.h" |
||
38 | |||
39 | #include "sp_quad_pipe.h" |
||
40 | |||
41 | |||
42 | /** Do polygon stipple in the draw module? */ |
||
43 | #define DO_PSTIPPLE_IN_DRAW_MODULE 0 |
||
44 | |||
45 | /** Do polygon stipple with the util module? */ |
||
46 | #define DO_PSTIPPLE_IN_HELPER_MODULE 1 |
||
47 | |||
48 | |||
49 | struct softpipe_vbuf_render; |
||
50 | struct draw_context; |
||
51 | struct draw_stage; |
||
52 | struct softpipe_tile_cache; |
||
53 | struct softpipe_tex_tile_cache; |
||
54 | struct sp_fragment_shader; |
||
55 | struct sp_vertex_shader; |
||
56 | struct sp_velems_state; |
||
57 | struct sp_so_state; |
||
58 | |||
59 | struct softpipe_context { |
||
60 | struct pipe_context pipe; /**< base class */ |
||
61 | |||
62 | /** Constant state objects */ |
||
63 | struct pipe_blend_state *blend; |
||
64 | struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; |
||
65 | struct pipe_depth_stencil_alpha_state *depth_stencil; |
||
66 | struct pipe_rasterizer_state *rasterizer; |
||
67 | struct sp_fragment_shader *fs; |
||
68 | struct sp_fragment_shader_variant *fs_variant; |
||
69 | struct sp_vertex_shader *vs; |
||
70 | struct sp_geometry_shader *gs; |
||
71 | struct sp_velems_state *velems; |
||
72 | struct sp_so_state *so; |
||
73 | |||
74 | /** Other rendering state */ |
||
75 | struct pipe_blend_color blend_color; |
||
76 | struct pipe_blend_color blend_color_clamped; |
||
77 | struct pipe_stencil_ref stencil_ref; |
||
78 | struct pipe_clip_state clip; |
||
79 | struct pipe_resource *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; |
||
80 | struct pipe_framebuffer_state framebuffer; |
||
81 | struct pipe_poly_stipple poly_stipple; |
||
82 | struct pipe_scissor_state scissor; |
||
83 | struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS]; |
||
84 | |||
85 | struct pipe_viewport_state viewport; |
||
86 | struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; |
||
87 | struct pipe_index_buffer index_buffer; |
||
88 | |||
89 | struct draw_so_target *so_targets[PIPE_MAX_SO_BUFFERS]; |
||
90 | unsigned num_so_targets; |
||
91 | |||
92 | struct pipe_query_data_so_statistics so_stats; |
||
93 | unsigned num_primitives_generated; |
||
94 | |||
95 | struct pipe_query_data_pipeline_statistics pipeline_statistics; |
||
96 | unsigned active_statistics_queries; |
||
97 | |||
98 | unsigned num_samplers[PIPE_SHADER_TYPES]; |
||
99 | unsigned num_sampler_views[PIPE_SHADER_TYPES]; |
||
100 | |||
101 | unsigned num_vertex_buffers; |
||
102 | |||
103 | unsigned dirty; /**< Mask of SP_NEW_x flags */ |
||
104 | |||
105 | /* Counter for occlusion queries. Note this supports overlapping |
||
106 | * queries. |
||
107 | */ |
||
108 | uint64_t occlusion_count; |
||
109 | unsigned active_query_count; |
||
110 | |||
111 | /** Mapped vertex buffers */ |
||
112 | ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS]; |
||
113 | |||
114 | /** Mapped constant buffers */ |
||
115 | const void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; |
||
116 | unsigned const_buffer_size[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; |
||
117 | |||
118 | /** Vertex format */ |
||
119 | struct vertex_info vertex_info; |
||
120 | struct vertex_info vertex_info_vbuf; |
||
121 | |||
122 | /** Which vertex shader output slot contains point size */ |
||
123 | int psize_slot; |
||
124 | |||
125 | /** The reduced version of the primitive supplied by the state tracker */ |
||
126 | unsigned reduced_api_prim; |
||
127 | |||
128 | /** Derived information about which winding orders to cull */ |
||
129 | unsigned cull_mode; |
||
130 | |||
131 | /** |
||
132 | * The reduced primitive after unfilled triangles, wide-line decomposition, |
||
133 | * etc, are taken into account. This is the primitive type that's actually |
||
134 | * rasterized. |
||
135 | */ |
||
136 | unsigned reduced_prim; |
||
137 | |||
138 | /** Derived from scissor and surface bounds: */ |
||
139 | struct pipe_scissor_state cliprect; |
||
140 | |||
141 | unsigned line_stipple_counter; |
||
142 | |||
143 | /** Conditional query object and mode */ |
||
144 | struct pipe_query *render_cond_query; |
||
145 | uint render_cond_mode; |
||
146 | boolean render_cond_cond; |
||
147 | |||
148 | /** Polygon stipple items */ |
||
149 | struct { |
||
150 | struct pipe_resource *texture; |
||
151 | struct pipe_sampler_state *sampler; |
||
152 | struct pipe_sampler_view *sampler_view; |
||
153 | } pstipple; |
||
154 | |||
155 | /** Software quad rendering pipeline */ |
||
156 | struct { |
||
157 | struct quad_stage *shade; |
||
158 | struct quad_stage *depth_test; |
||
159 | struct quad_stage *blend; |
||
160 | struct quad_stage *pstipple; |
||
161 | struct quad_stage *first; /**< points to one of the above stages */ |
||
162 | } quad; |
||
163 | |||
164 | /** TGSI exec things */ |
||
165 | struct { |
||
166 | struct sp_tgsi_sampler *sampler[PIPE_SHADER_TYPES]; |
||
167 | } tgsi; |
||
168 | |||
169 | struct tgsi_exec_machine *fs_machine; |
||
170 | |||
171 | /** The primitive drawing context */ |
||
172 | struct draw_context *draw; |
||
173 | |||
174 | /** Draw module backend */ |
||
175 | struct vbuf_render *vbuf_backend; |
||
176 | struct draw_stage *vbuf; |
||
177 | |||
178 | struct blitter_context *blitter; |
||
179 | |||
180 | boolean dirty_render_cache; |
||
181 | |||
182 | struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS]; |
||
183 | struct softpipe_tile_cache *zsbuf_cache; |
||
184 | |||
185 | unsigned tex_timestamp; |
||
186 | |||
187 | /* |
||
188 | * Texture caches for vertex, fragment, geometry stages. |
||
189 | * Don't use PIPE_SHADER_TYPES here to avoid allocating unused memory |
||
190 | * for compute shaders. |
||
191 | * XXX wouldn't it make more sense for the tile cache to just be part |
||
192 | * of sp_sampler_view? |
||
193 | */ |
||
194 | struct softpipe_tex_tile_cache *tex_cache[PIPE_SHADER_GEOMETRY+1][PIPE_MAX_SHADER_SAMPLER_VIEWS]; |
||
195 | |||
196 | unsigned dump_fs : 1; |
||
197 | unsigned dump_gs : 1; |
||
198 | unsigned no_rast : 1; |
||
199 | }; |
||
200 | |||
201 | |||
202 | static INLINE struct softpipe_context * |
||
203 | softpipe_context( struct pipe_context *pipe ) |
||
204 | { |
||
205 | return (struct softpipe_context *)pipe; |
||
206 | } |
||
207 | |||
208 | |||
209 | struct pipe_context * |
||
210 | softpipe_create_context( struct pipe_screen *, void *priv ); |
||
211 | |||
212 | struct pipe_resource * |
||
213 | softpipe_user_buffer_create(struct pipe_screen *screen, |
||
214 | void *ptr, |
||
215 | unsigned bytes, |
||
216 | unsigned bind_flags); |
||
217 | |||
218 | #define SP_UNREFERENCED 0 |
||
219 | #define SP_REFERENCED_FOR_READ (1 << 0) |
||
220 | #define SP_REFERENCED_FOR_WRITE (1 << 1) |
||
221 | |||
222 | unsigned int |
||
223 | softpipe_is_resource_referenced( struct pipe_context *pipe, |
||
224 | struct pipe_resource *texture, |
||
225 | unsigned level, int layer); |
||
226 | |||
227 | #endif /* SP_CONTEXT_H */><>><>>>> |