1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef PIPE_CONTEXT_H
29 #define PIPE_CONTEXT_H
33 struct pipe_state_cache
;
37 * Gallium rendering context. Basically:
38 * - state setting functions
39 * - VBO drawing functions
44 struct pipe_winsys
*winsys
;
46 void *priv
; /** context private data (for DRI for example) */
48 void (*destroy
)( struct pipe_context
* );
53 boolean (*is_format_supported
)( struct pipe_context
*pipe
,
56 const char *(*get_name
)( struct pipe_context
*pipe
);
58 const char *(*get_vendor
)( struct pipe_context
*pipe
);
60 int (*get_param
)( struct pipe_context
*pipe
, int param
);
61 float (*get_paramf
)( struct pipe_context
*pipe
, int param
);
66 * Return false on fallbacks (temporary??)
68 boolean (*draw_arrays
)( struct pipe_context
*pipe
,
69 unsigned mode
, unsigned start
, unsigned count
);
71 boolean (*draw_elements
)( struct pipe_context
*pipe
,
72 struct pipe_buffer_handle
*indexBuffer
,
74 unsigned mode
, unsigned start
, unsigned count
);
76 /** Clear a surface to given value (no scissor; clear whole surface) */
77 void (*clear
)(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
83 void (*begin_query
)(struct pipe_context
*pipe
, struct pipe_query_object
*q
);
84 void (*end_query
)(struct pipe_context
*pipe
, struct pipe_query_object
*q
);
85 void (*wait_query
)(struct pipe_context
*pipe
, struct pipe_query_object
*q
);
90 void * (*create_alpha_test_state
)(struct pipe_context
*,
91 const struct pipe_alpha_test_state
*);
92 void (*bind_alpha_test_state
)(struct pipe_context
*, void *);
93 void (*delete_alpha_test_state
)(struct pipe_context
*, void *);
95 void * (*create_blend_state
)(struct pipe_context
*,
96 const struct pipe_blend_state
*);
97 void (*bind_blend_state
)(struct pipe_context
*, void *);
98 void (*delete_blend_state
)(struct pipe_context
*, void *);
100 void * (*create_sampler_state
)(struct pipe_context
*,
101 const struct pipe_sampler_state
*);
102 void (*bind_sampler_state
)(struct pipe_context
*, unsigned unit
, void *);
103 void (*delete_sampler_state
)(struct pipe_context
*, void *);
105 void * (*create_rasterizer_state
)(struct pipe_context
*,
106 const struct pipe_rasterizer_state
*);
107 void (*bind_rasterizer_state
)(struct pipe_context
*, void *);
108 void (*delete_rasterizer_state
)(struct pipe_context
*, void *);
110 void * (*create_depth_stencil_state
)(struct pipe_context
*,
111 const struct pipe_depth_stencil_state
*);
112 void (*bind_depth_stencil_state
)(struct pipe_context
*, void *);
113 void (*delete_depth_stencil_state
)(struct pipe_context
*, void *);
115 void * (*create_fs_state
)(struct pipe_context
*,
116 const struct pipe_shader_state
*);
117 void (*bind_fs_state
)(struct pipe_context
*, void *);
118 void (*delete_fs_state
)(struct pipe_context
*, void *);
120 void * (*create_vs_state
)(struct pipe_context
*,
121 const struct pipe_shader_state
*);
122 void (*bind_vs_state
)(struct pipe_context
*, void *);
123 void (*delete_vs_state
)(struct pipe_context
*, void *);
125 /* The following look more properties than states.
126 * maybe combine a few of them into states or pass them
127 * in the bind calls to the state */
128 void (*set_blend_color
)( struct pipe_context
*,
129 const struct pipe_blend_color
* );
131 void (*set_clip_state
)( struct pipe_context
*,
132 const struct pipe_clip_state
* );
134 void (*set_clear_color_state
)( struct pipe_context
*,
135 const struct pipe_clear_color_state
* );
137 void (*set_constant_buffer
)( struct pipe_context
*,
138 uint shader
, uint index
,
139 const struct pipe_constant_buffer
*buf
);
141 void (*set_feedback_state
)( struct pipe_context
*,
142 const struct pipe_feedback_state
*);
144 void (*set_framebuffer_state
)( struct pipe_context
*,
145 const struct pipe_framebuffer_state
* );
147 void (*set_polygon_stipple
)( struct pipe_context
*,
148 const struct pipe_poly_stipple
* );
150 void (*set_sampler_units
)( struct pipe_context
*,
151 uint num_samplers
, const uint
*units
);
153 void (*set_scissor_state
)( struct pipe_context
*,
154 const struct pipe_scissor_state
* );
156 void (*set_texture_state
)( struct pipe_context
*,
158 struct pipe_texture
* );
160 void (*set_viewport_state
)( struct pipe_context
*,
161 const struct pipe_viewport_state
* );
166 void (*set_vertex_buffer
)( struct pipe_context
*,
168 const struct pipe_vertex_buffer
* );
170 void (*set_vertex_element
)( struct pipe_context
*,
172 const struct pipe_vertex_element
* );
177 void (*set_feedback_buffer
)(struct pipe_context
*,
179 const struct pipe_feedback_buffer
*);
181 /** Get a surface which is a "view" into a texture */
182 struct pipe_surface
*(*get_tex_surface
)(struct pipe_context
*pipe
,
183 struct pipe_texture
*texture
,
184 unsigned face
, unsigned level
,
187 /** Get a block of raw pixel data from a surface */
188 void (*get_tile
)(struct pipe_context
*pipe
,
189 struct pipe_surface
*ps
,
190 uint x
, uint y
, uint w
, uint h
,
191 void *p
, int dst_stride
);
192 /** Put a block of raw pixel data into a surface */
193 void (*put_tile
)(struct pipe_context
*pipe
,
194 struct pipe_surface
*ps
,
195 uint x
, uint y
, uint w
, uint h
,
196 const void *p
, int src_stride
);
197 /* XXX temporary here, move these to softpipe */
198 void (*get_tile_rgba
)(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
199 uint x
, uint y
, uint w
, uint h
, float *p
);
200 void (*put_tile_rgba
)(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
201 uint x
, uint y
, uint w
, uint h
, const float *p
);
207 void (*surface_data
)(struct pipe_context
*pipe
,
208 struct pipe_surface
*dest
,
209 unsigned destx
, unsigned desty
,
210 const void *src
, unsigned src_stride
,
211 unsigned srcx
, unsigned srcy
,
212 unsigned width
, unsigned height
);
214 void (*surface_copy
)(struct pipe_context
*pipe
,
215 struct pipe_surface
*dest
,
216 unsigned destx
, unsigned desty
,
217 struct pipe_surface
*src
, /* don't make this const -
219 unsigned srcx
, unsigned srcy
,
220 unsigned width
, unsigned height
);
222 void (*surface_fill
)(struct pipe_context
*pipe
,
223 struct pipe_surface
*dst
,
224 unsigned dstx
, unsigned dsty
,
225 unsigned width
, unsigned height
,
232 void (*texture_create
)(struct pipe_context
*pipe
,
233 struct pipe_texture
**pt
);
235 void (*texture_release
)(struct pipe_context
*pipe
,
236 struct pipe_texture
**pt
);
241 void (*flush
)( struct pipe_context
*pipe
,
245 #endif /* PIPE_CONTEXT_H */