Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2007-2008 VMware, Inc.
  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 VMWARE 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
  38. extern "C" {
  39. #endif
  40.  
  41. struct cso_context;
  42. struct u_vbuf;
  43.  
  44. struct cso_context *cso_create_context( struct pipe_context *pipe );
  45. void cso_destroy_context( struct cso_context *cso );
  46.  
  47.  
  48. enum pipe_error cso_set_blend( struct cso_context *cso,
  49.                                const struct pipe_blend_state *blend );
  50. void cso_save_blend(struct cso_context *cso);
  51. void cso_restore_blend(struct cso_context *cso);
  52.  
  53.  
  54.  
  55. enum pipe_error cso_set_depth_stencil_alpha( struct cso_context *cso,
  56.                                              const struct pipe_depth_stencil_alpha_state *dsa );
  57. void cso_save_depth_stencil_alpha(struct cso_context *cso);
  58. void cso_restore_depth_stencil_alpha(struct cso_context *cso);
  59.  
  60.  
  61.  
  62. enum pipe_error cso_set_rasterizer( struct cso_context *cso,
  63.                                     const struct pipe_rasterizer_state *rasterizer );
  64. void cso_save_rasterizer(struct cso_context *cso);
  65. void cso_restore_rasterizer(struct cso_context *cso);
  66.  
  67.  
  68. enum pipe_error
  69. cso_set_samplers(struct cso_context *cso,
  70.                  unsigned shader_stage,
  71.                  unsigned count,
  72.                  const struct pipe_sampler_state **states);
  73.  
  74. void
  75. cso_save_samplers(struct cso_context *cso, unsigned shader_stage);
  76.  
  77. void
  78. cso_restore_samplers(struct cso_context *cso, unsigned shader_stage);
  79.  
  80. /* Alternate interface to support state trackers that like to modify
  81.  * samplers one at a time:
  82.  */
  83. enum pipe_error
  84. cso_single_sampler(struct cso_context *cso,
  85.                    unsigned shader_stage,
  86.                    unsigned count,
  87.                    const struct pipe_sampler_state *states);
  88.  
  89. void
  90. cso_single_sampler_done(struct cso_context *cso, unsigned shader_stage);
  91.  
  92.  
  93. enum pipe_error cso_set_vertex_elements(struct cso_context *ctx,
  94.                                         unsigned count,
  95.                                         const struct pipe_vertex_element *states);
  96. void cso_save_vertex_elements(struct cso_context *ctx);
  97. void cso_restore_vertex_elements(struct cso_context *ctx);
  98.  
  99.  
  100. void cso_set_vertex_buffers(struct cso_context *ctx,
  101.                             unsigned start_slot, unsigned count,
  102.                             const struct pipe_vertex_buffer *buffers);
  103.  
  104. /* One vertex buffer slot is provided with the save/restore functionality.
  105.  * cso_context chooses the slot, it can be non-zero. */
  106. void cso_save_aux_vertex_buffer_slot(struct cso_context *ctx);
  107. void cso_restore_aux_vertex_buffer_slot(struct cso_context *ctx);
  108. unsigned cso_get_aux_vertex_buffer_slot(struct cso_context *ctx);
  109.  
  110.  
  111. void cso_set_stream_outputs(struct cso_context *ctx,
  112.                             unsigned num_targets,
  113.                             struct pipe_stream_output_target **targets,
  114.                             const unsigned *offsets);
  115. void cso_save_stream_outputs(struct cso_context *ctx);
  116. void cso_restore_stream_outputs(struct cso_context *ctx);
  117.  
  118.  
  119. /*
  120.  * We don't provide shader caching in CSO.  Most of the time the api provides
  121.  * object semantics for shaders anyway, and the cases where it doesn't
  122.  * (eg mesa's internally-generated texenv programs), it will be up to
  123.  * the state tracker to implement their own specialized caching.
  124.  */
  125.  
  126. void cso_set_fragment_shader_handle(struct cso_context *ctx, void *handle);
  127. void cso_delete_fragment_shader(struct cso_context *ctx, void *handle );
  128. void cso_save_fragment_shader(struct cso_context *cso);
  129. void cso_restore_fragment_shader(struct cso_context *cso);
  130.  
  131.  
  132. void cso_set_vertex_shader_handle(struct cso_context *ctx, void *handle);
  133. void cso_delete_vertex_shader(struct cso_context *ctx, void *handle );
  134. void cso_save_vertex_shader(struct cso_context *cso);
  135. void cso_restore_vertex_shader(struct cso_context *cso);
  136.  
  137.  
  138. void cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle);
  139. void cso_delete_geometry_shader(struct cso_context *ctx, void *handle);
  140. void cso_save_geometry_shader(struct cso_context *cso);
  141. void cso_restore_geometry_shader(struct cso_context *cso);
  142.  
  143.  
  144. void cso_set_tessctrl_shader_handle(struct cso_context *ctx, void *handle);
  145. void cso_delete_tessctrl_shader(struct cso_context *ctx, void *handle);
  146. void cso_save_tessctrl_shader(struct cso_context *cso);
  147. void cso_restore_tessctrl_shader(struct cso_context *cso);
  148.  
  149.  
  150. void cso_set_tesseval_shader_handle(struct cso_context *ctx, void *handle);
  151. void cso_delete_tesseval_shader(struct cso_context *ctx, void *handle);
  152. void cso_save_tesseval_shader(struct cso_context *cso);
  153. void cso_restore_tesseval_shader(struct cso_context *cso);
  154.  
  155.  
  156. void cso_set_framebuffer(struct cso_context *cso,
  157.                          const struct pipe_framebuffer_state *fb);
  158. void cso_save_framebuffer(struct cso_context *cso);
  159. void cso_restore_framebuffer(struct cso_context *cso);
  160.  
  161.  
  162. void cso_set_viewport(struct cso_context *cso,
  163.                       const struct pipe_viewport_state *vp);
  164. void cso_save_viewport(struct cso_context *cso);
  165. void cso_restore_viewport(struct cso_context *cso);
  166.  
  167.  
  168. void cso_set_blend_color(struct cso_context *cso,
  169.                          const struct pipe_blend_color *bc);
  170.  
  171. void cso_set_sample_mask(struct cso_context *cso, unsigned stencil_mask);
  172. void cso_save_sample_mask(struct cso_context *ctx);
  173. void cso_restore_sample_mask(struct cso_context *ctx);
  174.  
  175. void cso_set_min_samples(struct cso_context *cso, unsigned min_samples);
  176. void cso_save_min_samples(struct cso_context *ctx);
  177. void cso_restore_min_samples(struct cso_context *ctx);
  178.  
  179. void cso_set_stencil_ref(struct cso_context *cso,
  180.                          const struct pipe_stencil_ref *sr);
  181. void cso_save_stencil_ref(struct cso_context *cso);
  182. void cso_restore_stencil_ref(struct cso_context *cso);
  183.  
  184. void cso_set_render_condition(struct cso_context *cso,
  185.                               struct pipe_query *query,
  186.                               boolean condition, uint mode);
  187. void cso_save_render_condition(struct cso_context *cso);
  188. void cso_restore_render_condition(struct cso_context *cso);
  189.  
  190.  
  191. /* clip state */
  192.  
  193. void
  194. cso_set_clip(struct cso_context *cso,
  195.              const struct pipe_clip_state *clip);
  196.  
  197. void
  198. cso_save_clip(struct cso_context *cso);
  199.  
  200. void
  201. cso_restore_clip(struct cso_context *cso);
  202.  
  203.  
  204. /* sampler view state */
  205.  
  206. void
  207. cso_set_sampler_views(struct cso_context *cso,
  208.                       unsigned shader_stage,
  209.                       unsigned count,
  210.                       struct pipe_sampler_view **views);
  211.  
  212. void
  213. cso_save_sampler_views(struct cso_context *cso, unsigned shader_stage);
  214.  
  215. void
  216. cso_restore_sampler_views(struct cso_context *cso, unsigned shader_stage);
  217.  
  218.  
  219. /* constant buffers */
  220.  
  221. void cso_set_constant_buffer(struct cso_context *cso, unsigned shader_stage,
  222.                              unsigned index, struct pipe_constant_buffer *cb);
  223. void cso_set_constant_buffer_resource(struct cso_context *cso,
  224.                                       unsigned shader_stage,
  225.                                       unsigned index,
  226.                                       struct pipe_resource *buffer);
  227. void cso_save_constant_buffer_slot0(struct cso_context *cso,
  228.                                     unsigned shader_stage);
  229. void cso_restore_constant_buffer_slot0(struct cso_context *cso,
  230.                                        unsigned shader_stage);
  231.  
  232.  
  233. /* drawing */
  234.  
  235. void
  236. cso_set_index_buffer(struct cso_context *cso,
  237.                      const struct pipe_index_buffer *ib);
  238.  
  239. void
  240. cso_draw_vbo(struct cso_context *cso,
  241.              const struct pipe_draw_info *info);
  242.  
  243. void
  244. cso_draw_arrays_instanced(struct cso_context *cso, uint mode,
  245.                           uint start, uint count,
  246.                           uint start_instance, uint instance_count);
  247.  
  248. /* helper drawing function */
  249. void
  250. cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count);
  251.  
  252. #ifdef  __cplusplus
  253. }
  254. #endif
  255.  
  256. #endif
  257.