1848b8605Smrg 2848b8605Smrg/************************************************************************** 3848b8605Smrg * 4848b8605Smrg * Copyright 2007 VMware, Inc. 5848b8605Smrg * All Rights Reserved. 6848b8605Smrg * 7848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 8848b8605Smrg * copy of this software and associated documentation files (the 9848b8605Smrg * "Software"), to deal in the Software without restriction, including 10848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish, 11848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to 12848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to 13848b8605Smrg * the following conditions: 14848b8605Smrg * 15848b8605Smrg * The above copyright notice and this permission notice (including the 16848b8605Smrg * next paragraph) shall be included in all copies or substantial portions 17848b8605Smrg * of the Software. 18848b8605Smrg * 19848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22848b8605Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 23848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26848b8605Smrg * 27848b8605Smrg **************************************************************************/ 28848b8605Smrg 29848b8605Smrg/** 30848b8605Smrg * \brief Public interface into the drawing module. 31848b8605Smrg */ 32848b8605Smrg 33848b8605Smrg/* Authors: Keith Whitwell <keithw@vmware.com> 34848b8605Smrg */ 35848b8605Smrg 36848b8605Smrg 37848b8605Smrg#ifndef DRAW_CONTEXT_H 38848b8605Smrg#define DRAW_CONTEXT_H 39848b8605Smrg 40848b8605Smrg 41848b8605Smrg#include "pipe/p_state.h" 42848b8605Smrg 43848b8605Smrgstruct pipe_context; 44848b8605Smrgstruct draw_context; 45848b8605Smrgstruct draw_stage; 46848b8605Smrgstruct draw_vertex_shader; 47848b8605Smrgstruct draw_geometry_shader; 48848b8605Smrgstruct draw_fragment_shader; 49848b8605Smrgstruct tgsi_sampler; 50b8e80941Smrgstruct tgsi_image; 51b8e80941Smrgstruct tgsi_buffer; 52848b8605Smrg 53848b8605Smrg/* 54848b8605Smrg * structure to contain driver internal information 55848b8605Smrg * for stream out support. mapping stores the pointer 56848b8605Smrg * to the buffer contents, and internal offset stores 57848b8605Smrg * an internal counter to how much of the stream 58848b8605Smrg * out buffer is used (in bytes). 59848b8605Smrg */ 60848b8605Smrgstruct draw_so_target { 61848b8605Smrg struct pipe_stream_output_target target; 62848b8605Smrg void *mapping; 63848b8605Smrg int internal_offset; 64848b8605Smrg}; 65848b8605Smrg 66848b8605Smrgstruct draw_context *draw_create( struct pipe_context *pipe ); 67848b8605Smrg 68b8e80941Smrg#if HAVE_LLVM 69b8e80941Smrgstruct draw_context *draw_create_with_llvm_context(struct pipe_context *pipe, 70b8e80941Smrg void *context); 71b8e80941Smrg#endif 72b8e80941Smrg 73848b8605Smrgstruct draw_context *draw_create_no_llvm(struct pipe_context *pipe); 74848b8605Smrg 75848b8605Smrgvoid draw_destroy( struct draw_context *draw ); 76848b8605Smrg 77848b8605Smrgvoid draw_flush(struct draw_context *draw); 78848b8605Smrg 79848b8605Smrgvoid draw_set_viewport_states( struct draw_context *draw, 80848b8605Smrg unsigned start_slot, 81848b8605Smrg unsigned num_viewports, 82848b8605Smrg const struct pipe_viewport_state *viewports ); 83848b8605Smrg 84848b8605Smrgvoid draw_set_clip_state( struct draw_context *pipe, 85848b8605Smrg const struct pipe_clip_state *clip ); 86848b8605Smrg 87848b8605Smrg/** 88848b8605Smrg * Sets the rasterization state used by the draw module. 89848b8605Smrg * The rast_handle is used to pass the driver specific representation 90848b8605Smrg * of the rasterization state. It's going to be used when the 91848b8605Smrg * draw module sets the state back on the driver itself using the 92848b8605Smrg * pipe::bind_rasterizer_state method. 93848b8605Smrg * 94848b8605Smrg * NOTE: if you're calling this function from within the pipe's 95848b8605Smrg * bind_rasterizer_state you should always call it before binding 96848b8605Smrg * the actual state - that's because the draw module can try to 97848b8605Smrg * bind its own rasterizer state which would reset your newly 98848b8605Smrg * set state. i.e. always do 99848b8605Smrg * draw_set_rasterizer_state(driver->draw, state->pipe_state, state); 100848b8605Smrg * driver->state.raster = state; 101848b8605Smrg */ 102848b8605Smrgvoid draw_set_rasterizer_state( struct draw_context *draw, 103848b8605Smrg const struct pipe_rasterizer_state *raster, 104848b8605Smrg void *rast_handle ); 105848b8605Smrg 106848b8605Smrgvoid draw_set_rasterize_stage( struct draw_context *draw, 107848b8605Smrg struct draw_stage *stage ); 108848b8605Smrg 109848b8605Smrgvoid draw_wide_point_threshold(struct draw_context *draw, float threshold); 110848b8605Smrg 111848b8605Smrgvoid draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite); 112848b8605Smrg 113848b8605Smrgvoid draw_wide_line_threshold(struct draw_context *draw, float threshold); 114848b8605Smrg 115848b8605Smrgvoid draw_enable_line_stipple(struct draw_context *draw, boolean enable); 116848b8605Smrg 117848b8605Smrgvoid draw_enable_point_sprites(struct draw_context *draw, boolean enable); 118848b8605Smrg 119848b8605Smrgvoid draw_set_zs_format(struct draw_context *draw, enum pipe_format format); 120848b8605Smrg 121848b8605Smrgboolean 122848b8605Smrgdraw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe); 123848b8605Smrg 124848b8605Smrgboolean 125848b8605Smrgdraw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe); 126848b8605Smrg 127848b8605Smrgboolean 128848b8605Smrgdraw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe); 129848b8605Smrg 130848b8605Smrg 131848b8605Smrgstruct tgsi_shader_info * 132848b8605Smrgdraw_get_shader_info(const struct draw_context *draw); 133848b8605Smrg 134848b8605Smrgvoid 135848b8605Smrgdraw_prepare_shader_outputs(struct draw_context *draw); 136848b8605Smrg 137848b8605Smrgint 138848b8605Smrgdraw_find_shader_output(const struct draw_context *draw, 139848b8605Smrg uint semantic_name, uint semantic_index); 140848b8605Smrg 141848b8605Smrgboolean 142848b8605Smrgdraw_will_inject_frontface(const struct draw_context *draw); 143848b8605Smrg 144848b8605Smrguint 145848b8605Smrgdraw_num_shader_outputs(const struct draw_context *draw); 146848b8605Smrg 147848b8605Smrguint 148848b8605Smrgdraw_total_vs_outputs(const struct draw_context *draw); 149848b8605Smrg 150848b8605Smrguint 151848b8605Smrgdraw_total_gs_outputs(const struct draw_context *draw); 152848b8605Smrg 153848b8605Smrgvoid 154848b8605Smrgdraw_texture_sampler(struct draw_context *draw, 155b8e80941Smrg enum pipe_shader_type shader_type, 156848b8605Smrg struct tgsi_sampler *sampler); 157848b8605Smrg 158b8e80941Smrgvoid 159b8e80941Smrgdraw_image(struct draw_context *draw, 160b8e80941Smrg enum pipe_shader_type shader_type, 161b8e80941Smrg struct tgsi_image *image); 162b8e80941Smrg 163b8e80941Smrgvoid 164b8e80941Smrgdraw_buffer(struct draw_context *draw, 165b8e80941Smrg enum pipe_shader_type shader_type, 166b8e80941Smrg struct tgsi_buffer *buffer); 167b8e80941Smrg 168848b8605Smrgvoid 169848b8605Smrgdraw_set_sampler_views(struct draw_context *draw, 170b8e80941Smrg enum pipe_shader_type shader_stage, 171848b8605Smrg struct pipe_sampler_view **views, 172848b8605Smrg unsigned num); 173848b8605Smrgvoid 174848b8605Smrgdraw_set_samplers(struct draw_context *draw, 175b8e80941Smrg enum pipe_shader_type shader_stage, 176848b8605Smrg struct pipe_sampler_state **samplers, 177848b8605Smrg unsigned num); 178848b8605Smrg 179848b8605Smrgvoid 180848b8605Smrgdraw_set_mapped_texture(struct draw_context *draw, 181b8e80941Smrg enum pipe_shader_type shader_stage, 182848b8605Smrg unsigned sview_idx, 183848b8605Smrg uint32_t width, uint32_t height, uint32_t depth, 184848b8605Smrg uint32_t first_level, uint32_t last_level, 185848b8605Smrg const void *base, 186848b8605Smrg uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS], 187848b8605Smrg uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS], 188848b8605Smrg uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]); 189848b8605Smrg 190848b8605Smrg 191848b8605Smrg/* 192848b8605Smrg * Vertex shader functions 193848b8605Smrg */ 194848b8605Smrg 195848b8605Smrgstruct draw_vertex_shader * 196848b8605Smrgdraw_create_vertex_shader(struct draw_context *draw, 197848b8605Smrg const struct pipe_shader_state *shader); 198848b8605Smrgvoid draw_bind_vertex_shader(struct draw_context *draw, 199848b8605Smrg struct draw_vertex_shader *dvs); 200848b8605Smrgvoid draw_delete_vertex_shader(struct draw_context *draw, 201848b8605Smrg struct draw_vertex_shader *dvs); 202848b8605Smrgvoid draw_vs_attach_so(struct draw_vertex_shader *dvs, 203848b8605Smrg const struct pipe_stream_output_info *info); 204848b8605Smrgvoid draw_vs_reset_so(struct draw_vertex_shader *dvs); 205848b8605Smrg 206848b8605Smrg 207848b8605Smrg/* 208848b8605Smrg * Fragment shader functions 209848b8605Smrg */ 210848b8605Smrgstruct draw_fragment_shader * 211848b8605Smrgdraw_create_fragment_shader(struct draw_context *draw, 212848b8605Smrg const struct pipe_shader_state *shader); 213848b8605Smrgvoid draw_bind_fragment_shader(struct draw_context *draw, 214848b8605Smrg struct draw_fragment_shader *dvs); 215848b8605Smrgvoid draw_delete_fragment_shader(struct draw_context *draw, 216848b8605Smrg struct draw_fragment_shader *dvs); 217848b8605Smrg 218848b8605Smrg/* 219848b8605Smrg * Geometry shader functions 220848b8605Smrg */ 221848b8605Smrgstruct draw_geometry_shader * 222848b8605Smrgdraw_create_geometry_shader(struct draw_context *draw, 223848b8605Smrg const struct pipe_shader_state *shader); 224848b8605Smrgvoid draw_bind_geometry_shader(struct draw_context *draw, 225848b8605Smrg struct draw_geometry_shader *dvs); 226848b8605Smrgvoid draw_delete_geometry_shader(struct draw_context *draw, 227848b8605Smrg struct draw_geometry_shader *dvs); 228848b8605Smrg 229848b8605Smrg 230848b8605Smrg/* 231848b8605Smrg * Vertex data functions 232848b8605Smrg */ 233848b8605Smrg 234848b8605Smrgvoid draw_set_vertex_buffers(struct draw_context *draw, 235848b8605Smrg unsigned start_slot, unsigned count, 236848b8605Smrg const struct pipe_vertex_buffer *buffers); 237848b8605Smrg 238848b8605Smrgvoid draw_set_vertex_elements(struct draw_context *draw, 239848b8605Smrg unsigned count, 240848b8605Smrg const struct pipe_vertex_element *elements); 241848b8605Smrg 242848b8605Smrgvoid draw_set_indexes(struct draw_context *draw, 243848b8605Smrg const void *elements, unsigned elem_size, 244848b8605Smrg unsigned available_space); 245848b8605Smrg 246848b8605Smrgvoid draw_set_mapped_vertex_buffer(struct draw_context *draw, 247848b8605Smrg unsigned attr, const void *buffer, 248848b8605Smrg size_t size); 249848b8605Smrg 250848b8605Smrgvoid 251848b8605Smrgdraw_set_mapped_constant_buffer(struct draw_context *draw, 252b8e80941Smrg enum pipe_shader_type shader_type, 253848b8605Smrg unsigned slot, 254848b8605Smrg const void *buffer, 255848b8605Smrg unsigned size); 256848b8605Smrg 257848b8605Smrgvoid 258848b8605Smrgdraw_set_mapped_so_targets(struct draw_context *draw, 259848b8605Smrg int num_targets, 260848b8605Smrg struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]); 261848b8605Smrg 262848b8605Smrg 263848b8605Smrg/*********************************************************************** 264848b8605Smrg * draw_pt.c 265848b8605Smrg */ 266848b8605Smrg 267848b8605Smrgvoid draw_vbo(struct draw_context *draw, 268848b8605Smrg const struct pipe_draw_info *info); 269848b8605Smrg 270848b8605Smrg 271848b8605Smrg/******************************************************************************* 272848b8605Smrg * Driver backend interface 273848b8605Smrg */ 274848b8605Smrgstruct vbuf_render; 275848b8605Smrgvoid draw_set_render( struct draw_context *draw, 276848b8605Smrg struct vbuf_render *render ); 277848b8605Smrg 278848b8605Smrgvoid draw_set_driver_clipping( struct draw_context *draw, 279848b8605Smrg boolean bypass_clip_xy, 280848b8605Smrg boolean bypass_clip_z, 281848b8605Smrg boolean guard_band_xy, 282848b8605Smrg boolean bypass_clip_points); 283848b8605Smrg 284848b8605Smrgvoid draw_set_force_passthrough( struct draw_context *draw, 285848b8605Smrg boolean enable ); 286848b8605Smrg 287848b8605Smrg 288848b8605Smrg/******************************************************************************* 289848b8605Smrg * Draw statistics 290848b8605Smrg */ 291848b8605Smrgvoid draw_collect_pipeline_statistics(struct draw_context *draw, 292848b8605Smrg boolean enable); 293848b8605Smrg 294848b8605Smrg/******************************************************************************* 295848b8605Smrg * Draw pipeline 296848b8605Smrg */ 297848b8605Smrgboolean draw_need_pipeline(const struct draw_context *draw, 298848b8605Smrg const struct pipe_rasterizer_state *rasterizer, 299848b8605Smrg unsigned prim ); 300848b8605Smrg 301848b8605Smrgint 302b8e80941Smrgdraw_get_shader_param(enum pipe_shader_type shader, enum pipe_shader_cap param); 303848b8605Smrg 304848b8605Smrgint 305b8e80941Smrgdraw_get_shader_param_no_llvm(enum pipe_shader_type shader, 306b8e80941Smrg enum pipe_shader_cap param); 307848b8605Smrg 308848b8605Smrgboolean 309848b8605Smrgdraw_get_option_use_llvm(void); 310848b8605Smrg 311848b8605Smrg#endif /* DRAW_CONTEXT_H */ 312