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