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
32 #include "p_compiler.h"
36 * Software pipeline rendering context. Basically a collection of
37 * state setting functions, plus VBO drawing entrypoint.
40 struct pipe_winsys
*winsys
;
42 void (*destroy
)( struct pipe_context
* );
47 const unsigned *(*supported_formats
)(struct pipe_context
*pipe
,
48 unsigned *numFormats
);
50 void (*max_texture_size
)(struct pipe_context
*pipe
,
51 unsigned textureType
, /* PIPE_TEXTURE_x */
56 const char *(*get_name
)( struct pipe_context
*pipe
);
58 const char *(*get_vendor
)( struct pipe_context
*pipe
);
64 * Return false on fallbacks (temporary??)
66 boolean (*draw_arrays
)( struct pipe_context
*pipe
,
67 unsigned mode
, unsigned start
, unsigned count
);
69 boolean (*draw_elements
)( struct pipe_context
*pipe
,
70 struct pipe_buffer_handle
*indexBuffer
,
72 unsigned mode
, unsigned start
, unsigned count
);
74 /** Clear a surface to given value (no scissor; clear whole surface) */
75 void (*clear
)(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
78 /** occlusion counting (XXX this may be temporary - we should probably
79 * have generic query objects with begin/end methods)
81 void (*reset_occlusion_counter
)(struct pipe_context
*pipe
);
82 unsigned (*get_occlusion_counter
)(struct pipe_context
*pipe
);
87 void (*set_alpha_test_state
)( struct pipe_context
*,
88 const struct pipe_alpha_test_state
* );
90 void (*set_blend_state
)( struct pipe_context
*,
91 const struct pipe_blend_state
* );
93 void (*set_blend_color
)( struct pipe_context
*,
94 const struct pipe_blend_color
* );
96 void (*set_clip_state
)( struct pipe_context
*,
97 const struct pipe_clip_state
* );
99 void (*set_clear_color_state
)( struct pipe_context
*,
100 const struct pipe_clear_color_state
* );
102 void (*set_constant_buffer
)( struct pipe_context
*,
103 uint shader
, uint index
,
104 const struct pipe_constant_buffer
*buf
);
106 void (*set_depth_state
)( struct pipe_context
*,
107 const struct pipe_depth_state
* );
109 void (*set_framebuffer_state
)( struct pipe_context
*,
110 const struct pipe_framebuffer_state
* );
112 void (*set_fs_state
)( struct pipe_context
*,
113 const struct pipe_shader_state
* );
115 void (*set_vs_state
)( struct pipe_context
*,
116 const struct pipe_shader_state
* );
118 void (*set_polygon_stipple
)( struct pipe_context
*,
119 const struct pipe_poly_stipple
* );
121 void (*set_setup_state
)( struct pipe_context
*,
122 const struct pipe_setup_state
* );
124 void (*set_scissor_state
)( struct pipe_context
*,
125 const struct pipe_scissor_state
* );
127 void (*set_stencil_state
)( struct pipe_context
*,
128 const struct pipe_stencil_state
* );
130 void (*set_sampler_state
)( struct pipe_context
*,
132 const struct pipe_sampler_state
* );
134 void (*set_texture_state
)( struct pipe_context
*,
136 struct pipe_mipmap_tree
* );
138 void (*set_viewport_state
)( struct pipe_context
*,
139 const struct pipe_viewport_state
* );
141 void (*set_vertex_buffer
)( struct pipe_context
*,
143 const struct pipe_vertex_buffer
* );
145 void (*set_vertex_element
)( struct pipe_context
*,
147 const struct pipe_vertex_element
* );
152 * This might go away...
154 struct pipe_surface
*(*surface_alloc
)(struct pipe_context
*pipe
,
157 struct pipe_surface
*(*get_tex_surface
)(struct pipe_context
*pipe
,
158 struct pipe_mipmap_tree
*texture
,
159 unsigned face
, unsigned level
,
163 * Memory region functions
164 * Some of these may go away...
166 struct pipe_region
*(*region_alloc
)(struct pipe_context
*pipe
,
167 unsigned cpp
, unsigned width
, unsigned height
,
170 void (*region_release
)(struct pipe_context
*pipe
, struct pipe_region
**r
);
172 void (*region_idle
)(struct pipe_context
*pipe
, struct pipe_region
*region
);
174 ubyte
*(*region_map
)(struct pipe_context
*pipe
, struct pipe_region
*r
);
176 void (*region_unmap
)(struct pipe_context
*pipe
, struct pipe_region
*r
);
178 void (*region_data
)(struct pipe_context
*pipe
,
179 struct pipe_region
*dest
,
180 unsigned dest_offset
,
181 unsigned destx
, unsigned desty
,
182 const void *src
, unsigned src_stride
,
183 unsigned srcx
, unsigned srcy
, unsigned width
, unsigned height
);
185 void (*region_copy
)(struct pipe_context
*pipe
,
186 struct pipe_region
*dest
,
187 unsigned dest_offset
,
188 unsigned destx
, unsigned desty
,
189 struct pipe_region
*src
, /* don't make this const -
192 unsigned srcx
, unsigned srcy
, unsigned width
, unsigned height
);
194 void (*region_fill
)(struct pipe_context
*pipe
,
195 struct pipe_region
*dst
,
197 unsigned dstx
, unsigned dsty
,
198 unsigned width
, unsigned height
,
205 boolean (*mipmap_tree_layout
)( struct pipe_context
*pipe
,
206 struct pipe_mipmap_tree
*mt
);
211 void (*flush
)( struct pipe_context
*pipe
,
218 pipe_region_reference(struct pipe_region
**dst
, struct pipe_region
*src
)
220 assert(*dst
== NULL
);
229 pipe_surface_reference(struct pipe_surface
**dst
, struct pipe_surface
*src
)
231 assert(*dst
== NULL
);
239 pipe_surface_unreference(struct pipe_surface
**ps
)
243 if ((*ps
)->refcount
<= 0) {
244 /* XXX need a proper surface->free method */
251 #endif /* PIPE_CONTEXT_H */