Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1.  
  2. /**************************************************************************
  3.  *
  4.  * Copyright 2007 VMware, Inc.
  5.  * All Rights Reserved.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining a
  8.  * copy of this software and associated documentation files (the
  9.  * "Software"), to deal in the Software without restriction, including
  10.  * without limitation the rights to use, copy, modify, merge, publish,
  11.  * distribute, sub license, and/or sell copies of the Software, and to
  12.  * permit persons to whom the Software is furnished to do so, subject to
  13.  * the following conditions:
  14.  *
  15.  * The above copyright notice and this permission notice (including the
  16.  * next paragraph) shall be included in all copies or substantial portions
  17.  * of the Software.
  18.  *
  19.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  22.  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  23.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  24.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  25.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26.  *
  27.  **************************************************************************/
  28.  
  29. /**
  30.  * \brief  Public interface into the drawing module.
  31.  */
  32.  
  33. /* Authors:  Keith Whitwell <keithw@vmware.com>
  34.  */
  35.  
  36.  
  37. #ifndef DRAW_CONTEXT_H
  38. #define DRAW_CONTEXT_H
  39.  
  40.  
  41. #include "pipe/p_state.h"
  42. #include "tgsi/tgsi_exec.h"
  43.  
  44. struct pipe_context;
  45. struct draw_context;
  46. struct draw_stage;
  47. struct draw_vertex_shader;
  48. struct draw_geometry_shader;
  49. struct draw_fragment_shader;
  50. struct tgsi_sampler;
  51.  
  52. /*
  53.  * structure to contain driver internal information
  54.  * for stream out support. mapping stores the pointer
  55.  * to the buffer contents, and internal offset stores
  56.  * an internal counter to how much of the stream
  57.  * out buffer is used (in bytes).
  58.  */
  59. struct draw_so_target {
  60.    struct pipe_stream_output_target target;
  61.    void *mapping;
  62.    int internal_offset;
  63. };
  64.  
  65. struct draw_context *draw_create( struct pipe_context *pipe );
  66.  
  67. #if HAVE_LLVM
  68. struct draw_context *draw_create_with_llvm_context(struct pipe_context *pipe,
  69.                                                    void *context);
  70. #endif
  71.  
  72. struct draw_context *draw_create_no_llvm(struct pipe_context *pipe);
  73.  
  74. void draw_destroy( struct draw_context *draw );
  75.  
  76. void draw_flush(struct draw_context *draw);
  77.  
  78. void draw_set_viewport_states( struct draw_context *draw,
  79.                                unsigned start_slot,
  80.                                unsigned num_viewports,
  81.                                const struct pipe_viewport_state *viewports );
  82.  
  83. void draw_set_clip_state( struct draw_context *pipe,
  84.                           const struct pipe_clip_state *clip );
  85.  
  86. /**
  87.  * Sets the rasterization state used by the draw module.
  88.  * The rast_handle is used to pass the driver specific representation
  89.  * of the rasterization state. It's going to be used when the
  90.  * draw module sets the state back on the driver itself using the
  91.  * pipe::bind_rasterizer_state method.
  92.  *
  93.  * NOTE: if you're calling this function from within the pipe's
  94.  * bind_rasterizer_state you should always call it before binding
  95.  * the actual state - that's because the draw module can try to
  96.  * bind its own rasterizer state which would reset your newly
  97.  * set state. i.e. always do
  98.  * draw_set_rasterizer_state(driver->draw, state->pipe_state, state);
  99.  * driver->state.raster = state;
  100.  */
  101. void draw_set_rasterizer_state( struct draw_context *draw,
  102.                                 const struct pipe_rasterizer_state *raster,
  103.                                 void *rast_handle );
  104.  
  105. void draw_set_rasterize_stage( struct draw_context *draw,
  106.                                struct draw_stage *stage );
  107.  
  108. void draw_wide_point_threshold(struct draw_context *draw, float threshold);
  109.  
  110. void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
  111.  
  112. void draw_wide_line_threshold(struct draw_context *draw, float threshold);
  113.  
  114. void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
  115.  
  116. void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
  117.  
  118. void draw_set_zs_format(struct draw_context *draw, enum pipe_format format);
  119.  
  120. boolean
  121. draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
  122.  
  123. boolean
  124. draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
  125.  
  126. boolean
  127. draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
  128.  
  129.  
  130. struct tgsi_shader_info *
  131. draw_get_shader_info(const struct draw_context *draw);
  132.  
  133. void
  134. draw_prepare_shader_outputs(struct draw_context *draw);
  135.  
  136. int
  137. draw_find_shader_output(const struct draw_context *draw,
  138.                         uint semantic_name, uint semantic_index);
  139.  
  140. boolean
  141. draw_will_inject_frontface(const struct draw_context *draw);
  142.  
  143. uint
  144. draw_num_shader_outputs(const struct draw_context *draw);
  145.  
  146. uint
  147. draw_total_vs_outputs(const struct draw_context *draw);
  148.  
  149. uint
  150. draw_total_gs_outputs(const struct draw_context *draw);
  151.  
  152. void
  153. draw_texture_sampler(struct draw_context *draw,
  154.                      uint shader_type,
  155.                      struct tgsi_sampler *sampler);
  156.  
  157. void
  158. draw_set_sampler_views(struct draw_context *draw,
  159.                        unsigned shader_stage,
  160.                        struct pipe_sampler_view **views,
  161.                        unsigned num);
  162. void
  163. draw_set_samplers(struct draw_context *draw,
  164.                   unsigned shader_stage,
  165.                   struct pipe_sampler_state **samplers,
  166.                   unsigned num);
  167.  
  168. void
  169. draw_set_mapped_texture(struct draw_context *draw,
  170.                         unsigned shader_stage,
  171.                         unsigned sview_idx,
  172.                         uint32_t width, uint32_t height, uint32_t depth,
  173.                         uint32_t first_level, uint32_t last_level,
  174.                         const void *base,
  175.                         uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
  176.                         uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
  177.                         uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);
  178.  
  179.  
  180. /*
  181.  * Vertex shader functions
  182.  */
  183.  
  184. struct draw_vertex_shader *
  185. draw_create_vertex_shader(struct draw_context *draw,
  186.                           const struct pipe_shader_state *shader);
  187. void draw_bind_vertex_shader(struct draw_context *draw,
  188.                              struct draw_vertex_shader *dvs);
  189. void draw_delete_vertex_shader(struct draw_context *draw,
  190.                                struct draw_vertex_shader *dvs);
  191. void draw_vs_attach_so(struct draw_vertex_shader *dvs,
  192.                        const struct pipe_stream_output_info *info);
  193. void draw_vs_reset_so(struct draw_vertex_shader *dvs);
  194.  
  195.  
  196. /*
  197.  * Fragment shader functions
  198.  */
  199. struct draw_fragment_shader *
  200. draw_create_fragment_shader(struct draw_context *draw,
  201.                             const struct pipe_shader_state *shader);
  202. void draw_bind_fragment_shader(struct draw_context *draw,
  203.                                struct draw_fragment_shader *dvs);
  204. void draw_delete_fragment_shader(struct draw_context *draw,
  205.                                  struct draw_fragment_shader *dvs);
  206.  
  207. /*
  208.  * Geometry shader functions
  209.  */
  210. struct draw_geometry_shader *
  211. draw_create_geometry_shader(struct draw_context *draw,
  212.                             const struct pipe_shader_state *shader);
  213. void draw_bind_geometry_shader(struct draw_context *draw,
  214.                                struct draw_geometry_shader *dvs);
  215. void draw_delete_geometry_shader(struct draw_context *draw,
  216.                                  struct draw_geometry_shader *dvs);
  217.  
  218.  
  219. /*
  220.  * Vertex data functions
  221.  */
  222.  
  223. void draw_set_vertex_buffers(struct draw_context *draw,
  224.                              unsigned start_slot, unsigned count,
  225.                              const struct pipe_vertex_buffer *buffers);
  226.  
  227. void draw_set_vertex_elements(struct draw_context *draw,
  228.                               unsigned count,
  229.                               const struct pipe_vertex_element *elements);
  230.  
  231. void draw_set_indexes(struct draw_context *draw,
  232.                       const void *elements, unsigned elem_size,
  233.                       unsigned available_space);
  234.  
  235. void draw_set_mapped_vertex_buffer(struct draw_context *draw,
  236.                                    unsigned attr, const void *buffer,
  237.                                    size_t size);
  238.  
  239. void
  240. draw_set_mapped_constant_buffer(struct draw_context *draw,
  241.                                 unsigned shader_type,
  242.                                 unsigned slot,
  243.                                 const void *buffer,
  244.                                 unsigned size);
  245.  
  246. void
  247. draw_set_mapped_so_targets(struct draw_context *draw,
  248.                            int num_targets,
  249.                            struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]);
  250.  
  251.  
  252. /***********************************************************************
  253.  * draw_pt.c
  254.  */
  255.  
  256. void draw_vbo(struct draw_context *draw,
  257.               const struct pipe_draw_info *info);
  258.  
  259.  
  260. /*******************************************************************************
  261.  * Driver backend interface
  262.  */
  263. struct vbuf_render;
  264. void draw_set_render( struct draw_context *draw,
  265.                       struct vbuf_render *render );
  266.  
  267. void draw_set_driver_clipping( struct draw_context *draw,
  268.                                boolean bypass_clip_xy,
  269.                                boolean bypass_clip_z,
  270.                                boolean guard_band_xy,
  271.                                boolean bypass_clip_points);
  272.  
  273. void draw_set_force_passthrough( struct draw_context *draw,
  274.                                  boolean enable );
  275.  
  276.  
  277. /*******************************************************************************
  278.  * Draw statistics
  279.  */
  280. void draw_collect_pipeline_statistics(struct draw_context *draw,
  281.                                       boolean enable);
  282.  
  283. /*******************************************************************************
  284.  * Draw pipeline
  285.  */
  286. boolean draw_need_pipeline(const struct draw_context *draw,
  287.                            const struct pipe_rasterizer_state *rasterizer,
  288.                            unsigned prim );
  289.  
  290. int
  291. draw_get_shader_param(unsigned shader, enum pipe_shader_cap param);
  292.  
  293. int
  294. draw_get_shader_param_no_llvm(unsigned shader, enum pipe_shader_cap param);
  295.  
  296. boolean
  297. draw_get_option_use_llvm(void);
  298.  
  299. #endif /* DRAW_CONTEXT_H */
  300.