a543735b525d91177283e39bbeaf0679bbbfd1ae
[mesa.git] / src / mesa / pipe / softpipe / sp_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 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
29 */
30
31 #ifndef SP_STATE_H
32 #define SP_STATE_H
33
34 #include "pipe/p_state.h"
35
36 #include "x86/rtasm/x86sse.h"
37
38 #ifdef MESA_LLVM
39 struct gallivm_prog;
40 #endif
41
42 /**
43 * Softpipe fs state is derived from pipe_shader_state.
44 */
45 struct sp_fragment_shader_state {
46 struct pipe_shader_state shader;
47 #if defined(__i386__) || defined(__386__)
48 struct x86_function sse2_program;
49 #endif
50 #ifdef MESA_LLVM
51 struct gallivm_prog *llvm_prog;
52 #endif
53 };
54
55 struct softpipe_texture
56 {
57 struct pipe_texture base;
58
59 /* Derived from the above:
60 */
61 unsigned pitch;
62 unsigned depth_pitch; /* per-image on i945? */
63 unsigned total_height;
64
65 unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS];
66
67 /* Explicitly store the offset of each image for each cube face or
68 * depth value. Pretty much have to accept that hardware formats
69 * are going to be so diverse that there is no unified way to
70 * compute the offsets of depth/cube images within a mipmap level,
71 * so have to store them as a lookup table:
72 */
73 unsigned *image_offset[PIPE_MAX_TEXTURE_LEVELS]; /**< array [depth] of offsets */
74
75 /* Includes image offset tables:
76 */
77 unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS];
78
79 /* The data is held here:
80 */
81 struct pipe_region *region;
82 };
83
84 void *
85 softpipe_create_alpha_test_state(struct pipe_context *,
86 const struct pipe_alpha_test_state *);
87 void
88 softpipe_bind_alpha_test_state(struct pipe_context *, void *);
89 void
90 softpipe_delete_alpha_test_state(struct pipe_context *, void *);
91
92 void *
93 softpipe_create_blend_state(struct pipe_context *,
94 const struct pipe_blend_state *);
95 void softpipe_bind_blend_state(struct pipe_context *,
96 void *);
97 void softpipe_delete_blend_state(struct pipe_context *,
98 void *);
99
100 void *
101 softpipe_create_sampler_state(struct pipe_context *,
102 const struct pipe_sampler_state *);
103 void softpipe_bind_sampler_state(struct pipe_context *, unsigned, void *);
104 void softpipe_delete_sampler_state(struct pipe_context *, void *);
105
106 void *
107 softpipe_create_depth_stencil_state(struct pipe_context *,
108 const struct pipe_depth_stencil_state *);
109 void softpipe_bind_depth_stencil_state(struct pipe_context *, void *);
110 void softpipe_delete_depth_stencil_state(struct pipe_context *, void *);
111
112 void *
113 softpipe_create_rasterizer_state(struct pipe_context *,
114 const struct pipe_rasterizer_state *);
115 void softpipe_bind_rasterizer_state(struct pipe_context *, void *);
116 void softpipe_delete_rasterizer_state(struct pipe_context *, void *);
117
118 void softpipe_set_framebuffer_state( struct pipe_context *,
119 const struct pipe_framebuffer_state * );
120
121 void softpipe_set_blend_color( struct pipe_context *pipe,
122 const struct pipe_blend_color *blend_color );
123
124 void softpipe_set_clear_color_state( struct pipe_context *,
125 const struct pipe_clear_color_state * );
126
127 void softpipe_set_clip_state( struct pipe_context *,
128 const struct pipe_clip_state * );
129
130 void softpipe_set_constant_buffer(struct pipe_context *,
131 uint shader, uint index,
132 const struct pipe_constant_buffer *buf);
133
134 void softpipe_set_feedback_state( struct pipe_context *,
135 const struct pipe_feedback_state * );
136
137 void *softpipe_create_fs_state(struct pipe_context *,
138 const struct pipe_shader_state *);
139 void softpipe_bind_fs_state(struct pipe_context *, void *);
140 void softpipe_delete_fs_state(struct pipe_context *, void *);
141 void *softpipe_create_vs_state(struct pipe_context *,
142 const struct pipe_shader_state *);
143 void softpipe_bind_vs_state(struct pipe_context *, void *);
144 void softpipe_delete_vs_state(struct pipe_context *, void *);
145
146 void softpipe_set_polygon_stipple( struct pipe_context *,
147 const struct pipe_poly_stipple * );
148
149 void softpipe_set_sampler_units( struct pipe_context *,
150 uint numSamplers, const uint *units );
151
152 void softpipe_set_scissor_state( struct pipe_context *,
153 const struct pipe_scissor_state * );
154
155 void softpipe_set_texture_state( struct pipe_context *,
156 unsigned unit,
157 struct pipe_texture * );
158
159 void softpipe_set_viewport_state( struct pipe_context *,
160 const struct pipe_viewport_state * );
161
162 void softpipe_set_vertex_element(struct pipe_context *,
163 unsigned index,
164 const struct pipe_vertex_element *);
165
166 void softpipe_set_vertex_buffer(struct pipe_context *,
167 unsigned index,
168 const struct pipe_vertex_buffer *);
169
170 void softpipe_set_feedback_buffer(struct pipe_context *,
171 uint index,
172 const struct pipe_feedback_buffer *);
173
174
175
176 void softpipe_update_derived( struct softpipe_context *softpipe );
177
178
179 boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
180 unsigned start, unsigned count);
181
182 boolean softpipe_draw_elements(struct pipe_context *pipe,
183 struct pipe_buffer_handle *indexBuffer,
184 unsigned indexSize,
185 unsigned mode, unsigned start, unsigned count);
186
187
188 void
189 softpipe_map_surfaces(struct softpipe_context *sp);
190
191 void
192 softpipe_unmap_surfaces(struct softpipe_context *sp);
193
194 void
195 softpipe_map_texture_surfaces(struct softpipe_context *sp);
196
197 void
198 softpipe_unmap_texture_surfaces(struct softpipe_context *sp);
199
200 #endif