cso_context.h revision e0773da1e897164ed7597437070e32b867734ee5
1/************************************************************************** 2 * 3 * Copyright 2007-2008 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 29#ifndef CSO_CONTEXT_H 30#define CSO_CONTEXT_H 31 32#include "pipe/p_context.h" 33#include "pipe/p_state.h" 34#include "pipe/p_defines.h" 35 36 37#ifdef __cplusplus 38extern "C" { 39#endif 40 41struct cso_context; 42struct u_vbuf; 43 44struct cso_context *cso_create_context( struct pipe_context *pipe ); 45 46void cso_install_vbuf(struct cso_context *ctx, struct u_vbuf *vbuf); 47 48void cso_release_all( struct cso_context *ctx ); 49 50void cso_destroy_context( struct cso_context *cso ); 51 52 53 54enum pipe_error cso_set_blend( struct cso_context *cso, 55 const struct pipe_blend_state *blend ); 56void cso_save_blend(struct cso_context *cso); 57void cso_restore_blend(struct cso_context *cso); 58 59 60 61enum pipe_error cso_set_depth_stencil_alpha( struct cso_context *cso, 62 const struct pipe_depth_stencil_alpha_state *dsa ); 63void cso_save_depth_stencil_alpha(struct cso_context *cso); 64void cso_restore_depth_stencil_alpha(struct cso_context *cso); 65 66 67 68enum pipe_error cso_set_rasterizer( struct cso_context *cso, 69 const struct pipe_rasterizer_state *rasterizer ); 70void cso_save_rasterizer(struct cso_context *cso); 71void cso_restore_rasterizer(struct cso_context *cso); 72 73 74 75enum pipe_error cso_set_samplers( struct cso_context *cso, 76 unsigned count, 77 const struct pipe_sampler_state **states ); 78void cso_save_samplers(struct cso_context *cso); 79void cso_restore_samplers(struct cso_context *cso); 80 81/* Alternate interface to support state trackers that like to modify 82 * samplers one at a time: 83 */ 84enum pipe_error cso_single_sampler( struct cso_context *cso, 85 unsigned nr, 86 const struct pipe_sampler_state *states ); 87 88void cso_single_sampler_done( struct cso_context *cso ); 89 90enum pipe_error cso_set_vertex_samplers(struct cso_context *cso, 91 unsigned count, 92 const struct pipe_sampler_state **states); 93 94void 95cso_save_vertex_samplers(struct cso_context *cso); 96 97void 98cso_restore_vertex_samplers(struct cso_context *cso); 99 100enum pipe_error 101cso_single_vertex_sampler(struct cso_context *cso, 102 unsigned nr, 103 const struct pipe_sampler_state *states); 104 105void 106cso_single_vertex_sampler_done(struct cso_context *cso); 107 108 109enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, 110 unsigned count, 111 const struct pipe_vertex_element *states); 112void cso_save_vertex_elements(struct cso_context *ctx); 113void cso_restore_vertex_elements(struct cso_context *ctx); 114 115 116void cso_set_vertex_buffers(struct cso_context *ctx, 117 unsigned count, 118 const struct pipe_vertex_buffer *buffers); 119void cso_save_vertex_buffers(struct cso_context *ctx); 120void cso_restore_vertex_buffers(struct cso_context *ctx); 121 122 123void cso_set_stream_outputs(struct cso_context *ctx, 124 unsigned num_targets, 125 struct pipe_stream_output_target **targets, 126 unsigned append_bitmask); 127void cso_save_stream_outputs(struct cso_context *ctx); 128void cso_restore_stream_outputs(struct cso_context *ctx); 129 130 131enum pipe_error cso_set_fragment_shader_handle(struct cso_context *ctx, 132 void *handle ); 133void cso_delete_fragment_shader(struct cso_context *ctx, void *handle ); 134void cso_save_fragment_shader(struct cso_context *cso); 135void cso_restore_fragment_shader(struct cso_context *cso); 136 137 138enum pipe_error cso_set_vertex_shader_handle(struct cso_context *ctx, 139 void *handle ); 140void cso_delete_vertex_shader(struct cso_context *ctx, void *handle ); 141void cso_save_vertex_shader(struct cso_context *cso); 142void cso_restore_vertex_shader(struct cso_context *cso); 143 144 145enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx, 146 void *handle); 147void cso_delete_geometry_shader(struct cso_context *ctx, void *handle); 148void cso_save_geometry_shader(struct cso_context *cso); 149void cso_restore_geometry_shader(struct cso_context *cso); 150 151 152enum pipe_error cso_set_framebuffer(struct cso_context *cso, 153 const struct pipe_framebuffer_state *fb); 154void cso_save_framebuffer(struct cso_context *cso); 155void cso_restore_framebuffer(struct cso_context *cso); 156 157 158enum pipe_error cso_set_viewport(struct cso_context *cso, 159 const struct pipe_viewport_state *vp); 160void cso_save_viewport(struct cso_context *cso); 161void cso_restore_viewport(struct cso_context *cso); 162 163 164enum pipe_error cso_set_blend_color(struct cso_context *cso, 165 const struct pipe_blend_color *bc); 166 167enum pipe_error cso_set_sample_mask(struct cso_context *cso, 168 unsigned stencil_mask); 169 170enum pipe_error cso_set_stencil_ref(struct cso_context *cso, 171 const struct pipe_stencil_ref *sr); 172void cso_save_stencil_ref(struct cso_context *cso); 173void cso_restore_stencil_ref(struct cso_context *cso); 174 175 176/* clip state */ 177 178void 179cso_set_clip(struct cso_context *cso, 180 const struct pipe_clip_state *clip); 181 182void 183cso_save_clip(struct cso_context *cso); 184 185void 186cso_restore_clip(struct cso_context *cso); 187 188 189/* fragment sampler view state */ 190 191/* 192 * We don't provide shader caching in CSO. Most of the time the api provides 193 * object semantics for shaders anyway, and the cases where it doesn't 194 * (eg mesa's internally-generated texenv programs), it will be up to 195 * the state tracker to implement their own specialized caching. 196 */ 197 198void 199cso_set_fragment_sampler_views(struct cso_context *cso, 200 uint count, 201 struct pipe_sampler_view **views); 202 203void 204cso_save_fragment_sampler_views(struct cso_context *cso); 205 206void 207cso_restore_fragment_sampler_views(struct cso_context *cso); 208 209 210/* vertex sampler view state */ 211 212void 213cso_set_vertex_sampler_views(struct cso_context *cso, 214 uint count, 215 struct pipe_sampler_view **views); 216 217void 218cso_save_vertex_sampler_views(struct cso_context *cso); 219 220void 221cso_restore_vertex_sampler_views(struct cso_context *cso); 222 223/* drawing */ 224 225void 226cso_set_index_buffer(struct cso_context *cso, 227 const struct pipe_index_buffer *ib); 228 229void 230cso_draw_vbo(struct cso_context *cso, 231 const struct pipe_draw_info *info); 232 233/* helper drawing function */ 234void 235cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count); 236 237#ifdef __cplusplus 238} 239#endif 240 241#endif 242