Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. /**************************************************************************
  3.  *
  4.  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  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 TUNGSTEN GRAPHICS 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 <keith@tungstengraphics.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.  * stores 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.    int emitted_vertices;
  64. };
  65.  
  66. struct draw_context *draw_create( struct pipe_context *pipe );
  67.  
  68. struct draw_context *draw_create_no_llvm(struct pipe_context *pipe);
  69.  
  70. void draw_destroy( struct draw_context *draw );
  71.  
  72. void draw_flush(struct draw_context *draw);
  73.  
  74. void draw_set_viewport_states( struct draw_context *draw,
  75.                                unsigned start_slot,
  76.                                unsigned num_viewports,
  77.                                const struct pipe_viewport_state *viewports );
  78.  
  79. void draw_set_clip_state( struct draw_context *pipe,
  80.                           const struct pipe_clip_state *clip );
  81.  
  82. /**
  83.  * Sets the rasterization state used by the draw module.
  84.  * The rast_handle is used to pass the driver specific representation
  85.  * of the rasterization state. It's going to be used when the
  86.  * draw module sets the state back on the driver itself using the
  87.  * pipe::bind_rasterizer_state method.
  88.  *
  89.  * NOTE: if you're calling this function from within the pipe's
  90.  * bind_rasterizer_state you should always call it before binding
  91.  * the actual state - that's because the draw module can try to
  92.  * bind its own rasterizer state which would reset your newly
  93.  * set state. i.e. always do
  94.  * draw_set_rasterizer_state(driver->draw, state->pipe_state, state);
  95.  * driver->state.raster = state;
  96.  */
  97. void draw_set_rasterizer_state( struct draw_context *draw,
  98.                                 const struct pipe_rasterizer_state *raster,
  99.                                 void *rast_handle );
  100.  
  101. void draw_set_rasterize_stage( struct draw_context *draw,
  102.                                struct draw_stage *stage );
  103.  
  104. void draw_wide_point_threshold(struct draw_context *draw, float threshold);
  105.  
  106. void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
  107.  
  108. void draw_wide_line_threshold(struct draw_context *draw, float threshold);
  109.  
  110. void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
  111.  
  112. void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
  113.  
  114. void draw_set_mrd(struct draw_context *draw, double mrd);
  115.  
  116. boolean
  117. draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
  118.  
  119. boolean
  120. draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
  121.  
  122. boolean
  123. draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
  124.  
  125.  
  126. struct tgsi_shader_info *
  127. draw_get_shader_info(const struct draw_context *draw);
  128.  
  129. int
  130. draw_find_shader_output(const struct draw_context *draw,
  131.                         uint semantic_name, uint semantic_index);
  132.  
  133. uint
  134. draw_num_shader_outputs(const struct draw_context *draw);
  135.  
  136.  
  137. void
  138. draw_texture_sampler(struct draw_context *draw,
  139.                      uint shader_type,
  140.                      struct tgsi_sampler *sampler);
  141.  
  142. void
  143. draw_set_sampler_views(struct draw_context *draw,
  144.                        unsigned shader_stage,
  145.                        struct pipe_sampler_view **views,
  146.                        unsigned num);
  147. void
  148. draw_set_samplers(struct draw_context *draw,
  149.                   unsigned shader_stage,
  150.                   struct pipe_sampler_state **samplers,
  151.                   unsigned num);
  152.  
  153. void
  154. draw_set_mapped_texture(struct draw_context *draw,
  155.                         unsigned shader_stage,
  156.                         unsigned sview_idx,
  157.                         uint32_t width, uint32_t height, uint32_t depth,
  158.                         uint32_t first_level, uint32_t last_level,
  159.                         const void *base,
  160.                         uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
  161.                         uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
  162.                         uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);
  163.  
  164.  
  165. /*
  166.  * Vertex shader functions
  167.  */
  168.  
  169. struct draw_vertex_shader *
  170. draw_create_vertex_shader(struct draw_context *draw,
  171.                           const struct pipe_shader_state *shader);
  172. void draw_bind_vertex_shader(struct draw_context *draw,
  173.                              struct draw_vertex_shader *dvs);
  174. void draw_delete_vertex_shader(struct draw_context *draw,
  175.                                struct draw_vertex_shader *dvs);
  176. void draw_vs_attach_so(struct draw_vertex_shader *dvs,
  177.                        const struct pipe_stream_output_info *info);
  178. void draw_vs_reset_so(struct draw_vertex_shader *dvs);
  179.  
  180.  
  181. /*
  182.  * Fragment shader functions
  183.  */
  184. struct draw_fragment_shader *
  185. draw_create_fragment_shader(struct draw_context *draw,
  186.                             const struct pipe_shader_state *shader);
  187. void draw_bind_fragment_shader(struct draw_context *draw,
  188.                                struct draw_fragment_shader *dvs);
  189. void draw_delete_fragment_shader(struct draw_context *draw,
  190.                                  struct draw_fragment_shader *dvs);
  191.  
  192. /*
  193.  * Geometry shader functions
  194.  */
  195. struct draw_geometry_shader *
  196. draw_create_geometry_shader(struct draw_context *draw,
  197.                             const struct pipe_shader_state *shader);
  198. void draw_bind_geometry_shader(struct draw_context *draw,
  199.                                struct draw_geometry_shader *dvs);
  200. void draw_delete_geometry_shader(struct draw_context *draw,
  201.                                  struct draw_geometry_shader *dvs);
  202.  
  203.  
  204. /*
  205.  * Vertex data functions
  206.  */
  207.  
  208. void draw_set_vertex_buffers(struct draw_context *draw,
  209.                              unsigned start_slot, unsigned count,
  210.                              const struct pipe_vertex_buffer *buffers);
  211.  
  212. void draw_set_vertex_elements(struct draw_context *draw,
  213.                               unsigned count,
  214.                               const struct pipe_vertex_element *elements);
  215.  
  216. void draw_set_indexes(struct draw_context *draw,
  217.                       const void *elements, unsigned elem_size,
  218.                       unsigned available_space);
  219.  
  220. void draw_set_mapped_vertex_buffer(struct draw_context *draw,
  221.                                    unsigned attr, const void *buffer,
  222.                                    size_t size);
  223.  
  224. void
  225. draw_set_mapped_constant_buffer(struct draw_context *draw,
  226.                                 unsigned shader_type,
  227.                                 unsigned slot,
  228.                                 const void *buffer,
  229.                                 unsigned size);
  230.  
  231. void
  232. draw_set_mapped_so_targets(struct draw_context *draw,
  233.                            int num_targets,
  234.                            struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]);
  235.  
  236.  
  237. /***********************************************************************
  238.  * draw_pt.c
  239.  */
  240.  
  241. void draw_vbo(struct draw_context *draw,
  242.               const struct pipe_draw_info *info);
  243.  
  244.  
  245. /*******************************************************************************
  246.  * Driver backend interface
  247.  */
  248. struct vbuf_render;
  249. void draw_set_render( struct draw_context *draw,
  250.                       struct vbuf_render *render );
  251.  
  252. void draw_set_driver_clipping( struct draw_context *draw,
  253.                                boolean bypass_clip_xy,
  254.                                boolean bypass_clip_z,
  255.                                boolean guard_band_xy);
  256.  
  257. void draw_set_force_passthrough( struct draw_context *draw,
  258.                                  boolean enable );
  259.  
  260.  
  261. /*******************************************************************************
  262.  * Draw statistics
  263.  */
  264. void draw_collect_pipeline_statistics(struct draw_context *draw,
  265.                                       boolean enable);
  266.  
  267. /*******************************************************************************
  268.  * Draw pipeline
  269.  */
  270. boolean draw_need_pipeline(const struct draw_context *draw,
  271.                            const struct pipe_rasterizer_state *rasterizer,
  272.                            unsigned prim );
  273.  
  274. int
  275. draw_get_shader_param(unsigned shader, enum pipe_shader_cap param);
  276.  
  277. int
  278. draw_get_shader_param_no_llvm(unsigned shader, enum pipe_shader_cap param);
  279.  
  280. #ifdef HAVE_LLVM
  281. boolean
  282. draw_get_option_use_llvm(void);
  283. #endif
  284.  
  285. #endif /* DRAW_CONTEXT_H */
  286.