draw_context.h revision a45b7f47ee0e38b288cc8fc4f6a1c013e8c227bc
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 43struct pipe_context; 44struct draw_context; 45struct draw_stage; 46struct draw_vertex_shader; 47struct draw_geometry_shader; 48struct tgsi_sampler; 49 50 51struct draw_context *draw_create( struct pipe_context *pipe ); 52 53void draw_destroy( struct draw_context *draw ); 54 55void draw_set_viewport_state( struct draw_context *draw, 56 const struct pipe_viewport_state *viewport ); 57 58void draw_set_clip_state( struct draw_context *pipe, 59 const struct pipe_clip_state *clip ); 60 61void draw_set_rasterizer_state( struct draw_context *draw, 62 const struct pipe_rasterizer_state *raster, 63 void *rast_handle ); 64 65void draw_set_rasterize_stage( struct draw_context *draw, 66 struct draw_stage *stage ); 67 68void draw_wide_point_threshold(struct draw_context *draw, float threshold); 69 70void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite); 71 72void draw_wide_line_threshold(struct draw_context *draw, float threshold); 73 74void draw_enable_line_stipple(struct draw_context *draw, boolean enable); 75 76void draw_enable_point_sprites(struct draw_context *draw, boolean enable); 77 78void draw_set_mrd(struct draw_context *draw, double mrd); 79 80boolean 81draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe); 82 83boolean 84draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe); 85 86boolean 87draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe); 88 89 90int 91draw_find_shader_output(const struct draw_context *draw, 92 uint semantic_name, uint semantic_index); 93 94uint 95draw_num_shader_outputs(const struct draw_context *draw); 96 97 98void 99draw_texture_samplers(struct draw_context *draw, 100 uint num_samplers, 101 struct tgsi_sampler **samplers); 102 103 104 105/* 106 * Vertex shader functions 107 */ 108 109struct draw_vertex_shader * 110draw_create_vertex_shader(struct draw_context *draw, 111 const struct pipe_shader_state *shader); 112void draw_bind_vertex_shader(struct draw_context *draw, 113 struct draw_vertex_shader *dvs); 114void draw_delete_vertex_shader(struct draw_context *draw, 115 struct draw_vertex_shader *dvs); 116 117 118/* 119 * Geometry shader functions 120 */ 121struct draw_geometry_shader * 122draw_create_geometry_shader(struct draw_context *draw, 123 const struct pipe_shader_state *shader); 124void draw_bind_geometry_shader(struct draw_context *draw, 125 struct draw_geometry_shader *dvs); 126void draw_delete_geometry_shader(struct draw_context *draw, 127 struct draw_geometry_shader *dvs); 128 129 130/* 131 * Vertex data functions 132 */ 133 134void draw_set_vertex_buffers(struct draw_context *draw, 135 unsigned count, 136 const struct pipe_vertex_buffer *buffers); 137 138void draw_set_vertex_elements(struct draw_context *draw, 139 unsigned count, 140 const struct pipe_vertex_element *elements); 141 142void 143draw_set_mapped_element_buffer_range( struct draw_context *draw, 144 unsigned eltSize, 145 int eltBias, 146 unsigned min_index, 147 unsigned max_index, 148 const void *elements ); 149 150void draw_set_mapped_element_buffer( struct draw_context *draw, 151 unsigned eltSize, 152 int eltBias, 153 const void *elements ); 154 155void draw_set_mapped_vertex_buffer(struct draw_context *draw, 156 unsigned attr, const void *buffer); 157 158void 159draw_set_mapped_constant_buffer(struct draw_context *draw, 160 unsigned shader_type, 161 unsigned slot, 162 const void *buffer, 163 unsigned size); 164 165void 166draw_set_mapped_so_buffers(struct draw_context *draw, 167 void *buffers[PIPE_MAX_SO_BUFFERS], 168 unsigned num_buffers); 169void 170draw_set_so_state(struct draw_context *draw, 171 struct pipe_stream_output_state *state); 172 173 174/*********************************************************************** 175 * draw_prim.c 176 */ 177 178void draw_arrays(struct draw_context *draw, unsigned prim, 179 unsigned start, unsigned count); 180 181void 182draw_arrays_instanced(struct draw_context *draw, 183 unsigned mode, 184 unsigned start, 185 unsigned count, 186 unsigned startInstance, 187 unsigned instanceCount); 188 189void draw_flush(struct draw_context *draw); 190 191 192/******************************************************************************* 193 * Driver backend interface 194 */ 195struct vbuf_render; 196void draw_set_render( struct draw_context *draw, 197 struct vbuf_render *render ); 198 199void draw_set_driver_clipping( struct draw_context *draw, 200 boolean bypass_clipping ); 201 202void draw_set_force_passthrough( struct draw_context *draw, 203 boolean enable ); 204 205/******************************************************************************* 206 * Draw pipeline 207 */ 208boolean draw_need_pipeline(const struct draw_context *draw, 209 const struct pipe_rasterizer_state *rasterizer, 210 unsigned prim ); 211 212#endif /* DRAW_CONTEXT_H */ 213